evm.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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 <cpsw.h>
  20. #include <errno.h>
  21. #include <spl.h>
  22. #include <asm/arch/cpu.h>
  23. #include <asm/arch/hardware.h>
  24. #include <asm/arch/omap.h>
  25. #include <asm/arch/ddr_defs.h>
  26. #include <asm/arch/clock.h>
  27. #include <asm/arch/gpio.h>
  28. #include <asm/arch/mmc_host_def.h>
  29. #include <asm/arch/sys_proto.h>
  30. #include <asm/io.h>
  31. #include <asm/emif.h>
  32. #include <asm/gpio.h>
  33. #include "evm.h"
  34. DECLARE_GLOBAL_DATA_PTR;
  35. #ifdef CONFIG_SPL_BUILD
  36. static struct wd_timer *wdtimer = (struct wd_timer *)WDT_BASE;
  37. #endif
  38. static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
  39. /* UART Defines */
  40. #ifdef CONFIG_SPL_BUILD
  41. static void uart_enable(void)
  42. {
  43. /* UART softreset */
  44. uart_soft_reset();
  45. }
  46. static void wdt_disable(void)
  47. {
  48. writel(0xAAAA, &wdtimer->wdtwspr);
  49. while (readl(&wdtimer->wdtwwps) != 0x0)
  50. ;
  51. writel(0x5555, &wdtimer->wdtwspr);
  52. while (readl(&wdtimer->wdtwwps) != 0x0)
  53. ;
  54. }
  55. static const struct cmd_control evm_ddr2_cctrl_data = {
  56. .cmd0csratio = 0x80,
  57. .cmd0dldiff = 0x04,
  58. .cmd0iclkout = 0x00,
  59. .cmd1csratio = 0x80,
  60. .cmd1dldiff = 0x04,
  61. .cmd1iclkout = 0x00,
  62. .cmd2csratio = 0x80,
  63. .cmd2dldiff = 0x04,
  64. .cmd2iclkout = 0x00,
  65. };
  66. static const struct emif_regs evm_ddr2_emif0_regs = {
  67. .sdram_config = 0x40801ab2,
  68. .ref_ctrl = 0x10000c30,
  69. .sdram_tim1 = 0x0aaaf552,
  70. .sdram_tim2 = 0x043631d2,
  71. .sdram_tim3 = 0x00000327,
  72. .emif_ddr_phy_ctlr_1 = 0x00000007
  73. };
  74. static const struct emif_regs evm_ddr2_emif1_regs = {
  75. .sdram_config = 0x40801ab2,
  76. .ref_ctrl = 0x10000c30,
  77. .sdram_tim1 = 0x0aaaf552,
  78. .sdram_tim2 = 0x043631d2,
  79. .sdram_tim3 = 0x00000327,
  80. .emif_ddr_phy_ctlr_1 = 0x00000007
  81. };
  82. const struct dmm_lisa_map_regs evm_lisa_map_regs = {
  83. .dmm_lisa_map_0 = 0x00000000,
  84. .dmm_lisa_map_1 = 0x00000000,
  85. .dmm_lisa_map_2 = 0x806c0300,
  86. .dmm_lisa_map_3 = 0x806c0300,
  87. };
  88. static const struct ddr_data evm_ddr2_data = {
  89. .datardsratio0 = ((0x35<<10) | (0x35<<0)),
  90. .datawdsratio0 = ((0x20<<10) | (0x20<<0)),
  91. .datawiratio0 = ((0<<10) | (0<<0)),
  92. .datagiratio0 = ((0<<10) | (0<<0)),
  93. .datafwsratio0 = ((0x90<<10) | (0x90<<0)),
  94. .datawrsratio0 = ((0x50<<10) | (0x50<<0)),
  95. .datauserank0delay = 1,
  96. .datadldiff0 = 0x4,
  97. };
  98. #endif
  99. /*
  100. * early system init of muxing and clocks.
  101. */
  102. void s_init(void)
  103. {
  104. #ifdef CONFIG_SPL_BUILD
  105. /*
  106. * Save the boot parameters passed from romcode.
  107. * We cannot delay the saving further than this,
  108. * to prevent overwrites.
  109. */
  110. #ifdef CONFIG_SPL_BUILD
  111. save_omap_boot_params();
  112. #endif
  113. /* WDT1 is already running when the bootloader gets control
  114. * Disable it to avoid "random" resets
  115. */
  116. wdt_disable();
  117. /* Enable timer */
  118. timer_init();
  119. /* Setup the PLLs and the clocks for the peripherals */
  120. pll_init();
  121. /* Enable RTC32K clock */
  122. rtc32k_enable();
  123. /* Set UART pins */
  124. enable_uart0_pin_mux();
  125. /* Set MMC pins */
  126. enable_mmc1_pin_mux();
  127. /* Set Ethernet pins */
  128. enable_enet_pin_mux();
  129. /* Enable UART */
  130. uart_enable();
  131. gd = &gdata;
  132. preloader_console_init();
  133. config_dmm(&evm_lisa_map_regs);
  134. config_ddr(0, 0, &evm_ddr2_data, &evm_ddr2_cctrl_data,
  135. &evm_ddr2_emif0_regs, 0);
  136. config_ddr(0, 0, &evm_ddr2_data, &evm_ddr2_cctrl_data,
  137. &evm_ddr2_emif1_regs, 1);
  138. #endif
  139. }
  140. /*
  141. * Basic board specific setup. Pinmux has been handled already.
  142. */
  143. int board_init(void)
  144. {
  145. gd->bd->bi_boot_params = PHYS_DRAM_1 + 0x100;
  146. return 0;
  147. }
  148. #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_GENERIC_MMC)
  149. int board_mmc_init(bd_t *bis)
  150. {
  151. omap_mmc_init(1, 0, 0, -1, -1);
  152. return 0;
  153. }
  154. #endif
  155. #ifdef CONFIG_DRIVER_TI_CPSW
  156. static void cpsw_control(int enabled)
  157. {
  158. /* VTP can be added here */
  159. return;
  160. }
  161. static struct cpsw_slave_data cpsw_slaves[] = {
  162. {
  163. .slave_reg_ofs = 0x50,
  164. .sliver_reg_ofs = 0x700,
  165. .phy_id = 1,
  166. },
  167. {
  168. .slave_reg_ofs = 0x90,
  169. .sliver_reg_ofs = 0x740,
  170. .phy_id = 0,
  171. },
  172. };
  173. static struct cpsw_platform_data cpsw_data = {
  174. .mdio_base = CPSW_MDIO_BASE,
  175. .cpsw_base = CPSW_BASE,
  176. .mdio_div = 0xff,
  177. .channels = 8,
  178. .cpdma_reg_ofs = 0x100,
  179. .slaves = 1,
  180. .slave_data = cpsw_slaves,
  181. .ale_reg_ofs = 0x600,
  182. .ale_entries = 1024,
  183. .host_port_reg_ofs = 0x28,
  184. .hw_stats_reg_ofs = 0x400,
  185. .mac_control = (1 << 5),
  186. .control = cpsw_control,
  187. .host_port_num = 0,
  188. .version = CPSW_CTRL_VERSION_1,
  189. };
  190. #endif
  191. int board_eth_init(bd_t *bis)
  192. {
  193. uint8_t mac_addr[6];
  194. uint32_t mac_hi, mac_lo;
  195. if (!eth_getenv_enetaddr("ethaddr", mac_addr)) {
  196. printf("<ethaddr> not set. Reading from E-fuse\n");
  197. /* try reading mac address from efuse */
  198. mac_lo = readl(&cdev->macid0l);
  199. mac_hi = readl(&cdev->macid0h);
  200. mac_addr[0] = mac_hi & 0xFF;
  201. mac_addr[1] = (mac_hi & 0xFF00) >> 8;
  202. mac_addr[2] = (mac_hi & 0xFF0000) >> 16;
  203. mac_addr[3] = (mac_hi & 0xFF000000) >> 24;
  204. mac_addr[4] = mac_lo & 0xFF;
  205. mac_addr[5] = (mac_lo & 0xFF00) >> 8;
  206. if (is_valid_ether_addr(mac_addr))
  207. eth_setenv_enetaddr("ethaddr", mac_addr);
  208. else
  209. printf("Unable to read MAC address. Set <ethaddr>\n");
  210. }
  211. return cpsw_register(&cpsw_data);
  212. }