4 * Common board functions for AM33XX based boards
6 * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
16 * GNU General Public License for more details.
22 #include <asm/arch/cpu.h>
23 #include <asm/arch/hardware.h>
24 #include <asm/arch/omap.h>
25 #include <asm/arch/ddr_defs.h>
26 #include <asm/arch/clock.h>
27 #include <asm/arch/gpio.h>
28 #include <asm/arch/mem.h>
29 #include <asm/arch/mmc_host_def.h>
30 #include <asm/arch/sys_proto.h>
37 #include <asm/errno.h>
38 #include <linux/usb/ch9.h>
39 #include <linux/usb/gadget.h>
40 #include <linux/usb/musb.h>
41 #include <asm/omap_musb.h>
43 DECLARE_GLOBAL_DATA_PTR;
45 static const struct gpio_bank gpio_bank_am33xx[4] = {
46 { (void *)AM33XX_GPIO0_BASE, METHOD_GPIO_24XX },
47 { (void *)AM33XX_GPIO1_BASE, METHOD_GPIO_24XX },
48 { (void *)AM33XX_GPIO2_BASE, METHOD_GPIO_24XX },
49 { (void *)AM33XX_GPIO3_BASE, METHOD_GPIO_24XX },
52 const struct gpio_bank *const omap_gpio_bank = gpio_bank_am33xx;
54 #ifdef CONFIG_HW_WATCHDOG
55 void hw_watchdog_reset(void)
57 struct wd_timer *wdtimer = (struct wd_timer *)WDT_BASE;
58 static int trg __attribute__((section(".data")));
63 if (readl(&wdtimer->wdtwwps) & (1 << 4))
65 writel(trg ? 0x5555 : 0xaaaa, &wdtimer->wdtwspr);
68 if (readl(&wdtimer->wdtwwps) & (1 << 2))
71 writel(-32768 * 10, &wdtimer->wdtwldr);
73 if (readl(&wdtimer->wdtwwps) & (1 << 0))
76 writel(0, &wdtimer->wdtwclr);
82 if (readl(&wdtimer->wdtwwps) & (1 << 4))
84 writel((trg & 1) ? 0xBBBB : 0x4444, &wdtimer->wdtwspr);
88 /* retrigger watchdog */
89 if (readl(&wdtimer->wdtwwps) & (1 << 3))
92 writel(trg, &wdtimer->wdtwtgr);
100 #if defined(CONFIG_OMAP_HSMMC) && !defined(CONFIG_SPL_BUILD)
101 int cpu_mmc_init(bd_t *bis)
105 ret = omap_mmc_init(0, 0, 0);
109 return omap_mmc_init(1, 0, 0);
113 void setup_clocks_for_console(void)
115 /* Not yet implemented */
119 /* AM33XX has two MUSB controllers which can be host or gadget */
120 #if (defined(CONFIG_MUSB_GADGET) || defined(CONFIG_MUSB_HOST)) && \
121 (defined(CONFIG_AM335X_USB0) || defined(CONFIG_AM335X_USB1))
122 static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
124 /* USB 2.0 PHY Control */
125 #define CM_PHY_PWRDN (1 << 0)
126 #define CM_PHY_OTG_PWRDN (1 << 1)
127 #define OTGVDET_EN (1 << 19)
128 #define OTGSESSENDEN (1 << 20)
130 static void am33xx_usb_set_phy_power(u8 on, u32 *reg_addr)
133 clrsetbits_le32(reg_addr, CM_PHY_PWRDN | CM_PHY_OTG_PWRDN,
134 OTGVDET_EN | OTGSESSENDEN);
136 clrsetbits_le32(reg_addr, 0, CM_PHY_PWRDN | CM_PHY_OTG_PWRDN);
140 static struct musb_hdrc_config musb_config = {
147 #ifdef CONFIG_AM335X_USB0
148 static void am33xx_otg0_set_phy_power(u8 on)
150 am33xx_usb_set_phy_power(on, &cdev->usb_ctrl0);
153 struct omap_musb_board_data otg0_board_data = {
154 .set_phy_power = am33xx_otg0_set_phy_power,
157 static struct musb_hdrc_platform_data otg0_plat = {
158 .mode = CONFIG_AM335X_USB0_MODE,
159 .config = &musb_config,
161 .platform_ops = &musb_dsps_ops,
162 .board_data = &otg0_board_data,
166 #ifdef CONFIG_AM335X_USB1
167 static void am33xx_otg1_set_phy_power(u8 on)
169 am33xx_usb_set_phy_power(on, &cdev->usb_ctrl1);
172 struct omap_musb_board_data otg1_board_data = {
173 .set_phy_power = am33xx_otg1_set_phy_power,
176 static struct musb_hdrc_platform_data otg1_plat = {
177 .mode = CONFIG_AM335X_USB1_MODE,
178 .config = &musb_config,
180 .platform_ops = &musb_dsps_ops,
181 .board_data = &otg1_board_data,
186 int arch_misc_init(void)
188 #ifdef CONFIG_AM335X_USB0
189 musb_register(&otg0_plat, &otg0_board_data,
190 (void *)AM335X_USB0_OTG_BASE);
192 #ifdef CONFIG_AM335X_USB1
193 musb_register(&otg1_plat, &otg1_board_data,
194 (void *)AM335X_USB1_OTG_BASE);