evm.c 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2013
  4. * Texas Instruments Incorporated, <www.ti.com>
  5. *
  6. * Lokesh Vutla <lokeshvutla@ti.com>
  7. *
  8. * Based on previous work by:
  9. * Aneesh V <aneesh@ti.com>
  10. * Steve Sakoman <steve@sakoman.com>
  11. */
  12. #include <common.h>
  13. #include <palmas.h>
  14. #include <sata.h>
  15. #include <linux/string.h>
  16. #include <asm/gpio.h>
  17. #include <usb.h>
  18. #include <linux/usb/gadget.h>
  19. #include <asm/omap_common.h>
  20. #include <asm/omap_sec_common.h>
  21. #include <asm/arch/gpio.h>
  22. #include <asm/arch/dra7xx_iodelay.h>
  23. #include <asm/emif.h>
  24. #include <asm/arch/sys_proto.h>
  25. #include <asm/arch/mmc_host_def.h>
  26. #include <asm/arch/sata.h>
  27. #include <environment.h>
  28. #include <dwc3-uboot.h>
  29. #include <dwc3-omap-uboot.h>
  30. #include <ti-usb-phy-uboot.h>
  31. #include <miiphy.h>
  32. #include "mux_data.h"
  33. #include "../common/board_detect.h"
  34. #define board_is_dra76x_evm() board_ti_is("DRA76/7x")
  35. #define board_is_dra74x_evm() board_ti_is("5777xCPU")
  36. #define board_is_dra72x_evm() board_ti_is("DRA72x-T")
  37. #define board_is_dra71x_evm() board_ti_is("DRA79x,D")
  38. #define board_is_dra74x_revh_or_later() (board_is_dra74x_evm() && \
  39. (strncmp("H", board_ti_get_rev(), 1) <= 0))
  40. #define board_is_dra72x_revc_or_later() (board_is_dra72x_evm() && \
  41. (strncmp("C", board_ti_get_rev(), 1) <= 0))
  42. #define board_ti_get_emif_size() board_ti_get_emif1_size() + \
  43. board_ti_get_emif2_size()
  44. #ifdef CONFIG_DRIVER_TI_CPSW
  45. #include <cpsw.h>
  46. #endif
  47. DECLARE_GLOBAL_DATA_PTR;
  48. /* GPIO 7_11 */
  49. #define GPIO_DDR_VTT_EN 203
  50. #define SYSINFO_BOARD_NAME_MAX_LEN 37
  51. const struct omap_sysinfo sysinfo = {
  52. "Board: UNKNOWN(DRA7 EVM) REV UNKNOWN\n"
  53. };
  54. static const struct emif_regs emif1_ddr3_532_mhz_1cs = {
  55. .sdram_config_init = 0x61851ab2,
  56. .sdram_config = 0x61851ab2,
  57. .sdram_config2 = 0x08000000,
  58. .ref_ctrl = 0x000040F1,
  59. .ref_ctrl_final = 0x00001035,
  60. .sdram_tim1 = 0xCCCF36B3,
  61. .sdram_tim2 = 0x308F7FDA,
  62. .sdram_tim3 = 0x427F88A8,
  63. .read_idle_ctrl = 0x00050000,
  64. .zq_config = 0x0007190B,
  65. .temp_alert_config = 0x00000000,
  66. .emif_ddr_phy_ctlr_1_init = 0x0024400B,
  67. .emif_ddr_phy_ctlr_1 = 0x0E24400B,
  68. .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
  69. .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
  70. .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
  71. .emif_ddr_ext_phy_ctrl_4 = 0x009B009B,
  72. .emif_ddr_ext_phy_ctrl_5 = 0x009E009E,
  73. .emif_rd_wr_lvl_rmp_win = 0x00000000,
  74. .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
  75. .emif_rd_wr_lvl_ctl = 0x00000000,
  76. .emif_rd_wr_exec_thresh = 0x00000305
  77. };
  78. static const struct emif_regs emif2_ddr3_532_mhz_1cs = {
  79. .sdram_config_init = 0x61851B32,
  80. .sdram_config = 0x61851B32,
  81. .sdram_config2 = 0x08000000,
  82. .ref_ctrl = 0x000040F1,
  83. .ref_ctrl_final = 0x00001035,
  84. .sdram_tim1 = 0xCCCF36B3,
  85. .sdram_tim2 = 0x308F7FDA,
  86. .sdram_tim3 = 0x427F88A8,
  87. .read_idle_ctrl = 0x00050000,
  88. .zq_config = 0x0007190B,
  89. .temp_alert_config = 0x00000000,
  90. .emif_ddr_phy_ctlr_1_init = 0x0024400B,
  91. .emif_ddr_phy_ctlr_1 = 0x0E24400B,
  92. .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
  93. .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
  94. .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
  95. .emif_ddr_ext_phy_ctrl_4 = 0x009B009B,
  96. .emif_ddr_ext_phy_ctrl_5 = 0x009E009E,
  97. .emif_rd_wr_lvl_rmp_win = 0x00000000,
  98. .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
  99. .emif_rd_wr_lvl_ctl = 0x00000000,
  100. .emif_rd_wr_exec_thresh = 0x00000305
  101. };
  102. static const struct emif_regs emif_1_regs_ddr3_666_mhz_1cs_dra_es1 = {
  103. .sdram_config_init = 0x61862B32,
  104. .sdram_config = 0x61862B32,
  105. .sdram_config2 = 0x08000000,
  106. .ref_ctrl = 0x0000514C,
  107. .ref_ctrl_final = 0x0000144A,
  108. .sdram_tim1 = 0xD113781C,
  109. .sdram_tim2 = 0x30717FE3,
  110. .sdram_tim3 = 0x409F86A8,
  111. .read_idle_ctrl = 0x00050000,
  112. .zq_config = 0x5007190B,
  113. .temp_alert_config = 0x00000000,
  114. .emif_ddr_phy_ctlr_1_init = 0x0024400D,
  115. .emif_ddr_phy_ctlr_1 = 0x0E24400D,
  116. .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
  117. .emif_ddr_ext_phy_ctrl_2 = 0x00A400A4,
  118. .emif_ddr_ext_phy_ctrl_3 = 0x00A900A9,
  119. .emif_ddr_ext_phy_ctrl_4 = 0x00B000B0,
  120. .emif_ddr_ext_phy_ctrl_5 = 0x00B000B0,
  121. .emif_rd_wr_lvl_rmp_win = 0x00000000,
  122. .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
  123. .emif_rd_wr_lvl_ctl = 0x00000000,
  124. .emif_rd_wr_exec_thresh = 0x00000305
  125. };
  126. const struct emif_regs emif_1_regs_ddr3_666_mhz_1cs_dra_es2 = {
  127. .sdram_config_init = 0x61862BB2,
  128. .sdram_config = 0x61862BB2,
  129. .sdram_config2 = 0x00000000,
  130. .ref_ctrl = 0x0000514D,
  131. .ref_ctrl_final = 0x0000144A,
  132. .sdram_tim1 = 0xD1137824,
  133. .sdram_tim2 = 0x30B37FE3,
  134. .sdram_tim3 = 0x409F8AD8,
  135. .read_idle_ctrl = 0x00050000,
  136. .zq_config = 0x5007190B,
  137. .temp_alert_config = 0x00000000,
  138. .emif_ddr_phy_ctlr_1_init = 0x0824400E,
  139. .emif_ddr_phy_ctlr_1 = 0x0E24400E,
  140. .emif_ddr_ext_phy_ctrl_1 = 0x04040100,
  141. .emif_ddr_ext_phy_ctrl_2 = 0x006B009F,
  142. .emif_ddr_ext_phy_ctrl_3 = 0x006B00A2,
  143. .emif_ddr_ext_phy_ctrl_4 = 0x006B00A8,
  144. .emif_ddr_ext_phy_ctrl_5 = 0x006B00A8,
  145. .emif_rd_wr_lvl_rmp_win = 0x00000000,
  146. .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
  147. .emif_rd_wr_lvl_ctl = 0x00000000,
  148. .emif_rd_wr_exec_thresh = 0x00000305
  149. };
  150. const struct emif_regs emif1_ddr3_532_mhz_1cs_2G = {
  151. .sdram_config_init = 0x61851ab2,
  152. .sdram_config = 0x61851ab2,
  153. .sdram_config2 = 0x08000000,
  154. .ref_ctrl = 0x000040F1,
  155. .ref_ctrl_final = 0x00001035,
  156. .sdram_tim1 = 0xCCCF36B3,
  157. .sdram_tim2 = 0x30BF7FDA,
  158. .sdram_tim3 = 0x427F8BA8,
  159. .read_idle_ctrl = 0x00050000,
  160. .zq_config = 0x0007190B,
  161. .temp_alert_config = 0x00000000,
  162. .emif_ddr_phy_ctlr_1_init = 0x0024400B,
  163. .emif_ddr_phy_ctlr_1 = 0x0E24400B,
  164. .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
  165. .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
  166. .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
  167. .emif_ddr_ext_phy_ctrl_4 = 0x009B009B,
  168. .emif_ddr_ext_phy_ctrl_5 = 0x009E009E,
  169. .emif_rd_wr_lvl_rmp_win = 0x00000000,
  170. .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
  171. .emif_rd_wr_lvl_ctl = 0x00000000,
  172. .emif_rd_wr_exec_thresh = 0x00000305
  173. };
  174. const struct emif_regs emif2_ddr3_532_mhz_1cs_2G = {
  175. .sdram_config_init = 0x61851B32,
  176. .sdram_config = 0x61851B32,
  177. .sdram_config2 = 0x08000000,
  178. .ref_ctrl = 0x000040F1,
  179. .ref_ctrl_final = 0x00001035,
  180. .sdram_tim1 = 0xCCCF36B3,
  181. .sdram_tim2 = 0x308F7FDA,
  182. .sdram_tim3 = 0x427F88A8,
  183. .read_idle_ctrl = 0x00050000,
  184. .zq_config = 0x0007190B,
  185. .temp_alert_config = 0x00000000,
  186. .emif_ddr_phy_ctlr_1_init = 0x0024400B,
  187. .emif_ddr_phy_ctlr_1 = 0x0E24400B,
  188. .emif_ddr_ext_phy_ctrl_1 = 0x10040100,
  189. .emif_ddr_ext_phy_ctrl_2 = 0x00910091,
  190. .emif_ddr_ext_phy_ctrl_3 = 0x00950095,
  191. .emif_ddr_ext_phy_ctrl_4 = 0x009B009B,
  192. .emif_ddr_ext_phy_ctrl_5 = 0x009E009E,
  193. .emif_rd_wr_lvl_rmp_win = 0x00000000,
  194. .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
  195. .emif_rd_wr_lvl_ctl = 0x00000000,
  196. .emif_rd_wr_exec_thresh = 0x00000305
  197. };
  198. const struct emif_regs emif_1_regs_ddr3_666_mhz_1cs_dra76 = {
  199. .sdram_config_init = 0x61862B32,
  200. .sdram_config = 0x61862B32,
  201. .sdram_config2 = 0x00000000,
  202. .ref_ctrl = 0x0000514C,
  203. .ref_ctrl_final = 0x0000144A,
  204. .sdram_tim1 = 0xD113783C,
  205. .sdram_tim2 = 0x30B47FE3,
  206. .sdram_tim3 = 0x409F8AD8,
  207. .read_idle_ctrl = 0x00050000,
  208. .zq_config = 0x5007190B,
  209. .temp_alert_config = 0x00000000,
  210. .emif_ddr_phy_ctlr_1_init = 0x0824400D,
  211. .emif_ddr_phy_ctlr_1 = 0x0E24400D,
  212. .emif_ddr_ext_phy_ctrl_1 = 0x04040100,
  213. .emif_ddr_ext_phy_ctrl_2 = 0x006B009F,
  214. .emif_ddr_ext_phy_ctrl_3 = 0x006B00A2,
  215. .emif_ddr_ext_phy_ctrl_4 = 0x006B00A8,
  216. .emif_ddr_ext_phy_ctrl_5 = 0x006B00A8,
  217. .emif_rd_wr_lvl_rmp_win = 0x00000000,
  218. .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
  219. .emif_rd_wr_lvl_ctl = 0x00000000,
  220. .emif_rd_wr_exec_thresh = 0x00000305
  221. };
  222. const struct emif_regs emif_2_regs_ddr3_666_mhz_1cs_dra76 = {
  223. .sdram_config_init = 0x61862B32,
  224. .sdram_config = 0x61862B32,
  225. .sdram_config2 = 0x00000000,
  226. .ref_ctrl = 0x0000514C,
  227. .ref_ctrl_final = 0x0000144A,
  228. .sdram_tim1 = 0xD113781C,
  229. .sdram_tim2 = 0x30B47FE3,
  230. .sdram_tim3 = 0x409F8AD8,
  231. .read_idle_ctrl = 0x00050000,
  232. .zq_config = 0x5007190B,
  233. .temp_alert_config = 0x00000000,
  234. .emif_ddr_phy_ctlr_1_init = 0x0824400D,
  235. .emif_ddr_phy_ctlr_1 = 0x0E24400D,
  236. .emif_ddr_ext_phy_ctrl_1 = 0x04040100,
  237. .emif_ddr_ext_phy_ctrl_2 = 0x006B009F,
  238. .emif_ddr_ext_phy_ctrl_3 = 0x006B00A2,
  239. .emif_ddr_ext_phy_ctrl_4 = 0x006B00A8,
  240. .emif_ddr_ext_phy_ctrl_5 = 0x006B00A8,
  241. .emif_rd_wr_lvl_rmp_win = 0x00000000,
  242. .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
  243. .emif_rd_wr_lvl_ctl = 0x00000000,
  244. .emif_rd_wr_exec_thresh = 0x00000305
  245. };
  246. void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs)
  247. {
  248. u64 ram_size;
  249. ram_size = board_ti_get_emif_size();
  250. switch (omap_revision()) {
  251. case DRA752_ES1_0:
  252. case DRA752_ES1_1:
  253. case DRA752_ES2_0:
  254. switch (emif_nr) {
  255. case 1:
  256. if (ram_size > CONFIG_MAX_MEM_MAPPED)
  257. *regs = &emif1_ddr3_532_mhz_1cs_2G;
  258. else
  259. *regs = &emif1_ddr3_532_mhz_1cs;
  260. break;
  261. case 2:
  262. if (ram_size > CONFIG_MAX_MEM_MAPPED)
  263. *regs = &emif2_ddr3_532_mhz_1cs_2G;
  264. else
  265. *regs = &emif2_ddr3_532_mhz_1cs;
  266. break;
  267. }
  268. break;
  269. case DRA762_ABZ_ES1_0:
  270. case DRA762_ACD_ES1_0:
  271. case DRA762_ES1_0:
  272. if (emif_nr == 1)
  273. *regs = &emif_1_regs_ddr3_666_mhz_1cs_dra76;
  274. else
  275. *regs = &emif_2_regs_ddr3_666_mhz_1cs_dra76;
  276. break;
  277. case DRA722_ES1_0:
  278. case DRA722_ES2_0:
  279. case DRA722_ES2_1:
  280. if (ram_size < CONFIG_MAX_MEM_MAPPED)
  281. *regs = &emif_1_regs_ddr3_666_mhz_1cs_dra_es1;
  282. else
  283. *regs = &emif_1_regs_ddr3_666_mhz_1cs_dra_es2;
  284. break;
  285. default:
  286. *regs = &emif1_ddr3_532_mhz_1cs;
  287. }
  288. }
  289. static const struct dmm_lisa_map_regs lisa_map_dra7_1536MB = {
  290. .dmm_lisa_map_0 = 0x0,
  291. .dmm_lisa_map_1 = 0x80640300,
  292. .dmm_lisa_map_2 = 0xC0500220,
  293. .dmm_lisa_map_3 = 0xFF020100,
  294. .is_ma_present = 0x1
  295. };
  296. static const struct dmm_lisa_map_regs lisa_map_2G_x_2 = {
  297. .dmm_lisa_map_0 = 0x0,
  298. .dmm_lisa_map_1 = 0x0,
  299. .dmm_lisa_map_2 = 0x80600100,
  300. .dmm_lisa_map_3 = 0xFF020100,
  301. .is_ma_present = 0x1
  302. };
  303. const struct dmm_lisa_map_regs lisa_map_dra7_2GB = {
  304. .dmm_lisa_map_0 = 0x0,
  305. .dmm_lisa_map_1 = 0x0,
  306. .dmm_lisa_map_2 = 0x80740300,
  307. .dmm_lisa_map_3 = 0xFF020100,
  308. .is_ma_present = 0x1
  309. };
  310. /*
  311. * DRA722 EVM EMIF1 2GB CONFIGURATION
  312. * EMIF1 4 devices of 512Mb x 8 Micron
  313. */
  314. const struct dmm_lisa_map_regs lisa_map_2G_x_4 = {
  315. .dmm_lisa_map_0 = 0x0,
  316. .dmm_lisa_map_1 = 0x0,
  317. .dmm_lisa_map_2 = 0x80700100,
  318. .dmm_lisa_map_3 = 0xFF020100,
  319. .is_ma_present = 0x1
  320. };
  321. void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs)
  322. {
  323. u64 ram_size;
  324. ram_size = board_ti_get_emif_size();
  325. switch (omap_revision()) {
  326. case DRA762_ABZ_ES1_0:
  327. case DRA762_ACD_ES1_0:
  328. case DRA762_ES1_0:
  329. case DRA752_ES1_0:
  330. case DRA752_ES1_1:
  331. case DRA752_ES2_0:
  332. if (ram_size > CONFIG_MAX_MEM_MAPPED)
  333. *dmm_lisa_regs = &lisa_map_dra7_2GB;
  334. else
  335. *dmm_lisa_regs = &lisa_map_dra7_1536MB;
  336. break;
  337. case DRA722_ES1_0:
  338. case DRA722_ES2_0:
  339. case DRA722_ES2_1:
  340. default:
  341. if (ram_size < CONFIG_MAX_MEM_MAPPED)
  342. *dmm_lisa_regs = &lisa_map_2G_x_2;
  343. else
  344. *dmm_lisa_regs = &lisa_map_2G_x_4;
  345. break;
  346. }
  347. }
  348. struct vcores_data dra752_volts = {
  349. .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
  350. .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
  351. .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  352. .mpu.addr = TPS659038_REG_ADDR_SMPS12,
  353. .mpu.pmic = &tps659038,
  354. .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
  355. .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
  356. .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
  357. .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
  358. .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
  359. .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
  360. .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
  361. .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  362. .eve.addr = TPS659038_REG_ADDR_SMPS45,
  363. .eve.pmic = &tps659038,
  364. .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
  365. .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
  366. .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
  367. .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
  368. .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
  369. .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
  370. .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
  371. .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  372. .gpu.addr = TPS659038_REG_ADDR_SMPS6,
  373. .gpu.pmic = &tps659038,
  374. .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
  375. .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
  376. .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
  377. .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  378. .core.addr = TPS659038_REG_ADDR_SMPS7,
  379. .core.pmic = &tps659038,
  380. .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
  381. .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
  382. .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
  383. .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
  384. .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
  385. .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
  386. .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  387. .iva.addr = TPS659038_REG_ADDR_SMPS8,
  388. .iva.pmic = &tps659038,
  389. .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
  390. };
  391. struct vcores_data dra76x_volts = {
  392. .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
  393. .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
  394. .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  395. .mpu.addr = LP87565_REG_ADDR_BUCK01,
  396. .mpu.pmic = &lp87565,
  397. .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
  398. .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
  399. .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
  400. .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
  401. .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
  402. .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
  403. .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
  404. .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  405. .eve.addr = TPS65917_REG_ADDR_SMPS1,
  406. .eve.pmic = &tps659038,
  407. .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
  408. .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
  409. .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
  410. .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
  411. .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
  412. .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
  413. .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
  414. .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  415. .gpu.addr = LP87565_REG_ADDR_BUCK23,
  416. .gpu.pmic = &lp87565,
  417. .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
  418. .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
  419. .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
  420. .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  421. .core.addr = TPS65917_REG_ADDR_SMPS3,
  422. .core.pmic = &tps659038,
  423. .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
  424. .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
  425. .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
  426. .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
  427. .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
  428. .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
  429. .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  430. .iva.addr = TPS65917_REG_ADDR_SMPS4,
  431. .iva.pmic = &tps659038,
  432. .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
  433. };
  434. struct vcores_data dra722_volts = {
  435. .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
  436. .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
  437. .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  438. .mpu.addr = TPS65917_REG_ADDR_SMPS1,
  439. .mpu.pmic = &tps659038,
  440. .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
  441. .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
  442. .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
  443. .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  444. .core.addr = TPS65917_REG_ADDR_SMPS2,
  445. .core.pmic = &tps659038,
  446. /*
  447. * The DSPEVE, GPU and IVA rails are usually grouped on DRA72x
  448. * designs and powered by TPS65917 SMPS3, as on the J6Eco EVM.
  449. */
  450. .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
  451. .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD,
  452. .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH,
  453. .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
  454. .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD,
  455. .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH,
  456. .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  457. .gpu.addr = TPS65917_REG_ADDR_SMPS3,
  458. .gpu.pmic = &tps659038,
  459. .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
  460. .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
  461. .eve.value[OPP_OD] = VDD_EVE_DRA7_OD,
  462. .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
  463. .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
  464. .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD,
  465. .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
  466. .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  467. .eve.addr = TPS65917_REG_ADDR_SMPS3,
  468. .eve.pmic = &tps659038,
  469. .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
  470. .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
  471. .iva.value[OPP_OD] = VDD_IVA_DRA7_OD,
  472. .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
  473. .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
  474. .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD,
  475. .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
  476. .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  477. .iva.addr = TPS65917_REG_ADDR_SMPS3,
  478. .iva.pmic = &tps659038,
  479. .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
  480. };
  481. struct vcores_data dra718_volts = {
  482. /*
  483. * In the case of dra71x GPU MPU and CORE
  484. * are all powered up by BUCK0 of LP873X PMIC
  485. */
  486. .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM,
  487. .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM,
  488. .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  489. .mpu.addr = LP873X_REG_ADDR_BUCK0,
  490. .mpu.pmic = &lp8733,
  491. .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
  492. .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM,
  493. .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM,
  494. .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  495. .core.addr = LP873X_REG_ADDR_BUCK0,
  496. .core.pmic = &lp8733,
  497. .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM,
  498. .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM,
  499. .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  500. .gpu.addr = LP873X_REG_ADDR_BUCK0,
  501. .gpu.pmic = &lp8733,
  502. .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
  503. /*
  504. * The DSPEVE and IVA rails are grouped on DRA71x-evm
  505. * and are powered by BUCK1 of LP873X PMIC
  506. */
  507. .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM,
  508. .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH,
  509. .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
  510. .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH,
  511. .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  512. .eve.addr = LP873X_REG_ADDR_BUCK1,
  513. .eve.pmic = &lp8733,
  514. .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
  515. .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM,
  516. .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH,
  517. .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM,
  518. .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH,
  519. .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
  520. .iva.addr = LP873X_REG_ADDR_BUCK1,
  521. .iva.pmic = &lp8733,
  522. .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
  523. };
  524. int get_voltrail_opp(int rail_offset)
  525. {
  526. int opp;
  527. switch (rail_offset) {
  528. case VOLT_MPU:
  529. opp = DRA7_MPU_OPP;
  530. /* DRA71x supports only OPP_NOM for MPU */
  531. if (board_is_dra71x_evm())
  532. opp = OPP_NOM;
  533. break;
  534. case VOLT_CORE:
  535. opp = DRA7_CORE_OPP;
  536. /* DRA71x supports only OPP_NOM for CORE */
  537. if (board_is_dra71x_evm())
  538. opp = OPP_NOM;
  539. break;
  540. case VOLT_GPU:
  541. opp = DRA7_GPU_OPP;
  542. /* DRA71x supports only OPP_NOM for GPU */
  543. if (board_is_dra71x_evm())
  544. opp = OPP_NOM;
  545. break;
  546. case VOLT_EVE:
  547. opp = DRA7_DSPEVE_OPP;
  548. /*
  549. * DRA71x does not support OPP_OD for EVE.
  550. * If OPP_OD is selected by menuconfig, fallback
  551. * to OPP_NOM.
  552. */
  553. if (board_is_dra71x_evm() && opp == OPP_OD)
  554. opp = OPP_NOM;
  555. break;
  556. case VOLT_IVA:
  557. opp = DRA7_IVA_OPP;
  558. /*
  559. * DRA71x does not support OPP_OD for IVA.
  560. * If OPP_OD is selected by menuconfig, fallback
  561. * to OPP_NOM.
  562. */
  563. if (board_is_dra71x_evm() && opp == OPP_OD)
  564. opp = OPP_NOM;
  565. break;
  566. default:
  567. opp = OPP_NOM;
  568. }
  569. return opp;
  570. }
  571. /**
  572. * @brief board_init
  573. *
  574. * @return 0
  575. */
  576. int board_init(void)
  577. {
  578. gpmc_init();
  579. gd->bd->bi_boot_params = (0x80000000 + 0x100); /* boot param addr */
  580. return 0;
  581. }
  582. int dram_init_banksize(void)
  583. {
  584. u64 ram_size;
  585. ram_size = board_ti_get_emif_size();
  586. gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
  587. gd->bd->bi_dram[0].size = get_effective_memsize();
  588. if (ram_size > CONFIG_MAX_MEM_MAPPED) {
  589. gd->bd->bi_dram[1].start = 0x200000000;
  590. gd->bd->bi_dram[1].size = ram_size - CONFIG_MAX_MEM_MAPPED;
  591. }
  592. return 0;
  593. }
  594. int board_late_init(void)
  595. {
  596. #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
  597. char *name = "unknown";
  598. if (is_dra72x()) {
  599. if (board_is_dra72x_revc_or_later())
  600. name = "dra72x-revc";
  601. else if (board_is_dra71x_evm())
  602. name = "dra71x";
  603. else
  604. name = "dra72x";
  605. } else if (is_dra76x_abz()) {
  606. name = "dra76x_abz";
  607. } else if (is_dra76x_acd()) {
  608. name = "dra76x_acd";
  609. } else {
  610. name = "dra7xx";
  611. }
  612. set_board_info_env(name);
  613. /*
  614. * Default FIT boot on HS devices. Non FIT images are not allowed
  615. * on HS devices.
  616. */
  617. if (get_device_type() == HS_DEVICE)
  618. env_set("boot_fit", "1");
  619. omap_die_id_serial();
  620. omap_set_fastboot_vars();
  621. /*
  622. * Hook the LDO1 regulator to EN pin. This applies only to LP8733
  623. * Rest all regulators are hooked to EN Pin at reset.
  624. */
  625. if (board_is_dra71x_evm())
  626. palmas_i2c_write_u8(LP873X_I2C_SLAVE_ADDR, 0x9, 0x7);
  627. #endif
  628. return 0;
  629. }
  630. #ifdef CONFIG_SPL_BUILD
  631. void do_board_detect(void)
  632. {
  633. int rc;
  634. rc = ti_i2c_eeprom_dra7_get(CONFIG_EEPROM_BUS_ADDRESS,
  635. CONFIG_EEPROM_CHIP_ADDRESS);
  636. if (rc)
  637. printf("ti_i2c_eeprom_init failed %d\n", rc);
  638. }
  639. #else
  640. void do_board_detect(void)
  641. {
  642. char *bname = NULL;
  643. int rc;
  644. rc = ti_i2c_eeprom_dra7_get(CONFIG_EEPROM_BUS_ADDRESS,
  645. CONFIG_EEPROM_CHIP_ADDRESS);
  646. if (rc)
  647. printf("ti_i2c_eeprom_init failed %d\n", rc);
  648. if (board_is_dra74x_evm()) {
  649. bname = "DRA74x EVM";
  650. } else if (board_is_dra72x_evm()) {
  651. bname = "DRA72x EVM";
  652. } else if (board_is_dra71x_evm()) {
  653. bname = "DRA71x EVM";
  654. } else if (board_is_dra76x_evm()) {
  655. bname = "DRA76x EVM";
  656. } else {
  657. /* If EEPROM is not populated */
  658. if (is_dra72x())
  659. bname = "DRA72x EVM";
  660. else
  661. bname = "DRA74x EVM";
  662. }
  663. if (bname)
  664. snprintf(sysinfo.board_string, SYSINFO_BOARD_NAME_MAX_LEN,
  665. "Board: %s REV %s\n", bname, board_ti_get_rev());
  666. }
  667. #endif /* CONFIG_SPL_BUILD */
  668. void vcores_init(void)
  669. {
  670. if (board_is_dra74x_evm()) {
  671. *omap_vcores = &dra752_volts;
  672. } else if (board_is_dra72x_evm()) {
  673. *omap_vcores = &dra722_volts;
  674. } else if (board_is_dra71x_evm()) {
  675. *omap_vcores = &dra718_volts;
  676. } else if (board_is_dra76x_evm()) {
  677. *omap_vcores = &dra76x_volts;
  678. } else {
  679. /* If EEPROM is not populated */
  680. if (is_dra72x())
  681. *omap_vcores = &dra722_volts;
  682. else
  683. *omap_vcores = &dra752_volts;
  684. }
  685. }
  686. void set_muxconf_regs(void)
  687. {
  688. do_set_mux32((*ctrl)->control_padconf_core_base,
  689. early_padconf, ARRAY_SIZE(early_padconf));
  690. }
  691. #ifdef CONFIG_IODELAY_RECALIBRATION
  692. void recalibrate_iodelay(void)
  693. {
  694. struct pad_conf_entry const *pads, *delta_pads = NULL;
  695. struct iodelay_cfg_entry const *iodelay;
  696. int npads, niodelays, delta_npads = 0;
  697. int ret;
  698. switch (omap_revision()) {
  699. case DRA722_ES1_0:
  700. case DRA722_ES2_0:
  701. case DRA722_ES2_1:
  702. pads = dra72x_core_padconf_array_common;
  703. npads = ARRAY_SIZE(dra72x_core_padconf_array_common);
  704. if (board_is_dra71x_evm()) {
  705. pads = dra71x_core_padconf_array;
  706. npads = ARRAY_SIZE(dra71x_core_padconf_array);
  707. iodelay = dra71_iodelay_cfg_array;
  708. niodelays = ARRAY_SIZE(dra71_iodelay_cfg_array);
  709. } else if (board_is_dra72x_revc_or_later()) {
  710. delta_pads = dra72x_rgmii_padconf_array_revc;
  711. delta_npads =
  712. ARRAY_SIZE(dra72x_rgmii_padconf_array_revc);
  713. iodelay = dra72_iodelay_cfg_array_revc;
  714. niodelays = ARRAY_SIZE(dra72_iodelay_cfg_array_revc);
  715. } else {
  716. delta_pads = dra72x_rgmii_padconf_array_revb;
  717. delta_npads =
  718. ARRAY_SIZE(dra72x_rgmii_padconf_array_revb);
  719. iodelay = dra72_iodelay_cfg_array_revb;
  720. niodelays = ARRAY_SIZE(dra72_iodelay_cfg_array_revb);
  721. }
  722. break;
  723. case DRA752_ES1_0:
  724. case DRA752_ES1_1:
  725. pads = dra74x_core_padconf_array;
  726. npads = ARRAY_SIZE(dra74x_core_padconf_array);
  727. iodelay = dra742_es1_1_iodelay_cfg_array;
  728. niodelays = ARRAY_SIZE(dra742_es1_1_iodelay_cfg_array);
  729. break;
  730. case DRA762_ACD_ES1_0:
  731. case DRA762_ES1_0:
  732. pads = dra76x_core_padconf_array;
  733. npads = ARRAY_SIZE(dra76x_core_padconf_array);
  734. iodelay = dra76x_es1_0_iodelay_cfg_array;
  735. niodelays = ARRAY_SIZE(dra76x_es1_0_iodelay_cfg_array);
  736. break;
  737. default:
  738. case DRA752_ES2_0:
  739. case DRA762_ABZ_ES1_0:
  740. pads = dra74x_core_padconf_array;
  741. npads = ARRAY_SIZE(dra74x_core_padconf_array);
  742. iodelay = dra742_es2_0_iodelay_cfg_array;
  743. niodelays = ARRAY_SIZE(dra742_es2_0_iodelay_cfg_array);
  744. /* Setup port1 and port2 for rgmii with 'no-id' mode */
  745. clrset_spare_register(1, 0, RGMII2_ID_MODE_N_MASK |
  746. RGMII1_ID_MODE_N_MASK);
  747. break;
  748. }
  749. /* Setup I/O isolation */
  750. ret = __recalibrate_iodelay_start();
  751. if (ret)
  752. goto err;
  753. /* Do the muxing here */
  754. do_set_mux32((*ctrl)->control_padconf_core_base, pads, npads);
  755. /* Now do the weird minor deltas that should be safe */
  756. if (delta_npads)
  757. do_set_mux32((*ctrl)->control_padconf_core_base,
  758. delta_pads, delta_npads);
  759. if (is_dra76x())
  760. /* Set mux for MCAN instead of DCAN1 */
  761. clrsetbits_le32((*ctrl)->control_core_control_spare_rw,
  762. MCAN_SEL_ALT_MASK, MCAN_SEL);
  763. /* Setup IOdelay configuration */
  764. ret = do_set_iodelay((*ctrl)->iodelay_config_base, iodelay, niodelays);
  765. err:
  766. /* Closeup.. remove isolation */
  767. __recalibrate_iodelay_end(ret);
  768. }
  769. #endif
  770. #if defined(CONFIG_MMC)
  771. int board_mmc_init(bd_t *bis)
  772. {
  773. omap_mmc_init(0, 0, 0, -1, -1);
  774. omap_mmc_init(1, 0, 0, -1, -1);
  775. return 0;
  776. }
  777. void board_mmc_poweron_ldo(uint voltage)
  778. {
  779. if (board_is_dra71x_evm()) {
  780. if (voltage == LDO_VOLT_3V0)
  781. voltage = 0x19;
  782. else if (voltage == LDO_VOLT_1V8)
  783. voltage = 0xa;
  784. lp873x_mmc1_poweron_ldo(voltage);
  785. } else if (board_is_dra76x_evm()) {
  786. palmas_mmc1_poweron_ldo(LDO4_VOLTAGE, LDO4_CTRL, voltage);
  787. } else {
  788. palmas_mmc1_poweron_ldo(LDO1_VOLTAGE, LDO1_CTRL, voltage);
  789. }
  790. }
  791. static const struct mmc_platform_fixups dra7x_es1_1_mmc1_fixups = {
  792. .hw_rev = "rev11",
  793. .unsupported_caps = MMC_CAP(MMC_HS_200) |
  794. MMC_CAP(UHS_SDR104),
  795. .max_freq = 96000000,
  796. };
  797. static const struct mmc_platform_fixups dra7x_es1_1_mmc23_fixups = {
  798. .hw_rev = "rev11",
  799. .unsupported_caps = MMC_CAP(MMC_HS_200) |
  800. MMC_CAP(UHS_SDR104) |
  801. MMC_CAP(UHS_SDR50),
  802. .max_freq = 48000000,
  803. };
  804. const struct mmc_platform_fixups *platform_fixups_mmc(uint32_t addr)
  805. {
  806. switch (omap_revision()) {
  807. case DRA752_ES1_0:
  808. case DRA752_ES1_1:
  809. if (addr == OMAP_HSMMC1_BASE)
  810. return &dra7x_es1_1_mmc1_fixups;
  811. else
  812. return &dra7x_es1_1_mmc23_fixups;
  813. default:
  814. return NULL;
  815. }
  816. }
  817. #endif
  818. #ifdef CONFIG_USB_DWC3
  819. static struct dwc3_device usb_otg_ss1 = {
  820. .maximum_speed = USB_SPEED_SUPER,
  821. .base = DRA7_USB_OTG_SS1_BASE,
  822. .tx_fifo_resize = false,
  823. .index = 0,
  824. };
  825. static struct dwc3_omap_device usb_otg_ss1_glue = {
  826. .base = (void *)DRA7_USB_OTG_SS1_GLUE_BASE,
  827. .utmi_mode = DWC3_OMAP_UTMI_MODE_SW,
  828. .index = 0,
  829. };
  830. static struct ti_usb_phy_device usb_phy1_device = {
  831. .pll_ctrl_base = (void *)DRA7_USB3_PHY1_PLL_CTRL,
  832. .usb2_phy_power = (void *)DRA7_USB2_PHY1_POWER,
  833. .usb3_phy_power = (void *)DRA7_USB3_PHY1_POWER,
  834. .index = 0,
  835. };
  836. static struct dwc3_device usb_otg_ss2 = {
  837. .maximum_speed = USB_SPEED_SUPER,
  838. .base = DRA7_USB_OTG_SS2_BASE,
  839. .tx_fifo_resize = false,
  840. .index = 1,
  841. };
  842. static struct dwc3_omap_device usb_otg_ss2_glue = {
  843. .base = (void *)DRA7_USB_OTG_SS2_GLUE_BASE,
  844. .utmi_mode = DWC3_OMAP_UTMI_MODE_SW,
  845. .index = 1,
  846. };
  847. static struct ti_usb_phy_device usb_phy2_device = {
  848. .usb2_phy_power = (void *)DRA7_USB2_PHY2_POWER,
  849. .index = 1,
  850. };
  851. int board_usb_init(int index, enum usb_init_type init)
  852. {
  853. enable_usb_clocks(index);
  854. switch (index) {
  855. case 0:
  856. if (init == USB_INIT_DEVICE) {
  857. usb_otg_ss1.dr_mode = USB_DR_MODE_PERIPHERAL;
  858. usb_otg_ss1_glue.vbus_id_status = OMAP_DWC3_VBUS_VALID;
  859. } else {
  860. usb_otg_ss1.dr_mode = USB_DR_MODE_HOST;
  861. usb_otg_ss1_glue.vbus_id_status = OMAP_DWC3_ID_GROUND;
  862. }
  863. ti_usb_phy_uboot_init(&usb_phy1_device);
  864. dwc3_omap_uboot_init(&usb_otg_ss1_glue);
  865. dwc3_uboot_init(&usb_otg_ss1);
  866. break;
  867. case 1:
  868. if (init == USB_INIT_DEVICE) {
  869. usb_otg_ss2.dr_mode = USB_DR_MODE_PERIPHERAL;
  870. usb_otg_ss2_glue.vbus_id_status = OMAP_DWC3_VBUS_VALID;
  871. } else {
  872. usb_otg_ss2.dr_mode = USB_DR_MODE_HOST;
  873. usb_otg_ss2_glue.vbus_id_status = OMAP_DWC3_ID_GROUND;
  874. }
  875. ti_usb_phy_uboot_init(&usb_phy2_device);
  876. dwc3_omap_uboot_init(&usb_otg_ss2_glue);
  877. dwc3_uboot_init(&usb_otg_ss2);
  878. break;
  879. default:
  880. printf("Invalid Controller Index\n");
  881. }
  882. return 0;
  883. }
  884. int board_usb_cleanup(int index, enum usb_init_type init)
  885. {
  886. switch (index) {
  887. case 0:
  888. case 1:
  889. ti_usb_phy_uboot_exit(index);
  890. dwc3_uboot_exit(index);
  891. dwc3_omap_uboot_exit(index);
  892. break;
  893. default:
  894. printf("Invalid Controller Index\n");
  895. }
  896. disable_usb_clocks(index);
  897. return 0;
  898. }
  899. int usb_gadget_handle_interrupts(int index)
  900. {
  901. u32 status;
  902. status = dwc3_omap_uboot_interrupt_status(index);
  903. if (status)
  904. dwc3_uboot_handle_interrupt(index);
  905. return 0;
  906. }
  907. #endif
  908. #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_OS_BOOT)
  909. int spl_start_uboot(void)
  910. {
  911. /* break into full u-boot on 'c' */
  912. if (serial_tstc() && serial_getc() == 'c')
  913. return 1;
  914. #ifdef CONFIG_SPL_ENV_SUPPORT
  915. env_init();
  916. env_load();
  917. if (env_get_yesno("boot_os") != 1)
  918. return 1;
  919. #endif
  920. return 0;
  921. }
  922. #endif
  923. #ifdef CONFIG_DRIVER_TI_CPSW
  924. extern u32 *const omap_si_rev;
  925. static void cpsw_control(int enabled)
  926. {
  927. /* VTP can be added here */
  928. return;
  929. }
  930. static struct cpsw_slave_data cpsw_slaves[] = {
  931. {
  932. .slave_reg_ofs = 0x208,
  933. .sliver_reg_ofs = 0xd80,
  934. .phy_addr = 2,
  935. },
  936. {
  937. .slave_reg_ofs = 0x308,
  938. .sliver_reg_ofs = 0xdc0,
  939. .phy_addr = 3,
  940. },
  941. };
  942. static struct cpsw_platform_data cpsw_data = {
  943. .mdio_base = CPSW_MDIO_BASE,
  944. .cpsw_base = CPSW_BASE,
  945. .mdio_div = 0xff,
  946. .channels = 8,
  947. .cpdma_reg_ofs = 0x800,
  948. .slaves = 2,
  949. .slave_data = cpsw_slaves,
  950. .ale_reg_ofs = 0xd00,
  951. .ale_entries = 1024,
  952. .host_port_reg_ofs = 0x108,
  953. .hw_stats_reg_ofs = 0x900,
  954. .bd_ram_ofs = 0x2000,
  955. .mac_control = (1 << 5),
  956. .control = cpsw_control,
  957. .host_port_num = 0,
  958. .version = CPSW_CTRL_VERSION_2,
  959. };
  960. int board_eth_init(bd_t *bis)
  961. {
  962. int ret;
  963. uint8_t mac_addr[6];
  964. uint32_t mac_hi, mac_lo;
  965. uint32_t ctrl_val;
  966. /* try reading mac address from efuse */
  967. mac_lo = readl((*ctrl)->control_core_mac_id_0_lo);
  968. mac_hi = readl((*ctrl)->control_core_mac_id_0_hi);
  969. mac_addr[0] = (mac_hi & 0xFF0000) >> 16;
  970. mac_addr[1] = (mac_hi & 0xFF00) >> 8;
  971. mac_addr[2] = mac_hi & 0xFF;
  972. mac_addr[3] = (mac_lo & 0xFF0000) >> 16;
  973. mac_addr[4] = (mac_lo & 0xFF00) >> 8;
  974. mac_addr[5] = mac_lo & 0xFF;
  975. if (!env_get("ethaddr")) {
  976. printf("<ethaddr> not set. Validating first E-fuse MAC\n");
  977. if (is_valid_ethaddr(mac_addr))
  978. eth_env_set_enetaddr("ethaddr", mac_addr);
  979. }
  980. mac_lo = readl((*ctrl)->control_core_mac_id_1_lo);
  981. mac_hi = readl((*ctrl)->control_core_mac_id_1_hi);
  982. mac_addr[0] = (mac_hi & 0xFF0000) >> 16;
  983. mac_addr[1] = (mac_hi & 0xFF00) >> 8;
  984. mac_addr[2] = mac_hi & 0xFF;
  985. mac_addr[3] = (mac_lo & 0xFF0000) >> 16;
  986. mac_addr[4] = (mac_lo & 0xFF00) >> 8;
  987. mac_addr[5] = mac_lo & 0xFF;
  988. if (!env_get("eth1addr")) {
  989. if (is_valid_ethaddr(mac_addr))
  990. eth_env_set_enetaddr("eth1addr", mac_addr);
  991. }
  992. ctrl_val = readl((*ctrl)->control_core_control_io1) & (~0x33);
  993. ctrl_val |= 0x22;
  994. writel(ctrl_val, (*ctrl)->control_core_control_io1);
  995. if (*omap_si_rev == DRA722_ES1_0)
  996. cpsw_data.active_slave = 1;
  997. if (board_is_dra72x_revc_or_later()) {
  998. cpsw_slaves[0].phy_if = PHY_INTERFACE_MODE_RGMII_ID;
  999. cpsw_slaves[1].phy_if = PHY_INTERFACE_MODE_RGMII_ID;
  1000. }
  1001. ret = cpsw_register(&cpsw_data);
  1002. if (ret < 0)
  1003. printf("Error %d registering CPSW switch\n", ret);
  1004. return ret;
  1005. }
  1006. #endif
  1007. #ifdef CONFIG_BOARD_EARLY_INIT_F
  1008. /* VTT regulator enable */
  1009. static inline void vtt_regulator_enable(void)
  1010. {
  1011. if (omap_hw_init_context() == OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL)
  1012. return;
  1013. /* Do not enable VTT for DRA722 or DRA76x */
  1014. if (is_dra72x() || is_dra76x())
  1015. return;
  1016. /*
  1017. * EVM Rev G and later use gpio7_11 for DDR3 termination.
  1018. * This is safe enough to do on older revs.
  1019. */
  1020. gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en");
  1021. gpio_direction_output(GPIO_DDR_VTT_EN, 1);
  1022. }
  1023. int board_early_init_f(void)
  1024. {
  1025. vtt_regulator_enable();
  1026. return 0;
  1027. }
  1028. #endif
  1029. #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
  1030. int ft_board_setup(void *blob, bd_t *bd)
  1031. {
  1032. ft_cpu_setup(blob, bd);
  1033. return 0;
  1034. }
  1035. #endif
  1036. #ifdef CONFIG_SPL_LOAD_FIT
  1037. int board_fit_config_name_match(const char *name)
  1038. {
  1039. if (is_dra72x()) {
  1040. if (board_is_dra71x_evm()) {
  1041. if (!strcmp(name, "dra71-evm"))
  1042. return 0;
  1043. }else if(board_is_dra72x_revc_or_later()) {
  1044. if (!strcmp(name, "dra72-evm-revc"))
  1045. return 0;
  1046. } else if (!strcmp(name, "dra72-evm")) {
  1047. return 0;
  1048. }
  1049. } else if (is_dra76x_acd() && !strcmp(name, "dra76-evm")) {
  1050. return 0;
  1051. } else if (!is_dra72x() && !is_dra76x_acd() &&
  1052. !strcmp(name, "dra7-evm")) {
  1053. return 0;
  1054. }
  1055. return -1;
  1056. }
  1057. #endif
  1058. #ifdef CONFIG_TI_SECURE_DEVICE
  1059. void board_fit_image_post_process(void **p_image, size_t *p_size)
  1060. {
  1061. secure_boot_verify_image(p_image, p_size);
  1062. }
  1063. void board_tee_image_process(ulong tee_image, size_t tee_size)
  1064. {
  1065. secure_tee_install((u32)tee_image);
  1066. }
  1067. #if CONFIG_IS_ENABLED(FASTBOOT) && !CONFIG_IS_ENABLED(ENV_IS_NOWHERE)
  1068. int fastboot_set_reboot_flag(void)
  1069. {
  1070. printf("Setting reboot to fastboot flag ...\n");
  1071. env_set("dofastboot", "1");
  1072. env_save();
  1073. return 0;
  1074. }
  1075. #endif
  1076. U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_TEE, board_tee_image_process);
  1077. #endif