initcode.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. /*
  2. * initcode.c - Initialize the processor. This is usually entails things
  3. * like external memory, voltage regulators, etc... Note that this file
  4. * cannot make any function calls as it may be executed all by itself by
  5. * the Blackfin's bootrom in LDR format.
  6. *
  7. * Copyright (c) 2004-2008 Analog Devices Inc.
  8. *
  9. * Licensed under the GPL-2 or later.
  10. */
  11. #include <config.h>
  12. #include <asm/blackfin.h>
  13. #include <asm/mach-common/bits/bootrom.h>
  14. #include <asm/mach-common/bits/core.h>
  15. #include <asm/mach-common/bits/ebiu.h>
  16. #include <asm/mach-common/bits/pll.h>
  17. #include <asm/mach-common/bits/uart.h>
  18. #define BFIN_IN_INITCODE
  19. #include "serial.h"
  20. __attribute__((always_inline))
  21. static inline void serial_init(void)
  22. {
  23. #ifdef __ADSPBF54x__
  24. # ifdef BFIN_BOOT_UART_USE_RTS
  25. # define BFIN_UART_USE_RTS 1
  26. # else
  27. # define BFIN_UART_USE_RTS 0
  28. # endif
  29. if (BFIN_UART_USE_RTS && CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_UART) {
  30. size_t i;
  31. /* force RTS rather than relying on auto RTS */
  32. bfin_write_UART1_MCR(bfin_read_UART1_MCR() | FCPOL);
  33. /* Wait for the line to clear up. We cannot rely on UART
  34. * registers as none of them reflect the status of the RSR.
  35. * Instead, we'll sleep for ~10 bit times at 9600 baud.
  36. * We can precalc things here by assuming boot values for
  37. * PLL rather than loading registers and calculating.
  38. * baud = SCLK / (16 ^ (1 - EDBO) * Divisor)
  39. * EDB0 = 0
  40. * Divisor = (SCLK / baud) / 16
  41. * SCLK = baud * 16 * Divisor
  42. * SCLK = (0x14 * CONFIG_CLKIN_HZ) / 5
  43. * CCLK = (16 * Divisor * 5) * (9600 / 10)
  44. * In reality, this will probably be just about 1 second delay,
  45. * so assuming 9600 baud is OK (both as a very low and too high
  46. * speed as this will buffer things enough).
  47. */
  48. #define _NUMBITS (10) /* how many bits to delay */
  49. #define _LOWBAUD (9600) /* low baud rate */
  50. #define _SCLK ((0x14 * CONFIG_CLKIN_HZ) / 5) /* SCLK based on PLL */
  51. #define _DIVISOR ((_SCLK / _LOWBAUD) / 16) /* UART DLL/DLH */
  52. #define _NUMINS (3) /* how many instructions in loop */
  53. #define _CCLK (((16 * _DIVISOR * 5) * (_LOWBAUD / _NUMBITS)) / _NUMINS)
  54. i = _CCLK;
  55. while (i--)
  56. asm volatile("" : : : "memory");
  57. }
  58. #endif
  59. if (BFIN_DEBUG_EARLY_SERIAL) {
  60. int ucen = *pUART_GCTL & UCEN;
  61. serial_early_init();
  62. /* If the UART is off, that means we need to program
  63. * the baud rate ourselves initially.
  64. */
  65. if (ucen != UCEN)
  66. serial_early_set_baud(CONFIG_BAUDRATE);
  67. }
  68. }
  69. __attribute__((always_inline))
  70. static inline void serial_deinit(void)
  71. {
  72. #ifdef __ADSPBF54x__
  73. if (BFIN_UART_USE_RTS && CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_UART) {
  74. /* clear forced RTS rather than relying on auto RTS */
  75. bfin_write_UART1_MCR(bfin_read_UART1_MCR() & ~FCPOL);
  76. }
  77. #endif
  78. }
  79. __attribute__((always_inline))
  80. static inline void serial_putc(char c)
  81. {
  82. if (!BFIN_DEBUG_EARLY_SERIAL)
  83. return;
  84. if (c == '\n')
  85. serial_putc('\r');
  86. *pUART_THR = c;
  87. while (!(*pUART_LSR & TEMT))
  88. continue;
  89. }
  90. /* Max SCLK can be 133MHz ... dividing that by (2*4) gives
  91. * us a freq of 16MHz for SPI which should generally be
  92. * slow enough for the slow reads the bootrom uses.
  93. */
  94. #if !defined(CONFIG_SPI_FLASH_SLOW_READ) && \
  95. ((defined(__ADSPBF52x__) && __SILICON_REVISION__ >= 2) || \
  96. (defined(__ADSPBF54x__) && __SILICON_REVISION__ >= 1))
  97. # define BOOTROM_SUPPORTS_SPI_FAST_READ 1
  98. #else
  99. # define BOOTROM_SUPPORTS_SPI_FAST_READ 0
  100. #endif
  101. #ifndef CONFIG_SPI_BAUD_INITBLOCK
  102. # define CONFIG_SPI_BAUD_INITBLOCK (BOOTROM_SUPPORTS_SPI_FAST_READ ? 2 : 4)
  103. #endif
  104. #ifdef SPI0_BAUD
  105. # define bfin_write_SPI_BAUD bfin_write_SPI0_BAUD
  106. #endif
  107. /* PLL_DIV defines */
  108. #ifndef CONFIG_PLL_DIV_VAL
  109. # if (CONFIG_CCLK_DIV == 1)
  110. # define CONFIG_CCLK_ACT_DIV CCLK_DIV1
  111. # elif (CONFIG_CCLK_DIV == 2)
  112. # define CONFIG_CCLK_ACT_DIV CCLK_DIV2
  113. # elif (CONFIG_CCLK_DIV == 4)
  114. # define CONFIG_CCLK_ACT_DIV CCLK_DIV4
  115. # elif (CONFIG_CCLK_DIV == 8)
  116. # define CONFIG_CCLK_ACT_DIV CCLK_DIV8
  117. # else
  118. # define CONFIG_CCLK_ACT_DIV CONFIG_CCLK_DIV_not_defined_properly
  119. # endif
  120. # define CONFIG_PLL_DIV_VAL (CONFIG_CCLK_ACT_DIV | CONFIG_SCLK_DIV)
  121. #endif
  122. #ifndef CONFIG_PLL_LOCKCNT_VAL
  123. # define CONFIG_PLL_LOCKCNT_VAL 0x0300
  124. #endif
  125. #ifndef CONFIG_PLL_CTL_VAL
  126. # define CONFIG_PLL_CTL_VAL (SPORT_HYST | (CONFIG_VCO_MULT << 9) | CONFIG_CLKIN_HALF)
  127. #endif
  128. #ifndef CONFIG_EBIU_RSTCTL_VAL
  129. # define CONFIG_EBIU_RSTCTL_VAL 0 /* only MDDRENABLE is useful */
  130. #endif
  131. #if ((CONFIG_EBIU_RSTCTL_VAL & 0xFFFFFFC4) != 0)
  132. # error invalid EBIU_RSTCTL value: must not set reserved bits
  133. #endif
  134. #ifndef CONFIG_EBIU_MBSCTL_VAL
  135. # define CONFIG_EBIU_MBSCTL_VAL 0
  136. #endif
  137. #if defined(CONFIG_EBIU_DDRQUE_VAL) && ((CONFIG_EBIU_DDRQUE_VAL & 0xFFFF8000) != 0)
  138. # error invalid EBIU_DDRQUE value: must not set reserved bits
  139. #endif
  140. /* Make sure our voltage value is sane so we don't blow up! */
  141. #ifndef CONFIG_VR_CTL_VAL
  142. # define BFIN_CCLK ((CONFIG_CLKIN_HZ * CONFIG_VCO_MULT) / CONFIG_CCLK_DIV)
  143. # if defined(__ADSPBF533__) || defined(__ADSPBF532__) || defined(__ADSPBF531__)
  144. # define CCLK_VLEV_120 400000000
  145. # define CCLK_VLEV_125 533000000
  146. # elif defined(__ADSPBF537__) || defined(__ADSPBF536__) || defined(__ADSPBF534__)
  147. # define CCLK_VLEV_120 401000000
  148. # define CCLK_VLEV_125 401000000
  149. # elif defined(__ADSPBF561__)
  150. # define CCLK_VLEV_120 300000000
  151. # define CCLK_VLEV_125 501000000
  152. # endif
  153. # if BFIN_CCLK < CCLK_VLEV_120
  154. # define CONFIG_VR_CTL_VLEV VLEV_120
  155. # elif BFIN_CCLK < CCLK_VLEV_125
  156. # define CONFIG_VR_CTL_VLEV VLEV_125
  157. # else
  158. # define CONFIG_VR_CTL_VLEV VLEV_130
  159. # endif
  160. # if defined(__ADSPBF52x__) /* TBD; use default */
  161. # undef CONFIG_VR_CTL_VLEV
  162. # define CONFIG_VR_CTL_VLEV VLEV_110
  163. # elif defined(__ADSPBF54x__) /* TBD; use default */
  164. # undef CONFIG_VR_CTL_VLEV
  165. # define CONFIG_VR_CTL_VLEV VLEV_120
  166. # elif defined(__ADSPBF538__) || defined(__ADSPBF539__) /* TBD; use default */
  167. # undef CONFIG_VR_CTL_VLEV
  168. # define CONFIG_VR_CTL_VLEV VLEV_125
  169. # endif
  170. # ifdef CONFIG_BFIN_MAC
  171. # define CONFIG_VR_CTL_CLKBUF CLKBUFOE
  172. # else
  173. # define CONFIG_VR_CTL_CLKBUF 0
  174. # endif
  175. # if defined(__ADSPBF52x__)
  176. # define CONFIG_VR_CTL_FREQ FREQ_1000
  177. # else
  178. # define CONFIG_VR_CTL_FREQ (GAIN_20 | FREQ_1000)
  179. # endif
  180. # define CONFIG_VR_CTL_VAL (CONFIG_VR_CTL_CLKBUF | CONFIG_VR_CTL_VLEV | CONFIG_VR_CTL_FREQ)
  181. #endif
  182. /* some parts do not have an on-chip voltage regulator */
  183. #if defined(__ADSPBF51x__)
  184. # define CONFIG_HAS_VR 0
  185. # undef CONFIG_VR_CTL_VAL
  186. # define CONFIG_VR_CTL_VAL 0
  187. #else
  188. # define CONFIG_HAS_VR 1
  189. #endif
  190. #ifndef EBIU_RSTCTL
  191. /* Blackfin with SDRAM */
  192. #ifndef CONFIG_EBIU_SDBCTL_VAL
  193. # if CONFIG_MEM_SIZE == 16
  194. # define CONFIG_EBSZ_VAL EBSZ_16
  195. # elif CONFIG_MEM_SIZE == 32
  196. # define CONFIG_EBSZ_VAL EBSZ_32
  197. # elif CONFIG_MEM_SIZE == 64
  198. # define CONFIG_EBSZ_VAL EBSZ_64
  199. # elif CONFIG_MEM_SIZE == 128
  200. # define CONFIG_EBSZ_VAL EBSZ_128
  201. # elif CONFIG_MEM_SIZE == 256
  202. # define CONFIG_EBSZ_VAL EBSZ_256
  203. # elif CONFIG_MEM_SIZE == 512
  204. # define CONFIG_EBSZ_VAL EBSZ_512
  205. # else
  206. # error You need to define CONFIG_EBIU_SDBCTL_VAL or CONFIG_MEM_SIZE
  207. # endif
  208. # if CONFIG_MEM_ADD_WDTH == 8
  209. # define CONFIG_EBCAW_VAL EBCAW_8
  210. # elif CONFIG_MEM_ADD_WDTH == 9
  211. # define CONFIG_EBCAW_VAL EBCAW_9
  212. # elif CONFIG_MEM_ADD_WDTH == 10
  213. # define CONFIG_EBCAW_VAL EBCAW_10
  214. # elif CONFIG_MEM_ADD_WDTH == 11
  215. # define CONFIG_EBCAW_VAL EBCAW_11
  216. # else
  217. # error You need to define CONFIG_EBIU_SDBCTL_VAL or CONFIG_MEM_ADD_WDTH
  218. # endif
  219. # define CONFIG_EBIU_SDBCTL_VAL (CONFIG_EBCAW_VAL | CONFIG_EBSZ_VAL | EBE)
  220. #endif
  221. #endif
  222. /* Conflicting Column Address Widths Causes SDRAM Errors:
  223. * EB2CAW and EB3CAW must be the same
  224. */
  225. #if ANOMALY_05000362
  226. # if ((CONFIG_EBIU_SDBCTL_VAL & 0x30000000) >> 8) != (CONFIG_EBIU_SDBCTL_VAL & 0x00300000)
  227. # error "Anomaly 05000362: EB2CAW and EB3CAW must be the same"
  228. # endif
  229. #endif
  230. BOOTROM_CALLED_FUNC_ATTR
  231. void initcode(ADI_BOOT_DATA *bootstruct)
  232. {
  233. ADI_BOOT_DATA bootstruct_scratch;
  234. /* Save the clock pieces that are used in baud rate calculation */
  235. unsigned int sdivB, divB, vcoB;
  236. serial_init();
  237. if (BFIN_DEBUG_EARLY_SERIAL || CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_UART) {
  238. sdivB = bfin_read_PLL_DIV() & 0xf;
  239. vcoB = (bfin_read_PLL_CTL() >> 9) & 0x3f;
  240. divB = serial_early_get_div();
  241. }
  242. serial_putc('A');
  243. /* If the bootstruct is NULL, then it's because we're loading
  244. * dynamically and not via LDR (bootrom). So set the struct to
  245. * some scratch space.
  246. */
  247. if (!bootstruct)
  248. bootstruct = &bootstruct_scratch;
  249. #ifdef CONFIG_HW_WATCHDOG
  250. # ifndef CONFIG_HW_WATCHDOG_TIMEOUT_INITCODE
  251. # define CONFIG_HW_WATCHDOG_TIMEOUT_INITCODE 20000
  252. # endif
  253. /* Program the watchdog with an initial timeout of ~20 seconds.
  254. * Hopefully that should be long enough to load the u-boot LDR
  255. * (from wherever) and then the common u-boot code can take over.
  256. * In bypass mode, the start.S would have already set a much lower
  257. * timeout, so don't clobber that.
  258. */
  259. if (CONFIG_BFIN_BOOT_MODE != BFIN_BOOT_BYPASS) {
  260. bfin_write_WDOG_CNT(MSEC_TO_SCLK(CONFIG_HW_WATCHDOG_TIMEOUT_INITCODE));
  261. bfin_write_WDOG_CTL(0);
  262. }
  263. #endif
  264. serial_putc('B');
  265. /* If external memory is enabled, put it into self refresh first. */
  266. bool put_into_srfs = false;
  267. #ifdef EBIU_RSTCTL
  268. if (bfin_read_EBIU_RSTCTL() & DDR_SRESET) {
  269. bfin_write_EBIU_RSTCTL(bfin_read_EBIU_RSTCTL() | SRREQ);
  270. put_into_srfs = true;
  271. }
  272. #else
  273. if (bfin_read_EBIU_SDBCTL() & EBE) {
  274. bfin_write_EBIU_SDGCTL(bfin_read_EBIU_SDGCTL() | SRFS);
  275. put_into_srfs = true;
  276. }
  277. #endif
  278. serial_putc('C');
  279. /* Blackfin bootroms use the SPI slow read opcode instead of the SPI
  280. * fast read, so we need to slow down the SPI clock a lot more during
  281. * boot. Once we switch over to u-boot's SPI flash driver, we'll
  282. * increase the speed appropriately.
  283. */
  284. if (CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_SPI_MASTER) {
  285. if (BOOTROM_SUPPORTS_SPI_FAST_READ && CONFIG_SPI_BAUD_INITBLOCK < 4)
  286. bootstruct->dFlags |= BFLAG_FASTREAD;
  287. bfin_write_SPI_BAUD(CONFIG_SPI_BAUD_INITBLOCK);
  288. }
  289. serial_putc('D');
  290. /* If we're entering self refresh, make sure it has happened. */
  291. if (put_into_srfs)
  292. #ifdef EBIU_RSTCTL
  293. while (!(bfin_read_EBIU_RSTCTL() & SRACK))
  294. #else
  295. while (!(bfin_read_EBIU_SDSTAT() & SDSRA))
  296. #endif
  297. continue;
  298. serial_putc('E');
  299. /* With newer bootroms, we use the helper function to set up
  300. * the memory controller. Older bootroms lacks such helpers
  301. * so we do it ourselves.
  302. */
  303. uint16_t vr_ctl = bfin_read_VR_CTL();
  304. if (!ANOMALY_05000386) {
  305. serial_putc('F');
  306. /* Always programming PLL_LOCKCNT avoids Anomaly 05000430 */
  307. ADI_SYSCTRL_VALUES memory_settings;
  308. uint32_t actions = SYSCTRL_WRITE | SYSCTRL_PLLCTL | SYSCTRL_PLLDIV | SYSCTRL_LOCKCNT;
  309. if (CONFIG_HAS_VR) {
  310. actions |= SYSCTRL_VRCTL;
  311. if (CONFIG_VR_CTL_VAL & FREQ_MASK)
  312. actions |= SYSCTRL_INTVOLTAGE;
  313. else
  314. actions |= SYSCTRL_EXTVOLTAGE;
  315. memory_settings.uwVrCtl = CONFIG_VR_CTL_VAL;
  316. } else
  317. actions |= SYSCTRL_EXTVOLTAGE;
  318. memory_settings.uwPllCtl = CONFIG_PLL_CTL_VAL;
  319. memory_settings.uwPllDiv = CONFIG_PLL_DIV_VAL;
  320. memory_settings.uwPllLockCnt = CONFIG_PLL_LOCKCNT_VAL;
  321. #if ANOMALY_05000432
  322. bfin_write_SIC_IWR1(0);
  323. #endif
  324. bfrom_SysControl(actions, &memory_settings, NULL);
  325. #if ANOMALY_05000432
  326. bfin_write_SIC_IWR1(-1);
  327. #endif
  328. #if ANOMALY_05000171
  329. bfin_write_SICA_IWR0(-1);
  330. bfin_write_SICA_IWR1(-1);
  331. #endif
  332. } else {
  333. serial_putc('G');
  334. /* Disable all peripheral wakeups except for the PLL event. */
  335. #ifdef SIC_IWR0
  336. bfin_write_SIC_IWR0(1);
  337. bfin_write_SIC_IWR1(0);
  338. # ifdef SIC_IWR2
  339. bfin_write_SIC_IWR2(0);
  340. # endif
  341. #elif defined(SICA_IWR0)
  342. bfin_write_SICA_IWR0(1);
  343. bfin_write_SICA_IWR1(0);
  344. #else
  345. bfin_write_SIC_IWR(1);
  346. #endif
  347. serial_putc('H');
  348. /* Always programming PLL_LOCKCNT avoids Anomaly 05000430 */
  349. bfin_write_PLL_LOCKCNT(CONFIG_PLL_LOCKCNT_VAL);
  350. serial_putc('I');
  351. /* Only reprogram when needed to avoid triggering unnecessary
  352. * PLL relock sequences.
  353. */
  354. if (vr_ctl != CONFIG_VR_CTL_VAL) {
  355. serial_putc('!');
  356. bfin_write_VR_CTL(CONFIG_VR_CTL_VAL);
  357. asm("idle;");
  358. }
  359. serial_putc('J');
  360. bfin_write_PLL_DIV(CONFIG_PLL_DIV_VAL);
  361. serial_putc('K');
  362. /* Only reprogram when needed to avoid triggering unnecessary
  363. * PLL relock sequences.
  364. */
  365. if (ANOMALY_05000242 || bfin_read_PLL_CTL() != CONFIG_PLL_CTL_VAL) {
  366. serial_putc('!');
  367. bfin_write_PLL_CTL(CONFIG_PLL_CTL_VAL);
  368. asm("idle;");
  369. }
  370. serial_putc('L');
  371. /* Restore all peripheral wakeups. */
  372. #ifdef SIC_IWR0
  373. bfin_write_SIC_IWR0(-1);
  374. bfin_write_SIC_IWR1(-1);
  375. # ifdef SIC_IWR2
  376. bfin_write_SIC_IWR2(-1);
  377. # endif
  378. #elif defined(SICA_IWR0)
  379. bfin_write_SICA_IWR0(-1);
  380. bfin_write_SICA_IWR1(-1);
  381. #else
  382. bfin_write_SIC_IWR(-1);
  383. #endif
  384. }
  385. serial_putc('M');
  386. /* Since we've changed the SCLK above, we may need to update
  387. * the UART divisors (UART baud rates are based on SCLK).
  388. * Do the division by hand as there are no native instructions
  389. * for dividing which means we'd generate a libgcc reference.
  390. */
  391. if (CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_UART) {
  392. unsigned int sdivR, vcoR;
  393. sdivR = bfin_read_PLL_DIV() & 0xf;
  394. vcoR = (bfin_read_PLL_CTL() >> 9) & 0x3f;
  395. int dividend = sdivB * divB * vcoR;
  396. int divisor = vcoB * sdivR;
  397. unsigned int quotient;
  398. for (quotient = 0; dividend > 0; ++quotient)
  399. dividend -= divisor;
  400. serial_early_put_div(quotient - ANOMALY_05000230);
  401. }
  402. serial_putc('N');
  403. /* Program the external memory controller before we come out of
  404. * self-refresh. This only works with our SDRAM controller.
  405. */
  406. #ifndef EBIU_RSTCTL
  407. bfin_write_EBIU_SDRRC(CONFIG_EBIU_SDRRC_VAL);
  408. bfin_write_EBIU_SDBCTL(CONFIG_EBIU_SDBCTL_VAL);
  409. bfin_write_EBIU_SDGCTL(CONFIG_EBIU_SDGCTL_VAL);
  410. #endif
  411. serial_putc('O');
  412. /* Now that we've reprogrammed, take things out of self refresh. */
  413. if (put_into_srfs)
  414. #ifdef EBIU_RSTCTL
  415. bfin_write_EBIU_RSTCTL(bfin_read_EBIU_RSTCTL() & ~(SRREQ));
  416. #else
  417. bfin_write_EBIU_SDGCTL(bfin_read_EBIU_SDGCTL() & ~(SRFS));
  418. #endif
  419. serial_putc('P');
  420. /* Our DDR controller sucks and cannot be programmed while in
  421. * self-refresh. So we have to pull it out before programming.
  422. */
  423. #ifdef EBIU_RSTCTL
  424. bfin_write_EBIU_RSTCTL(bfin_read_EBIU_RSTCTL() | 0x1 /*DDRSRESET*/ | CONFIG_EBIU_RSTCTL_VAL);
  425. bfin_write_EBIU_DDRCTL0(CONFIG_EBIU_DDRCTL0_VAL);
  426. bfin_write_EBIU_DDRCTL1(CONFIG_EBIU_DDRCTL1_VAL);
  427. bfin_write_EBIU_DDRCTL2(CONFIG_EBIU_DDRCTL2_VAL);
  428. # ifdef CONFIG_EBIU_DDRCTL3_VAL
  429. /* default is disable, so don't need to force this */
  430. bfin_write_EBIU_DDRCTL3(CONFIG_EBIU_DDRCTL3_VAL);
  431. # endif
  432. # ifdef CONFIG_EBIU_DDRQUE_VAL
  433. bfin_write_EBIU_DDRQUE(bfin_read_EBIU_DDRQUE() | CONFIG_EBIU_DDRQUE_VAL);
  434. # endif
  435. #endif
  436. serial_putc('Q');
  437. /* Are we coming out of hibernate (suspend to memory) ?
  438. * The memory layout is:
  439. * 0x0: hibernate magic for anomaly 307 (0xDEADBEEF)
  440. * 0x4: return address
  441. * 0x8: stack pointer
  442. *
  443. * SCKELOW is unreliable on older parts (anomaly 307)
  444. */
  445. if (ANOMALY_05000307 || vr_ctl & 0x8000) {
  446. uint32_t *hibernate_magic = 0;
  447. __builtin_bfin_ssync(); /* make sure memory controller is done */
  448. if (hibernate_magic[0] == 0xDEADBEEF) {
  449. serial_putc('R');
  450. bfin_write_EVT15(hibernate_magic[1]);
  451. bfin_write_IMASK(EVT_IVG15);
  452. __asm__ __volatile__ (
  453. /* load reti early to avoid anomaly 281 */
  454. "reti = %0;"
  455. /* clear hibernate magic */
  456. "[%0] = %1;"
  457. /* load stack pointer */
  458. "SP = [%0 + 8];"
  459. /* lower ourselves from reset ivg to ivg15 */
  460. "raise 15;"
  461. "rti;"
  462. :
  463. : "p"(hibernate_magic), "d"(0x2000 /* jump.s 0 */)
  464. );
  465. }
  466. }
  467. serial_putc('S');
  468. /* Program the async banks controller. */
  469. bfin_write_EBIU_AMBCTL0(CONFIG_EBIU_AMBCTL0_VAL);
  470. bfin_write_EBIU_AMBCTL1(CONFIG_EBIU_AMBCTL1_VAL);
  471. bfin_write_EBIU_AMGCTL(CONFIG_EBIU_AMGCTL_VAL);
  472. #ifdef EBIU_MODE
  473. /* Not all parts have these additional MMRs. */
  474. bfin_write_EBIU_MBSCTL(CONFIG_EBIU_MBSCTL_VAL);
  475. bfin_write_EBIU_MODE(CONFIG_EBIU_MODE_VAL);
  476. bfin_write_EBIU_FCTL(CONFIG_EBIU_FCTL_VAL);
  477. #endif
  478. serial_putc('T');
  479. #ifdef CONFIG_BFIN_BOOTROM_USES_EVT1
  480. /* tell the bootrom where our entry point is */
  481. if (CONFIG_BFIN_BOOT_MODE != BFIN_BOOT_BYPASS)
  482. bfin_write_EVT1(CONFIG_SYS_MONITOR_BASE);
  483. #endif
  484. serial_putc('>');
  485. serial_putc('\n');
  486. serial_deinit();
  487. }