summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Yanok <ilya.yanok@cogentembedded.com>2012-08-11 00:44:33 +0400
committerVishveshwar Bhat <vishveshwar.bhat@ti.com>2012-10-23 12:18:59 +0530
commit0739b40c6d04ecf97c09a26b3f28923ce394f94a (patch)
treee3dc7a386933b913899500aaf687f7b7de330c06
parent7479f7e206412ce590adfd01d961aa5772099683 (diff)
downloadu-boot-beaglebone-0739b40c6d04ecf97c09a26b3f28923ce394f94a.tar.gz
am335x_evm: init OTG hardware and new musb gadget driver
AM335x has support for dual port MUSB OTG controller. This patch adds initialization for the controller using new MUSB gadget driver and ether gadget. Enable musb gadget in Ethernet mode on port 0. Signed-off-by: Ilya Yanok <ilya.yanok@cogentembedded.com>
-rw-r--r--board/ti/am335x/evm.c82
-rw-r--r--board/ti/am335x/pll.c7
-rwxr-xr-xinclude/configs/am335x_evm.h17
3 files changed, 105 insertions, 1 deletions
diff --git a/board/ti/am335x/evm.c b/board/ti/am335x/evm.c
index d1c7024cc..93cc6d5b1 100644
--- a/board/ti/am335x/evm.c
+++ b/board/ti/am335x/evm.c
@@ -38,6 +38,11 @@
#include "tps65217.h"
#include <i2c.h>
#include <serial.h>
+#include <asm/errno.h>
+#include <linux/usb/ch9.h>
+#include <linux/usb/gadget.h>
+#include <linux/usb/musb.h>
+#include <asm/omap_musb.h>
#include <fastboot.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -1166,9 +1171,66 @@ static struct cpsw_platform_data cpsw_data = {
.host_port_num = 0,
.version = CPSW_CTRL_VERSION_2,
};
+#endif
+
+#if defined(CONFIG_MUSB_GADGET) && !defined(CONFIG_SPL_BUILD)
+#ifdef CONFIG_MUSB_GADGET_PORT0
+#define USB_CTRL_REG USB_CTRL0
+#define OTG_REGS_BASE ((void *)AM335X_USB0_OTG_BASE)
+#elif defined(CONFIG_MUSB_GADGET_PORT1)
+#define USB_CTRL_REG USB_CTRL1
+#define OTG_REGS_BASE ((void *)AM335X_USB1_OTG_BASE)
+#else
+#error "Please define CONFIG_MUSB_GADGET_PORT0 or CONFIG_MUSB_GADGET_PORT1"
+#endif
+
+/* USB 2.0 PHY Control */
+#define CM_PHY_PWRDN (1 << 0)
+#define CM_PHY_OTG_PWRDN (1 << 1)
+#define OTGVDET_EN (1 << 19)
+#define OTGSESSENDEN (1 << 20)
+
+static void am33xx_usb_set_phy_power(u8 on)
+{
+ u32 usb_ctrl_reg;
+
+ usb_ctrl_reg = readl(USB_CTRL_REG);
+ if (on) {
+ usb_ctrl_reg &= ~(CM_PHY_PWRDN | CM_PHY_OTG_PWRDN);
+ usb_ctrl_reg |= (OTGVDET_EN | OTGSESSENDEN);
+ } else {
+ usb_ctrl_reg |= (CM_PHY_PWRDN | CM_PHY_OTG_PWRDN);
+ }
+ writel(usb_ctrl_reg, USB_CTRL_REG);
+}
+
+static struct musb_hdrc_config musb_config = {
+ .multipoint = 1,
+ .dyn_fifo = 1,
+ .num_eps = 16,
+ .ram_bits = 12,
+};
+struct omap_musb_board_data musb_board_data = {
+ .set_phy_power = am33xx_usb_set_phy_power,
+};
+
+static struct musb_hdrc_platform_data musb_plat = {
+ .mode = MUSB_PERIPHERAL,
+ .config = &musb_config,
+ .power = 50,
+ .platform_ops = &musb_dsps_ops,
+ .board_data = &musb_board_data,
+};
+#endif
+
+#if defined(CONFIG_DRIVER_TI_CPSW) || \
+ (defined(CONFIG_USB_ETHER) && defined(CONFIG_MUSB_GADGET) && \
+ !defined(CONFIG_SPL_BUILD))
int board_eth_init(bd_t *bis)
{
+ int rv, n = 0;
+#ifdef CONFIG_DRIVER_TI_CPSW
uint8_t mac_addr[6];
uint32_t mac_hi, mac_lo;
u_int32_t i;
@@ -1224,7 +1286,25 @@ int board_eth_init(bd_t *bis)
if (board_id == GP_BOARD && !strncmp(header.version, "1.0", 3))
cpsw_data.gigabit_en = 0;
- return cpsw_register(&cpsw_data);
+ rv = cpsw_register(&cpsw_data);
+ if (rv < 0)
+ printf("Error %d registering CPSW switch\n", rv);
+ else
+ n += rv;
+#endif
+#if defined(CONFIG_USB_ETHER) && !defined(CONFIG_SPL_BUILD)
+ rv = musb_register(&musb_plat, &musb_board_data, OTG_REGS_BASE);
+ if (rv < 0) {
+ printf("Error %d registering MUSB device\n", rv);
+ } else {
+ rv = usb_eth_initialize(bis);
+ if (rv < 0)
+ printf("Error %d registering USB_ETHER\n", rv);
+ else
+ n += rv;
+ }
+#endif
+ return n;
}
#endif
diff --git a/board/ti/am335x/pll.c b/board/ti/am335x/pll.c
index 818e68b5e..0cdc0618d 100644
--- a/board/ti/am335x/pll.c
+++ b/board/ti/am335x/pll.c
@@ -21,6 +21,7 @@
#define PRCM_MOD_EN 0x2
#define PRCM_FORCE_WAKEUP 0x2
+#define DPLL_CLKDCOLDO_GATE_CTRL 0x300
#define PRCM_EMIF_CLK_ACTIVITY (0x1 << 2)
#define PRCM_L3_GCLK_ACTIVITY (0x1 << 4)
@@ -141,6 +142,10 @@ static void per_clocks_enable(void)
/* RTC */
writel(PRCM_MOD_EN, CM_RTC_RTC_CLKCTRL);
while (readl(CM_RTC_RTC_CLKCTRL) != PRCM_MOD_EN);
+
+ /* OTG */
+ writel(PRCM_MOD_EN, CM_PER_USB0_CLKCTRL);
+ while (readl(CM_PER_USB0_CLKCTRL) != PRCM_MOD_EN);
}
void mpu_pll_config(int mpupll_M)
@@ -233,6 +238,8 @@ static void per_pll_config(void)
writel(clkmode, CM_CLKMODE_DPLL_PER);
while(readl(CM_IDLEST_DPLL_PER) != 0x1);
+
+ writel(DPLL_CLKDCOLDO_GATE_CTRL, CM_CLKDCOLDO_DPLL_PER);
}
void ddr_pll_config(unsigned int ddrpll_M)
diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index 76d199e50..b8725306e 100755
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -549,6 +549,23 @@ to a higher value if a higher sized RAM support is available in Hardware */
#define CONFIG_CMD_EXT2
#endif
+/*
+ * USB configuration
+ */
+#define CONFIG_USB_AM335X
+#define CONFIG_MUSB_GADGET
+#define CONFIG_MUSB_GADGET_PORT0
+#define CONFIG_MUSB_PIO_ONLY
+#define CONFIG_USB_GADGET_DUALSPEED
+
+#ifdef CONFIG_MUSB_GADGET
+#define CONFIG_USB_ETHER
+#define CONFIG_USB_ETH_RNDIS
+#define CONFIG_CMD_NET
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_TFTP
+#endif /* CONFIG_MUSB_GADGET */
+
/* Unsupported features */
#undef CONFIG_USE_IRQ