evm.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. * SPDX-License-Identifier: GPL-2.0+
  9. */
  10. #include <common.h>
  11. #include <cpsw.h>
  12. #include <errno.h>
  13. #include <spl.h>
  14. #include <asm/arch/cpu.h>
  15. #include <asm/arch/hardware.h>
  16. #include <asm/arch/omap.h>
  17. #include <asm/arch/ddr_defs.h>
  18. #include <asm/arch/clock.h>
  19. #include <asm/arch/gpio.h>
  20. #include <asm/arch/mmc_host_def.h>
  21. #include <asm/arch/sys_proto.h>
  22. #include <asm/io.h>
  23. #include <asm/emif.h>
  24. #include <asm/gpio.h>
  25. #include "evm.h"
  26. DECLARE_GLOBAL_DATA_PTR;
  27. static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
  28. /* UART Defines */
  29. #ifdef CONFIG_SPL_BUILD
  30. static const struct cmd_control evm_ddr2_cctrl_data = {
  31. .cmd0csratio = 0x80,
  32. .cmd0iclkout = 0x00,
  33. .cmd1csratio = 0x80,
  34. .cmd1iclkout = 0x00,
  35. .cmd2csratio = 0x80,
  36. .cmd2iclkout = 0x00,
  37. };
  38. static const struct emif_regs evm_ddr2_emif0_regs = {
  39. .sdram_config = 0x40801ab2,
  40. .ref_ctrl = 0x10000c30,
  41. .sdram_tim1 = 0x0aaaf552,
  42. .sdram_tim2 = 0x043631d2,
  43. .sdram_tim3 = 0x00000327,
  44. .emif_ddr_phy_ctlr_1 = 0x00000007
  45. };
  46. static const struct emif_regs evm_ddr2_emif1_regs = {
  47. .sdram_config = 0x40801ab2,
  48. .ref_ctrl = 0x10000c30,
  49. .sdram_tim1 = 0x0aaaf552,
  50. .sdram_tim2 = 0x043631d2,
  51. .sdram_tim3 = 0x00000327,
  52. .emif_ddr_phy_ctlr_1 = 0x00000007
  53. };
  54. const struct dmm_lisa_map_regs evm_lisa_map_regs = {
  55. .dmm_lisa_map_0 = 0x00000000,
  56. .dmm_lisa_map_1 = 0x00000000,
  57. .dmm_lisa_map_2 = 0x806c0300,
  58. .dmm_lisa_map_3 = 0x806c0300,
  59. };
  60. static const struct ddr_data evm_ddr2_data = {
  61. .datardsratio0 = ((0x35<<10) | (0x35<<0)),
  62. .datawdsratio0 = ((0x20<<10) | (0x20<<0)),
  63. .datawiratio0 = ((0<<10) | (0<<0)),
  64. .datagiratio0 = ((0<<10) | (0<<0)),
  65. .datafwsratio0 = ((0x90<<10) | (0x90<<0)),
  66. .datawrsratio0 = ((0x50<<10) | (0x50<<0)),
  67. };
  68. void set_uart_mux_conf(void)
  69. {
  70. /* Set UART pins */
  71. enable_uart0_pin_mux();
  72. }
  73. void set_mux_conf_regs(void)
  74. {
  75. /* Set MMC pins */
  76. enable_mmc1_pin_mux();
  77. /* Set Ethernet pins */
  78. enable_enet_pin_mux();
  79. }
  80. void sdram_init(void)
  81. {
  82. config_dmm(&evm_lisa_map_regs);
  83. config_ddr(0, NULL, &evm_ddr2_data, &evm_ddr2_cctrl_data,
  84. &evm_ddr2_emif0_regs, 0);
  85. config_ddr(0, NULL, &evm_ddr2_data, &evm_ddr2_cctrl_data,
  86. &evm_ddr2_emif1_regs, 1);
  87. }
  88. #endif
  89. /*
  90. * Basic board specific setup. Pinmux has been handled already.
  91. */
  92. int board_init(void)
  93. {
  94. gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
  95. return 0;
  96. }
  97. #if defined(CONFIG_GENERIC_MMC)
  98. int board_mmc_init(bd_t *bis)
  99. {
  100. omap_mmc_init(1, 0, 0, -1, -1);
  101. return 0;
  102. }
  103. #endif
  104. #ifdef CONFIG_DRIVER_TI_CPSW
  105. static void cpsw_control(int enabled)
  106. {
  107. /* VTP can be added here */
  108. return;
  109. }
  110. static struct cpsw_slave_data cpsw_slaves[] = {
  111. {
  112. .slave_reg_ofs = 0x50,
  113. .sliver_reg_ofs = 0x700,
  114. .phy_addr = 1,
  115. },
  116. {
  117. .slave_reg_ofs = 0x90,
  118. .sliver_reg_ofs = 0x740,
  119. .phy_addr = 0,
  120. },
  121. };
  122. static struct cpsw_platform_data cpsw_data = {
  123. .mdio_base = CPSW_MDIO_BASE,
  124. .cpsw_base = CPSW_BASE,
  125. .mdio_div = 0xff,
  126. .channels = 8,
  127. .cpdma_reg_ofs = 0x100,
  128. .slaves = 1,
  129. .slave_data = cpsw_slaves,
  130. .ale_reg_ofs = 0x600,
  131. .ale_entries = 1024,
  132. .host_port_reg_ofs = 0x28,
  133. .hw_stats_reg_ofs = 0x400,
  134. .bd_ram_ofs = 0x2000,
  135. .mac_control = (1 << 5),
  136. .control = cpsw_control,
  137. .host_port_num = 0,
  138. .version = CPSW_CTRL_VERSION_1,
  139. };
  140. #endif
  141. int board_eth_init(bd_t *bis)
  142. {
  143. uint8_t mac_addr[6];
  144. uint32_t mac_hi, mac_lo;
  145. if (!eth_getenv_enetaddr("ethaddr", mac_addr)) {
  146. printf("<ethaddr> not set. Reading from E-fuse\n");
  147. /* try reading mac address from efuse */
  148. mac_lo = readl(&cdev->macid0l);
  149. mac_hi = readl(&cdev->macid0h);
  150. mac_addr[0] = mac_hi & 0xFF;
  151. mac_addr[1] = (mac_hi & 0xFF00) >> 8;
  152. mac_addr[2] = (mac_hi & 0xFF0000) >> 16;
  153. mac_addr[3] = (mac_hi & 0xFF000000) >> 24;
  154. mac_addr[4] = mac_lo & 0xFF;
  155. mac_addr[5] = (mac_lo & 0xFF00) >> 8;
  156. if (is_valid_ethaddr(mac_addr))
  157. eth_setenv_enetaddr("ethaddr", mac_addr);
  158. else
  159. printf("Unable to read MAC address. Set <ethaddr>\n");
  160. }
  161. return cpsw_register(&cpsw_data);
  162. }