1 // SPDX-License-Identifier: GPL-2.0+
4 * Gumstix Inc. <www.gumstix.com>
11 #include <asm/arch/sys_proto.h>
12 #include <asm/arch/mmc_host_def.h>
15 #include <asm/arch/clock.h>
16 #include <asm/arch/gpio.h>
18 #include <asm/mach-types.h>
20 #include "duovero_mux_data.h"
24 #if defined(CONFIG_CMD_NET)
25 #define SMSC_NRESET 45
26 static void setup_net_chip(void);
29 #ifdef CONFIG_USB_EHCI_HCD
31 #include <asm/arch/ehci.h>
32 #include <asm/ehci-omap.h>
35 DECLARE_GLOBAL_DATA_PTR;
37 const struct omap_sysinfo sysinfo = {
41 struct omap4_scrm_regs *const scrm = (struct omap4_scrm_regs *)0x4a30a000;
52 gd->bd->bi_arch_number = MACH_TYPE_DUOVERO;
53 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
59 * @brief misc_init_r - Configure board specific configurations
60 * such as power configurations, ethernet initialization as phase2 of
70 /* wifi setup: first enable 32Khz clock from 6030 pmic */
72 ret = i2c_write(TWL6030_CHIP_PM, 0xbe, 1, &val, 1);
74 printf("Failed to enable 32Khz clock to wifi module\n");
76 /* then setup WIFI_EN as an output pin and send reset pulse */
77 if (!gpio_request(WIFI_EN, "")) {
78 gpio_direction_output(WIFI_EN, 0);
79 gpio_set_value(WIFI_EN, 1);
81 gpio_set_value(WIFI_EN, 0);
83 gpio_set_value(WIFI_EN, 1);
86 #if defined(CONFIG_CMD_NET)
92 void set_muxconf_regs(void)
94 do_set_mux((*ctrl)->control_padconf_core_base,
95 core_padconf_array_essential,
96 sizeof(core_padconf_array_essential) /
97 sizeof(struct pad_conf_entry));
99 do_set_mux((*ctrl)->control_padconf_wkup_base,
100 wkup_padconf_array_essential,
101 sizeof(wkup_padconf_array_essential) /
102 sizeof(struct pad_conf_entry));
104 do_set_mux((*ctrl)->control_padconf_core_base,
105 core_padconf_array_non_essential,
106 sizeof(core_padconf_array_non_essential) /
107 sizeof(struct pad_conf_entry));
109 do_set_mux((*ctrl)->control_padconf_wkup_base,
110 wkup_padconf_array_non_essential,
111 sizeof(wkup_padconf_array_non_essential) /
112 sizeof(struct pad_conf_entry));
115 #if defined(CONFIG_MMC)
116 int board_mmc_init(bd_t *bis)
118 return omap_mmc_init(0, 0, 0, -1, -1);
121 #if !defined(CONFIG_SPL_BUILD)
122 void board_mmc_power_init(void)
124 twl6030_power_mmc_init(0);
129 #if defined(CONFIG_CMD_NET)
131 #define GPMC_SIZE_16M 0xF
132 #define GPMC_BASEADDR_MASK 0x3F
133 #define GPMC_CS_ENABLE 0x1
135 static void enable_gpmc_net_config(const u32 *gpmc_config, const struct gpmc_cs *cs,
138 writel(0, &cs->config7);
140 /* Delay for settling */
141 writel(gpmc_config[0], &cs->config1);
142 writel(gpmc_config[1], &cs->config2);
143 writel(gpmc_config[2], &cs->config3);
144 writel(gpmc_config[3], &cs->config4);
145 writel(gpmc_config[4], &cs->config5);
146 writel(gpmc_config[5], &cs->config6);
149 * Enable the config. size is the CS size and goes in
150 * bits 11:8. We set bit 6 to enable this CS and the base
151 * address goes into bits 5:0.
153 writel((size << 8) | (GPMC_CS_ENABLE << 6) |
154 ((base >> 24) & GPMC_BASEADDR_MASK),
160 /* GPMC CS configuration for an SMSC LAN9221 ethernet controller */
161 #define NET_LAN9221_GPMC_CONFIG1 0x2a001203
162 #define NET_LAN9221_GPMC_CONFIG2 0x000a0a02
163 #define NET_LAN9221_GPMC_CONFIG3 0x00020200
164 #define NET_LAN9221_GPMC_CONFIG4 0x0a030a03
165 #define NET_LAN9221_GPMC_CONFIG5 0x000a0a0a
166 #define NET_LAN9221_GPMC_CONFIG6 0x8a070707
167 #define NET_LAN9221_GPMC_CONFIG7 0x00000f6c
169 /* GPMC definitions for LAN9221 chips on expansion boards */
170 static const u32 gpmc_lan_config[] = {
171 NET_LAN9221_GPMC_CONFIG1,
172 NET_LAN9221_GPMC_CONFIG2,
173 NET_LAN9221_GPMC_CONFIG3,
174 NET_LAN9221_GPMC_CONFIG4,
175 NET_LAN9221_GPMC_CONFIG5,
176 NET_LAN9221_GPMC_CONFIG6,
177 /*CONFIG7- computed as params */
181 * Routine: setup_net_chip
182 * Description: Setting up the configuration GPMC registers specific to the
185 static void setup_net_chip(void)
187 enable_gpmc_net_config(gpmc_lan_config, &gpmc_cfg->cs[5], 0x2C000000,
190 /* Make GPIO SMSC_NRESET as output pin and send reset pulse */
191 if (!gpio_request(SMSC_NRESET, "")) {
192 gpio_direction_output(SMSC_NRESET, 0);
193 gpio_set_value(SMSC_NRESET, 1);
195 gpio_set_value(SMSC_NRESET, 0);
197 gpio_set_value(SMSC_NRESET, 1);
202 int board_eth_init(bd_t *bis)
205 #ifdef CONFIG_SMC911X
206 rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
211 #ifdef CONFIG_USB_EHCI_HCD
213 static struct omap_usbhs_board_data usbhs_bdata = {
214 .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
215 .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
216 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
219 int ehci_hcd_init(int index, enum usb_init_type init,
220 struct ehci_hccr **hccr, struct ehci_hcor **hcor)
223 unsigned int utmi_clk;
224 u32 auxclk, altclksrc;
226 /* Now we can enable our port clocks */
227 utmi_clk = readl((void *)CM_L3INIT_HSUSBHOST_CLKCTRL);
228 utmi_clk |= HSUSBHOST_CLKCTRL_CLKSEL_UTMI_P1_MASK;
229 setbits_le32((void *)CM_L3INIT_HSUSBHOST_CLKCTRL, utmi_clk);
231 auxclk = readl(&scrm->auxclk3);
233 auxclk &= ~AUXCLK_SRCSELECT_MASK;
234 auxclk |= AUXCLK_SRCSELECT_SYS_CLK << AUXCLK_SRCSELECT_SHIFT;
235 /* Set the divisor to 2 */
236 auxclk &= ~AUXCLK_CLKDIV_MASK;
237 auxclk |= AUXCLK_CLKDIV_2 << AUXCLK_CLKDIV_SHIFT;
238 /* Request auxilary clock #3 */
239 auxclk |= AUXCLK_ENABLE_MASK;
240 writel(auxclk, &scrm->auxclk3);
242 altclksrc = readl(&scrm->altclksrc);
244 /* Activate alternate system clock supplier */
245 altclksrc &= ~ALTCLKSRC_MODE_MASK;
246 altclksrc |= ALTCLKSRC_MODE_ACTIVE;
249 altclksrc |= ALTCLKSRC_ENABLE_INT_MASK | ALTCLKSRC_ENABLE_EXT_MASK;
251 writel(altclksrc, &scrm->altclksrc);
253 ret = omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
260 int ehci_hcd_stop(int index)
262 return omap_ehci_hcd_stop();
267 * get_board_rev() - get board revision
269 u32 get_board_rev(void)