evm.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. /*
  2. * (C) Copyright 2004-2011
  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 <linux/mtd/nand.h>
  41. #include "evm.h"
  42. #define OMAP3EVM_GPIO_ETH_RST_GEN1 64
  43. #define OMAP3EVM_GPIO_ETH_RST_GEN2 7
  44. DECLARE_GLOBAL_DATA_PTR;
  45. static u32 omap3_evm_version;
  46. u32 get_omap3_evm_rev(void)
  47. {
  48. return omap3_evm_version;
  49. }
  50. static void omap3_evm_get_revision(void)
  51. {
  52. #if defined(CONFIG_CMD_NET)
  53. /*
  54. * Board revision can be ascertained only by identifying
  55. * the Ethernet chipset.
  56. */
  57. unsigned int smsc_id;
  58. /* Ethernet PHY ID is stored at ID_REV register */
  59. smsc_id = readl(CONFIG_SMC911X_BASE + 0x50) & 0xFFFF0000;
  60. printf("Read back SMSC id 0x%x\n", smsc_id);
  61. switch (smsc_id) {
  62. /* SMSC9115 chipset */
  63. case 0x01150000:
  64. omap3_evm_version = OMAP3EVM_BOARD_GEN_1;
  65. break;
  66. /* SMSC 9220 chipset */
  67. case 0x92200000:
  68. default:
  69. omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
  70. }
  71. #else
  72. #if defined(CONFIG_STATIC_BOARD_REV)
  73. /*
  74. * Look for static defintion of the board revision
  75. */
  76. omap3_evm_version = CONFIG_STATIC_BOARD_REV;
  77. #else
  78. /*
  79. * Fallback to the default above.
  80. */
  81. omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
  82. #endif
  83. #endif /* CONFIG_CMD_NET */
  84. }
  85. #ifdef CONFIG_USB_OMAP3
  86. /*
  87. * MUSB port on OMAP3EVM Rev >= E requires extvbus programming.
  88. */
  89. u8 omap3_evm_need_extvbus(void)
  90. {
  91. u8 retval = 0;
  92. if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2)
  93. retval = 1;
  94. return retval;
  95. }
  96. #endif
  97. /*
  98. * Routine: board_init
  99. * Description: Early hardware init.
  100. */
  101. int board_init(void)
  102. {
  103. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  104. /* board id for Linux */
  105. gd->bd->bi_arch_number = MACH_TYPE_OMAP3EVM;
  106. /* boot param addr */
  107. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  108. return 0;
  109. }
  110. #ifdef CONFIG_SPL_BUILD
  111. /*
  112. * Routine: get_board_mem_timings
  113. * Description: If we use SPL then there is no x-loader nor config header
  114. * so we have to setup the DDR timings ourself on the first bank. This
  115. * provides the timing values back to the function that configures
  116. * the memory.
  117. */
  118. void get_board_mem_timings(struct board_sdrc_timings *timings)
  119. {
  120. int pop_mfr, pop_id;
  121. /*
  122. * We need to identify what PoP memory is on the board so that
  123. * we know what timings to use. To map the ID values please see
  124. * nand_ids.c
  125. */
  126. identify_nand_chip(&pop_mfr, &pop_id);
  127. if (pop_mfr == NAND_MFR_HYNIX && pop_id == 0xbc) {
  128. /* 256MB DDR */
  129. timings->mcfg = HYNIX_V_MCFG_200(256 << 20);
  130. timings->ctrla = HYNIX_V_ACTIMA_200;
  131. timings->ctrlb = HYNIX_V_ACTIMB_200;
  132. } else {
  133. /* 128MB DDR */
  134. timings->mcfg = MICRON_V_MCFG_165(128 << 20);
  135. timings->ctrla = MICRON_V_ACTIMA_165;
  136. timings->ctrlb = MICRON_V_ACTIMB_165;
  137. }
  138. timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
  139. timings->mr = MICRON_V_MR_165;
  140. }
  141. #endif
  142. /*
  143. * Routine: misc_init_r
  144. * Description: Init ethernet (done here so udelay works)
  145. */
  146. int misc_init_r(void)
  147. {
  148. #ifdef CONFIG_DRIVER_OMAP34XX_I2C
  149. i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
  150. #endif
  151. #if defined(CONFIG_CMD_NET)
  152. setup_net_chip();
  153. #endif
  154. omap3_evm_get_revision();
  155. #if defined(CONFIG_CMD_NET)
  156. reset_net_chip();
  157. #endif
  158. dieid_num_r();
  159. return 0;
  160. }
  161. /*
  162. * Routine: set_muxconf_regs
  163. * Description: Setting up the configuration Mux registers specific to the
  164. * hardware. Many pins need to be moved from protect to primary
  165. * mode.
  166. */
  167. void set_muxconf_regs(void)
  168. {
  169. MUX_EVM();
  170. }
  171. #ifdef CONFIG_CMD_NET
  172. /*
  173. * Routine: setup_net_chip
  174. * Description: Setting up the configuration GPMC registers specific to the
  175. * Ethernet hardware.
  176. */
  177. static void setup_net_chip(void)
  178. {
  179. struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
  180. /* Configure GPMC registers */
  181. writel(NET_GPMC_CONFIG1, &gpmc_cfg->cs[5].config1);
  182. writel(NET_GPMC_CONFIG2, &gpmc_cfg->cs[5].config2);
  183. writel(NET_GPMC_CONFIG3, &gpmc_cfg->cs[5].config3);
  184. writel(NET_GPMC_CONFIG4, &gpmc_cfg->cs[5].config4);
  185. writel(NET_GPMC_CONFIG5, &gpmc_cfg->cs[5].config5);
  186. writel(NET_GPMC_CONFIG6, &gpmc_cfg->cs[5].config6);
  187. writel(NET_GPMC_CONFIG7, &gpmc_cfg->cs[5].config7);
  188. /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
  189. writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
  190. /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
  191. writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
  192. /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
  193. writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
  194. &ctrl_base->gpmc_nadv_ale);
  195. }
  196. /**
  197. * Reset the ethernet chip.
  198. */
  199. static void reset_net_chip(void)
  200. {
  201. int ret;
  202. int rst_gpio;
  203. if (get_omap3_evm_rev() == OMAP3EVM_BOARD_GEN_1) {
  204. rst_gpio = OMAP3EVM_GPIO_ETH_RST_GEN1;
  205. } else {
  206. rst_gpio = OMAP3EVM_GPIO_ETH_RST_GEN2;
  207. }
  208. ret = gpio_request(rst_gpio, "");
  209. if (ret < 0) {
  210. printf("Unable to get GPIO %d\n", rst_gpio);
  211. return ;
  212. }
  213. /* Configure as output */
  214. gpio_direction_output(rst_gpio, 0);
  215. /* Send a pulse on the GPIO pin */
  216. gpio_set_value(rst_gpio, 1);
  217. udelay(1);
  218. gpio_set_value(rst_gpio, 0);
  219. udelay(1);
  220. gpio_set_value(rst_gpio, 1);
  221. }
  222. int board_eth_init(bd_t *bis)
  223. {
  224. int rc = 0;
  225. #ifdef CONFIG_SMC911X
  226. #define STR_ENV_ETHADDR "ethaddr"
  227. struct eth_device *dev;
  228. uchar eth_addr[6];
  229. rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
  230. if (!eth_getenv_enetaddr(STR_ENV_ETHADDR, eth_addr)) {
  231. dev = eth_get_dev_by_index(0);
  232. if (dev) {
  233. eth_setenv_enetaddr(STR_ENV_ETHADDR, dev->enetaddr);
  234. } else {
  235. printf("omap3evm: Couldn't get eth device\n");
  236. rc = -1;
  237. }
  238. }
  239. #endif
  240. return rc;
  241. }
  242. #endif /* CONFIG_CMD_NET */
  243. #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
  244. int board_mmc_init(bd_t *bis)
  245. {
  246. return omap_mmc_init(0, 0, 0, -1);
  247. }
  248. #endif