evm.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /*
  2. * evm.c
  3. *
  4. * Board functions for TI814x EVM
  5. *
  6. * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
  16. * GNU General Public License for more details.
  17. */
  18. #include <common.h>
  19. #include <errno.h>
  20. #include <spl.h>
  21. #include <asm/arch/cpu.h>
  22. #include <asm/arch/hardware.h>
  23. #include <asm/arch/omap.h>
  24. #include <asm/arch/ddr_defs.h>
  25. #include <asm/arch/clock.h>
  26. #include <asm/arch/gpio.h>
  27. #include <asm/arch/mmc_host_def.h>
  28. #include <asm/arch/sys_proto.h>
  29. #include <asm/io.h>
  30. #include <asm/emif.h>
  31. #include <asm/gpio.h>
  32. #include "evm.h"
  33. DECLARE_GLOBAL_DATA_PTR;
  34. #ifdef CONFIG_SPL_BUILD
  35. static struct wd_timer *wdtimer = (struct wd_timer *)WDT_BASE;
  36. static struct uart_sys *uart_base = (struct uart_sys *)DEFAULT_UART_BASE;
  37. #endif
  38. /* UART Defines */
  39. #ifdef CONFIG_SPL_BUILD
  40. #define UART_RESET (0x1 << 1)
  41. #define UART_CLK_RUNNING_MASK 0x1
  42. #define UART_SMART_IDLE_EN (0x1 << 0x3)
  43. static void rtc32k_enable(void)
  44. {
  45. struct rtc_regs *rtc = (struct rtc_regs *)RTC_BASE;
  46. /*
  47. * Unlock the RTC's registers. For more details please see the
  48. * RTC_SS section of the TRM. In order to unlock we need to
  49. * write these specific values (keys) in this order.
  50. */
  51. writel(0x83e70b13, &rtc->kick0r);
  52. writel(0x95a4f1e0, &rtc->kick1r);
  53. /* Enable the RTC 32K OSC by setting bits 3 and 6. */
  54. writel((1 << 3) | (1 << 6), &rtc->osc);
  55. }
  56. static void uart_enable(void)
  57. {
  58. u32 regVal;
  59. /* UART softreset */
  60. regVal = readl(&uart_base->uartsyscfg);
  61. regVal |= UART_RESET;
  62. writel(regVal, &uart_base->uartsyscfg);
  63. while ((readl(&uart_base->uartsyssts) &
  64. UART_CLK_RUNNING_MASK) != UART_CLK_RUNNING_MASK)
  65. ;
  66. /* Disable smart idle */
  67. regVal = readl(&uart_base->uartsyscfg);
  68. regVal |= UART_SMART_IDLE_EN;
  69. writel(regVal, &uart_base->uartsyscfg);
  70. }
  71. static void wdt_disable(void)
  72. {
  73. writel(0xAAAA, &wdtimer->wdtwspr);
  74. while (readl(&wdtimer->wdtwwps) != 0x0)
  75. ;
  76. writel(0x5555, &wdtimer->wdtwspr);
  77. while (readl(&wdtimer->wdtwwps) != 0x0)
  78. ;
  79. }
  80. static const struct cmd_control evm_ddr2_cctrl_data = {
  81. .cmd0csratio = 0x80,
  82. .cmd0dldiff = 0x04,
  83. .cmd0iclkout = 0x00,
  84. .cmd1csratio = 0x80,
  85. .cmd1dldiff = 0x04,
  86. .cmd1iclkout = 0x00,
  87. .cmd2csratio = 0x80,
  88. .cmd2dldiff = 0x04,
  89. .cmd2iclkout = 0x00,
  90. };
  91. static const struct emif_regs evm_ddr2_emif0_regs = {
  92. .sdram_config = 0x40801ab2,
  93. .ref_ctrl = 0x10000c30,
  94. .sdram_tim1 = 0x0aaaf552,
  95. .sdram_tim2 = 0x043631d2,
  96. .sdram_tim3 = 0x00000327,
  97. .emif_ddr_phy_ctlr_1 = 0x00000007
  98. };
  99. static const struct emif_regs evm_ddr2_emif1_regs = {
  100. .sdram_config = 0x40801ab2,
  101. .ref_ctrl = 0x10000c30,
  102. .sdram_tim1 = 0x0aaaf552,
  103. .sdram_tim2 = 0x043631d2,
  104. .sdram_tim3 = 0x00000327,
  105. .emif_ddr_phy_ctlr_1 = 0x00000007
  106. };
  107. const struct dmm_lisa_map_regs evm_lisa_map_regs = {
  108. .dmm_lisa_map_0 = 0x00000000,
  109. .dmm_lisa_map_1 = 0x00000000,
  110. .dmm_lisa_map_2 = 0x806c0300,
  111. .dmm_lisa_map_3 = 0x806c0300,
  112. };
  113. static const struct ddr_data evm_ddr2_data = {
  114. .datardsratio0 = ((0x35<<10) | (0x35<<0)),
  115. .datawdsratio0 = ((0x20<<10) | (0x20<<0)),
  116. .datawiratio0 = ((0<<10) | (0<<0)),
  117. .datagiratio0 = ((0<<10) | (0<<0)),
  118. .datafwsratio0 = ((0x90<<10) | (0x90<<0)),
  119. .datawrsratio0 = ((0x50<<10) | (0x50<<0)),
  120. .datauserank0delay = 1,
  121. .datadldiff0 = 0x4,
  122. };
  123. #endif
  124. /*
  125. * early system init of muxing and clocks.
  126. */
  127. void s_init(void)
  128. {
  129. #ifdef CONFIG_SPL_BUILD
  130. /* WDT1 is already running when the bootloader gets control
  131. * Disable it to avoid "random" resets
  132. */
  133. wdt_disable();
  134. /* Setup the PLLs and the clocks for the peripherals */
  135. pll_init();
  136. /* Enable RTC32K clock */
  137. rtc32k_enable();
  138. /* Set UART pins */
  139. enable_uart0_pin_mux();
  140. /* Set MMC pins */
  141. enable_mmc1_pin_mux();
  142. /* Enable UART */
  143. uart_enable();
  144. gd = &gdata;
  145. preloader_console_init();
  146. config_dmm(&evm_lisa_map_regs);
  147. config_ddr(0, 0, &evm_ddr2_data, &evm_ddr2_cctrl_data,
  148. &evm_ddr2_emif0_regs, 0);
  149. config_ddr(0, 0, &evm_ddr2_data, &evm_ddr2_cctrl_data,
  150. &evm_ddr2_emif1_regs, 1);
  151. #endif
  152. }
  153. /*
  154. * Basic board specific setup. Pinmux has been handled already.
  155. */
  156. int board_init(void)
  157. {
  158. gd->bd->bi_boot_params = PHYS_DRAM_1 + 0x100;
  159. return 0;
  160. }
  161. #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_GENERIC_MMC)
  162. int board_mmc_init(bd_t *bis)
  163. {
  164. omap_mmc_init(1, 0, 0, -1, -1);
  165. return 0;
  166. }
  167. #endif