0005-chiliboard-support.patch 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686
  1. From 22efc5d711cf5a91a236b3a54f94cbcad0fc7b5e Mon Sep 17 00:00:00 2001
  2. From: Kevin Mihelich <kevin@archlinuxarm.org>
  3. Date: Sat, 29 Aug 2015 08:56:32 -0600
  4. Subject: [PATCH 5/6] chiliboard support
  5. ---
  6. board/grinn/chiliboard/Makefile | 13 +
  7. board/grinn/chiliboard/board.c | 447 +++++++++++++++++++
  8. board/grinn/chiliboard/board.h | 20 +
  9. board/grinn/chiliboard/mux.c | 99 +++++
  10. board/grinn/chiliboard/u-boot.lds | 131 ++++++
  11. boards.cfg | 5 +
  12. drivers/mtd/nand/omap_gpmc.c | 6 +-
  13. include/configs/chiliboard.h | 878 ++++++++++++++++++++++++++++++++++++++
  14. 8 files changed, 1597 insertions(+), 2 deletions(-)
  15. create mode 100644 board/grinn/chiliboard/Makefile
  16. create mode 100644 board/grinn/chiliboard/board.c
  17. create mode 100644 board/grinn/chiliboard/board.h
  18. create mode 100644 board/grinn/chiliboard/mux.c
  19. create mode 100644 board/grinn/chiliboard/u-boot.lds
  20. create mode 100644 include/configs/chiliboard.h
  21. diff --git a/board/grinn/chiliboard/Makefile b/board/grinn/chiliboard/Makefile
  22. new file mode 100644
  23. index 0000000..804ac37
  24. --- /dev/null
  25. +++ b/board/grinn/chiliboard/Makefile
  26. @@ -0,0 +1,13 @@
  27. +#
  28. +# Makefile
  29. +#
  30. +# Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
  31. +#
  32. +# SPDX-License-Identifier: GPL-2.0+
  33. +#
  34. +
  35. +ifeq ($(CONFIG_SKIP_LOWLEVEL_INIT),)
  36. +obj-y := mux.o
  37. +endif
  38. +
  39. +obj-y += board.o
  40. diff --git a/board/grinn/chiliboard/board.c b/board/grinn/chiliboard/board.c
  41. new file mode 100644
  42. index 0000000..ed8ab63
  43. --- /dev/null
  44. +++ b/board/grinn/chiliboard/board.c
  45. @@ -0,0 +1,447 @@
  46. +/*
  47. + * board.c
  48. + *
  49. + * Board functions for Grinn chiliboard, AM335X based boards
  50. + *
  51. + * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
  52. + *
  53. + * Copyright (C) 2015, Grinn - http://www.grinn-global.com
  54. + * Grzegorz Glomb, g.glomb@grinn-global.com
  55. + *
  56. + * SPDX-License-Identifier: GPL-2.0+
  57. + */
  58. +
  59. +#include <common.h>
  60. +#include <errno.h>
  61. +#include <spl.h>
  62. +#include <asm/arch/cpu.h>
  63. +#include <asm/arch/hardware.h>
  64. +#include <asm/arch/omap.h>
  65. +#include <asm/arch/ddr_defs.h>
  66. +#include <asm/arch/clock.h>
  67. +#include <asm/arch/gpio.h>
  68. +#include <asm/arch/mmc_host_def.h>
  69. +#include <asm/arch/sys_proto.h>
  70. +#include <asm/arch/mem.h>
  71. +#include <asm/io.h>
  72. +#include <asm/emif.h>
  73. +#include <asm/gpio.h>
  74. +#include <i2c.h>
  75. +#include <miiphy.h>
  76. +#include <cpsw.h>
  77. +#include <power/tps65217.h>
  78. +#include <power/tps65910.h>
  79. +#include <environment.h>
  80. +#include <watchdog.h>
  81. +#include <environment.h>
  82. +#include "board.h"
  83. +
  84. +DECLARE_GLOBAL_DATA_PTR;
  85. +#define HDR_NAME_LEN 8
  86. +
  87. +static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
  88. +
  89. +#ifndef CONFIG_SKIP_LOWLEVEL_INIT
  90. +static const struct ddr_data ddr2_chilisom_gcs1_data = {
  91. + .datardsratio0 = ((MT47H128M16RT25E_RD_DQS<<30) |
  92. + (MT47H128M16RT25E_RD_DQS<<20) |
  93. + (MT47H128M16RT25E_RD_DQS<<10) |
  94. + (MT47H128M16RT25E_RD_DQS<<0)),
  95. + .datawdsratio0 = ((MT47H128M16RT25E_WR_DQS<<30) |
  96. + (MT47H128M16RT25E_WR_DQS<<20) |
  97. + (MT47H128M16RT25E_WR_DQS<<10) |
  98. + (MT47H128M16RT25E_WR_DQS<<0)),
  99. + .datawiratio0 = ((MT47H128M16RT25E_PHY_WRLVL<<30) |
  100. + (MT47H128M16RT25E_PHY_WRLVL<<20) |
  101. + (MT47H128M16RT25E_PHY_WRLVL<<10) |
  102. + (MT47H128M16RT25E_PHY_WRLVL<<0)),
  103. + .datagiratio0 = ((MT47H128M16RT25E_PHY_GATELVL<<30) |
  104. + (MT47H128M16RT25E_PHY_GATELVL<<20) |
  105. + (MT47H128M16RT25E_PHY_GATELVL<<10) |
  106. + (MT47H128M16RT25E_PHY_GATELVL<<0)),
  107. + .datafwsratio0 = ((MT47H128M16RT25E_PHY_FIFO_WE<<30) |
  108. + (MT47H128M16RT25E_PHY_FIFO_WE<<20) |
  109. + (MT47H128M16RT25E_PHY_FIFO_WE<<10) |
  110. + (MT47H128M16RT25E_PHY_FIFO_WE<<0)),
  111. + .datawrsratio0 = ((MT47H128M16RT25E_PHY_WR_DATA<<30) |
  112. + (MT47H128M16RT25E_PHY_WR_DATA<<20) |
  113. + (MT47H128M16RT25E_PHY_WR_DATA<<10) |
  114. + (MT47H128M16RT25E_PHY_WR_DATA<<0)),
  115. +};
  116. +
  117. +static const struct cmd_control ddr2_chilisom_gcs1_cmd_ctrl_data = {
  118. + .cmd0csratio = MT47H128M16RT25E_RATIO,
  119. + .cmd0iclkout = MT47H128M16RT25E_INVERT_CLKOUT,
  120. +
  121. + .cmd1csratio = MT47H128M16RT25E_RATIO,
  122. + .cmd1iclkout = MT47H128M16RT25E_INVERT_CLKOUT,
  123. +
  124. + .cmd2csratio = MT47H128M16RT25E_RATIO,
  125. + .cmd2iclkout = MT47H128M16RT25E_INVERT_CLKOUT,
  126. +};
  127. +
  128. +static const struct emif_regs ddr2_chilisom_gcs1_emif_reg_data = {
  129. + .sdram_config = MT47H128M16RT25E_EMIF_SDCFG,
  130. + .ref_ctrl = MT47H128M16RT25E_EMIF_SDREF,
  131. + .sdram_tim1 = MT47H128M16RT25E_EMIF_TIM1,
  132. + .sdram_tim2 = MT47H128M16RT25E_EMIF_TIM2,
  133. + .sdram_tim3 = MT47H128M16RT25E_EMIF_TIM3,
  134. + .emif_ddr_phy_ctlr_1 = MT47H128M16RT25E_EMIF_READ_LATENCY,
  135. +};
  136. +
  137. +static const struct ddr_data ddr3_chilisom_gcs2_data = {
  138. + .datardsratio0 = MT41K256M16HA125E_RD_DQS,
  139. + .datawdsratio0 = MT41K256M16HA125E_WR_DQS,
  140. + .datafwsratio0 = MT41K256M16HA125E_PHY_FIFO_WE,
  141. + .datawrsratio0 = MT41K256M16HA125E_PHY_WR_DATA,
  142. +};
  143. +
  144. +static const struct cmd_control ddr3_chilisom_gcs2_cmd_ctrl_data = {
  145. + .cmd0csratio = MT41K256M16HA125E_RATIO,
  146. + .cmd0iclkout = MT41K256M16HA125E_INVERT_CLKOUT,
  147. +
  148. + .cmd1csratio = MT41K256M16HA125E_RATIO,
  149. + .cmd1iclkout = MT41K256M16HA125E_INVERT_CLKOUT,
  150. +
  151. + .cmd2csratio = MT41K256M16HA125E_RATIO,
  152. + .cmd2iclkout = MT41K256M16HA125E_INVERT_CLKOUT,
  153. +};
  154. +
  155. +static struct emif_regs ddr3_chilisom_gcs2_emif_reg_data = {
  156. + .sdram_config = MT41K256M16HA125E_EMIF_SDCFG,
  157. + .ref_ctrl = MT41K256M16HA125E_EMIF_SDREF,
  158. + .sdram_tim1 = MT41K256M16HA125E_EMIF_TIM1,
  159. + .sdram_tim2 = MT41K256M16HA125E_EMIF_TIM2,
  160. + .sdram_tim3 = MT41K256M16HA125E_EMIF_TIM3,
  161. + .zq_config = MT41K256M16HA125E_ZQ_CFG,
  162. + .emif_ddr_phy_ctlr_1 = MT41K256M16HA125E_EMIF_READ_LATENCY,
  163. +};
  164. +
  165. +#ifdef CONFIG_SPL_OS_BOOT
  166. +int spl_start_uboot(void)
  167. +{
  168. + /* break into full u-boot on 'c' */
  169. + if (serial_tstc() && serial_getc() == 'c')
  170. + return 1;
  171. +
  172. +#ifdef CONFIG_SPL_ENV_SUPPORT
  173. + env_init();
  174. + env_relocate_spec();
  175. + if (getenv_yesno("boot_os") != 1)
  176. + return 1;
  177. +#endif
  178. +
  179. + return 0;
  180. +}
  181. +#endif
  182. +
  183. +#define OSC (V_OSCK/1000000)
  184. +const struct dpll_params dpll_ddr_chilisom_gcs1 = {
  185. + 266, OSC-1, 1, -1, -1, -1, -1};
  186. +const struct dpll_params dpll_ddr_chilisom_gcs2 = {
  187. + 400, OSC-1, 1, -1, -1, -1, -1};
  188. +
  189. +void am33xx_spl_board_init(void)
  190. +{
  191. + int mpu_vdd;
  192. +
  193. + dpll_mpu_opp100.m = am335x_get_efuse_mpu_max_freq(cdev);
  194. +
  195. + int usb_cur_lim;
  196. +
  197. + if (i2c_probe(TPS65217_CHIP_PM))
  198. + return;
  199. +
  200. + uchar pmic_status_reg;
  201. + if (tps65217_reg_read(TPS65217_STATUS, &pmic_status_reg))
  202. + return;
  203. + if (!(pmic_status_reg & TPS65217_PWR_SRC_AC_BITMASK)) {
  204. + puts("No AC power, disabling frequency switch\n");
  205. + return;
  206. + }
  207. +
  208. + /*
  209. + * Increase USB current limit to 1300mA or 1800mA and set
  210. + * the MPU voltage controller as needed.
  211. + */
  212. + if (dpll_mpu_opp100.m == MPUPLL_M_1000) {
  213. + usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1800MA;
  214. + mpu_vdd = TPS65217_DCDC_VOLT_SEL_1325MV;
  215. + } else {
  216. + usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1300MA;
  217. + mpu_vdd = TPS65217_DCDC_VOLT_SEL_1275MV;
  218. + }
  219. +
  220. + if (tps65217_reg_write(TPS65217_PROT_LEVEL_NONE,
  221. + TPS65217_POWER_PATH,
  222. + usb_cur_lim,
  223. + TPS65217_USB_INPUT_CUR_LIMIT_MASK))
  224. + puts("tps65217_reg_write failure\n");
  225. +
  226. + /* Set DCDC3 (CORE) voltage to 1.125V */
  227. + if (tps65217_voltage_update(TPS65217_DEFDCDC3,
  228. + TPS65217_DCDC_VOLT_SEL_1125MV)) {
  229. + puts("tps65217_voltage_update failure\n");
  230. + return;
  231. + }
  232. +
  233. + do_setup_dpll(&dpll_core_regs, &dpll_core_opp100);
  234. + if (tps65217_voltage_update(TPS65217_DEFDCDC2, mpu_vdd)) {
  235. + puts("tps65217_voltage_update failure\n");
  236. + return;
  237. + }
  238. +
  239. + /* Set LDO3, LDO4 output voltage to 3.3V for GCS1.
  240. + * Set LDO3 to 1.8V and LDO4 to 3.3V for GCS2. */
  241. +
  242. + #ifdef CONFIG_CHILISOM_GCS2
  243. + if (tps65217_reg_write(TPS65217_PROT_LEVEL_2,
  244. + TPS65217_DEFLS1,
  245. + TPS65217_LDO_VOLTAGE_OUT_1_8,
  246. + TPS65217_LDO_MASK))
  247. + puts("tps65217_reg_write failure\n");
  248. + if (tps65217_reg_write(TPS65217_PROT_LEVEL_2,
  249. + TPS65217_DEFLS2,
  250. + TPS65217_LDO_VOLTAGE_OUT_3_3,
  251. + TPS65217_LDO_MASK))
  252. + puts("tps65217_reg_write failure\n");
  253. + #else
  254. +
  255. + if (tps65217_reg_write(TPS65217_PROT_LEVEL_2,
  256. + TPS65217_DEFLS1,
  257. + TPS65217_LDO_VOLTAGE_OUT_3_3,
  258. + TPS65217_LDO_MASK))
  259. + puts("tps65217_reg_write failure\n");
  260. + if (tps65217_reg_write(TPS65217_PROT_LEVEL_2,
  261. + TPS65217_DEFLS2,
  262. + TPS65217_LDO_VOLTAGE_OUT_3_3,
  263. + TPS65217_LDO_MASK))
  264. + puts("tps65217_reg_write failure\n");
  265. + #endif
  266. +
  267. + do_setup_dpll(&dpll_mpu_regs, &dpll_mpu_opp100);
  268. +}
  269. +
  270. +const struct dpll_params *get_dpll_ddr_params(void)
  271. +{
  272. + enable_i2c0_pin_mux();
  273. + i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
  274. +
  275. +#ifndef CONFIG_CHILISOM_GCS2
  276. + return &dpll_ddr_chilisom_gcs1;
  277. +#else
  278. + return &dpll_ddr_chilisom_gcs2;
  279. +#endif
  280. +}
  281. +
  282. +void set_uart_mux_conf(void)
  283. +{
  284. +#ifdef CONFIG_SERIAL1
  285. + enable_uart0_pin_mux();
  286. +#endif /* CONFIG_SERIAL1 */
  287. +}
  288. +
  289. +void set_mux_conf_regs(void)
  290. +{
  291. + enable_board_pin_mux();
  292. +}
  293. +
  294. +const struct ctrl_ioregs ioregs_chilisom_gcs1 = {
  295. + .cm0ioctl = MT47H128M16RT25E_IOCTRL_VALUE,
  296. + .cm1ioctl = MT47H128M16RT25E_IOCTRL_VALUE,
  297. + .cm2ioctl = MT47H128M16RT25E_IOCTRL_VALUE,
  298. + .dt0ioctl = MT47H128M16RT25E_IOCTRL_VALUE,
  299. + .dt1ioctl = MT47H128M16RT25E_IOCTRL_VALUE,
  300. +};
  301. +
  302. +const struct ctrl_ioregs ioregs_chilisom_gcs2 = {
  303. + .cm0ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
  304. + .cm1ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
  305. + .cm2ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
  306. + .dt0ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
  307. + .dt1ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
  308. +};
  309. +
  310. +void sdram_init(void)
  311. +{
  312. +#ifndef CONFIG_CHILISOM_GCS2
  313. + config_ddr(266, &ioregs_chilisom_gcs1,
  314. + &ddr2_chilisom_gcs1_data,
  315. + &ddr2_chilisom_gcs1_cmd_ctrl_data,
  316. + &ddr2_chilisom_gcs1_emif_reg_data, 0);
  317. +#else
  318. + config_ddr(400, &ioregs_chilisom_gcs2,
  319. + &ddr3_chilisom_gcs2_data,
  320. + &ddr3_chilisom_gcs2_cmd_ctrl_data,
  321. + &ddr3_chilisom_gcs2_emif_reg_data, 0);
  322. +#endif
  323. +}
  324. +#endif
  325. +
  326. +/*
  327. + * Basic board specific setup. Pinmux has been handled already.
  328. + */
  329. +int board_init(void)
  330. +{
  331. +#if defined(CONFIG_HW_WATCHDOG)
  332. + hw_watchdog_init();
  333. +#endif
  334. +
  335. + gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
  336. +#if defined(CONFIG_NOR) || defined(CONFIG_NAND)
  337. + gpmc_init();
  338. +#endif
  339. + return 0;
  340. +}
  341. +
  342. +#ifdef CONFIG_BOARD_LATE_INIT
  343. +int board_late_init(void)
  344. +{
  345. +#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
  346. + char safe_string[HDR_NAME_LEN + 1];
  347. +
  348. + /* Now set variables based on the header. */
  349. + strncpy(safe_string, (char *)"CHILISOM", 8);
  350. + safe_string[8] = 0;
  351. + setenv("board_name", safe_string);
  352. +
  353. +#ifndef CONFIG_CHILISOM_GCS2
  354. + strncpy(safe_string, (char *)"1.1", 3);
  355. + safe_string[3] = 0;
  356. + setenv("board_rev", safe_string);
  357. +#else
  358. + strncpy(safe_string, (char *)"2.2", 3);
  359. + safe_string[3] = 0;
  360. + setenv("board_rev", safe_string);
  361. +#endif
  362. +#endif
  363. + return 0;
  364. +}
  365. +#endif
  366. +
  367. +#if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \
  368. + (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))
  369. +static void cpsw_control(int enabled)
  370. +{
  371. + /* VTP can be added here */
  372. +
  373. + return;
  374. +}
  375. +
  376. +static struct cpsw_slave_data cpsw_slaves[] = {
  377. + {
  378. + .slave_reg_ofs = 0x208,
  379. + .sliver_reg_ofs = 0xd80,
  380. + .phy_addr = 0,
  381. + },
  382. + {
  383. + .slave_reg_ofs = 0x308,
  384. + .sliver_reg_ofs = 0xdc0,
  385. + .phy_addr = 1,
  386. + },
  387. +};
  388. +
  389. +static struct cpsw_platform_data cpsw_data = {
  390. + .mdio_base = CPSW_MDIO_BASE,
  391. + .cpsw_base = CPSW_BASE,
  392. + .mdio_div = 0xff,
  393. + .channels = 8,
  394. + .cpdma_reg_ofs = 0x800,
  395. + .slaves = 1,
  396. + .slave_data = cpsw_slaves,
  397. + .ale_reg_ofs = 0xd00,
  398. + .ale_entries = 1024,
  399. + .host_port_reg_ofs = 0x108,
  400. + .hw_stats_reg_ofs = 0x900,
  401. + .bd_ram_ofs = 0x2000,
  402. + .mac_control = (1 << 5),
  403. + .control = cpsw_control,
  404. + .host_port_num = 0,
  405. + .version = CPSW_CTRL_VERSION_2,
  406. +};
  407. +#endif
  408. +
  409. +/*
  410. + * This function will:
  411. + * Read the eFuse for MAC addresses, and set ethaddr/eth1addr/usbnet_devaddr
  412. + * in the environment
  413. + * Perform fixups to the PHY present on certain boards. We only need this
  414. + * function in:
  415. + * - SPL with either CPSW or USB ethernet support
  416. + * - Full U-Boot, with either CPSW or USB ethernet
  417. + * Build in only these cases to avoid warnings about unused variables
  418. + * when we build an SPL that has neither option but full U-Boot will.
  419. + */
  420. +
  421. +#if ((defined(CONFIG_SPL_ETH_SUPPORT) || defined(CONFIG_SPL_USBETH_SUPPORT)) \
  422. + && defined(CONFIG_SPL_BUILD)) || \
  423. + ((defined(CONFIG_DRIVER_TI_CPSW) || \
  424. + defined(CONFIG_USB_ETHER) && defined(CONFIG_MUSB_GADGET)) && \
  425. + !defined(CONFIG_SPL_BUILD))
  426. +int board_eth_init(bd_t *bis)
  427. +{
  428. + int rv, n = 0;
  429. + uint8_t mac_addr[6];
  430. + uint32_t mac_hi, mac_lo;
  431. +
  432. + /* try reading mac address from efuse */
  433. + mac_lo = readl(&cdev->macid0l);
  434. + mac_hi = readl(&cdev->macid0h);
  435. + mac_addr[0] = mac_hi & 0xFF;
  436. + mac_addr[1] = (mac_hi & 0xFF00) >> 8;
  437. + mac_addr[2] = (mac_hi & 0xFF0000) >> 16;
  438. + mac_addr[3] = (mac_hi & 0xFF000000) >> 24;
  439. + mac_addr[4] = mac_lo & 0xFF;
  440. + mac_addr[5] = (mac_lo & 0xFF00) >> 8;
  441. +
  442. +#if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \
  443. + (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))
  444. + if (!getenv("ethaddr")) {
  445. + printf("<ethaddr> not set. Validating first E-fuse MAC\n");
  446. +
  447. + if (is_valid_ether_addr(mac_addr))
  448. + eth_setenv_enetaddr("ethaddr", mac_addr);
  449. + }
  450. +
  451. +#ifdef CONFIG_DRIVER_TI_CPSW
  452. +
  453. + mac_lo = readl(&cdev->macid1l);
  454. + mac_hi = readl(&cdev->macid1h);
  455. + mac_addr[0] = mac_hi & 0xFF;
  456. + mac_addr[1] = (mac_hi & 0xFF00) >> 8;
  457. + mac_addr[2] = (mac_hi & 0xFF0000) >> 16;
  458. + mac_addr[3] = (mac_hi & 0xFF000000) >> 24;
  459. + mac_addr[4] = mac_lo & 0xFF;
  460. + mac_addr[5] = (mac_lo & 0xFF00) >> 8;
  461. +
  462. + if (!getenv("eth1addr")) {
  463. + if (is_valid_ether_addr(mac_addr))
  464. + eth_setenv_enetaddr("eth1addr", mac_addr);
  465. + }
  466. +
  467. + /* writel(MII_MODE_ENABLE, &cdev->miisel); */
  468. + writel(RMII_MODE_ENABLE | RMII_CHIPCKL_ENABLE, &cdev->miisel);
  469. +
  470. + cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if = PHY_INTERFACE_MODE_RMII;
  471. +
  472. + rv = cpsw_register(&cpsw_data);
  473. + if (rv < 0)
  474. + printf("Error %d registering CPSW switch\n", rv);
  475. + else
  476. + n += rv;
  477. +#endif
  478. +#endif
  479. +#if defined(CONFIG_USB_ETHER) && \
  480. + (!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USBETH_SUPPORT))
  481. + if (is_valid_ether_addr(mac_addr))
  482. + eth_setenv_enetaddr("usbnet_devaddr", mac_addr);
  483. +
  484. + rv = usb_eth_initialize(bis);
  485. + if (rv < 0)
  486. + printf("Error %d registering USB_ETHER\n", rv);
  487. + else
  488. + n += rv;
  489. +#endif
  490. + return n;
  491. +}
  492. +#endif
  493. diff --git a/board/grinn/chiliboard/board.h b/board/grinn/chiliboard/board.h
  494. new file mode 100644
  495. index 0000000..6753e74
  496. --- /dev/null
  497. +++ b/board/grinn/chiliboard/board.h
  498. @@ -0,0 +1,20 @@
  499. +/*
  500. + * board.h
  501. + *
  502. + * Grinn AM335x boards information header
  503. + *
  504. + * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
  505. + *
  506. + * Copyright (C) 2015, Grinn - http://www.grinn-global.com
  507. + * Grzegorz Glomb, g.glomb@grinn-global.com
  508. + *
  509. + * SPDX-License-Identifier: GPL-2.0+
  510. + */
  511. +
  512. +#ifndef _BOARD_H_
  513. +#define _BOARD_H_
  514. +
  515. +void enable_uart0_pin_mux(void);
  516. +void enable_i2c0_pin_mux(void);
  517. +void enable_board_pin_mux(void);
  518. +#endif
  519. diff --git a/board/grinn/chiliboard/mux.c b/board/grinn/chiliboard/mux.c
  520. new file mode 100644
  521. index 0000000..644f211
  522. --- /dev/null
  523. +++ b/board/grinn/chiliboard/mux.c
  524. @@ -0,0 +1,99 @@
  525. +/*
  526. + * mux.c
  527. + *
  528. + * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
  529. + *
  530. + * Copyright (C) 2015, Grinn - http://www.grinn-global.com
  531. + * Grzegorz Glomb, g.glomb@grinn-global.com
  532. + *
  533. + * SPDX-License-Identifier: GPL-2.0+
  534. + */
  535. +
  536. +#include <common.h>
  537. +#include <asm/arch/sys_proto.h>
  538. +#include <asm/arch/hardware.h>
  539. +#include <asm/arch/mux.h>
  540. +#include <asm/io.h>
  541. +#include <i2c.h>
  542. +#include "board.h"
  543. +
  544. +static struct module_pin_mux uart0_pin_mux[] = {
  545. + {OFFSET(uart0_rxd), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* UART0_RXD */
  546. + {OFFSET(uart0_txd), (MODE(0) | PULLUDEN)}, /* UART0_TXD */
  547. + {-1},
  548. +};
  549. +
  550. +static struct module_pin_mux mmc0_pin_mux[] = {
  551. + {OFFSET(mmc0_dat3), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT3 */
  552. + {OFFSET(mmc0_dat2), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT2 */
  553. + {OFFSET(mmc0_dat1), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT1 */
  554. + {OFFSET(mmc0_dat0), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT0 */
  555. + {OFFSET(mmc0_clk), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CLK */
  556. + {OFFSET(mmc0_cmd), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CMD */
  557. + {-1},
  558. +};
  559. +
  560. +static struct module_pin_mux i2c0_pin_mux[] = {
  561. + {OFFSET(i2c0_sda), (MODE(0) | RXACTIVE |
  562. + PULLUDEN | SLEWCTRL)}, /* I2C_DATA */
  563. + {OFFSET(i2c0_scl), (MODE(0) | RXACTIVE |
  564. + PULLUDEN | SLEWCTRL)}, /* I2C_SCLK */
  565. + {-1},
  566. +};
  567. +
  568. +static struct module_pin_mux rmii1_pin_mux[] = {
  569. + {OFFSET(mii1_crs), MODE(1) | RXACTIVE}, /* RMII1_CRS */
  570. + {OFFSET(mii1_rxerr), MODE(1) | RXACTIVE}, /* RMII1_RXERR */
  571. + {OFFSET(mii1_txen), MODE(1)}, /* RMII1_TXEN */
  572. + {OFFSET(mii1_txd1), MODE(1)}, /* RMII1_TXD1 */
  573. + {OFFSET(mii1_txd0), MODE(1)}, /* RMII1_TXD0 */
  574. + {OFFSET(mii1_rxd1), MODE(1) | RXACTIVE}, /* RMII1_RXD1 */
  575. + {OFFSET(mii1_rxd0), MODE(1) | RXACTIVE}, /* RMII1_RXD0 */
  576. + {OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN}, /* MDIO_DATA */
  577. + {OFFSET(mdio_clk), MODE(0) | PULLUP_EN}, /* MDIO_CLK */
  578. + {OFFSET(rmii1_refclk), MODE(0) | RXACTIVE}, /* RMII1_REFCLK */
  579. + {-1},
  580. +};
  581. +
  582. +static struct module_pin_mux nand_pin_mux[] = {
  583. + {OFFSET(gpmc_ad0), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD0 */
  584. + {OFFSET(gpmc_ad1), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD1 */
  585. + {OFFSET(gpmc_ad2), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD2 */
  586. + {OFFSET(gpmc_ad3), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD3 */
  587. + {OFFSET(gpmc_ad4), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD4 */
  588. + {OFFSET(gpmc_ad5), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD5 */
  589. + {OFFSET(gpmc_ad6), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD6 */
  590. + {OFFSET(gpmc_ad7), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD7 */
  591. + {OFFSET(gpmc_wait0), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* NAND WAIT */
  592. + {OFFSET(gpmc_wpn), (MODE(7) | PULLUP_EN | RXACTIVE)}, /* NAND_WPN */
  593. + {OFFSET(gpmc_csn0), (MODE(0) | PULLUDEN)}, /* NAND_CS0 */
  594. + {OFFSET(gpmc_advn_ale), (MODE(0) | PULLUDEN)}, /* NAND_ADV_ALE */
  595. + {OFFSET(gpmc_oen_ren), (MODE(0) | PULLUDEN)}, /* NAND_OE */
  596. + {OFFSET(gpmc_wen), (MODE(0) | PULLUDEN)}, /* NAND_WEN */
  597. + {OFFSET(gpmc_be0n_cle), (MODE(0) | PULLUDEN)}, /* NAND_BE_CLE */
  598. + {-1},
  599. +};
  600. +
  601. +void enable_uart0_pin_mux(void)
  602. +{
  603. + configure_module_pin_mux(uart0_pin_mux);
  604. +}
  605. +
  606. +void enable_i2c0_pin_mux(void)
  607. +{
  608. + configure_module_pin_mux(i2c0_pin_mux);
  609. +}
  610. +
  611. +void enable_board_pin_mux(void)
  612. +{
  613. + /* chiliboard pinmux */
  614. + configure_module_pin_mux(rmii1_pin_mux);
  615. + configure_module_pin_mux(nand_pin_mux);
  616. + configure_module_pin_mux(mmc0_pin_mux);
  617. +
  618. +#ifndef CONFIG_CHILISOM_GCS2
  619. + puts("Configuration for Chilisom GCS1\n");
  620. +#else
  621. + puts("Configuration for Chilisom GCS2\n");
  622. +#endif
  623. +}
  624. diff --git a/board/grinn/chiliboard/u-boot.lds b/board/grinn/chiliboard/u-boot.lds
  625. new file mode 100644
  626. index 0000000..bf70d88
  627. --- /dev/null
  628. +++ b/board/grinn/chiliboard/u-boot.lds
  629. @@ -0,0 +1,131 @@
  630. +/*
  631. + * Copyright (c) 2004-2008 Texas Instruments
  632. + *
  633. + * (C) Copyright 2002
  634. + * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
  635. + *
  636. + * Copyright (C) 2015, Grinn - http://www.grinn-global.com
  637. + * Grzegorz Glomb, g.glomb@grinn-global.com
  638. + *
  639. + * See file CREDITS for list of people who contributed to this
  640. + * project.
  641. + *
  642. + * This program is free software; you can redistribute it and/or
  643. + * modify it under the terms of the GNU General Public License as
  644. + * published by the Free Software Foundation; either version 2 of
  645. + * the License, or (at your option) any later version.
  646. + *
  647. + * This program is distributed in the hope that it will be useful,
  648. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  649. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  650. + * GNU General Public License for more details.
  651. + *
  652. + * You should have received a copy of the GNU General Public License
  653. + * along with this program; if not, write to the Free Software
  654. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  655. + * MA 02111-1307 USA
  656. + */
  657. +
  658. +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
  659. +OUTPUT_ARCH(arm)
  660. +ENTRY(_start)
  661. +SECTIONS
  662. +{
  663. + . = 0x00000000;
  664. +
  665. + . = ALIGN(4);
  666. + .text :
  667. + {
  668. + *(.__image_copy_start)
  669. + *(.vectors)
  670. + CPUDIR/start.o (.text*)
  671. + board/grinn/chiliboard/built-in.o (.text*)
  672. + *(.text*)
  673. + }
  674. +
  675. + . = ALIGN(4);
  676. + .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
  677. +
  678. + . = ALIGN(4);
  679. + .data : {
  680. + *(.data*)
  681. + }
  682. +
  683. + . = ALIGN(4);
  684. +
  685. + . = .;
  686. +
  687. + . = ALIGN(4);
  688. + .u_boot_list : {
  689. + KEEP(*(SORT(.u_boot_list*)));
  690. + }
  691. +
  692. + . = ALIGN(4);
  693. +
  694. + .image_copy_end :
  695. + {
  696. + *(.__image_copy_end)
  697. + }
  698. +
  699. + .rel_dyn_start :
  700. + {
  701. + *(.__rel_dyn_start)
  702. + }
  703. +
  704. + .rel.dyn : {
  705. + *(.rel*)
  706. + }
  707. +
  708. + .rel_dyn_end :
  709. + {
  710. + *(.__rel_dyn_end)
  711. + }
  712. +
  713. + .hash : { *(.hash*) }
  714. +
  715. + .end :
  716. + {
  717. + *(.__end)
  718. + }
  719. +
  720. + _image_binary_end = .;
  721. +
  722. + /*
  723. + * Deprecated: this MMU section is used by pxa at present but
  724. + * should not be used by new boards/CPUs.
  725. + */
  726. + . = ALIGN(4096);
  727. + .mmutable : {
  728. + *(.mmutable)
  729. + }
  730. +
  731. +/*
  732. + * Compiler-generated __bss_start and __bss_end, see arch/arm/lib/bss.c
  733. + * __bss_base and __bss_limit are for linker only (overlay ordering)
  734. + */
  735. +
  736. + .bss_start __rel_dyn_start (OVERLAY) : {
  737. + KEEP(*(.__bss_start));
  738. + __bss_base = .;
  739. + }
  740. +
  741. + .bss __bss_base (OVERLAY) : {
  742. + *(.bss*)
  743. + . = ALIGN(4);
  744. + __bss_limit = .;
  745. + }
  746. +
  747. + .bss_end __bss_limit (OVERLAY) : {
  748. + KEEP(*(.__bss_end));
  749. + }
  750. +
  751. + .dynsym _image_binary_end : { *(.dynsym) }
  752. + .dynbss : { *(.dynbss) }
  753. + .dynstr : { *(.dynstr*) }
  754. + .dynamic : { *(.dynamic*) }
  755. + .gnu.hash : { *(.gnu.hash) }
  756. + .plt : { *(.plt*) }
  757. + .interp : { *(.interp*) }
  758. + .gnu : { *(.gnu*) }
  759. + .ARM.exidx : { *(.ARM.exidx*) }
  760. +}
  761. diff --git a/boards.cfg b/boards.cfg
  762. index 1ba2081..b432704 100644
  763. --- a/boards.cfg
  764. +++ b/boards.cfg
  765. @@ -258,6 +258,11 @@ Active arm armv7 am33xx BuR tseries
  766. Active arm armv7 am33xx BuR tseries tseries_nand tseries:SERIAL1,CONS_INDEX=1,NAND Hannes Petermaier <hannes.petermaier@br-automation.com>
  767. Active arm armv7 am33xx BuR tseries tseries_spi tseries:SERIAL1,CONS_INDEX=1,SPI_BOOT,EMMC_BOOT Hannes Petermaier <hannes.petermaier@br-automation.com>
  768. Active arm armv7 am33xx compulab cm_t335 cm_t335 - Igor Grinberg <grinberg@compulab.co.il>
  769. +Active arm armv7 am33xx grinn chiliboard chiliboard_ram128m chiliboard:CHILISOM_GCS2,NAND,RAM128MB Grzegorz Glomb <g.glomb@grinn-global.com>
  770. +Active arm armv7 am33xx grinn chiliboard chiliboard_nand0m_ram128m chiliboard:CHILISOM_GCS2,RAM128MB Grzegorz Glomb <g.glomb@grinn-global.com>
  771. +Active arm armv7 am33xx grinn chiliboard chiliboard_nand512m chiliboard:CHILISOM_GCS2,NAND,NAND512MB Grzegorz Glomb <g.glomb@grinn-global.com>
  772. +Active arm armv7 am33xx grinn chiliboard chiliboard_nand0m chiliboard:CHILISOM_GCS2 Grzegorz Glomb <g.glomb@grinn-global.com>
  773. +Active arm armv7 am33xx grinn chiliboard chiliboard chiliboard:CHILISOM_GCS2,NAND Grzegorz Glomb <g.glomb@grinn-global.com>
  774. Active arm armv7 am33xx gumstix pepper pepper - Ash Charles <ash@gumstix.com>
  775. Active arm armv7 am33xx isee igep0033 am335x_igep0033 - Enric Balletbo i Serra <eballetbo@iseebcn.com>
  776. Active arm armv7 am33xx phytec pcm051 pcm051_rev1 pcm051:REV1 Lars Poeschel <poeschel@lemonage.de>
  777. diff --git a/drivers/mtd/nand/omap_gpmc.c b/drivers/mtd/nand/omap_gpmc.c
  778. index 1acf06b..0c9cde3 100644
  779. --- a/drivers/mtd/nand/omap_gpmc.c
  780. +++ b/drivers/mtd/nand/omap_gpmc.c
  781. @@ -478,11 +478,13 @@ static int omap_read_page_bch(struct mtd_info *mtd, struct nand_chip *chip,
  782. oob += eccbytes) {
  783. chip->ecc.hwctl(mtd, NAND_ECC_READ);
  784. /* read data */
  785. - chip->cmdfunc(mtd, NAND_CMD_RNDOUT, data_pos, page);
  786. + /* chip->cmdfunc(mtd, NAND_CMD_RNDOUT, data_pos, page); */
  787. + chip->cmdfunc(mtd, NAND_CMD_RNDOUT, data_pos, -1);
  788. chip->read_buf(mtd, p, eccsize);
  789. /* read respective ecc from oob area */
  790. - chip->cmdfunc(mtd, NAND_CMD_RNDOUT, oob_pos, page);
  791. + /* chip->cmdfunc(mtd, NAND_CMD_RNDOUT, oob_pos, page); */
  792. + chip->cmdfunc(mtd, NAND_CMD_RNDOUT, oob_pos, -1);
  793. chip->read_buf(mtd, oob, eccbytes);
  794. /* read syndrome */
  795. chip->ecc.calculate(mtd, p, &ecc_calc[i]);
  796. diff --git a/include/configs/chiliboard.h b/include/configs/chiliboard.h
  797. new file mode 100644
  798. index 0000000..eacc9af
  799. --- /dev/null
  800. +++ b/include/configs/chiliboard.h
  801. @@ -0,0 +1,878 @@
  802. +/*
  803. + * chiliboard.h
  804. + *
  805. + * Grinn chiliboard configuration header
  806. + *
  807. + * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
  808. + *
  809. + * Copyright (C) 2015, Grinn - http://www.grinn-global.com
  810. + * Grzegorz Glomb, g.glomb@grinn-global.com
  811. + *
  812. + * SPDX-License-Identifier: GPL-2.0+
  813. + */
  814. +
  815. +#ifndef __CONFIG_CHILIBOARD_H
  816. +#define __CONFIG_CHILIBOARD_H
  817. +
  818. +#define CONFIG_AM33XX
  819. +#define CONFIG_ARCH_CPU_INIT
  820. +#define CONFIG_SYS_CACHELINE_SIZE 64
  821. +#define CONFIG_MAX_RAM_BANK_SIZE (1024 << 20) /* 1GB */
  822. +#define CONFIG_SYS_TIMERBASE 0x48040000 /* Use Timer2 */
  823. +#define CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC
  824. +
  825. +#include <asm/arch/omap.h>
  826. +
  827. +/* NS16550 Configuration */
  828. +#define CONFIG_SYS_NS16550
  829. +#define CONFIG_SYS_NS16550_SERIAL
  830. +#define CONFIG_SYS_NS16550_REG_SIZE (-4)
  831. +#define CONFIG_SYS_NS16550_CLK 48000000
  832. +
  833. +/* Network defines. */
  834. +#define CONFIG_CMD_NET /* 'bootp' and 'tftp' */
  835. +#define CONFIG_CMD_DHCP
  836. +#define CONFIG_CMD_MII
  837. +#define CONFIG_BOOTP_DNS /* Configurable parts of CMD_DHCP */
  838. +#define CONFIG_BOOTP_DNS2
  839. +#define CONFIG_BOOTP_SEND_HOSTNAME
  840. +#define CONFIG_BOOTP_GATEWAY
  841. +#define CONFIG_BOOTP_SUBNETMASK
  842. +#define CONFIG_NET_RETRY_COUNT 10
  843. +#define CONFIG_CMD_PING
  844. +#define CONFIG_DRIVER_TI_CPSW /* Driver for IP block */
  845. +#define CONFIG_MII /* Required in net/eth.c */
  846. +
  847. +/*
  848. + * RTC related defines. To use bootcount you must set bootlimit in the
  849. + * environment to a non-zero value and enable CONFIG_BOOTCOUNT_LIMIT
  850. + * in the board config.
  851. + */
  852. +#define CONFIG_SYS_BOOTCOUNT_ADDR 0x44E3E000
  853. +
  854. +/* Enable the HW watchdog, since we can use this with bootcount */
  855. +#define CONFIG_HW_WATCHDOG
  856. +#define CONFIG_OMAP_WATCHDOG
  857. +
  858. +/*
  859. + * SPL related defines. The Public RAM memory map the ROM defines the
  860. + * area between 0x402F0400 and 0x4030B800 as a download area and
  861. + * 0x4030B800 to 0x4030CE00 as a public stack area. The ROM also
  862. + * supports X-MODEM loading via UART, and we leverage this and then use
  863. + * Y-MODEM to load u-boot.img, when booted over UART.
  864. + */
  865. +#define CONFIG_SPL_TEXT_BASE 0x402F0400
  866. +#define CONFIG_SPL_MAX_SIZE (0x4030B800 - CONFIG_SPL_TEXT_BASE)
  867. +#define CONFIG_SYS_SPL_ARGS_ADDR (CONFIG_SYS_SDRAM_BASE + \
  868. + (128 << 20))
  869. +
  870. +/* Enable the watchdog inside of SPL */
  871. +#define CONFIG_SPL_WATCHDOG_SUPPORT
  872. +
  873. +/*
  874. + * Since SPL did pll and ddr initialization for us,
  875. + * we don't need to do it twice.
  876. + */
  877. +#if !defined(CONFIG_SPL_BUILD) && !defined(CONFIG_NOR_BOOT)
  878. +#define CONFIG_SKIP_LOWLEVEL_INIT
  879. +#endif
  880. +
  881. +/*
  882. + * When building U-Boot such that there is no previous loader
  883. + * we need to call board_early_init_f. This is taken care of in
  884. + * s_init when we have SPL used.
  885. + */
  886. +#if !defined(CONFIG_SKIP_LOWLEVEL_INIT) && !defined(CONFIG_SPL)
  887. +#define CONFIG_BOARD_EARLY_INIT_F
  888. +#endif
  889. +
  890. +#ifdef CONFIG_NAND
  891. +#define CONFIG_SPL_NAND_AM33XX_BCH /* ELM support */
  892. +#endif
  893. +
  894. +/* Common define for many platforms. */
  895. +#define CONFIG_OMAP
  896. +#define CONFIG_OMAP_COMMON
  897. +#define CONFIG_SYS_GENERIC_BOARD
  898. +
  899. +/*
  900. + * We typically do not contain NOR flash. In the cases where we do, we
  901. + * undefine this later.
  902. + */
  903. +#define CONFIG_SYS_NO_FLASH
  904. +
  905. +/* Support both device trees and ATAGs. */
  906. +#define CONFIG_OF_LIBFDT
  907. +#define CONFIG_CMDLINE_TAG
  908. +#define CONFIG_SETUP_MEMORY_TAGS
  909. +#define CONFIG_INITRD_TAG
  910. +
  911. +/*
  912. + * Our DDR memory always starts at 0x80000000 and U-Boot shall have
  913. + * relocated itself to higher in memory by the time this value is used.
  914. + * However, set this to a 32MB offset to allow for easier Linux kernel
  915. + * booting as the default is often used as the kernel load address.
  916. + */
  917. +#define CONFIG_SYS_LOAD_ADDR 0x82000000
  918. +
  919. +/*
  920. + * We setup defaults based on constraints from the Linux kernel, which should
  921. + * also be safe elsewhere. We have the default load at 32MB into DDR (for
  922. + * the kernel), FDT above 128MB (the maximum location for the end of the
  923. + * kernel), and the ramdisk 512KB above that (allowing for hopefully never
  924. + * seen large trees). We say all of this must be within the first 256MB
  925. + * as that will normally be within the kernel lowmem and thus visible via
  926. + * bootm_size and we only run on platforms with 256MB or more of memory.
  927. + */
  928. +#ifdef CONFIG_RAM128MB
  929. +#define DEFAULT_LINUX_BOOT_ENV \
  930. + "loadaddr=0x82000000\0" \
  931. + "kernel_addr_r=0x82000000\0" \
  932. + "fdtaddr=0x84000000\0" \
  933. + "fdt_addr_r=0x84000000\0" \
  934. + "rdaddr=0x84080000\0" \
  935. + "ramdisk_addr_r=0x84080000\0" \
  936. + "bootm_size=0x8000000\0"
  937. +#else
  938. +#define DEFAULT_LINUX_BOOT_ENV \
  939. + "loadaddr=0x82000000\0" \
  940. + "kernel_addr_r=0x82000000\0" \
  941. + "fdtaddr=0x88000000\0" \
  942. + "fdt_addr_r=0x88000000\0" \
  943. + "rdaddr=0x88080000\0" \
  944. + "ramdisk_addr_r=0x88080000\0" \
  945. + "bootm_size=0x10000000\0"
  946. +#endif
  947. +
  948. +/*
  949. + * Default to a quick boot delay.
  950. + */
  951. +#define CONFIG_BOOTDELAY 1
  952. +
  953. +/*
  954. + * DDR information. If the CONFIG_NR_DRAM_BANKS is not defined,
  955. + * we say (for simplicity) that we have 1 bank, always, even when
  956. + * we have more. We always start at 0x80000000, and we place the
  957. + * initial stack pointer in our SRAM. Otherwise, we can define
  958. + * CONFIG_NR_DRAM_BANKS before including this file.
  959. + */
  960. +#ifndef CONFIG_NR_DRAM_BANKS
  961. +#define CONFIG_NR_DRAM_BANKS 1
  962. +#endif
  963. +#define CONFIG_SYS_SDRAM_BASE 0x80000000
  964. +#define CONFIG_SYS_INIT_SP_ADDR (NON_SECURE_SRAM_END - \
  965. + GENERATED_GBL_DATA_SIZE)
  966. +
  967. +/* Timer information. */
  968. +#define CONFIG_SYS_PTV 2 /* Divisor: 2^(PTV+1) => 8 */
  969. +
  970. +/* I2C IP block */
  971. +#define CONFIG_I2C
  972. +#define CONFIG_CMD_I2C
  973. +#define CONFIG_SYS_I2C
  974. +#define CONFIG_SYS_OMAP24_I2C_SPEED 100000
  975. +#define CONFIG_SYS_OMAP24_I2C_SLAVE 1
  976. +#define CONFIG_SYS_I2C_OMAP24XX
  977. +
  978. +/* MMC/SD IP block */
  979. +#define CONFIG_MMC
  980. +#define CONFIG_GENERIC_MMC
  981. +#define CONFIG_OMAP_HSMMC
  982. +#define CONFIG_CMD_MMC
  983. +
  984. +/* McSPI IP block */
  985. +#define CONFIG_SPI
  986. +#define CONFIG_OMAP3_SPI
  987. +#define CONFIG_CMD_SPI
  988. +
  989. +/* GPIO block */
  990. +#define CONFIG_OMAP_GPIO
  991. +#define CONFIG_CMD_GPIO
  992. +
  993. +/*
  994. + * GPMC NAND block. We support 1 device and the physical address to
  995. + * access CS0 at is 0x8000000.
  996. + */
  997. +#ifdef CONFIG_NAND
  998. +#define CONFIG_NAND_OMAP_GPMC
  999. +#ifndef CONFIG_SYS_NAND_BASE
  1000. +#define CONFIG_SYS_NAND_BASE 0x8000000
  1001. +#endif
  1002. +#define CONFIG_SYS_MAX_NAND_DEVICE 1
  1003. +#define CONFIG_CMD_NAND
  1004. +#endif
  1005. +
  1006. +/*
  1007. + * The following are general good-enough settings for U-Boot. We set a
  1008. + * large malloc pool as we generally have a lot of DDR, and we opt for
  1009. + * function over binary size in the main portion of U-Boot as this is
  1010. + * generally easily constrained later if needed. We enable the config
  1011. + * options that give us information in the environment about what board
  1012. + * we are on so we do not need to rely on the command prompt. We set a
  1013. + * console baudrate of 115200 and use the default baud rate table.
  1014. + */
  1015. +#define CONFIG_SYS_MALLOC_LEN (16 << 20)
  1016. +#define CONFIG_SYS_HUSH_PARSER
  1017. +#define CONFIG_SYS_PROMPT "U-Boot# "
  1018. +#define CONFIG_SYS_CONSOLE_INFO_QUIET
  1019. +#define CONFIG_BAUDRATE 115200
  1020. +#define CONFIG_ENV_VARS_UBOOT_CONFIG /* Strongly encouraged */
  1021. +#define CONFIG_ENV_OVERWRITE /* Overwrite ethaddr / serial# */
  1022. +
  1023. +/* As stated above, the following choices are optional. */
  1024. +#define CONFIG_SYS_LONGHELP
  1025. +#define CONFIG_AUTO_COMPLETE
  1026. +#define CONFIG_CMDLINE_EDITING
  1027. +#define CONFIG_VERSION_VARIABLE
  1028. +
  1029. +/* We set the max number of command args high to avoid HUSH bugs. */
  1030. +#define CONFIG_SYS_MAXARGS 64
  1031. +
  1032. +/* Console I/O Buffer Size */
  1033. +#define CONFIG_SYS_CBSIZE 512
  1034. +/* Print Buffer Size */
  1035. +#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE \
  1036. + + sizeof(CONFIG_SYS_PROMPT) + 16)
  1037. +/* Boot Argument Buffer Size */
  1038. +#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
  1039. +
  1040. +/*
  1041. + * When we have SPI, NOR or NAND flash we expect to be making use of
  1042. + * mtdparts, both for ease of use in U-Boot and for passing information
  1043. + * on to the Linux kernel.
  1044. + */
  1045. +#if defined(CONFIG_SPI_BOOT) || defined(CONFIG_NOR) || defined(CONFIG_NAND)
  1046. +#define CONFIG_MTD_DEVICE /* Required for mtdparts */
  1047. +#define CONFIG_CMD_MTDPARTS
  1048. +#endif
  1049. +
  1050. +/*
  1051. + * For commands to use, we take the default list and add a few other
  1052. + * useful commands. Note that we must have set CONFIG_SYS_NO_FLASH
  1053. + * prior to this include, in order to skip a few commands. When we do
  1054. + * have flash, if we expect these commands they must be enabled in that
  1055. + * config. If desired, a specific list of desired commands can be used
  1056. + * instead.
  1057. + */
  1058. +#include <config_cmd_default.h>
  1059. +#define CONFIG_CMD_ASKENV
  1060. +#define CONFIG_CMD_ECHO
  1061. +#define CONFIG_CMD_BOOTZ
  1062. +
  1063. +/*
  1064. + * Common filesystems support. When we have removable storage we
  1065. + * enabled a number of useful commands and support.
  1066. + */
  1067. +#if defined(CONFIG_MMC) || defined(CONFIG_USB_STORAGE)
  1068. +#define CONFIG_DOS_PARTITION
  1069. +#define CONFIG_CMD_FAT
  1070. +#define CONFIG_FAT_WRITE
  1071. +#define CONFIG_CMD_EXT2
  1072. +#define CONFIG_CMD_EXT4
  1073. +#define CONFIG_CMD_FS_GENERIC
  1074. +#endif
  1075. +
  1076. +/*
  1077. + * Our platforms make use of SPL to initalize the hardware (primarily
  1078. + * memory) enough for full U-Boot to be loaded. We also support Falcon
  1079. + * Mode so that the Linux kernel can be booted directly from SPL
  1080. + * instead, if desired. We make use of the general SPL framework found
  1081. + * under common/spl/. Given our generally common memory map, we set a
  1082. + * number of related defaults and sizes here.
  1083. + */
  1084. +#if !defined(CONFIG_NOR_BOOT) && \
  1085. + !(defined(CONFIG_QSPI_BOOT) && defined(CONFIG_AM43XX))
  1086. +#define CONFIG_SPL
  1087. +#define CONFIG_SPL_FRAMEWORK
  1088. +#define CONFIG_SPL_OS_BOOT
  1089. +
  1090. +/*
  1091. + * Place the image at the start of the ROM defined image space.
  1092. + * We limit our size to the ROM-defined downloaded image area, and use the
  1093. + * rest of the space for stack. We load U-Boot itself into memory at
  1094. + * 0x80800000 for legacy reasons (to not conflict with older SPLs). We
  1095. + * have our BSS be placed 1MiB after this, to allow for the default
  1096. + * Linux kernel address of 0x80008000 to work, in the Falcon Mode case.
  1097. + * We have the SPL malloc pool at the end of the BSS area.
  1098. + */
  1099. +#define CONFIG_SPL_STACK CONFIG_SYS_INIT_SP_ADDR
  1100. +#ifndef CONFIG_SYS_TEXT_BASE
  1101. +#define CONFIG_SYS_TEXT_BASE 0x80800000
  1102. +#endif
  1103. +#ifndef CONFIG_SPL_BSS_START_ADDR
  1104. +#define CONFIG_SPL_BSS_START_ADDR 0x80a00000
  1105. +#define CONFIG_SPL_BSS_MAX_SIZE 0x80000 /* 512 KB */
  1106. +#endif
  1107. +#ifndef CONFIG_SYS_SPL_MALLOC_START
  1108. +#define CONFIG_SYS_SPL_MALLOC_START (CONFIG_SPL_BSS_START_ADDR + \
  1109. + CONFIG_SPL_BSS_MAX_SIZE)
  1110. +#define CONFIG_SYS_SPL_MALLOC_SIZE CONFIG_SYS_MALLOC_LEN
  1111. +#endif
  1112. +
  1113. +/* RAW SD card / eMMC locations. */
  1114. +#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x300 /* address 0x60000 */
  1115. +#define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS 0x200 /* 256 KB */
  1116. +
  1117. +/* FAT sd card locations. */
  1118. +#define CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION 1
  1119. +#define CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME "u-boot.img"
  1120. +
  1121. +#ifdef CONFIG_SPL_OS_BOOT
  1122. +/* FAT */
  1123. +#define CONFIG_SPL_FAT_LOAD_KERNEL_NAME "uImage"
  1124. +#define CONFIG_SPL_FAT_LOAD_ARGS_NAME "args"
  1125. +
  1126. +/* RAW SD card / eMMC */
  1127. +#define CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR 0x900 /* address 0x120000 */
  1128. +#define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR 0x80 /* address 0x10000 */
  1129. +#define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS 0x80 /* 64KiB */
  1130. +
  1131. +/* NAND */
  1132. +#ifdef CONFIG_NAND
  1133. +#define CONFIG_CMD_SPL_NAND_OFS 0x240000 /* end of u-boot */
  1134. +#define CONFIG_SYS_NAND_SPL_KERNEL_OFFS 0x280000
  1135. +#define CONFIG_CMD_SPL_WRITE_SIZE 0x2000
  1136. +#endif
  1137. +
  1138. +/* spl export command */
  1139. +#define CONFIG_CMD_SPL
  1140. +#endif
  1141. +
  1142. +#ifdef CONFIG_MMC
  1143. +#define CONFIG_SPL_LIBDISK_SUPPORT
  1144. +#define CONFIG_SPL_MMC_SUPPORT
  1145. +#define CONFIG_SPL_FAT_SUPPORT
  1146. +#endif
  1147. +
  1148. +/* General parts of the framework, required. */
  1149. +#define CONFIG_SPL_I2C_SUPPORT
  1150. +#define CONFIG_SPL_LIBCOMMON_SUPPORT
  1151. +#define CONFIG_SPL_LIBGENERIC_SUPPORT
  1152. +#define CONFIG_SPL_SERIAL_SUPPORT
  1153. +#define CONFIG_SPL_GPIO_SUPPORT
  1154. +#define CONFIG_SPL_BOARD_INIT
  1155. +
  1156. +#ifdef CONFIG_NAND
  1157. +#define CONFIG_SPL_NAND_SUPPORT
  1158. +#define CONFIG_SPL_NAND_BASE
  1159. +#define CONFIG_SPL_NAND_DRIVERS
  1160. +#define CONFIG_SPL_NAND_ECC
  1161. +#define CONFIG_SPL_MTD_SUPPORT
  1162. +#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
  1163. +/* #define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000 */ /* Defined later in this configuration */
  1164. +#endif
  1165. +#endif /* !CONFIG_NOR_BOOT */
  1166. +
  1167. +#ifndef CONFIG_SPL_BUILD
  1168. +# define CONFIG_FIT
  1169. +# define CONFIG_TIMESTAMP
  1170. +# define CONFIG_LZO
  1171. +# ifdef CONFIG_ENABLE_VBOOT
  1172. +# define CONFIG_OF_CONTROL
  1173. +# define CONFIG_OF_SEPARATE
  1174. +# define CONFIG_DEFAULT_DEVICE_TREE am335x-chiliboard
  1175. +# define CONFIG_FIT_SIGNATURE
  1176. +# define CONFIG_RSA
  1177. +# endif
  1178. +#endif
  1179. +
  1180. +#define CONFIG_SYS_BOOTM_LEN (16 << 20)
  1181. +
  1182. +#define CONFIG_BOARD_LATE_INIT
  1183. +
  1184. +#define CONFIG_SERIAL1 1
  1185. +#define CONFIG_CONS_INDEX 1
  1186. +
  1187. +/* Clock Defines */
  1188. +#define V_OSCK 24000000 /* Clock output from T2 */
  1189. +#define V_SCLK (V_OSCK)
  1190. +
  1191. +/* Custom script for NOR */
  1192. +#define CONFIG_SYS_LDSCRIPT "board/grinn/chiliboard/u-boot.lds"
  1193. +
  1194. +/* Always 128 KiB env size */
  1195. +#define CONFIG_ENV_SIZE (128 << 10)
  1196. +
  1197. +/* Enhance our eMMC support / experience. */
  1198. +#define CONFIG_CMD_GPT
  1199. +#define CONFIG_EFI_PARTITION
  1200. +#define CONFIG_PARTITION_UUIDS
  1201. +#define CONFIG_CMD_PART
  1202. +
  1203. +#ifdef CONFIG_NAND
  1204. +#ifndef CONFIG_NAND512MB
  1205. +#define NANDARGS \
  1206. + "mtdids=" MTDIDS_DEFAULT "\0" \
  1207. + "mtdparts=" MTDPARTS_DEFAULT "\0" \
  1208. + "nandargs=setenv bootargs console=${console} " \
  1209. + "${optargs} " \
  1210. + "root=${nandroot} " \
  1211. + "rootfstype=${nandrootfstype}\0" \
  1212. + "nandroot=ubi0:rootfs rw ubi.mtd=8,2048\0" \
  1213. + "nandrootfstype=ubifs rootwait=1\0" \
  1214. + "nandboot=echo Booting from nand ...; " \
  1215. + "run nandargs; " \
  1216. + "nand read ${fdtaddr} u-boot-spl-os; " \
  1217. + "nand read ${loadaddr} kernel; " \
  1218. + "bootz ${loadaddr} - ${fdtaddr}\0"
  1219. +#else
  1220. +#define NANDARGS \
  1221. + "mtdids=" MTDIDS_DEFAULT "\0" \
  1222. + "mtdparts=" MTDPARTS_DEFAULT "\0" \
  1223. + "nandargs=setenv bootargs console=${console} " \
  1224. + "${optargs} " \
  1225. + "root=${nandroot} " \
  1226. + "rootfstype=${nandrootfstype}\0" \
  1227. + "nandroot=ubi0:rootfs rw ubi.mtd=8,4096\0" \
  1228. + "nandrootfstype=ubifs rootwait=1\0" \
  1229. + "nandboot=echo Booting from nand ...; " \
  1230. + "run nandargs; " \
  1231. + "nand read ${fdtaddr} u-boot-spl-os; " \
  1232. + "nand read ${loadaddr} kernel; " \
  1233. + "bootz ${loadaddr} - ${fdtaddr}\0"
  1234. +#endif
  1235. +#else
  1236. +#define NANDARGS ""
  1237. +#endif
  1238. +
  1239. +#define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
  1240. +
  1241. +#ifndef CONFIG_SPL_BUILD
  1242. +#define CONFIG_EXTRA_ENV_SETTINGS \
  1243. + DEFAULT_LINUX_BOOT_ENV \
  1244. + "boot_fdt=try\0" \
  1245. + "bootpart=0:2\0" \
  1246. + "bootdir=/boot\0" \
  1247. + "bootfile=zImage\0" \
  1248. + "fdtfile=undefined\0" \
  1249. + "console=ttyO0,115200n8\0" \
  1250. + "partitions=" \
  1251. + "uuid_disk=${uuid_gpt_disk};" \
  1252. + "name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}\0" \
  1253. + "optargs=\0" \
  1254. + "mmcdev=0\0" \
  1255. + "mmcroot=/dev/mmcblk0p2 rw\0" \
  1256. + "mmcrootfstype=ext4 rootwait\0" \
  1257. + "rootpath=/export/rootfs\0" \
  1258. + "nfsopts=nolock\0" \
  1259. + "static_ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}" \
  1260. + "::off\0" \
  1261. + "ramroot=/dev/ram0 rw\0" \
  1262. + "ramrootfstype=ext2\0" \
  1263. + "mmcargs=setenv bootargs console=${console} " \
  1264. + "${optargs} " \
  1265. + "root=${mmcroot} " \
  1266. + "rootfstype=${mmcrootfstype}\0" \
  1267. + "spiroot=/dev/mtdblock4 rw\0" \
  1268. + "spirootfstype=jffs2\0" \
  1269. + "spisrcaddr=0xe0000\0" \
  1270. + "spiimgsize=0x362000\0" \
  1271. + "spibusno=0\0" \
  1272. + "spiargs=setenv bootargs console=${console} " \
  1273. + "${optargs} " \
  1274. + "root=${spiroot} " \
  1275. + "rootfstype=${spirootfstype}\0" \
  1276. + "netargs=setenv bootargs console=${console} " \
  1277. + "${optargs} " \
  1278. + "root=/dev/nfs " \
  1279. + "nfsroot=${serverip}:${rootpath},${nfsopts} rw " \
  1280. + "ip=dhcp\0" \
  1281. + "bootenv=uEnv.txt\0" \
  1282. + "loadbootenv=load mmc ${mmcdev} ${loadaddr} ${bootenv}\0" \
  1283. + "importbootenv=echo Importing environment from mmc ...; " \
  1284. + "env import -t $loadaddr $filesize\0" \
  1285. + "ramargs=setenv bootargs console=${console} " \
  1286. + "${optargs} " \
  1287. + "root=${ramroot} " \
  1288. + "rootfstype=${ramrootfstype}\0" \
  1289. + "loadramdisk=load mmc ${mmcdev} ${rdaddr} ramdisk.gz\0" \
  1290. + "loadimage=load mmc ${bootpart} ${loadaddr} ${bootdir}/${bootfile}\0" \
  1291. + "loadfdt=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}\0" \
  1292. + "mmcloados=run mmcargs; " \
  1293. + "if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
  1294. + "if run loadfdt; then " \
  1295. + "bootz ${loadaddr} - ${fdtaddr}; " \
  1296. + "else " \
  1297. + "if test ${boot_fdt} = try; then " \
  1298. + "bootz; " \
  1299. + "else " \
  1300. + "echo WARN: Cannot load the DT; " \
  1301. + "fi; " \
  1302. + "fi; " \
  1303. + "else " \
  1304. + "bootz; " \
  1305. + "fi;\0" \
  1306. + "mmcboot=mmc dev ${mmcdev}; " \
  1307. + "if mmc rescan; then " \
  1308. + "echo SD/MMC found on device ${mmcdev};" \
  1309. + "if run loadbootenv; then " \
  1310. + "echo Loaded environment from ${bootenv};" \
  1311. + "run importbootenv;" \
  1312. + "fi;" \
  1313. + "if test -n $uenvcmd; then " \
  1314. + "echo Running uenvcmd ...;" \
  1315. + "run uenvcmd;" \
  1316. + "fi;" \
  1317. + "if run loadimage; then " \
  1318. + "run mmcloados;" \
  1319. + "fi;" \
  1320. + "fi;\0" \
  1321. + "spiboot=echo Booting from spi ...; " \
  1322. + "run spiargs; " \
  1323. + "sf probe ${spibusno}:0; " \
  1324. + "sf read ${loadaddr} ${spisrcaddr} ${spiimgsize}; " \
  1325. + "bootz ${loadaddr}\0" \
  1326. + "netboot=echo Booting from network ...; " \
  1327. + "setenv autoload no; " \
  1328. + "dhcp; " \
  1329. + "tftp ${loadaddr} ${bootfile}; " \
  1330. + "tftp ${fdtaddr} ${fdtfile}; " \
  1331. + "run netargs; " \
  1332. + "bootz ${loadaddr} - ${fdtaddr}\0" \
  1333. + "ramboot=echo Booting from ramdisk ...; " \
  1334. + "run ramargs; " \
  1335. + "bootz ${loadaddr} ${rdaddr} ${fdtaddr}\0" \
  1336. + "findfdt="\
  1337. + "setenv fdtfile am335x-chiliboard.dtb;\0" \
  1338. + NANDARGS \
  1339. + DFUARGS
  1340. +#endif
  1341. +
  1342. +#define CONFIG_BOOTCOMMAND \
  1343. + "run findfdt; " \
  1344. + "run mmcboot;" \
  1345. + "setenv mmcdev 1; " \
  1346. + "setenv bootpart 1:2; " \
  1347. + "run mmcboot;" \
  1348. + "run nandboot;"
  1349. +
  1350. +/* NS16550 Configuration */
  1351. +#define CONFIG_SYS_NS16550_COM1 0x44e09000 /* Base EVM has UART0 */
  1352. +#define CONFIG_SYS_NS16550_COM2 0x48022000 /* UART1 */
  1353. +#define CONFIG_SYS_NS16550_COM3 0x48024000 /* UART2 */
  1354. +#define CONFIG_SYS_NS16550_COM4 0x481a6000 /* UART3 */
  1355. +#define CONFIG_SYS_NS16550_COM5 0x481a8000 /* UART4 */
  1356. +#define CONFIG_SYS_NS16550_COM6 0x481aa000 /* UART5 */
  1357. +#define CONFIG_BAUDRATE 115200
  1358. +
  1359. +/*
  1360. +#define CONFIG_CMD_EEPROM
  1361. +#define CONFIG_ENV_EEPROM_IS_ON_I2C
  1362. +#define CONFIG_SYS_I2C_EEPROM_ADDR 0x50
  1363. +#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
  1364. +#define CONFIG_SYS_I2C_MULTI_EEPROMS
  1365. +*/
  1366. +
  1367. +/* PMIC support */
  1368. +#define CONFIG_POWER_TPS65217
  1369. +/* #define CONFIG_POWER_TPS65910 */
  1370. +
  1371. +/* SPL */
  1372. +#ifndef CONFIG_NOR_BOOT
  1373. +#define CONFIG_SPL_POWER_SUPPORT
  1374. +#define CONFIG_SPL_YMODEM_SUPPORT
  1375. +
  1376. +/* Bootcount using the RTC block */
  1377. +#define CONFIG_BOOTCOUNT_LIMIT
  1378. +#define CONFIG_BOOTCOUNT_AM33XX
  1379. +
  1380. +/* USB gadget RNDIS */
  1381. +#define CONFIG_SPL_MUSB_NEW_SUPPORT
  1382. +
  1383. +/* General network SPL, both CPSW and USB gadget RNDIS */
  1384. +#define CONFIG_SPL_NET_SUPPORT
  1385. +#define CONFIG_SPL_ENV_SUPPORT
  1386. +#define CONFIG_SPL_NET_VCI_STRING "AM335x U-Boot SPL"
  1387. +
  1388. +#define CONFIG_SPL_LDSCRIPT "$(CPUDIR)/am33xx/u-boot-spl.lds"
  1389. +
  1390. +#ifdef CONFIG_NAND
  1391. +#define CONFIG_NAND_OMAP_GPMC
  1392. +#define CONFIG_NAND_OMAP_ELM
  1393. +#define CONFIG_SYS_NAND_5_ADDR_CYCLE
  1394. +#define CONFIG_SYS_NAND_PAGE_COUNT (CONFIG_SYS_NAND_BLOCK_SIZE / \
  1395. + CONFIG_SYS_NAND_PAGE_SIZE)
  1396. +
  1397. +#ifndef CONFIG_NAND512MB
  1398. +#define CONFIG_SYS_NAND_PAGE_SIZE 2048
  1399. +#define CONFIG_SYS_NAND_OOBSIZE 64
  1400. +#define CONFIG_SYS_NAND_BLOCK_SIZE (128*1024)
  1401. +#define CONFIG_SYS_NAND_BAD_BLOCK_POS NAND_LARGE_BADBLOCK_POS
  1402. +#define CONFIG_SYS_NAND_ECCPOS { 2, 3, 4, 5, 6, 7, 8, 9, \
  1403. + 10, 11, 12, 13, 14, 15, 16, 17, \
  1404. + 18, 19, 20, 21, 22, 23, 24, 25, \
  1405. + 26, 27, 28, 29, 30, 31, 32, 33, \
  1406. + 34, 35, 36, 37, 38, 39, 40, 41, \
  1407. + 42, 43, 44, 45, 46, 47, 48, 49, \
  1408. + 50, 51, 52, 53, 54, 55, 56, 57, }
  1409. +
  1410. +#define CONFIG_SYS_NAND_ECCSIZE 512
  1411. +#define CONFIG_SYS_NAND_ECCBYTES 14
  1412. +#define CONFIG_SYS_NAND_ONFI_DETECTION
  1413. +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_BCH8_CODE_HW
  1414. +#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
  1415. +#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
  1416. +#else
  1417. +#define CONFIG_SYS_NAND_PAGE_SIZE 4096
  1418. +#define CONFIG_SYS_NAND_OOBSIZE 224
  1419. +#define CONFIG_SYS_NAND_BLOCK_SIZE (256*1024)
  1420. +#define CONFIG_SYS_NAND_BAD_BLOCK_POS NAND_LARGE_BADBLOCK_POS
  1421. +#define CONFIG_SYS_NAND_ECCPOS {\
  1422. + 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,\
  1423. + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,\
  1424. + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,\
  1425. + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,\
  1426. + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,\
  1427. + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,\
  1428. + 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,\
  1429. + 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,\
  1430. + 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,\
  1431. + 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,\
  1432. + 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,\
  1433. + 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,\
  1434. + 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,\
  1435. + 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,\
  1436. + 160, 161, 162, 163, 164, 165, 166, 167, 168, 169,\
  1437. + 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,\
  1438. + 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,\
  1439. + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199,\
  1440. + 200, 201, 202, 203, 204, 205, 206, 207, 208, 209}
  1441. +
  1442. +#define CONFIG_SYS_NAND_ECCSIZE 512
  1443. +#define CONFIG_SYS_NAND_ECCBYTES 26
  1444. +#define CONFIG_SYS_NAND_ONFI_DETECTION
  1445. +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_BCH16_CODE_HW
  1446. +#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
  1447. +#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x100000
  1448. +#endif
  1449. +
  1450. +#endif
  1451. +#endif
  1452. +
  1453. +/*
  1454. + * For NOR boot, we must set this to the start of where NOR is mapped
  1455. + * in memory.
  1456. + */
  1457. +#ifdef CONFIG_NOR_BOOT
  1458. +#define CONFIG_SYS_TEXT_BASE 0x08000000
  1459. +#endif
  1460. +
  1461. +/*
  1462. + * USB configuration. We enable MUSB support, both for host and for
  1463. + * gadget. We set USB0 as peripheral and USB1 as host, based on the
  1464. + * board schematic and physical port wired to each. Then for host we
  1465. + * add mass storage support and for gadget we add both RNDIS ethernet
  1466. + * and DFU.
  1467. + */
  1468. +#define CONFIG_USB_MUSB_DSPS
  1469. +#define CONFIG_ARCH_MISC_INIT
  1470. +#define CONFIG_MUSB_GADGET
  1471. +#define CONFIG_MUSB_PIO_ONLY
  1472. +#define CONFIG_MUSB_DISABLE_BULK_COMBINE_SPLIT
  1473. +#define CONFIG_USB_GADGET
  1474. +#define CONFIG_USBDOWNLOAD_GADGET
  1475. +#define CONFIG_USB_GADGET_DUALSPEED
  1476. +#define CONFIG_USB_GADGET_VBUS_DRAW 2
  1477. +#define CONFIG_MUSB_HOST
  1478. +#define CONFIG_AM335X_USB0
  1479. +#define CONFIG_AM335X_USB0_MODE MUSB_PERIPHERAL
  1480. +#define CONFIG_AM335X_USB1
  1481. +#define CONFIG_AM335X_USB1_MODE MUSB_HOST
  1482. +
  1483. +#ifdef CONFIG_MUSB_HOST
  1484. +#define CONFIG_CMD_USB
  1485. +#define CONFIG_USB_STORAGE
  1486. +#endif
  1487. +
  1488. +#ifdef CONFIG_MUSB_GADGET
  1489. +#define CONFIG_USB_ETHER
  1490. +#define CONFIG_USB_ETH_RNDIS
  1491. +#define CONFIG_USBNET_HOST_ADDR "de:ad:be:af:00:00"
  1492. +
  1493. +/* USB TI's IDs */
  1494. +#define CONFIG_G_DNL_VENDOR_NUM 0x0403
  1495. +#define CONFIG_G_DNL_PRODUCT_NUM 0xBD00
  1496. +#define CONFIG_G_DNL_MANUFACTURER "Texas Instruments"
  1497. +#endif /* CONFIG_MUSB_GADGET */
  1498. +
  1499. +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_USBETH_SUPPORT)
  1500. +/* disable host part of MUSB in SPL */
  1501. +#undef CONFIG_MUSB_HOST
  1502. +/* disable EFI partitions and partition UUID support */
  1503. +#undef CONFIG_PARTITION_UUIDS
  1504. +#undef CONFIG_EFI_PARTITION
  1505. +/*
  1506. + * Disable CPSW SPL support so we fit within the 101KiB limit.
  1507. + */
  1508. +#undef CONFIG_SPL_ETH_SUPPORT
  1509. +#endif
  1510. +
  1511. +/* USB Device Firmware Update support */
  1512. +#ifndef CONFIG_SPL_BUILD
  1513. +#define CONFIG_DFU_FUNCTION
  1514. +#define CONFIG_DFU_MMC
  1515. +#define CONFIG_CMD_DFU
  1516. +#define DFU_ALT_INFO_MMC \
  1517. + "dfu_alt_info_mmc=" \
  1518. + "boot part 0 1;" \
  1519. + "rootfs part 0 2;" \
  1520. + "MLO fat 0 1;" \
  1521. + "MLO.raw mmc 0x100 0x100;" \
  1522. + "u-boot.img.raw mmc 0x300 0x400;" \
  1523. + "spl-os-args.raw mmc 0x80 0x80;" \
  1524. + "spl-os-image.raw mmc 0x900 0x2000;" \
  1525. + "spl-os-args fat 0 1;" \
  1526. + "spl-os-image fat 0 1;" \
  1527. + "u-boot.img fat 0 1;" \
  1528. + "uEnv.txt fat 0 1\0"
  1529. +#ifdef CONFIG_NAND
  1530. +#define CONFIG_DFU_NAND
  1531. +#define DFU_ALT_INFO_NAND \
  1532. + "dfu_alt_info_nand=" \
  1533. + "SPL part 0 1;" \
  1534. + "SPL.backup1 part 0 2;" \
  1535. + "SPL.backup2 part 0 3;" \
  1536. + "SPL.backup3 part 0 4;" \
  1537. + "u-boot part 0 5;" \
  1538. + "u-boot-spl-os part 0 6;" \
  1539. + "kernel part 0 8;" \
  1540. + "rootfs part 0 9\0"
  1541. +#else
  1542. +#define DFU_ALT_INFO_NAND ""
  1543. +#endif
  1544. +#define CONFIG_DFU_RAM
  1545. +#define DFU_ALT_INFO_RAM \
  1546. + "dfu_alt_info_ram=" \
  1547. + "kernel ram 0x80200000 0xD80000;" \
  1548. + "fdt ram 0x80F80000 0x80000;" \
  1549. + "ramdisk ram 0x81000000 0x4000000\0"
  1550. +#define DFUARGS \
  1551. + "dfu_alt_info_emmc=rawemmc mmc 0 3751936\0" \
  1552. + DFU_ALT_INFO_MMC \
  1553. + DFU_ALT_INFO_RAM \
  1554. + DFU_ALT_INFO_NAND
  1555. +#endif
  1556. +
  1557. +/*
  1558. + * Default to using SPI for environment, etc.
  1559. + * 0x000000 - 0x020000 : SPL (128KiB)
  1560. + * 0x020000 - 0x0A0000 : U-Boot (512KiB)
  1561. + * 0x0A0000 - 0x0BFFFF : First copy of U-Boot Environment (128KiB)
  1562. + * 0x0C0000 - 0x0DFFFF : Second copy of U-Boot Environment (128KiB)
  1563. + * 0x0E0000 - 0x442000 : Linux Kernel
  1564. + * 0x442000 - 0x800000 : Userland
  1565. + */
  1566. +#if defined(CONFIG_SPI_BOOT)
  1567. +/* SPL related */
  1568. +#undef CONFIG_SPL_OS_BOOT /* Not supported by existing map */
  1569. +#define CONFIG_SPL_SPI_SUPPORT
  1570. +#define CONFIG_SPL_SPI_FLASH_SUPPORT
  1571. +#define CONFIG_SPL_SPI_LOAD
  1572. +#define CONFIG_SPL_SPI_BUS 0
  1573. +#define CONFIG_SPL_SPI_CS 0
  1574. +#define CONFIG_SYS_SPI_U_BOOT_OFFS 0x20000
  1575. +
  1576. +#define CONFIG_ENV_IS_IN_SPI_FLASH
  1577. +#define CONFIG_SYS_REDUNDAND_ENVIRONMENT
  1578. +#define CONFIG_ENV_SPI_MAX_HZ CONFIG_SF_DEFAULT_SPEED
  1579. +#define CONFIG_ENV_SECT_SIZE (4 << 10) /* 4 KB sectors */
  1580. +#define CONFIG_ENV_OFFSET (768 << 10) /* 768 KiB in */
  1581. +#define CONFIG_ENV_OFFSET_REDUND (896 << 10) /* 896 KiB in */
  1582. +#define MTDIDS_DEFAULT "nor0=m25p80-flash.0"
  1583. +#define MTDPARTS_DEFAULT "mtdparts=m25p80-flash.0:128k(SPL)," \
  1584. + "512k(u-boot),128k(u-boot-env1)," \
  1585. + "128k(u-boot-env2),3464k(kernel)," \
  1586. + "-(rootfs)"
  1587. +#elif defined(CONFIG_EMMC_BOOT)
  1588. +#undef CONFIG_ENV_IS_NOWHERE
  1589. +#define CONFIG_ENV_IS_IN_MMC
  1590. +#define CONFIG_SYS_MMC_ENV_DEV 1
  1591. +#define CONFIG_SYS_MMC_ENV_PART 2
  1592. +#define CONFIG_ENV_OFFSET 0x0
  1593. +#define CONFIG_ENV_OFFSET_REDUND (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)
  1594. +#define CONFIG_SYS_REDUNDAND_ENVIRONMENT
  1595. +#endif
  1596. +
  1597. +/* SPI flash. */
  1598. +#define CONFIG_CMD_SF
  1599. +#define CONFIG_SPI_FLASH
  1600. +#define CONFIG_SPI_FLASH_WINBOND
  1601. +#define CONFIG_SF_DEFAULT_SPEED 24000000
  1602. +
  1603. +/* Network. */
  1604. +#define CONFIG_PHY_GIGE
  1605. +#define CONFIG_PHYLIB
  1606. +#define CONFIG_PHY_SMSC
  1607. +
  1608. +/* NAND support */
  1609. +#ifdef CONFIG_NAND
  1610. +#define CONFIG_CMD_NAND
  1611. +#if !defined(CONFIG_SPI_BOOT) && !defined(CONFIG_NOR_BOOT)
  1612. +#define MTDIDS_DEFAULT "nand0=omap2-nand.0"
  1613. +
  1614. +#ifndef CONFIG_NAND512MB
  1615. +#define MTDPARTS_DEFAULT "mtdparts=omap2-nand.0:128k(SPL)," \
  1616. + "128k(SPL.backup1)," \
  1617. + "128k(SPL.backup2)," \
  1618. + "128k(SPL.backup3),1792k(u-boot)," \
  1619. + "128k(u-boot-spl-os)," \
  1620. + "128k(u-boot-env),5m(kernel),-(rootfs)"
  1621. +#define CONFIG_ENV_IS_IN_NAND
  1622. +#define CONFIG_ENV_OFFSET 0x260000 /* environment starts here */
  1623. +#define CONFIG_SYS_ENV_SECT_SIZE (128 << 10) /* 128 KiB */
  1624. +#else
  1625. +#define MTDPARTS_DEFAULT "mtdparts=omap2-nand.0:256k(SPL)," \
  1626. + "256k(SPL.backup1)," \
  1627. + "256k(SPL.backup2)," \
  1628. + "256k(SPL.backup3),2048k(u-boot)," \
  1629. + "256k(u-boot-spl-os)," \
  1630. + "256k(u-boot-env),5m(kernel),-(rootfs)"
  1631. +#define CONFIG_ENV_IS_IN_NAND
  1632. +#define CONFIG_ENV_OFFSET 0x340000 /* environment starts here */
  1633. +#define CONFIG_SYS_ENV_SECT_SIZE (128 << 10) /* 128 KiB */
  1634. +#endif
  1635. +
  1636. +#endif
  1637. +#endif
  1638. +
  1639. +/*
  1640. + * NOR Size = 16 MiB
  1641. + * Number of Sectors/Blocks = 128
  1642. + * Sector Size = 128 KiB
  1643. + * Word length = 16 bits
  1644. + * Default layout:
  1645. + * 0x000000 - 0x07FFFF : U-Boot (512 KiB)
  1646. + * 0x080000 - 0x09FFFF : First copy of U-Boot Environment (128 KiB)
  1647. + * 0x0A0000 - 0x0BFFFF : Second copy of U-Boot Environment (128 KiB)
  1648. + * 0x0C0000 - 0x4BFFFF : Linux Kernel (4 MiB)
  1649. + * 0x4C0000 - 0xFFFFFF : Userland (11 MiB + 256 KiB)
  1650. + */
  1651. +#if defined(CONFIG_NOR)
  1652. +#undef CONFIG_SYS_NO_FLASH
  1653. +#define CONFIG_CMD_FLASH
  1654. +#define CONFIG_SYS_FLASH_USE_BUFFER_WRITE
  1655. +#define CONFIG_SYS_FLASH_PROTECTION
  1656. +#define CONFIG_SYS_FLASH_CFI
  1657. +#define CONFIG_FLASH_CFI_DRIVER
  1658. +#define CONFIG_FLASH_CFI_MTD
  1659. +#define CONFIG_SYS_MAX_FLASH_SECT 128
  1660. +#define CONFIG_SYS_MAX_FLASH_BANKS 1
  1661. +#define CONFIG_SYS_FLASH_BASE (0x08000000)
  1662. +#define CONFIG_SYS_FLASH_CFI_WIDTH FLASH_CFI_16BIT
  1663. +#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_FLASH_BASE
  1664. +/* Reduce SPL size by removing unlikey targets */
  1665. +#ifdef CONFIG_NOR_BOOT
  1666. +#define CONFIG_ENV_IS_IN_FLASH
  1667. +#define CONFIG_ENV_SECT_SIZE (128 << 10) /* 128 KiB */
  1668. +#define CONFIG_ENV_OFFSET (512 << 10) /* 512 KiB */
  1669. +#define CONFIG_ENV_OFFSET_REDUND (768 << 10) /* 768 KiB */
  1670. +#define MTDIDS_DEFAULT "nor0=physmap-flash.0"
  1671. +#define MTDPARTS_DEFAULT "mtdparts=physmap-flash.0:" \
  1672. + "512k(u-boot)," \
  1673. + "128k(u-boot-env1)," \
  1674. + "128k(u-boot-env2)," \
  1675. + "4m(kernel),-(rootfs)"
  1676. +#endif
  1677. +#endif /* NOR support */
  1678. +
  1679. +#endif /* ! __CONFIG_CHILISOM_H */
  1680. --
  1681. 2.5.0