evm.c 6.1 KB

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