board.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
  4. *
  5. * Author: Felipe Balbi <balbi@ti.com>
  6. *
  7. * Based on board/ti/dra7xx/evm.c
  8. */
  9. #include <common.h>
  10. #include <palmas.h>
  11. #include <sata.h>
  12. #include <usb.h>
  13. #include <asm/omap_common.h>
  14. #include <asm/omap_sec_common.h>
  15. #include <asm/emif.h>
  16. #include <asm/gpio.h>
  17. #include <asm/arch/gpio.h>
  18. #include <asm/arch/clock.h>
  19. #include <asm/arch/dra7xx_iodelay.h>
  20. #include <asm/arch/sys_proto.h>
  21. #include <asm/arch/mmc_host_def.h>
  22. #include <asm/arch/sata.h>
  23. #include <asm/arch/gpio.h>
  24. #include <asm/arch/omap.h>
  25. #include <environment.h>
  26. #include <usb.h>
  27. #include <linux/usb/gadget.h>
  28. #include <dwc3-uboot.h>
  29. #include <dwc3-omap-uboot.h>
  30. #include <ti-usb-phy-uboot.h>
  31. #include <mmc.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. env_set("idk_lcd", idk_lcd);
  607. return;
  608. }
  609. int board_late_init(void)
  610. {
  611. setup_board_eeprom_env();
  612. u8 val;
  613. /*
  614. * DEV_CTRL.DEV_ON = 1 please - else palmas switches off in 8 seconds
  615. * This is the POWERHOLD-in-Low behavior.
  616. */
  617. palmas_i2c_write_u8(TPS65903X_CHIP_P1, 0xA0, 0x1);
  618. /*
  619. * Default FIT boot on HS devices. Non FIT images are not allowed
  620. * on HS devices.
  621. */
  622. if (get_device_type() == HS_DEVICE)
  623. env_set("boot_fit", "1");
  624. /*
  625. * Set the GPIO7 Pad to POWERHOLD. This has higher priority
  626. * over DEV_CTRL.DEV_ON bit. This can be reset in case of
  627. * PMIC Power off. So to be on the safer side set it back
  628. * to POWERHOLD mode irrespective of the current state.
  629. */
  630. palmas_i2c_read_u8(TPS65903X_CHIP_P1, TPS65903X_PRIMARY_SECONDARY_PAD2,
  631. &val);
  632. val = val | TPS65903X_PAD2_POWERHOLD_MASK;
  633. palmas_i2c_write_u8(TPS65903X_CHIP_P1, TPS65903X_PRIMARY_SECONDARY_PAD2,
  634. val);
  635. omap_die_id_serial();
  636. omap_set_fastboot_vars();
  637. am57x_idk_lcd_detect();
  638. #if !defined(CONFIG_SPL_BUILD)
  639. board_ti_set_ethaddr(2);
  640. #endif
  641. return 0;
  642. }
  643. void set_muxconf_regs(void)
  644. {
  645. do_set_mux32((*ctrl)->control_padconf_core_base,
  646. early_padconf, ARRAY_SIZE(early_padconf));
  647. }
  648. #ifdef CONFIG_IODELAY_RECALIBRATION
  649. void recalibrate_iodelay(void)
  650. {
  651. const struct pad_conf_entry *pconf;
  652. const struct iodelay_cfg_entry *iod, *delta_iod;
  653. int pconf_sz, iod_sz, delta_iod_sz = 0;
  654. int ret;
  655. if (board_is_am572x_idk()) {
  656. pconf = core_padconf_array_essential_am572x_idk;
  657. pconf_sz = ARRAY_SIZE(core_padconf_array_essential_am572x_idk);
  658. iod = iodelay_cfg_array_am572x_idk;
  659. iod_sz = ARRAY_SIZE(iodelay_cfg_array_am572x_idk);
  660. } else if (board_is_am574x_idk()) {
  661. pconf = core_padconf_array_essential_am574x_idk;
  662. pconf_sz = ARRAY_SIZE(core_padconf_array_essential_am574x_idk);
  663. iod = iodelay_cfg_array_am574x_idk;
  664. iod_sz = ARRAY_SIZE(iodelay_cfg_array_am574x_idk);
  665. } else if (board_is_am571x_idk()) {
  666. pconf = core_padconf_array_essential_am571x_idk;
  667. pconf_sz = ARRAY_SIZE(core_padconf_array_essential_am571x_idk);
  668. iod = iodelay_cfg_array_am571x_idk;
  669. iod_sz = ARRAY_SIZE(iodelay_cfg_array_am571x_idk);
  670. } else {
  671. /* Common for X15/GPEVM */
  672. pconf = core_padconf_array_essential_x15;
  673. pconf_sz = ARRAY_SIZE(core_padconf_array_essential_x15);
  674. /* There never was an SR1.0 X15.. So.. */
  675. if (omap_revision() == DRA752_ES1_1) {
  676. iod = iodelay_cfg_array_x15_sr1_1;
  677. iod_sz = ARRAY_SIZE(iodelay_cfg_array_x15_sr1_1);
  678. } else {
  679. /* Since full production should switch to SR2.0 */
  680. iod = iodelay_cfg_array_x15_sr2_0;
  681. iod_sz = ARRAY_SIZE(iodelay_cfg_array_x15_sr2_0);
  682. }
  683. }
  684. /* Setup I/O isolation */
  685. ret = __recalibrate_iodelay_start();
  686. if (ret)
  687. goto err;
  688. /* Do the muxing here */
  689. do_set_mux32((*ctrl)->control_padconf_core_base, pconf, pconf_sz);
  690. /* Now do the weird minor deltas that should be safe */
  691. if (board_is_x15() || board_is_am572x_evm()) {
  692. if (board_is_x15_revb1() || board_is_am572x_evm_reva3() ||
  693. board_is_x15_revc()) {
  694. pconf = core_padconf_array_delta_x15_sr2_0;
  695. pconf_sz = ARRAY_SIZE(core_padconf_array_delta_x15_sr2_0);
  696. } else {
  697. pconf = core_padconf_array_delta_x15_sr1_1;
  698. pconf_sz = ARRAY_SIZE(core_padconf_array_delta_x15_sr1_1);
  699. }
  700. do_set_mux32((*ctrl)->control_padconf_core_base, pconf, pconf_sz);
  701. }
  702. if (board_is_am571x_idk()) {
  703. if (am571x_idk_needs_lcd()) {
  704. pconf = core_padconf_array_vout_am571x_idk;
  705. pconf_sz = ARRAY_SIZE(core_padconf_array_vout_am571x_idk);
  706. delta_iod = iodelay_cfg_array_am571x_idk_4port;
  707. delta_iod_sz = ARRAY_SIZE(iodelay_cfg_array_am571x_idk_4port);
  708. } else {
  709. pconf = core_padconf_array_icss1eth_am571x_idk;
  710. pconf_sz = ARRAY_SIZE(core_padconf_array_icss1eth_am571x_idk);
  711. }
  712. do_set_mux32((*ctrl)->control_padconf_core_base, pconf, pconf_sz);
  713. }
  714. /* Setup IOdelay configuration */
  715. ret = do_set_iodelay((*ctrl)->iodelay_config_base, iod, iod_sz);
  716. if (delta_iod_sz)
  717. ret = do_set_iodelay((*ctrl)->iodelay_config_base, delta_iod,
  718. delta_iod_sz);
  719. err:
  720. /* Closeup.. remove isolation */
  721. __recalibrate_iodelay_end(ret);
  722. }
  723. #endif
  724. #if defined(CONFIG_MMC)
  725. int board_mmc_init(bd_t *bis)
  726. {
  727. omap_mmc_init(0, 0, 0, -1, -1);
  728. omap_mmc_init(1, 0, 0, -1, -1);
  729. return 0;
  730. }
  731. static const struct mmc_platform_fixups am57x_es1_1_mmc1_fixups = {
  732. .hw_rev = "rev11",
  733. .unsupported_caps = MMC_CAP(MMC_HS_200) |
  734. MMC_CAP(UHS_SDR104),
  735. .max_freq = 96000000,
  736. };
  737. static const struct mmc_platform_fixups am57x_es1_1_mmc23_fixups = {
  738. .hw_rev = "rev11",
  739. .unsupported_caps = MMC_CAP(MMC_HS_200) |
  740. MMC_CAP(UHS_SDR104) |
  741. MMC_CAP(UHS_SDR50),
  742. .max_freq = 48000000,
  743. };
  744. const struct mmc_platform_fixups *platform_fixups_mmc(uint32_t addr)
  745. {
  746. switch (omap_revision()) {
  747. case DRA752_ES1_0:
  748. case DRA752_ES1_1:
  749. if (addr == OMAP_HSMMC1_BASE)
  750. return &am57x_es1_1_mmc1_fixups;
  751. else
  752. return &am57x_es1_1_mmc23_fixups;
  753. default:
  754. return NULL;
  755. }
  756. }
  757. #endif
  758. #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_OS_BOOT)
  759. int spl_start_uboot(void)
  760. {
  761. /* break into full u-boot on 'c' */
  762. if (serial_tstc() && serial_getc() == 'c')
  763. return 1;
  764. #ifdef CONFIG_SPL_ENV_SUPPORT
  765. env_init();
  766. env_load();
  767. if (env_get_yesno("boot_os") != 1)
  768. return 1;
  769. #endif
  770. return 0;
  771. }
  772. #endif
  773. #ifdef CONFIG_USB_DWC3
  774. static struct dwc3_device usb_otg_ss2 = {
  775. .maximum_speed = USB_SPEED_HIGH,
  776. .base = DRA7_USB_OTG_SS2_BASE,
  777. .tx_fifo_resize = false,
  778. .index = 1,
  779. };
  780. static struct dwc3_omap_device usb_otg_ss2_glue = {
  781. .base = (void *)DRA7_USB_OTG_SS2_GLUE_BASE,
  782. .utmi_mode = DWC3_OMAP_UTMI_MODE_SW,
  783. .index = 1,
  784. };
  785. static struct ti_usb_phy_device usb_phy2_device = {
  786. .usb2_phy_power = (void *)DRA7_USB2_PHY2_POWER,
  787. .index = 1,
  788. };
  789. int usb_gadget_handle_interrupts(int index)
  790. {
  791. u32 status;
  792. status = dwc3_omap_uboot_interrupt_status(index);
  793. if (status)
  794. dwc3_uboot_handle_interrupt(index);
  795. return 0;
  796. }
  797. #endif /* CONFIG_USB_DWC3 */
  798. #if defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_XHCI_OMAP)
  799. int board_usb_init(int index, enum usb_init_type init)
  800. {
  801. enable_usb_clocks(index);
  802. switch (index) {
  803. case 0:
  804. if (init == USB_INIT_DEVICE) {
  805. printf("port %d can't be used as device\n", index);
  806. disable_usb_clocks(index);
  807. return -EINVAL;
  808. }
  809. break;
  810. case 1:
  811. if (init == USB_INIT_DEVICE) {
  812. #ifdef CONFIG_USB_DWC3
  813. usb_otg_ss2.dr_mode = USB_DR_MODE_PERIPHERAL;
  814. usb_otg_ss2_glue.vbus_id_status = OMAP_DWC3_VBUS_VALID;
  815. ti_usb_phy_uboot_init(&usb_phy2_device);
  816. dwc3_omap_uboot_init(&usb_otg_ss2_glue);
  817. dwc3_uboot_init(&usb_otg_ss2);
  818. #endif
  819. } else {
  820. printf("port %d can't be used as host\n", index);
  821. disable_usb_clocks(index);
  822. return -EINVAL;
  823. }
  824. break;
  825. default:
  826. printf("Invalid Controller Index\n");
  827. }
  828. return 0;
  829. }
  830. int board_usb_cleanup(int index, enum usb_init_type init)
  831. {
  832. #ifdef CONFIG_USB_DWC3
  833. switch (index) {
  834. case 0:
  835. case 1:
  836. if (init == USB_INIT_DEVICE) {
  837. ti_usb_phy_uboot_exit(index);
  838. dwc3_uboot_exit(index);
  839. dwc3_omap_uboot_exit(index);
  840. }
  841. break;
  842. default:
  843. printf("Invalid Controller Index\n");
  844. }
  845. #endif
  846. disable_usb_clocks(index);
  847. return 0;
  848. }
  849. #endif /* defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_XHCI_OMAP) */
  850. #ifdef CONFIG_DRIVER_TI_CPSW
  851. /* Delay value to add to calibrated value */
  852. #define RGMII0_TXCTL_DLY_VAL ((0x3 << 5) + 0x8)
  853. #define RGMII0_TXD0_DLY_VAL ((0x3 << 5) + 0x8)
  854. #define RGMII0_TXD1_DLY_VAL ((0x3 << 5) + 0x2)
  855. #define RGMII0_TXD2_DLY_VAL ((0x4 << 5) + 0x0)
  856. #define RGMII0_TXD3_DLY_VAL ((0x4 << 5) + 0x0)
  857. #define VIN2A_D13_DLY_VAL ((0x3 << 5) + 0x8)
  858. #define VIN2A_D17_DLY_VAL ((0x3 << 5) + 0x8)
  859. #define VIN2A_D16_DLY_VAL ((0x3 << 5) + 0x2)
  860. #define VIN2A_D15_DLY_VAL ((0x4 << 5) + 0x0)
  861. #define VIN2A_D14_DLY_VAL ((0x4 << 5) + 0x0)
  862. static void cpsw_control(int enabled)
  863. {
  864. /* VTP can be added here */
  865. }
  866. static struct cpsw_slave_data cpsw_slaves[] = {
  867. {
  868. .slave_reg_ofs = 0x208,
  869. .sliver_reg_ofs = 0xd80,
  870. .phy_addr = 1,
  871. },
  872. {
  873. .slave_reg_ofs = 0x308,
  874. .sliver_reg_ofs = 0xdc0,
  875. .phy_addr = 2,
  876. },
  877. };
  878. static struct cpsw_platform_data cpsw_data = {
  879. .mdio_base = CPSW_MDIO_BASE,
  880. .cpsw_base = CPSW_BASE,
  881. .mdio_div = 0xff,
  882. .channels = 8,
  883. .cpdma_reg_ofs = 0x800,
  884. .slaves = 1,
  885. .slave_data = cpsw_slaves,
  886. .ale_reg_ofs = 0xd00,
  887. .ale_entries = 1024,
  888. .host_port_reg_ofs = 0x108,
  889. .hw_stats_reg_ofs = 0x900,
  890. .bd_ram_ofs = 0x2000,
  891. .mac_control = (1 << 5),
  892. .control = cpsw_control,
  893. .host_port_num = 0,
  894. .version = CPSW_CTRL_VERSION_2,
  895. };
  896. static u64 mac_to_u64(u8 mac[6])
  897. {
  898. int i;
  899. u64 addr = 0;
  900. for (i = 0; i < 6; i++) {
  901. addr <<= 8;
  902. addr |= mac[i];
  903. }
  904. return addr;
  905. }
  906. static void u64_to_mac(u64 addr, u8 mac[6])
  907. {
  908. mac[5] = addr;
  909. mac[4] = addr >> 8;
  910. mac[3] = addr >> 16;
  911. mac[2] = addr >> 24;
  912. mac[1] = addr >> 32;
  913. mac[0] = addr >> 40;
  914. }
  915. int board_eth_init(bd_t *bis)
  916. {
  917. int ret;
  918. uint8_t mac_addr[6];
  919. uint32_t mac_hi, mac_lo;
  920. uint32_t ctrl_val;
  921. int i;
  922. u64 mac1, mac2;
  923. u8 mac_addr1[6], mac_addr2[6];
  924. int num_macs;
  925. /* try reading mac address from efuse */
  926. mac_lo = readl((*ctrl)->control_core_mac_id_0_lo);
  927. mac_hi = readl((*ctrl)->control_core_mac_id_0_hi);
  928. mac_addr[0] = (mac_hi & 0xFF0000) >> 16;
  929. mac_addr[1] = (mac_hi & 0xFF00) >> 8;
  930. mac_addr[2] = mac_hi & 0xFF;
  931. mac_addr[3] = (mac_lo & 0xFF0000) >> 16;
  932. mac_addr[4] = (mac_lo & 0xFF00) >> 8;
  933. mac_addr[5] = mac_lo & 0xFF;
  934. if (!env_get("ethaddr")) {
  935. printf("<ethaddr> not set. Validating first E-fuse MAC\n");
  936. if (is_valid_ethaddr(mac_addr))
  937. eth_env_set_enetaddr("ethaddr", mac_addr);
  938. }
  939. mac_lo = readl((*ctrl)->control_core_mac_id_1_lo);
  940. mac_hi = readl((*ctrl)->control_core_mac_id_1_hi);
  941. mac_addr[0] = (mac_hi & 0xFF0000) >> 16;
  942. mac_addr[1] = (mac_hi & 0xFF00) >> 8;
  943. mac_addr[2] = mac_hi & 0xFF;
  944. mac_addr[3] = (mac_lo & 0xFF0000) >> 16;
  945. mac_addr[4] = (mac_lo & 0xFF00) >> 8;
  946. mac_addr[5] = mac_lo & 0xFF;
  947. if (!env_get("eth1addr")) {
  948. if (is_valid_ethaddr(mac_addr))
  949. eth_env_set_enetaddr("eth1addr", mac_addr);
  950. }
  951. ctrl_val = readl((*ctrl)->control_core_control_io1) & (~0x33);
  952. ctrl_val |= 0x22;
  953. writel(ctrl_val, (*ctrl)->control_core_control_io1);
  954. /* The phy address for the AM57xx IDK are different than x15 */
  955. if (board_is_am572x_idk() || board_is_am571x_idk() ||
  956. board_is_am574x_idk()) {
  957. cpsw_data.slave_data[0].phy_addr = 0;
  958. cpsw_data.slave_data[1].phy_addr = 1;
  959. }
  960. ret = cpsw_register(&cpsw_data);
  961. if (ret < 0)
  962. printf("Error %d registering CPSW switch\n", ret);
  963. /*
  964. * Export any Ethernet MAC addresses from EEPROM.
  965. * On AM57xx the 2 MAC addresses define the address range
  966. */
  967. board_ti_get_eth_mac_addr(0, mac_addr1);
  968. board_ti_get_eth_mac_addr(1, mac_addr2);
  969. if (is_valid_ethaddr(mac_addr1) && is_valid_ethaddr(mac_addr2)) {
  970. mac1 = mac_to_u64(mac_addr1);
  971. mac2 = mac_to_u64(mac_addr2);
  972. /* must contain an address range */
  973. num_macs = mac2 - mac1 + 1;
  974. /* <= 50 to protect against user programming error */
  975. if (num_macs > 0 && num_macs <= 50) {
  976. for (i = 0; i < num_macs; i++) {
  977. u64_to_mac(mac1 + i, mac_addr);
  978. if (is_valid_ethaddr(mac_addr)) {
  979. eth_env_set_enetaddr_by_index("eth",
  980. i + 2,
  981. mac_addr);
  982. }
  983. }
  984. }
  985. }
  986. return ret;
  987. }
  988. #endif
  989. #ifdef CONFIG_BOARD_EARLY_INIT_F
  990. /* VTT regulator enable */
  991. static inline void vtt_regulator_enable(void)
  992. {
  993. if (omap_hw_init_context() == OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL)
  994. return;
  995. gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en");
  996. gpio_direction_output(GPIO_DDR_VTT_EN, 1);
  997. }
  998. int board_early_init_f(void)
  999. {
  1000. vtt_regulator_enable();
  1001. return 0;
  1002. }
  1003. #endif
  1004. #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
  1005. int ft_board_setup(void *blob, bd_t *bd)
  1006. {
  1007. ft_cpu_setup(blob, bd);
  1008. return 0;
  1009. }
  1010. #endif
  1011. #ifdef CONFIG_SPL_LOAD_FIT
  1012. int board_fit_config_name_match(const char *name)
  1013. {
  1014. if (board_is_x15()) {
  1015. if (board_is_x15_revb1()) {
  1016. if (!strcmp(name, "am57xx-beagle-x15-revb1"))
  1017. return 0;
  1018. } else if (board_is_x15_revc()) {
  1019. if (!strcmp(name, "am57xx-beagle-x15-revc"))
  1020. return 0;
  1021. } else if (!strcmp(name, "am57xx-beagle-x15")) {
  1022. return 0;
  1023. }
  1024. } else if (board_is_am572x_evm() &&
  1025. !strcmp(name, "am57xx-beagle-x15")) {
  1026. return 0;
  1027. } else if (board_is_am572x_idk() && !strcmp(name, "am572x-idk")) {
  1028. return 0;
  1029. } else if (board_is_am574x_idk() && !strcmp(name, "am574x-idk")) {
  1030. return 0;
  1031. } else if (board_is_am571x_idk() && !strcmp(name, "am571x-idk")) {
  1032. return 0;
  1033. }
  1034. return -1;
  1035. }
  1036. #endif
  1037. #ifdef CONFIG_TI_SECURE_DEVICE
  1038. void board_fit_image_post_process(void **p_image, size_t *p_size)
  1039. {
  1040. secure_boot_verify_image(p_image, p_size);
  1041. }
  1042. void board_tee_image_process(ulong tee_image, size_t tee_size)
  1043. {
  1044. secure_tee_install((u32)tee_image);
  1045. }
  1046. #if CONFIG_IS_ENABLED(FASTBOOT) && !CONFIG_IS_ENABLED(ENV_IS_NOWHERE)
  1047. int fastboot_set_reboot_flag(void)
  1048. {
  1049. printf("Setting reboot to fastboot flag ...\n");
  1050. env_set("dofastboot", "1");
  1051. env_save();
  1052. return 0;
  1053. }
  1054. #endif
  1055. U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_TEE, board_tee_image_process);
  1056. #endif