evm.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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/mmc_host_def.h>
  37. #include <asm/gpio.h>
  38. #include <i2c.h>
  39. #include <asm/mach-types.h>
  40. #include "evm.h"
  41. #define OMAP3EVM_GPIO_ETH_RST_GEN1 64
  42. #define OMAP3EVM_GPIO_ETH_RST_GEN2 7
  43. DECLARE_GLOBAL_DATA_PTR;
  44. static u32 omap3_evm_version;
  45. u32 get_omap3_evm_rev(void)
  46. {
  47. return omap3_evm_version;
  48. }
  49. static void omap3_evm_get_revision(void)
  50. {
  51. #if defined(CONFIG_CMD_NET)
  52. /*
  53. * Board revision can be ascertained only by identifying
  54. * the Ethernet chipset.
  55. */
  56. unsigned int smsc_id;
  57. /* Ethernet PHY ID is stored at ID_REV register */
  58. smsc_id = readl(CONFIG_SMC911X_BASE + 0x50) & 0xFFFF0000;
  59. printf("Read back SMSC id 0x%x\n", smsc_id);
  60. switch (smsc_id) {
  61. /* SMSC9115 chipset */
  62. case 0x01150000:
  63. omap3_evm_version = OMAP3EVM_BOARD_GEN_1;
  64. break;
  65. /* SMSC 9220 chipset */
  66. case 0x92200000:
  67. default:
  68. omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
  69. }
  70. #else
  71. #if defined(CONFIG_STATIC_BOARD_REV)
  72. /*
  73. * Look for static defintion of the board revision
  74. */
  75. omap3_evm_version = CONFIG_STATIC_BOARD_REV;
  76. #else
  77. /*
  78. * Fallback to the default above.
  79. */
  80. omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
  81. #endif
  82. #endif /* CONFIG_CMD_NET */
  83. }
  84. #ifdef CONFIG_USB_OMAP3
  85. /*
  86. * MUSB port on OMAP3EVM Rev >= E requires extvbus programming.
  87. */
  88. u8 omap3_evm_need_extvbus(void)
  89. {
  90. u8 retval = 0;
  91. if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2)
  92. retval = 1;
  93. return retval;
  94. }
  95. #endif
  96. /*
  97. * Routine: board_init
  98. * Description: Early hardware init.
  99. */
  100. int board_init(void)
  101. {
  102. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  103. /* board id for Linux */
  104. gd->bd->bi_arch_number = MACH_TYPE_OMAP3EVM;
  105. /* boot param addr */
  106. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  107. return 0;
  108. }
  109. /*
  110. * Routine: misc_init_r
  111. * Description: Init ethernet (done here so udelay works)
  112. */
  113. int misc_init_r(void)
  114. {
  115. #ifdef CONFIG_DRIVER_OMAP34XX_I2C
  116. i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
  117. #endif
  118. #if defined(CONFIG_CMD_NET)
  119. setup_net_chip();
  120. #endif
  121. omap3_evm_get_revision();
  122. #if defined(CONFIG_CMD_NET)
  123. reset_net_chip();
  124. #endif
  125. dieid_num_r();
  126. return 0;
  127. }
  128. /*
  129. * Routine: set_muxconf_regs
  130. * Description: Setting up the configuration Mux registers specific to the
  131. * hardware. Many pins need to be moved from protect to primary
  132. * mode.
  133. */
  134. void set_muxconf_regs(void)
  135. {
  136. MUX_EVM();
  137. }
  138. #ifdef CONFIG_CMD_NET
  139. /*
  140. * Routine: setup_net_chip
  141. * Description: Setting up the configuration GPMC registers specific to the
  142. * Ethernet hardware.
  143. */
  144. static void setup_net_chip(void)
  145. {
  146. struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
  147. /* Configure GPMC registers */
  148. writel(NET_GPMC_CONFIG1, &gpmc_cfg->cs[5].config1);
  149. writel(NET_GPMC_CONFIG2, &gpmc_cfg->cs[5].config2);
  150. writel(NET_GPMC_CONFIG3, &gpmc_cfg->cs[5].config3);
  151. writel(NET_GPMC_CONFIG4, &gpmc_cfg->cs[5].config4);
  152. writel(NET_GPMC_CONFIG5, &gpmc_cfg->cs[5].config5);
  153. writel(NET_GPMC_CONFIG6, &gpmc_cfg->cs[5].config6);
  154. writel(NET_GPMC_CONFIG7, &gpmc_cfg->cs[5].config7);
  155. /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
  156. writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
  157. /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
  158. writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
  159. /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
  160. writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
  161. &ctrl_base->gpmc_nadv_ale);
  162. }
  163. /**
  164. * Reset the ethernet chip.
  165. */
  166. static void reset_net_chip(void)
  167. {
  168. int ret;
  169. int rst_gpio;
  170. if (get_omap3_evm_rev() == OMAP3EVM_BOARD_GEN_1) {
  171. rst_gpio = OMAP3EVM_GPIO_ETH_RST_GEN1;
  172. } else {
  173. rst_gpio = OMAP3EVM_GPIO_ETH_RST_GEN2;
  174. }
  175. ret = gpio_request(rst_gpio, "");
  176. if (ret < 0) {
  177. printf("Unable to get GPIO %d\n", rst_gpio);
  178. return ;
  179. }
  180. /* Configure as output */
  181. gpio_direction_output(rst_gpio, 0);
  182. /* Send a pulse on the GPIO pin */
  183. gpio_set_value(rst_gpio, 1);
  184. udelay(1);
  185. gpio_set_value(rst_gpio, 0);
  186. udelay(1);
  187. gpio_set_value(rst_gpio, 1);
  188. }
  189. int board_eth_init(bd_t *bis)
  190. {
  191. int rc = 0;
  192. #ifdef CONFIG_SMC911X
  193. rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
  194. #endif
  195. return rc;
  196. }
  197. #endif /* CONFIG_CMD_NET */
  198. #ifdef CONFIG_GENERIC_MMC
  199. int board_mmc_init(bd_t *bis)
  200. {
  201. omap_mmc_init(0);
  202. return 0;
  203. }
  204. #endif