2 * (C) Copyright 2004-2011
3 * Texas Instruments, <www.ti.com>
8 * Derived from Beagle Board and 3430 SDP code by
12 * SPDX-License-Identifier: GPL-2.0+
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>
24 #include <asm/mach-types.h>
25 #include <linux/mtd/nand.h>
28 #define OMAP3EVM_GPIO_ETH_RST_GEN1 64
29 #define OMAP3EVM_GPIO_ETH_RST_GEN2 7
31 DECLARE_GLOBAL_DATA_PTR;
33 static u32 omap3_evm_version;
35 u32 get_omap3_evm_rev(void)
37 return omap3_evm_version;
40 static void omap3_evm_get_revision(void)
42 #if defined(CONFIG_CMD_NET)
44 * Board revision can be ascertained only by identifying
45 * the Ethernet chipset.
49 /* Ethernet PHY ID is stored at ID_REV register */
50 smsc_id = readl(CONFIG_SMC911X_BASE + 0x50) & 0xFFFF0000;
51 printf("Read back SMSC id 0x%x\n", smsc_id);
54 /* SMSC9115 chipset */
56 omap3_evm_version = OMAP3EVM_BOARD_GEN_1;
58 /* SMSC 9220 chipset */
61 omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
64 #if defined(CONFIG_STATIC_BOARD_REV)
66 * Look for static defintion of the board revision
68 omap3_evm_version = CONFIG_STATIC_BOARD_REV;
71 * Fallback to the default above.
73 omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
75 #endif /* CONFIG_CMD_NET */
78 #ifdef CONFIG_USB_OMAP3
80 * MUSB port on OMAP3EVM Rev >= E requires extvbus programming.
82 u8 omap3_evm_need_extvbus(void)
86 if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2)
95 * Description: Early hardware init.
99 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
100 /* board id for Linux */
101 gd->bd->bi_arch_number = MACH_TYPE_OMAP3EVM;
102 /* boot param addr */
103 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
108 #ifdef CONFIG_SPL_BUILD
110 * Routine: get_board_mem_timings
111 * Description: If we use SPL then there is no x-loader nor config header
112 * so we have to setup the DDR timings ourself on the first bank. This
113 * provides the timing values back to the function that configures
116 void get_board_mem_timings(struct board_sdrc_timings *timings)
121 * We need to identify what PoP memory is on the board so that
122 * we know what timings to use. To map the ID values please see
125 identify_nand_chip(&pop_mfr, &pop_id);
127 if (pop_mfr == NAND_MFR_HYNIX && pop_id == 0xbc) {
129 timings->mcfg = HYNIX_V_MCFG_200(256 << 20);
130 timings->ctrla = HYNIX_V_ACTIMA_200;
131 timings->ctrlb = HYNIX_V_ACTIMB_200;
134 timings->mcfg = MICRON_V_MCFG_165(128 << 20);
135 timings->ctrla = MICRON_V_ACTIMA_165;
136 timings->ctrlb = MICRON_V_ACTIMB_165;
138 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
139 timings->mr = MICRON_V_MR_165;
144 * Routine: misc_init_r
145 * Description: Init ethernet (done here so udelay works)
147 int misc_init_r(void)
150 #ifdef CONFIG_SYS_I2C_OMAP34XX
151 i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
154 #if defined(CONFIG_CMD_NET)
157 omap3_evm_get_revision();
159 #if defined(CONFIG_CMD_NET)
168 * Routine: set_muxconf_regs
169 * Description: Setting up the configuration Mux registers specific to the
170 * hardware. Many pins need to be moved from protect to primary
173 void set_muxconf_regs(void)
178 #ifdef CONFIG_CMD_NET
180 * Routine: setup_net_chip
181 * Description: Setting up the configuration GPMC registers specific to the
184 static void setup_net_chip(void)
186 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
188 /* Configure GPMC registers */
189 writel(NET_GPMC_CONFIG1, &gpmc_cfg->cs[5].config1);
190 writel(NET_GPMC_CONFIG2, &gpmc_cfg->cs[5].config2);
191 writel(NET_GPMC_CONFIG3, &gpmc_cfg->cs[5].config3);
192 writel(NET_GPMC_CONFIG4, &gpmc_cfg->cs[5].config4);
193 writel(NET_GPMC_CONFIG5, &gpmc_cfg->cs[5].config5);
194 writel(NET_GPMC_CONFIG6, &gpmc_cfg->cs[5].config6);
195 writel(NET_GPMC_CONFIG7, &gpmc_cfg->cs[5].config7);
197 /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
198 writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
199 /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
200 writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
201 /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
202 writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
203 &ctrl_base->gpmc_nadv_ale);
207 * Reset the ethernet chip.
209 static void reset_net_chip(void)
214 if (get_omap3_evm_rev() == OMAP3EVM_BOARD_GEN_1) {
215 rst_gpio = OMAP3EVM_GPIO_ETH_RST_GEN1;
217 rst_gpio = OMAP3EVM_GPIO_ETH_RST_GEN2;
220 ret = gpio_request(rst_gpio, "");
222 printf("Unable to get GPIO %d\n", rst_gpio);
226 /* Configure as output */
227 gpio_direction_output(rst_gpio, 0);
229 /* Send a pulse on the GPIO pin */
230 gpio_set_value(rst_gpio, 1);
232 gpio_set_value(rst_gpio, 0);
234 gpio_set_value(rst_gpio, 1);
237 int board_eth_init(bd_t *bis)
240 #ifdef CONFIG_SMC911X
241 #define STR_ENV_ETHADDR "ethaddr"
243 struct eth_device *dev;
246 rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
248 if (!eth_getenv_enetaddr(STR_ENV_ETHADDR, eth_addr)) {
249 dev = eth_get_dev_by_index(0);
251 eth_setenv_enetaddr(STR_ENV_ETHADDR, dev->enetaddr);
253 printf("omap3evm: Couldn't get eth device\n");
260 #endif /* CONFIG_CMD_NET */
262 #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
263 int board_mmc_init(bd_t *bis)
265 return omap_mmc_init(0, 0, 0, -1, -1);
269 #if defined(CONFIG_GENERIC_MMC)
270 void board_mmc_power_init(void)
272 twl4030_power_mmc_init(0);