1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2004-2011
4 * Texas Instruments, <www.ti.com>
7 * Manikandan Pillai <mani.pillai@ti.com>
9 * Derived from Beagle Board and 3430 SDP code by
10 * Richard Woodruff <r-woodruff2@ti.com>
11 * Syed Mohammed Khasim <khasim@ti.com>
20 #include <asm/arch/mem.h>
21 #include <asm/arch/mux.h>
22 #include <asm/arch/sys_proto.h>
23 #include <asm/arch/mmc_host_def.h>
27 #include <asm/mach-types.h>
28 #include <asm/omap_musb.h>
29 #include <linux/mtd/rawnand.h>
30 #include <linux/usb/ch9.h>
31 #include <linux/usb/gadget.h>
32 #include <linux/usb/musb.h>
35 #define OMAP3EVM_GPIO_ETH_RST_GEN1 64
36 #define OMAP3EVM_GPIO_ETH_RST_GEN2 7
38 DECLARE_GLOBAL_DATA_PTR;
40 static u32 omap3_evm_version;
42 u32 get_omap3_evm_rev(void)
44 return omap3_evm_version;
47 static void omap3_evm_get_revision(void)
49 #if defined(CONFIG_CMD_NET)
51 * Board revision can be ascertained only by identifying
52 * the Ethernet chipset.
56 /* Ethernet PHY ID is stored at ID_REV register */
57 smsc_id = readl(CONFIG_SMC911X_BASE + 0x50) & 0xFFFF0000;
58 printf("Read back SMSC id 0x%x\n", smsc_id);
61 /* SMSC9115 chipset */
63 omap3_evm_version = OMAP3EVM_BOARD_GEN_1;
65 /* SMSC 9220 chipset */
68 omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
70 #else /* !CONFIG_CMD_NET */
71 #if defined(CONFIG_STATIC_BOARD_REV)
72 /* Look for static defintion of the board revision */
73 omap3_evm_version = CONFIG_STATIC_BOARD_REV;
75 /* Fallback to the default above */
76 omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
77 #endif /* CONFIG_STATIC_BOARD_REV */
78 #endif /* CONFIG_CMD_NET */
81 #if defined(CONFIG_USB_MUSB_GADGET) || defined(CONFIG_USB_MUSB_HOST)
82 /* MUSB port on OMAP3EVM Rev >= E requires extvbus programming. */
83 u8 omap3_evm_need_extvbus(void)
87 if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2)
92 #endif /* CONFIG_USB_MUSB_{GADGET,HOST} */
96 * Description: Early hardware init.
100 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
101 /* board id for Linux */
102 gd->bd->bi_arch_number = MACH_TYPE_OMAP3EVM;
103 /* boot param addr */
104 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
109 #if defined(CONFIG_SPL_OS_BOOT)
110 int spl_start_uboot(void)
112 /* break into full u-boot on 'c' */
113 if (serial_tstc() && serial_getc() == 'c')
118 #endif /* CONFIG_SPL_OS_BOOT */
120 #if defined(CONFIG_SPL_BUILD)
122 * Routine: get_board_mem_timings
123 * Description: If we use SPL then there is no x-loader nor config header
124 * so we have to setup the DDR timings ourself on the first bank. This
125 * provides the timing values back to the function that configures
128 void get_board_mem_timings(struct board_sdrc_timings *timings)
133 * We need to identify what PoP memory is on the board so that
134 * we know what timings to use. To map the ID values please see
137 identify_nand_chip(&pop_mfr, &pop_id);
139 if (pop_mfr == NAND_MFR_HYNIX && pop_id == 0xbc) {
141 timings->mcfg = HYNIX_V_MCFG_200(256 << 20);
142 timings->ctrla = HYNIX_V_ACTIMA_200;
143 timings->ctrlb = HYNIX_V_ACTIMB_200;
146 timings->mcfg = MICRON_V_MCFG_165(128 << 20);
147 timings->ctrla = MICRON_V_ACTIMA_165;
148 timings->ctrlb = MICRON_V_ACTIMB_165;
150 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
151 timings->mr = MICRON_V_MR_165;
153 #endif /* CONFIG_SPL_BUILD */
155 #if defined(CONFIG_USB_MUSB_OMAP2PLUS)
156 static struct musb_hdrc_config musb_config = {
163 static struct omap_musb_board_data musb_board_data = {
164 .interface_type = MUSB_INTERFACE_ULPI,
167 static struct musb_hdrc_platform_data musb_plat = {
168 #if defined(CONFIG_USB_MUSB_HOST)
170 #elif defined(CONFIG_USB_MUSB_GADGET)
171 .mode = MUSB_PERIPHERAL,
173 #error "Please define either CONFIG_USB_MUSB_HOST or CONFIG_USB_MUSB_GADGET"
174 #endif /* CONFIG_USB_MUSB_{GADGET,HOST} */
175 .config = &musb_config,
177 .platform_ops = &omap2430_ops,
178 .board_data = &musb_board_data,
180 #endif /* CONFIG_USB_MUSB_OMAP2PLUS */
183 * Routine: misc_init_r
184 * Description: Init ethernet (done here so udelay works)
186 int misc_init_r(void)
188 twl4030_power_init();
190 #ifdef CONFIG_SYS_I2C_OMAP24XX
191 i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
194 #if defined(CONFIG_CMD_NET)
197 omap3_evm_get_revision();
199 #if defined(CONFIG_CMD_NET)
202 omap_die_id_display();
204 #if defined(CONFIG_USB_MUSB_OMAP2PLUS)
205 musb_register(&musb_plat, &musb_board_data, (void *)MUSB_BASE);
208 #if defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_MUSB_GADGET)
209 omap_die_id_usbethaddr();
215 * Routine: set_muxconf_regs
216 * Description: Setting up the configuration Mux registers specific to the
217 * hardware. Many pins need to be moved from protect to primary
220 void set_muxconf_regs(void)
225 #if defined(CONFIG_CMD_NET)
227 * Routine: setup_net_chip
228 * Description: Setting up the configuration GPMC registers specific to the
231 static void setup_net_chip(void)
233 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
235 /* Configure GPMC registers */
236 writel(NET_GPMC_CONFIG1, &gpmc_cfg->cs[5].config1);
237 writel(NET_GPMC_CONFIG2, &gpmc_cfg->cs[5].config2);
238 writel(NET_GPMC_CONFIG3, &gpmc_cfg->cs[5].config3);
239 writel(NET_GPMC_CONFIG4, &gpmc_cfg->cs[5].config4);
240 writel(NET_GPMC_CONFIG5, &gpmc_cfg->cs[5].config5);
241 writel(NET_GPMC_CONFIG6, &gpmc_cfg->cs[5].config6);
242 writel(NET_GPMC_CONFIG7, &gpmc_cfg->cs[5].config7);
244 /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
245 writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
246 /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
247 writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
248 /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
249 writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
250 &ctrl_base->gpmc_nadv_ale);
254 * Reset the ethernet chip.
256 static void reset_net_chip(void)
261 if (get_omap3_evm_rev() == OMAP3EVM_BOARD_GEN_1) {
262 rst_gpio = OMAP3EVM_GPIO_ETH_RST_GEN1;
264 rst_gpio = OMAP3EVM_GPIO_ETH_RST_GEN2;
267 ret = gpio_request(rst_gpio, "");
269 printf("Unable to get GPIO %d\n", rst_gpio);
273 /* Configure as output */
274 gpio_direction_output(rst_gpio, 0);
276 /* Send a pulse on the GPIO pin */
277 gpio_set_value(rst_gpio, 1);
279 gpio_set_value(rst_gpio, 0);
281 gpio_set_value(rst_gpio, 1);
284 int board_eth_init(bd_t *bis)
286 #if defined(CONFIG_SMC911X)
287 env_set("ethaddr", NULL);
288 return smc911x_initialize(0, CONFIG_SMC911X_BASE);
293 #endif /* CONFIG_CMD_NET */
295 #if defined(CONFIG_MMC)
296 int board_mmc_init(bd_t *bis)
298 return omap_mmc_init(0, 0, 0, -1, -1);
301 void board_mmc_power_init(void)
303 twl4030_power_mmc_init(0);
305 #endif /* CONFIG_MMC */
307 #if defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_MUSB_GADGET) && !defined(CONFIG_CMD_NET)
308 int board_eth_init(bd_t *bis)
310 return usb_eth_initialize(bis);
312 #endif /* CONFIG_USB_ETHER */