board.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236
  1. /*
  2. * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
  3. *
  4. * Author: Felipe Balbi <balbi@ti.com>
  5. *
  6. * Based on board/ti/dra7xx/evm.c
  7. *
  8. * SPDX-License-Identifier: GPL-2.0+
  9. */
  10. #include <common.h>
  11. #include <palmas.h>
  12. #include <sata.h>
  13. #include <usb.h>
  14. #include <asm/omap_common.h>
  15. #include <asm/omap_sec_common.h>
  16. #include <asm/emif.h>
  17. #include <asm/gpio.h>
  18. #include <asm/arch/gpio.h>
  19. #include <asm/arch/clock.h>
  20. #include <asm/arch/dra7xx_iodelay.h>
  21. #include <asm/arch/sys_proto.h>
  22. #include <asm/arch/mmc_host_def.h>
  23. #include <asm/arch/sata.h>
  24. #include <asm/arch/gpio.h>
  25. #include <asm/arch/omap.h>
  26. #include <environment.h>
  27. #include <usb.h>
  28. #include <linux/usb/gadget.h>
  29. #include <dwc3-uboot.h>
  30. #include <dwc3-omap-uboot.h>
  31. #include <ti-usb-phy-uboot.h>
  32. #include "../common/board_detect.h"
  33. #include "mux_data.h"
  34. #define board_is_x15() board_ti_is("BBRDX15_")
  35. #define board_is_x15_revb1() (board_ti_is("BBRDX15_") && \
  36. !strncmp("B.10", board_ti_get_rev(), 3))
  37. #define board_is_x15_revc() (board_ti_is("BBRDX15_") && \
  38. !strncmp("C.00", board_ti_get_rev(), 3))
  39. #define board_is_am572x_evm() board_ti_is("AM572PM_")
  40. #define board_is_am572x_evm_reva3() \
  41. (board_ti_is("AM572PM_") && \
  42. !strncmp("A.30", board_ti_get_rev(), 3))
  43. #define board_is_am574x_idk() board_ti_is("AM574IDK")
  44. #define board_is_am572x_idk() board_ti_is("AM572IDK")
  45. #define board_is_am571x_idk() board_ti_is("AM571IDK")
  46. #ifdef CONFIG_DRIVER_TI_CPSW
  47. #include <cpsw.h>
  48. #endif
  49. DECLARE_GLOBAL_DATA_PTR;
  50. #define GPIO_ETH_LCD GPIO_TO_PIN(2, 22)
  51. /* GPIO 7_11 */
  52. #define GPIO_DDR_VTT_EN 203
  53. /* Touch screen controller to identify the LCD */
  54. #define OSD_TS_FT_BUS_ADDRESS 0
  55. #define OSD_TS_FT_CHIP_ADDRESS 0x38
  56. #define OSD_TS_FT_REG_ID 0xA3
  57. /*
  58. * Touchscreen IDs for various OSD panels
  59. * Ref: http://www.osddisplays.com/TI/OSD101T2587-53TS_A.1.pdf
  60. */
  61. /* Used on newer osd101t2587 Panels */
  62. #define OSD_TS_FT_ID_5x46 0x54
  63. /* Used on older osd101t2045 Panels */
  64. #define OSD_TS_FT_ID_5606 0x08
  65. #define SYSINFO_BOARD_NAME_MAX_LEN 45
  66. #define TPS65903X_PRIMARY_SECONDARY_PAD2 0xFB
  67. #define TPS65903X_PAD2_POWERHOLD_MASK 0x20
  68. const struct omap_sysinfo sysinfo = {
  69. "Board: UNKNOWN(BeagleBoard X15?) REV UNKNOWN\n"
  70. };
  71. static const struct dmm_lisa_map_regs beagle_x15_lisa_regs = {
  72. .dmm_lisa_map_3 = 0x80740300,
  73. .is_ma_present = 0x1
  74. };
  75. static const struct dmm_lisa_map_regs am571x_idk_lisa_regs = {
  76. .dmm_lisa_map_3 = 0x80640100,
  77. .is_ma_present = 0x1
  78. };
  79. static const struct dmm_lisa_map_regs am574x_idk_lisa_regs = {
  80. .dmm_lisa_map_2 = 0xc0600200,
  81. .dmm_lisa_map_3 = 0x80600100,
  82. .is_ma_present = 0x1
  83. };
  84. void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs)
  85. {
  86. if (board_is_am571x_idk())
  87. *dmm_lisa_regs = &am571x_idk_lisa_regs;
  88. else if (board_is_am574x_idk())
  89. *dmm_lisa_regs = &am574x_idk_lisa_regs;
  90. else
  91. *dmm_lisa_regs = &beagle_x15_lisa_regs;
  92. }
  93. static const struct emif_regs beagle_x15_emif1_ddr3_532mhz_emif_regs = {
  94. .sdram_config_init = 0x61851b32,
  95. .sdram_config = 0x61851b32,
  96. .sdram_config2 = 0x08000000,
  97. .ref_ctrl = 0x000040F1,
  98. .ref_ctrl_final = 0x00001035,
  99. .sdram_tim1 = 0xcccf36ab,
  100. .sdram_tim2 = 0x308f7fda,
  101. .sdram_tim3 = 0x409f88a8,
  102. .read_idle_ctrl = 0x00050000,
  103. .zq_config = 0x5007190b,
  104. .temp_alert_config = 0x00000000,
  105. .emif_ddr_phy_ctlr_1_init = 0x0024400b,
  106. .emif_ddr_phy_ctlr_1 = 0x0e24400b,
  107. .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
  108. .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
  109. .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
  110. .emif_ddr_ext_phy_ctrl_4 = 0x009b009b,
  111. .emif_ddr_ext_phy_ctrl_5 = 0x009e009e,
  112. .emif_rd_wr_lvl_rmp_win = 0x00000000,
  113. .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
  114. .emif_rd_wr_lvl_ctl = 0x00000000,
  115. .emif_rd_wr_exec_thresh = 0x00000305
  116. };
  117. /* Ext phy ctrl regs 1-35 */
  118. static const u32 beagle_x15_emif1_ddr3_ext_phy_ctrl_const_regs[] = {
  119. 0x10040100,
  120. 0x00910091,
  121. 0x00950095,
  122. 0x009B009B,
  123. 0x009E009E,
  124. 0x00980098,
  125. 0x00340034,
  126. 0x00350035,
  127. 0x00340034,
  128. 0x00310031,
  129. 0x00340034,
  130. 0x007F007F,
  131. 0x007F007F,
  132. 0x007F007F,
  133. 0x007F007F,
  134. 0x007F007F,
  135. 0x00480048,
  136. 0x004A004A,
  137. 0x00520052,
  138. 0x00550055,
  139. 0x00500050,
  140. 0x00000000,
  141. 0x00600020,
  142. 0x40011080,
  143. 0x08102040,
  144. 0x0,
  145. 0x0,
  146. 0x0,
  147. 0x0,
  148. 0x0,
  149. 0x0,
  150. 0x0,
  151. 0x0,
  152. 0x0,
  153. 0x0
  154. };
  155. static const struct emif_regs beagle_x15_emif2_ddr3_532mhz_emif_regs = {
  156. .sdram_config_init = 0x61851b32,
  157. .sdram_config = 0x61851b32,
  158. .sdram_config2 = 0x08000000,
  159. .ref_ctrl = 0x000040F1,
  160. .ref_ctrl_final = 0x00001035,
  161. .sdram_tim1 = 0xcccf36b3,
  162. .sdram_tim2 = 0x308f7fda,
  163. .sdram_tim3 = 0x407f88a8,
  164. .read_idle_ctrl = 0x00050000,
  165. .zq_config = 0x5007190b,
  166. .temp_alert_config = 0x00000000,
  167. .emif_ddr_phy_ctlr_1_init = 0x0024400b,
  168. .emif_ddr_phy_ctlr_1 = 0x0e24400b,
  169. .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
  170. .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
  171. .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
  172. .emif_ddr_ext_phy_ctrl_4 = 0x009b009b,
  173. .emif_ddr_ext_phy_ctrl_5 = 0x009e009e,
  174. .emif_rd_wr_lvl_rmp_win = 0x00000000,
  175. .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
  176. .emif_rd_wr_lvl_ctl = 0x00000000,
  177. .emif_rd_wr_exec_thresh = 0x00000305
  178. };
  179. static const u32 beagle_x15_emif2_ddr3_ext_phy_ctrl_const_regs[] = {
  180. 0x10040100,
  181. 0x00910091,
  182. 0x00950095,
  183. 0x009B009B,
  184. 0x009E009E,
  185. 0x00980098,
  186. 0x00340034,
  187. 0x00350035,
  188. 0x00340034,
  189. 0x00310031,
  190. 0x00340034,
  191. 0x007F007F,
  192. 0x007F007F,
  193. 0x007F007F,
  194. 0x007F007F,
  195. 0x007F007F,
  196. 0x00480048,
  197. 0x004A004A,
  198. 0x00520052,
  199. 0x00550055,
  200. 0x00500050,
  201. 0x00000000,
  202. 0x00600020,
  203. 0x40011080,
  204. 0x08102040,
  205. 0x0,
  206. 0x0,
  207. 0x0,
  208. 0x0,
  209. 0x0,
  210. 0x0,
  211. 0x0,
  212. 0x0,
  213. 0x0,
  214. 0x0
  215. };
  216. static const struct emif_regs am571x_emif1_ddr3_666mhz_emif_regs = {
  217. .sdram_config_init = 0x61863332,
  218. .sdram_config = 0x61863332,
  219. .sdram_config2 = 0x08000000,
  220. .ref_ctrl = 0x0000514d,
  221. .ref_ctrl_final = 0x0000144a,
  222. .sdram_tim1 = 0xd333887c,
  223. .sdram_tim2 = 0x30b37fe3,
  224. .sdram_tim3 = 0x409f8ad8,
  225. .read_idle_ctrl = 0x00050000,
  226. .zq_config = 0x5007190b,
  227. .temp_alert_config = 0x00000000,
  228. .emif_ddr_phy_ctlr_1_init = 0x0024400f,
  229. .emif_ddr_phy_ctlr_1 = 0x0e24400f,
  230. .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
  231. .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
  232. .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
  233. .emif_ddr_ext_phy_ctrl_4 = 0x009b009b,
  234. .emif_ddr_ext_phy_ctrl_5 = 0x009e009e,
  235. .emif_rd_wr_lvl_rmp_win = 0x00000000,
  236. .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
  237. .emif_rd_wr_lvl_ctl = 0x00000000,
  238. .emif_rd_wr_exec_thresh = 0x00000305
  239. };
  240. static const struct emif_regs am574x_emif1_ddr3_666mhz_emif_ecc_regs = {
  241. .sdram_config_init = 0x61863332,
  242. .sdram_config = 0x61863332,
  243. .sdram_config2 = 0x08000000,
  244. .ref_ctrl = 0x0000514d,
  245. .ref_ctrl_final = 0x0000144a,
  246. .sdram_tim1 = 0xd333887c,
  247. .sdram_tim2 = 0x30b37fe3,
  248. .sdram_tim3 = 0x409f8ad8,
  249. .read_idle_ctrl = 0x00050000,
  250. .zq_config = 0x5007190b,
  251. .temp_alert_config = 0x00000000,
  252. .emif_ddr_phy_ctlr_1_init = 0x0024400f,
  253. .emif_ddr_phy_ctlr_1 = 0x0e24400f,
  254. .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
  255. .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
  256. .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
  257. .emif_ddr_ext_phy_ctrl_4 = 0x009b009b,
  258. .emif_ddr_ext_phy_ctrl_5 = 0x009e009e,
  259. .emif_rd_wr_lvl_rmp_win = 0x00000000,
  260. .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
  261. .emif_rd_wr_lvl_ctl = 0x00000000,
  262. .emif_rd_wr_exec_thresh = 0x00000305,
  263. .emif_ecc_ctrl_reg = 0xD0000001,
  264. .emif_ecc_address_range_1 = 0x3FFF0000,
  265. .emif_ecc_address_range_2 = 0x00000000
  266. };
  267. void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs)
  268. {
  269. switch (emif_nr) {
  270. case 1:
  271. if (board_is_am571x_idk())
  272. *regs = &am571x_emif1_ddr3_666mhz_emif_regs;
  273. else if (board_is_am574x_idk())
  274. *regs = &am574x_emif1_ddr3_666mhz_emif_ecc_regs;
  275. else
  276. *regs = &beagle_x15_emif1_ddr3_532mhz_emif_regs;
  277. break;
  278. case 2:
  279. if (board_is_am574x_idk())
  280. *regs = &am571x_emif1_ddr3_666mhz_emif_regs;
  281. else
  282. *regs = &beagle_x15_emif2_ddr3_532mhz_emif_regs;
  283. break;
  284. }
  285. }
  286. void emif_get_ext_phy_ctrl_const_regs(u32 emif_nr, const u32 **regs, u32 *size)
  287. {
  288. switch (emif_nr) {
  289. case 1:
  290. *regs = beagle_x15_emif1_ddr3_ext_phy_ctrl_const_regs;
  291. *size = ARRAY_SIZE(beagle_x15_emif1_ddr3_ext_phy_ctrl_const_regs);
  292. break;
  293. case 2:
  294. *regs = beagle_x15_emif2_ddr3_ext_phy_ctrl_const_regs;
  295. *size = ARRAY_SIZE(beagle_x15_emif2_ddr3_ext_phy_ctrl_const_regs);
  296. break;
  297. }
  298. }
  299. struct vcores_data beagle_x15_volts = {
  300. .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
  301. .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
  302. .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  303. .mpu.addr = TPS659038_REG_ADDR_SMPS12,
  304. .mpu.pmic = &tps659038,
  305. .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
  306. .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
  307. .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
  308. .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
  309. .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
  310. .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
  311. .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
  312. .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  313. .eve.addr = TPS659038_REG_ADDR_SMPS45,
  314. .eve.pmic = &tps659038,
  315. .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
  316. .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
  317. .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
  318. .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
  319. .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
  320. .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
  321. .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
  322. .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  323. .gpu.addr = TPS659038_REG_ADDR_SMPS45,
  324. .gpu.pmic = &tps659038,
  325. .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
  326. .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
  327. .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
  328. .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  329. .core.addr = TPS659038_REG_ADDR_SMPS6,
  330. .core.pmic = &tps659038,
  331. .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
  332. .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
  333. .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
  334. .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
  335. .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
  336. .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
  337. .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  338. .iva.addr = TPS659038_REG_ADDR_SMPS45,
  339. .iva.pmic = &tps659038,
  340. .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
  341. };
  342. struct vcores_data am572x_idk_volts = {
  343. .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
  344. .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
  345. .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  346. .mpu.addr = TPS659038_REG_ADDR_SMPS12,
  347. .mpu.pmic = &tps659038,
  348. .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
  349. .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
  350. .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
  351. .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
  352. .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
  353. .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
  354. .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
  355. .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  356. .eve.addr = TPS659038_REG_ADDR_SMPS45,
  357. .eve.pmic = &tps659038,
  358. .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
  359. .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
  360. .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
  361. .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
  362. .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
  363. .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
  364. .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
  365. .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  366. .gpu.addr = TPS659038_REG_ADDR_SMPS6,
  367. .gpu.pmic = &tps659038,
  368. .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
  369. .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
  370. .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
  371. .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  372. .core.addr = TPS659038_REG_ADDR_SMPS7,
  373. .core.pmic = &tps659038,
  374. .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
  375. .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
  376. .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
  377. .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
  378. .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
  379. .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
  380. .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  381. .iva.addr = TPS659038_REG_ADDR_SMPS8,
  382. .iva.pmic = &tps659038,
  383. .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
  384. };
  385. struct vcores_data am571x_idk_volts = {
  386. .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
  387. .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
  388. .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  389. .mpu.addr = TPS659038_REG_ADDR_SMPS12,
  390. .mpu.pmic = &tps659038,
  391. .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
  392. .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
  393. .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
  394. .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
  395. .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
  396. .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
  397. .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
  398. .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  399. .eve.addr = TPS659038_REG_ADDR_SMPS45,
  400. .eve.pmic = &tps659038,
  401. .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
  402. .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
  403. .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
  404. .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
  405. .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
  406. .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
  407. .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
  408. .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  409. .gpu.addr = TPS659038_REG_ADDR_SMPS6,
  410. .gpu.pmic = &tps659038,
  411. .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
  412. .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
  413. .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
  414. .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  415. .core.addr = TPS659038_REG_ADDR_SMPS7,
  416. .core.pmic = &tps659038,
  417. .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
  418. .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
  419. .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
  420. .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
  421. .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
  422. .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
  423. .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  424. .iva.addr = TPS659038_REG_ADDR_SMPS45,
  425. .iva.pmic = &tps659038,
  426. .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
  427. };
  428. int get_voltrail_opp(int rail_offset)
  429. {
  430. int opp;
  431. switch (rail_offset) {
  432. case VOLT_MPU:
  433. opp = DRA7_MPU_OPP;
  434. break;
  435. case VOLT_CORE:
  436. opp = DRA7_CORE_OPP;
  437. break;
  438. case VOLT_GPU:
  439. opp = DRA7_GPU_OPP;
  440. break;
  441. case VOLT_EVE:
  442. opp = DRA7_DSPEVE_OPP;
  443. break;
  444. case VOLT_IVA:
  445. opp = DRA7_IVA_OPP;
  446. break;
  447. default:
  448. opp = OPP_NOM;
  449. }
  450. return opp;
  451. }
  452. #ifdef CONFIG_SPL_BUILD
  453. /* No env to setup for SPL */
  454. static inline void setup_board_eeprom_env(void) { }
  455. /* Override function to read eeprom information */
  456. void do_board_detect(void)
  457. {
  458. int rc;
  459. rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
  460. CONFIG_EEPROM_CHIP_ADDRESS);
  461. if (rc)
  462. printf("ti_i2c_eeprom_init failed %d\n", rc);
  463. }
  464. #else /* CONFIG_SPL_BUILD */
  465. /* Override function to read eeprom information: actual i2c read done by SPL*/
  466. void do_board_detect(void)
  467. {
  468. char *bname = NULL;
  469. int rc;
  470. rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
  471. CONFIG_EEPROM_CHIP_ADDRESS);
  472. if (rc)
  473. printf("ti_i2c_eeprom_init failed %d\n", rc);
  474. if (board_is_x15())
  475. bname = "BeagleBoard X15";
  476. else if (board_is_am572x_evm())
  477. bname = "AM572x EVM";
  478. else if (board_is_am574x_idk())
  479. bname = "AM574x IDK";
  480. else if (board_is_am572x_idk())
  481. bname = "AM572x IDK";
  482. else if (board_is_am571x_idk())
  483. bname = "AM571x IDK";
  484. if (bname)
  485. snprintf(sysinfo.board_string, SYSINFO_BOARD_NAME_MAX_LEN,
  486. "Board: %s REV %s\n", bname, board_ti_get_rev());
  487. }
  488. static void setup_board_eeprom_env(void)
  489. {
  490. char *name = "beagle_x15";
  491. int rc;
  492. rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
  493. CONFIG_EEPROM_CHIP_ADDRESS);
  494. if (rc)
  495. goto invalid_eeprom;
  496. if (board_is_x15()) {
  497. if (board_is_x15_revb1())
  498. name = "beagle_x15_revb1";
  499. else if (board_is_x15_revc())
  500. name = "beagle_x15_revc";
  501. else
  502. name = "beagle_x15";
  503. } else if (board_is_am572x_evm()) {
  504. if (board_is_am572x_evm_reva3())
  505. name = "am57xx_evm_reva3";
  506. else
  507. name = "am57xx_evm";
  508. } else if (board_is_am574x_idk()) {
  509. name = "am574x_idk";
  510. } else if (board_is_am572x_idk()) {
  511. name = "am572x_idk";
  512. } else if (board_is_am571x_idk()) {
  513. name = "am571x_idk";
  514. } else {
  515. printf("Unidentified board claims %s in eeprom header\n",
  516. board_ti_get_name());
  517. }
  518. invalid_eeprom:
  519. set_board_info_env(name);
  520. }
  521. #endif /* CONFIG_SPL_BUILD */
  522. void vcores_init(void)
  523. {
  524. if (board_is_am572x_idk() || board_is_am574x_idk())
  525. *omap_vcores = &am572x_idk_volts;
  526. else if (board_is_am571x_idk())
  527. *omap_vcores = &am571x_idk_volts;
  528. else
  529. *omap_vcores = &beagle_x15_volts;
  530. }
  531. void hw_data_init(void)
  532. {
  533. *prcm = &dra7xx_prcm;
  534. if (is_dra72x())
  535. *dplls_data = &dra72x_dplls;
  536. else if (is_dra76x())
  537. *dplls_data = &dra76x_dplls;
  538. else
  539. *dplls_data = &dra7xx_dplls;
  540. *ctrl = &dra7xx_ctrl;
  541. }
  542. bool am571x_idk_needs_lcd(void)
  543. {
  544. bool needs_lcd;
  545. gpio_request(GPIO_ETH_LCD, "nLCD_Detect");
  546. if (gpio_get_value(GPIO_ETH_LCD))
  547. needs_lcd = false;
  548. else
  549. needs_lcd = true;
  550. gpio_free(GPIO_ETH_LCD);
  551. return needs_lcd;
  552. }
  553. int board_init(void)
  554. {
  555. gpmc_init();
  556. gd->bd->bi_boot_params = (CONFIG_SYS_SDRAM_BASE + 0x100);
  557. return 0;
  558. }
  559. void am57x_idk_lcd_detect(void)
  560. {
  561. int r = -ENODEV;
  562. char *idk_lcd = "no";
  563. uint8_t buf = 0;
  564. /* Only valid for IDKs */
  565. if (board_is_x15() || board_is_am572x_evm())
  566. return;
  567. /* Only AM571x IDK has gpio control detect.. so check that */
  568. if (board_is_am571x_idk() && !am571x_idk_needs_lcd())
  569. goto out;
  570. r = i2c_set_bus_num(OSD_TS_FT_BUS_ADDRESS);
  571. if (r) {
  572. printf("%s: Failed to set bus address to %d: %d\n",
  573. __func__, OSD_TS_FT_BUS_ADDRESS, r);
  574. goto out;
  575. }
  576. r = i2c_probe(OSD_TS_FT_CHIP_ADDRESS);
  577. if (r) {
  578. /* AM572x IDK has no explicit settings for optional LCD kit */
  579. if (board_is_am571x_idk()) {
  580. printf("%s: Touch screen detect failed: %d!\n",
  581. __func__, r);
  582. }
  583. goto out;
  584. }
  585. /* Read FT ID */
  586. r = i2c_read(OSD_TS_FT_CHIP_ADDRESS, OSD_TS_FT_REG_ID, 1, &buf, 1);
  587. if (r) {
  588. printf("%s: Touch screen ID read %d:0x%02x[0x%02x] failed:%d\n",
  589. __func__, OSD_TS_FT_BUS_ADDRESS, OSD_TS_FT_CHIP_ADDRESS,
  590. OSD_TS_FT_REG_ID, r);
  591. goto out;
  592. }
  593. switch (buf) {
  594. case OSD_TS_FT_ID_5606:
  595. idk_lcd = "osd101t2045";
  596. break;
  597. case OSD_TS_FT_ID_5x46:
  598. idk_lcd = "osd101t2587";
  599. break;
  600. default:
  601. printf("%s: Unidentifed Touch screen ID 0x%02x\n",
  602. __func__, buf);
  603. /* we will let default be "no lcd" */
  604. }
  605. out:
  606. setenv("idk_lcd", idk_lcd);
  607. /*
  608. * On AM571x_IDK, no Display with J51 set to LCD is considered as an
  609. * invalid configuration and we prevent boot to get user attention.
  610. */
  611. if (board_is_am571x_idk() && am571x_idk_needs_lcd() &&
  612. !strncmp(idk_lcd, "no", 2)) {
  613. printf("%s: Invalid HW configuration: display not detected/supported but J51 is set. Remove J51 to boot without display.\n",
  614. __func__);
  615. hang();
  616. }
  617. return;
  618. }
  619. int board_late_init(void)
  620. {
  621. setup_board_eeprom_env();
  622. u8 val;
  623. /*
  624. * DEV_CTRL.DEV_ON = 1 please - else palmas switches off in 8 seconds
  625. * This is the POWERHOLD-in-Low behavior.
  626. */
  627. palmas_i2c_write_u8(TPS65903X_CHIP_P1, 0xA0, 0x1);
  628. /*
  629. * Default FIT boot on HS devices. Non FIT images are not allowed
  630. * on HS devices.
  631. */
  632. if (get_device_type() == HS_DEVICE)
  633. setenv("boot_fit", "1");
  634. /*
  635. * Set the GPIO7 Pad to POWERHOLD. This has higher priority
  636. * over DEV_CTRL.DEV_ON bit. This can be reset in case of
  637. * PMIC Power off. So to be on the safer side set it back
  638. * to POWERHOLD mode irrespective of the current state.
  639. */
  640. palmas_i2c_read_u8(TPS65903X_CHIP_P1, TPS65903X_PRIMARY_SECONDARY_PAD2,
  641. &val);
  642. val = val | TPS65903X_PAD2_POWERHOLD_MASK;
  643. palmas_i2c_write_u8(TPS65903X_CHIP_P1, TPS65903X_PRIMARY_SECONDARY_PAD2,
  644. val);
  645. am57x_idk_lcd_detect();
  646. #if !defined(CONFIG_SPL_BUILD)
  647. board_ti_set_ethaddr(2);
  648. #endif
  649. omap_die_id_serial();
  650. omap_set_fastboot_vars();
  651. return 0;
  652. }
  653. void set_muxconf_regs(void)
  654. {
  655. do_set_mux32((*ctrl)->control_padconf_core_base,
  656. early_padconf, ARRAY_SIZE(early_padconf));
  657. }
  658. #ifdef CONFIG_IODELAY_RECALIBRATION
  659. void recalibrate_iodelay(void)
  660. {
  661. const struct pad_conf_entry *pconf;
  662. const struct iodelay_cfg_entry *iod, *delta_iod;
  663. int pconf_sz, iod_sz, delta_iod_sz = 0;
  664. int ret;
  665. if (board_is_am572x_idk()) {
  666. pconf = core_padconf_array_essential_am572x_idk;
  667. pconf_sz = ARRAY_SIZE(core_padconf_array_essential_am572x_idk);
  668. iod = iodelay_cfg_array_am572x_idk;
  669. iod_sz = ARRAY_SIZE(iodelay_cfg_array_am572x_idk);
  670. } else if (board_is_am574x_idk()) {
  671. pconf = core_padconf_array_essential_am574x_idk;
  672. pconf_sz = ARRAY_SIZE(core_padconf_array_essential_am574x_idk);
  673. iod = iodelay_cfg_array_am574x_idk;
  674. iod_sz = ARRAY_SIZE(iodelay_cfg_array_am574x_idk);
  675. } else if (board_is_am571x_idk()) {
  676. pconf = core_padconf_array_essential_am571x_idk;
  677. pconf_sz = ARRAY_SIZE(core_padconf_array_essential_am571x_idk);
  678. iod = iodelay_cfg_array_am571x_idk;
  679. iod_sz = ARRAY_SIZE(iodelay_cfg_array_am571x_idk);
  680. } else {
  681. /* Common for X15/GPEVM */
  682. pconf = core_padconf_array_essential_x15;
  683. pconf_sz = ARRAY_SIZE(core_padconf_array_essential_x15);
  684. /* There never was an SR1.0 X15.. So.. */
  685. if (omap_revision() == DRA752_ES1_1) {
  686. iod = iodelay_cfg_array_x15_sr1_1;
  687. iod_sz = ARRAY_SIZE(iodelay_cfg_array_x15_sr1_1);
  688. } else {
  689. /* Since full production should switch to SR2.0 */
  690. iod = iodelay_cfg_array_x15_sr2_0;
  691. iod_sz = ARRAY_SIZE(iodelay_cfg_array_x15_sr2_0);
  692. }
  693. }
  694. /* Setup I/O isolation */
  695. ret = __recalibrate_iodelay_start();
  696. if (ret)
  697. goto err;
  698. /* Do the muxing here */
  699. do_set_mux32((*ctrl)->control_padconf_core_base, pconf, pconf_sz);
  700. /* Now do the weird minor deltas that should be safe */
  701. if (board_is_x15() || board_is_am572x_evm()) {
  702. if (board_is_x15_revb1() || board_is_am572x_evm_reva3() ||
  703. board_is_x15_revc()) {
  704. pconf = core_padconf_array_delta_x15_sr2_0;
  705. pconf_sz = ARRAY_SIZE(core_padconf_array_delta_x15_sr2_0);
  706. } else {
  707. pconf = core_padconf_array_delta_x15_sr1_1;
  708. pconf_sz = ARRAY_SIZE(core_padconf_array_delta_x15_sr1_1);
  709. }
  710. do_set_mux32((*ctrl)->control_padconf_core_base, pconf, pconf_sz);
  711. }
  712. if (board_is_am571x_idk()) {
  713. if (am571x_idk_needs_lcd()) {
  714. pconf = core_padconf_array_vout_am571x_idk;
  715. pconf_sz = ARRAY_SIZE(core_padconf_array_vout_am571x_idk);
  716. delta_iod = iodelay_cfg_array_am571x_idk_4port;
  717. delta_iod_sz = ARRAY_SIZE(iodelay_cfg_array_am571x_idk_4port);
  718. } else {
  719. pconf = core_padconf_array_icss1eth_am571x_idk;
  720. pconf_sz = ARRAY_SIZE(core_padconf_array_icss1eth_am571x_idk);
  721. }
  722. do_set_mux32((*ctrl)->control_padconf_core_base, pconf, pconf_sz);
  723. }
  724. /* Setup IOdelay configuration */
  725. ret = do_set_iodelay((*ctrl)->iodelay_config_base, iod, iod_sz);
  726. if (delta_iod_sz)
  727. ret = do_set_iodelay((*ctrl)->iodelay_config_base, delta_iod,
  728. delta_iod_sz);
  729. err:
  730. /* Closeup.. remove isolation */
  731. __recalibrate_iodelay_end(ret);
  732. }
  733. #endif
  734. #if defined(CONFIG_GENERIC_MMC)
  735. int board_mmc_init(bd_t *bis)
  736. {
  737. omap_mmc_init(0, 0, 0, -1, -1);
  738. omap_mmc_init(1, 0, 0, -1, -1);
  739. return 0;
  740. }
  741. #endif
  742. #if defined(CONFIG_IODELAY_RECALIBRATION) && \
  743. (defined(CONFIG_SPL_BUILD) || !defined(CONFIG_DM_MMC))
  744. struct pinctrl_desc {
  745. const char *name;
  746. struct omap_hsmmc_pinctrl_state *pinctrl;
  747. };
  748. static struct pinctrl_desc pinctrl_descs_hsmmc1[] = {
  749. {"default", &hsmmc1_default},
  750. {"hs", &hsmmc1_default},
  751. {NULL}
  752. };
  753. static struct pinctrl_desc pinctrl_descs_hsmmc2_am572[] = {
  754. {"default", &hsmmc2_default_hs},
  755. {"hs", &hsmmc2_default_hs},
  756. {"ddr_1_8v", &hsmmc2_ddr_am572},
  757. {NULL}
  758. };
  759. static struct pinctrl_desc pinctrl_descs_hsmmc2_am571[] = {
  760. {"default", &hsmmc2_default_hs},
  761. {"hs", &hsmmc2_default_hs},
  762. {"ddr_1_8v", &hsmmc2_ddr_am571},
  763. {NULL}
  764. };
  765. struct omap_hsmmc_pinctrl_state *platform_fixup_get_pinctrl_by_mode
  766. (struct hsmmc *base, const char *mode)
  767. {
  768. struct pinctrl_desc *p = NULL;
  769. switch ((u32)&base->res1) {
  770. case OMAP_HSMMC1_BASE:
  771. p = pinctrl_descs_hsmmc1;
  772. break;
  773. case OMAP_HSMMC2_BASE:
  774. if (is_dra72x())
  775. p = pinctrl_descs_hsmmc2_am571;
  776. else
  777. p = pinctrl_descs_hsmmc2_am572;
  778. break;
  779. default:
  780. break;
  781. }
  782. if (!p) {
  783. printf("%s no pinctrl defined for MMC@%p\n", __func__,
  784. base);
  785. return NULL;
  786. }
  787. while (p->name) {
  788. if (strcmp(mode, p->name) == 0)
  789. return p->pinctrl;
  790. p++;
  791. }
  792. return NULL;
  793. }
  794. #endif
  795. #ifdef CONFIG_OMAP_HSMMC
  796. int platform_fixup_disable_uhs_mode(void)
  797. {
  798. return omap_revision() == DRA752_ES1_1;
  799. }
  800. #endif
  801. #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_OS_BOOT)
  802. int spl_start_uboot(void)
  803. {
  804. /* break into full u-boot on 'c' */
  805. if (serial_tstc() && serial_getc() == 'c')
  806. return 1;
  807. #ifdef CONFIG_SPL_ENV_SUPPORT
  808. env_init();
  809. env_relocate_spec();
  810. if (getenv_yesno("boot_os") != 1)
  811. return 1;
  812. #endif
  813. return 0;
  814. }
  815. #endif
  816. #ifdef CONFIG_USB_DWC3
  817. static struct dwc3_device usb_otg_ss2 = {
  818. .maximum_speed = USB_SPEED_HIGH,
  819. .base = DRA7_USB_OTG_SS2_BASE,
  820. .tx_fifo_resize = false,
  821. .index = 1,
  822. };
  823. static struct dwc3_omap_device usb_otg_ss2_glue = {
  824. .base = (void *)DRA7_USB_OTG_SS2_GLUE_BASE,
  825. .utmi_mode = DWC3_OMAP_UTMI_MODE_SW,
  826. .index = 1,
  827. };
  828. static struct ti_usb_phy_device usb_phy2_device = {
  829. .usb2_phy_power = (void *)DRA7_USB2_PHY2_POWER,
  830. .index = 1,
  831. };
  832. int usb_gadget_handle_interrupts(int index)
  833. {
  834. u32 status;
  835. status = dwc3_omap_uboot_interrupt_status(index);
  836. if (status)
  837. dwc3_uboot_handle_interrupt(index);
  838. return 0;
  839. }
  840. #endif /* CONFIG_USB_DWC3 */
  841. #if defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_XHCI_OMAP)
  842. int board_usb_init(int index, enum usb_init_type init)
  843. {
  844. enable_usb_clocks(index);
  845. switch (index) {
  846. case 0:
  847. if (init == USB_INIT_DEVICE) {
  848. printf("port %d can't be used as device\n", index);
  849. disable_usb_clocks(index);
  850. return -EINVAL;
  851. }
  852. break;
  853. case 1:
  854. if (init == USB_INIT_DEVICE) {
  855. #ifdef CONFIG_USB_DWC3
  856. usb_otg_ss2.dr_mode = USB_DR_MODE_PERIPHERAL;
  857. usb_otg_ss2_glue.vbus_id_status = OMAP_DWC3_VBUS_VALID;
  858. ti_usb_phy_uboot_init(&usb_phy2_device);
  859. dwc3_omap_uboot_init(&usb_otg_ss2_glue);
  860. dwc3_uboot_init(&usb_otg_ss2);
  861. #endif
  862. } else {
  863. printf("port %d can't be used as host\n", index);
  864. disable_usb_clocks(index);
  865. return -EINVAL;
  866. }
  867. break;
  868. default:
  869. printf("Invalid Controller Index\n");
  870. }
  871. return 0;
  872. }
  873. int board_usb_cleanup(int index, enum usb_init_type init)
  874. {
  875. #ifdef CONFIG_USB_DWC3
  876. switch (index) {
  877. case 0:
  878. case 1:
  879. if (init == USB_INIT_DEVICE) {
  880. ti_usb_phy_uboot_exit(index);
  881. dwc3_uboot_exit(index);
  882. dwc3_omap_uboot_exit(index);
  883. }
  884. break;
  885. default:
  886. printf("Invalid Controller Index\n");
  887. }
  888. #endif
  889. disable_usb_clocks(index);
  890. return 0;
  891. }
  892. #endif /* defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_XHCI_OMAP) */
  893. #ifdef CONFIG_DRIVER_TI_CPSW
  894. /* Delay value to add to calibrated value */
  895. #define RGMII0_TXCTL_DLY_VAL ((0x3 << 5) + 0x8)
  896. #define RGMII0_TXD0_DLY_VAL ((0x3 << 5) + 0x8)
  897. #define RGMII0_TXD1_DLY_VAL ((0x3 << 5) + 0x2)
  898. #define RGMII0_TXD2_DLY_VAL ((0x4 << 5) + 0x0)
  899. #define RGMII0_TXD3_DLY_VAL ((0x4 << 5) + 0x0)
  900. #define VIN2A_D13_DLY_VAL ((0x3 << 5) + 0x8)
  901. #define VIN2A_D17_DLY_VAL ((0x3 << 5) + 0x8)
  902. #define VIN2A_D16_DLY_VAL ((0x3 << 5) + 0x2)
  903. #define VIN2A_D15_DLY_VAL ((0x4 << 5) + 0x0)
  904. #define VIN2A_D14_DLY_VAL ((0x4 << 5) + 0x0)
  905. static void cpsw_control(int enabled)
  906. {
  907. /* VTP can be added here */
  908. }
  909. static struct cpsw_slave_data cpsw_slaves[] = {
  910. {
  911. .slave_reg_ofs = 0x208,
  912. .sliver_reg_ofs = 0xd80,
  913. .phy_addr = 1,
  914. },
  915. {
  916. .slave_reg_ofs = 0x308,
  917. .sliver_reg_ofs = 0xdc0,
  918. .phy_addr = 2,
  919. },
  920. };
  921. static struct cpsw_platform_data cpsw_data = {
  922. .mdio_base = CPSW_MDIO_BASE,
  923. .cpsw_base = CPSW_BASE,
  924. .mdio_div = 0xff,
  925. .channels = 8,
  926. .cpdma_reg_ofs = 0x800,
  927. .slaves = 1,
  928. .slave_data = cpsw_slaves,
  929. .ale_reg_ofs = 0xd00,
  930. .ale_entries = 1024,
  931. .host_port_reg_ofs = 0x108,
  932. .hw_stats_reg_ofs = 0x900,
  933. .bd_ram_ofs = 0x2000,
  934. .mac_control = (1 << 5),
  935. .control = cpsw_control,
  936. .host_port_num = 0,
  937. .version = CPSW_CTRL_VERSION_2,
  938. };
  939. static u64 mac_to_u64(u8 mac[6])
  940. {
  941. int i;
  942. u64 addr = 0;
  943. for (i = 0; i < 6; i++) {
  944. addr <<= 8;
  945. addr |= mac[i];
  946. }
  947. return addr;
  948. }
  949. static void u64_to_mac(u64 addr, u8 mac[6])
  950. {
  951. mac[5] = addr;
  952. mac[4] = addr >> 8;
  953. mac[3] = addr >> 16;
  954. mac[2] = addr >> 24;
  955. mac[1] = addr >> 32;
  956. mac[0] = addr >> 40;
  957. }
  958. int board_eth_init(bd_t *bis)
  959. {
  960. int ret;
  961. uint8_t mac_addr[6];
  962. uint32_t mac_hi, mac_lo;
  963. uint32_t ctrl_val;
  964. int i;
  965. u64 mac1, mac2;
  966. u8 mac_addr1[6], mac_addr2[6];
  967. int num_macs;
  968. /* try reading mac address from efuse */
  969. mac_lo = readl((*ctrl)->control_core_mac_id_0_lo);
  970. mac_hi = readl((*ctrl)->control_core_mac_id_0_hi);
  971. mac_addr[0] = (mac_hi & 0xFF0000) >> 16;
  972. mac_addr[1] = (mac_hi & 0xFF00) >> 8;
  973. mac_addr[2] = mac_hi & 0xFF;
  974. mac_addr[3] = (mac_lo & 0xFF0000) >> 16;
  975. mac_addr[4] = (mac_lo & 0xFF00) >> 8;
  976. mac_addr[5] = mac_lo & 0xFF;
  977. if (!getenv("ethaddr")) {
  978. printf("<ethaddr> not set. Validating first E-fuse MAC\n");
  979. if (is_valid_ethaddr(mac_addr))
  980. eth_setenv_enetaddr("ethaddr", mac_addr);
  981. }
  982. mac_lo = readl((*ctrl)->control_core_mac_id_1_lo);
  983. mac_hi = readl((*ctrl)->control_core_mac_id_1_hi);
  984. mac_addr[0] = (mac_hi & 0xFF0000) >> 16;
  985. mac_addr[1] = (mac_hi & 0xFF00) >> 8;
  986. mac_addr[2] = mac_hi & 0xFF;
  987. mac_addr[3] = (mac_lo & 0xFF0000) >> 16;
  988. mac_addr[4] = (mac_lo & 0xFF00) >> 8;
  989. mac_addr[5] = mac_lo & 0xFF;
  990. if (!getenv("eth1addr")) {
  991. if (is_valid_ethaddr(mac_addr))
  992. eth_setenv_enetaddr("eth1addr", mac_addr);
  993. }
  994. ctrl_val = readl((*ctrl)->control_core_control_io1) & (~0x33);
  995. ctrl_val |= 0x22;
  996. writel(ctrl_val, (*ctrl)->control_core_control_io1);
  997. /* The phy address for the AM57xx IDK are different than x15 */
  998. if (board_is_am572x_idk() || board_is_am571x_idk() ||
  999. board_is_am574x_idk()) {
  1000. cpsw_data.slave_data[0].phy_addr = 0;
  1001. cpsw_data.slave_data[1].phy_addr = 1;
  1002. }
  1003. ret = cpsw_register(&cpsw_data);
  1004. if (ret < 0)
  1005. printf("Error %d registering CPSW switch\n", ret);
  1006. /*
  1007. * Export any Ethernet MAC addresses from EEPROM.
  1008. * On AM57xx the 2 MAC addresses define the address range
  1009. */
  1010. board_ti_get_eth_mac_addr(0, mac_addr1);
  1011. board_ti_get_eth_mac_addr(1, mac_addr2);
  1012. if (is_valid_ethaddr(mac_addr1) && is_valid_ethaddr(mac_addr2)) {
  1013. mac1 = mac_to_u64(mac_addr1);
  1014. mac2 = mac_to_u64(mac_addr2);
  1015. /* must contain an address range */
  1016. num_macs = mac2 - mac1 + 1;
  1017. /* <= 50 to protect against user programming error */
  1018. if (num_macs > 0 && num_macs <= 50) {
  1019. for (i = 0; i < num_macs; i++) {
  1020. u64_to_mac(mac1 + i, mac_addr);
  1021. if (is_valid_ethaddr(mac_addr)) {
  1022. eth_setenv_enetaddr_by_index("eth",
  1023. i + 2,
  1024. mac_addr);
  1025. }
  1026. }
  1027. }
  1028. }
  1029. return ret;
  1030. }
  1031. #endif
  1032. #ifdef CONFIG_BOARD_EARLY_INIT_F
  1033. /* VTT regulator enable */
  1034. static inline void vtt_regulator_enable(void)
  1035. {
  1036. if (omap_hw_init_context() == OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL)
  1037. return;
  1038. gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en");
  1039. gpio_direction_output(GPIO_DDR_VTT_EN, 1);
  1040. }
  1041. int board_early_init_f(void)
  1042. {
  1043. vtt_regulator_enable();
  1044. return 0;
  1045. }
  1046. #endif
  1047. #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
  1048. int ft_board_setup(void *blob, bd_t *bd)
  1049. {
  1050. ft_cpu_setup(blob, bd);
  1051. return 0;
  1052. }
  1053. #endif
  1054. #ifdef CONFIG_SPL_LOAD_FIT
  1055. int board_fit_config_name_match(const char *name)
  1056. {
  1057. if (board_is_x15()) {
  1058. if (board_is_x15_revb1()) {
  1059. if (!strcmp(name, "am57xx-beagle-x15-revb1"))
  1060. return 0;
  1061. } else if (board_is_x15_revc()) {
  1062. if (!strcmp(name, "am57xx-beagle-x15-revc"))
  1063. return 0;
  1064. } else if (!strcmp(name, "am57xx-beagle-x15")) {
  1065. return 0;
  1066. }
  1067. } else if (board_is_am572x_evm()) {
  1068. if (board_is_am572x_evm_reva3()) {
  1069. if (!strcmp(name, "am57xx-evm-reva3"))
  1070. return 0;
  1071. } else if (!strcmp(name, "am57xx-beagle-x15")) {
  1072. return 0;
  1073. }
  1074. } else if (board_is_am572x_idk() && !strcmp(name, "am572x-idk")) {
  1075. return 0;
  1076. } else if (board_is_am574x_idk() && !strcmp(name, "am574x-idk")) {
  1077. return 0;
  1078. } else if (board_is_am571x_idk() && !strcmp(name, "am571x-idk")) {
  1079. return 0;
  1080. }
  1081. return -1;
  1082. }
  1083. #endif
  1084. #ifdef CONFIG_TI_SECURE_DEVICE
  1085. void board_fit_image_post_process(void **p_image, size_t *p_size)
  1086. {
  1087. secure_boot_verify_image(p_image, p_size);
  1088. }
  1089. void board_tee_image_process(ulong tee_image, size_t tee_size)
  1090. {
  1091. secure_tee_install((u32)tee_image);
  1092. }
  1093. U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_TEE, board_tee_image_process);
  1094. #endif