evm.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /*
  2. * (C) Copyright 2004-2008
  3. * Texas Instruments, <www.ti.com>
  4. *
  5. * Author :
  6. * Manikandan Pillai <mani.pillai@ti.com>
  7. *
  8. * Derived from Beagle Board and 3430 SDP code by
  9. * Richard Woodruff <r-woodruff2@ti.com>
  10. * Syed Mohammed Khasim <khasim@ti.com>
  11. *
  12. * See file CREDITS for list of people who contributed to this
  13. * project.
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License as
  17. * published by the Free Software Foundation; either version 2 of
  18. * the License, or (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, write to the Free Software
  27. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  28. * MA 02111-1307 USA
  29. */
  30. #include <common.h>
  31. #include <netdev.h>
  32. #include <asm/io.h>
  33. #include <asm/arch/mem.h>
  34. #include <asm/arch/mux.h>
  35. #include <asm/arch/sys_proto.h>
  36. #include <asm/arch/gpio.h>
  37. #include <i2c.h>
  38. #include <asm/mach-types.h>
  39. #include "evm.h"
  40. #define OMAP3EVM_GPIO_ETH_RST_GEN1 64
  41. #define OMAP3EVM_GPIO_ETH_RST_GEN2 7
  42. DECLARE_GLOBAL_DATA_PTR;
  43. static u32 omap3_evm_version;
  44. u32 get_omap3_evm_rev(void)
  45. {
  46. return omap3_evm_version;
  47. }
  48. static void omap3_evm_get_revision(void)
  49. {
  50. #if defined(CONFIG_CMD_NET)
  51. /*
  52. * Board revision can be ascertained only by identifying
  53. * the Ethernet chipset.
  54. */
  55. unsigned int smsc_id;
  56. /* Ethernet PHY ID is stored at ID_REV register */
  57. smsc_id = readl(CONFIG_SMC911X_BASE + 0x50) & 0xFFFF0000;
  58. printf("Read back SMSC id 0x%x\n", smsc_id);
  59. switch (smsc_id) {
  60. /* SMSC9115 chipset */
  61. case 0x01150000:
  62. omap3_evm_version = OMAP3EVM_BOARD_GEN_1;
  63. break;
  64. /* SMSC 9220 chipset */
  65. case 0x92200000:
  66. default:
  67. omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
  68. }
  69. #else
  70. #if defined(CONFIG_STATIC_BOARD_REV)
  71. /*
  72. * Look for static defintion of the board revision
  73. */
  74. omap3_evm_version = CONFIG_STATIC_BOARD_REV;
  75. #else
  76. /*
  77. * Fallback to the default above.
  78. */
  79. omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
  80. #endif
  81. #endif /* CONFIG_CMD_NET */
  82. }
  83. #ifdef CONFIG_USB_OMAP3
  84. /*
  85. * MUSB port on OMAP3EVM Rev >= E requires extvbus programming.
  86. */
  87. u8 omap3_evm_need_extvbus(void)
  88. {
  89. u8 retval = 0;
  90. if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2)
  91. retval = 1;
  92. return retval;
  93. }
  94. #endif
  95. /*
  96. * Routine: board_init
  97. * Description: Early hardware init.
  98. */
  99. int board_init(void)
  100. {
  101. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  102. /* board id for Linux */
  103. gd->bd->bi_arch_number = MACH_TYPE_OMAP3EVM;
  104. /* boot param addr */
  105. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  106. return 0;
  107. }
  108. /*
  109. * Routine: misc_init_r
  110. * Description: Init ethernet (done here so udelay works)
  111. */
  112. int misc_init_r(void)
  113. {
  114. #ifdef CONFIG_DRIVER_OMAP34XX_I2C
  115. i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
  116. #endif
  117. #if defined(CONFIG_CMD_NET)
  118. setup_net_chip();
  119. #endif
  120. omap3_evm_get_revision();
  121. #if defined(CONFIG_CMD_NET)
  122. reset_net_chip();
  123. #endif
  124. dieid_num_r();
  125. return 0;
  126. }
  127. /*
  128. * Routine: set_muxconf_regs
  129. * Description: Setting up the configuration Mux registers specific to the
  130. * hardware. Many pins need to be moved from protect to primary
  131. * mode.
  132. */
  133. void set_muxconf_regs(void)
  134. {
  135. MUX_EVM();
  136. }
  137. #ifdef CONFIG_CMD_NET
  138. /*
  139. * Routine: setup_net_chip
  140. * Description: Setting up the configuration GPMC registers specific to the
  141. * Ethernet hardware.
  142. */
  143. static void setup_net_chip(void)
  144. {
  145. struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
  146. /* Configure GPMC registers */
  147. writel(NET_GPMC_CONFIG1, &gpmc_cfg->cs[5].config1);
  148. writel(NET_GPMC_CONFIG2, &gpmc_cfg->cs[5].config2);
  149. writel(NET_GPMC_CONFIG3, &gpmc_cfg->cs[5].config3);
  150. writel(NET_GPMC_CONFIG4, &gpmc_cfg->cs[5].config4);
  151. writel(NET_GPMC_CONFIG5, &gpmc_cfg->cs[5].config5);
  152. writel(NET_GPMC_CONFIG6, &gpmc_cfg->cs[5].config6);
  153. writel(NET_GPMC_CONFIG7, &gpmc_cfg->cs[5].config7);
  154. /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
  155. writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
  156. /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
  157. writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
  158. /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
  159. writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
  160. &ctrl_base->gpmc_nadv_ale);
  161. }
  162. /**
  163. * Reset the ethernet chip.
  164. */
  165. static void reset_net_chip(void)
  166. {
  167. int ret;
  168. int rst_gpio;
  169. if (get_omap3_evm_rev() == OMAP3EVM_BOARD_GEN_1) {
  170. rst_gpio = OMAP3EVM_GPIO_ETH_RST_GEN1;
  171. } else {
  172. rst_gpio = OMAP3EVM_GPIO_ETH_RST_GEN2;
  173. }
  174. ret = omap_request_gpio(rst_gpio);
  175. if (ret < 0) {
  176. printf("Unable to get GPIO %d\n", rst_gpio);
  177. return ;
  178. }
  179. /* Configure as output */
  180. omap_set_gpio_direction(rst_gpio, 0);
  181. /* Send a pulse on the GPIO pin */
  182. omap_set_gpio_dataout(rst_gpio, 1);
  183. udelay(1);
  184. omap_set_gpio_dataout(rst_gpio, 0);
  185. udelay(1);
  186. omap_set_gpio_dataout(rst_gpio, 1);
  187. }
  188. int board_eth_init(bd_t *bis)
  189. {
  190. int rc = 0;
  191. #ifdef CONFIG_SMC911X
  192. rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
  193. #endif
  194. return rc;
  195. }
  196. #endif /* CONFIG_CMD_NET */