1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2004-2011
4 * Texas Instruments, <www.ti.com>
9 * Derived from Beagle Board and 3430 SDP code by
18 #include <asm/arch/mem.h>
19 #include <asm/arch/mux.h>
20 #include <asm/arch/sys_proto.h>
21 #include <asm/arch/mmc_host_def.h>
25 #include <asm/mach-types.h>
26 #include <asm/omap_musb.h>
27 #include <linux/mtd/rawnand.h>
28 #include <linux/usb/ch9.h>
29 #include <linux/usb/gadget.h>
30 #include <linux/usb/musb.h>
33 #define OMAP3EVM_GPIO_ETH_RST_GEN1 64
34 #define OMAP3EVM_GPIO_ETH_RST_GEN2 7
36 DECLARE_GLOBAL_DATA_PTR;
38 static u32 omap3_evm_version;
40 u32 get_omap3_evm_rev(void)
42 return omap3_evm_version;
45 static void omap3_evm_get_revision(void)
47 #if defined(CONFIG_CMD_NET)
49 * Board revision can be ascertained only by identifying
50 * the Ethernet chipset.
54 /* Ethernet PHY ID is stored at ID_REV register */
55 smsc_id = readl(CONFIG_SMC911X_BASE + 0x50) & 0xFFFF0000;
56 printf("Read back SMSC id 0x%x\n", smsc_id);
59 /* SMSC9115 chipset */
61 omap3_evm_version = OMAP3EVM_BOARD_GEN_1;
63 /* SMSC 9220 chipset */
66 omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
68 #else /* !CONFIG_CMD_NET */
69 #if defined(CONFIG_STATIC_BOARD_REV)
70 /* Look for static defintion of the board revision */
71 omap3_evm_version = CONFIG_STATIC_BOARD_REV;
73 /* Fallback to the default above */
74 omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
75 #endif /* CONFIG_STATIC_BOARD_REV */
76 #endif /* CONFIG_CMD_NET */
79 #if defined(CONFIG_USB_MUSB_GADGET) || defined(CONFIG_USB_MUSB_HOST)
80 /* MUSB port on OMAP3EVM Rev >= E requires extvbus programming. */
81 u8 omap3_evm_need_extvbus(void)
85 if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2)
90 #endif /* CONFIG_USB_MUSB_{GADGET,HOST} */
94 * Description: Early hardware init.
98 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
99 /* board id for Linux */
100 gd->bd->bi_arch_number = MACH_TYPE_OMAP3EVM;
101 /* boot param addr */
102 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
107 #if defined(CONFIG_SPL_OS_BOOT)
108 int spl_start_uboot(void)
110 /* break into full u-boot on 'c' */
111 if (serial_tstc() && serial_getc() == 'c')
116 #endif /* CONFIG_SPL_OS_BOOT */
118 #if defined(CONFIG_SPL_BUILD)
120 * Routine: get_board_mem_timings
121 * Description: If we use SPL then there is no x-loader nor config header
122 * so we have to setup the DDR timings ourself on the first bank. This
123 * provides the timing values back to the function that configures
126 void get_board_mem_timings(struct board_sdrc_timings *timings)
131 * We need to identify what PoP memory is on the board so that
132 * we know what timings to use. To map the ID values please see
135 identify_nand_chip(&pop_mfr, &pop_id);
137 if (pop_mfr == NAND_MFR_HYNIX && pop_id == 0xbc) {
139 timings->mcfg = HYNIX_V_MCFG_200(256 << 20);
140 timings->ctrla = HYNIX_V_ACTIMA_200;
141 timings->ctrlb = HYNIX_V_ACTIMB_200;
144 timings->mcfg = MICRON_V_MCFG_165(128 << 20);
145 timings->ctrla = MICRON_V_ACTIMA_165;
146 timings->ctrlb = MICRON_V_ACTIMB_165;
148 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
149 timings->mr = MICRON_V_MR_165;
151 #endif /* CONFIG_SPL_BUILD */
153 #if defined(CONFIG_USB_MUSB_OMAP2PLUS)
154 static struct musb_hdrc_config musb_config = {
161 static struct omap_musb_board_data musb_board_data = {
162 .interface_type = MUSB_INTERFACE_ULPI,
165 static struct musb_hdrc_platform_data musb_plat = {
166 #if defined(CONFIG_USB_MUSB_HOST)
168 #elif defined(CONFIG_USB_MUSB_GADGET)
169 .mode = MUSB_PERIPHERAL,
171 #error "Please define either CONFIG_USB_MUSB_HOST or CONFIG_USB_MUSB_GADGET"
172 #endif /* CONFIG_USB_MUSB_{GADGET,HOST} */
173 .config = &musb_config,
175 .platform_ops = &omap2430_ops,
176 .board_data = &musb_board_data,
178 #endif /* CONFIG_USB_MUSB_OMAP2PLUS */
181 * Routine: misc_init_r
182 * Description: Init ethernet (done here so udelay works)
184 int misc_init_r(void)
186 twl4030_power_init();
188 #ifdef CONFIG_SYS_I2C_OMAP24XX
189 i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
192 #if defined(CONFIG_CMD_NET)
195 omap3_evm_get_revision();
197 #if defined(CONFIG_CMD_NET)
200 omap_die_id_display();
202 #if defined(CONFIG_USB_MUSB_OMAP2PLUS)
203 musb_register(&musb_plat, &musb_board_data, (void *)MUSB_BASE);
206 #if defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_MUSB_GADGET)
207 omap_die_id_usbethaddr();
213 * Routine: set_muxconf_regs
214 * Description: Setting up the configuration Mux registers specific to the
215 * hardware. Many pins need to be moved from protect to primary
218 void set_muxconf_regs(void)
223 #if defined(CONFIG_CMD_NET)
225 * Routine: setup_net_chip
226 * Description: Setting up the configuration GPMC registers specific to the
229 static void setup_net_chip(void)
231 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
233 /* Configure GPMC registers */
234 writel(NET_GPMC_CONFIG1, &gpmc_cfg->cs[5].config1);
235 writel(NET_GPMC_CONFIG2, &gpmc_cfg->cs[5].config2);
236 writel(NET_GPMC_CONFIG3, &gpmc_cfg->cs[5].config3);
237 writel(NET_GPMC_CONFIG4, &gpmc_cfg->cs[5].config4);
238 writel(NET_GPMC_CONFIG5, &gpmc_cfg->cs[5].config5);
239 writel(NET_GPMC_CONFIG6, &gpmc_cfg->cs[5].config6);
240 writel(NET_GPMC_CONFIG7, &gpmc_cfg->cs[5].config7);
242 /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
243 writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
244 /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
245 writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
246 /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
247 writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
248 &ctrl_base->gpmc_nadv_ale);
252 * Reset the ethernet chip.
254 static void reset_net_chip(void)
259 if (get_omap3_evm_rev() == OMAP3EVM_BOARD_GEN_1) {
260 rst_gpio = OMAP3EVM_GPIO_ETH_RST_GEN1;
262 rst_gpio = OMAP3EVM_GPIO_ETH_RST_GEN2;
265 ret = gpio_request(rst_gpio, "");
267 printf("Unable to get GPIO %d\n", rst_gpio);
271 /* Configure as output */
272 gpio_direction_output(rst_gpio, 0);
274 /* Send a pulse on the GPIO pin */
275 gpio_set_value(rst_gpio, 1);
277 gpio_set_value(rst_gpio, 0);
279 gpio_set_value(rst_gpio, 1);
282 int board_eth_init(bd_t *bis)
284 #if defined(CONFIG_SMC911X)
285 env_set("ethaddr", NULL);
286 return smc911x_initialize(0, CONFIG_SMC911X_BASE);
291 #endif /* CONFIG_CMD_NET */
293 #if defined(CONFIG_MMC)
294 int board_mmc_init(bd_t *bis)
296 return omap_mmc_init(0, 0, 0, -1, -1);
299 void board_mmc_power_init(void)
301 twl4030_power_mmc_init(0);
303 #endif /* CONFIG_MMC */
305 #if defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_MUSB_GADGET) && !defined(CONFIG_CMD_NET)
306 int board_eth_init(bd_t *bis)
308 return usb_eth_initialize(bis);
310 #endif /* CONFIG_USB_ETHER */