@@ -20,12 +20,6 @@ extern void davinci_irq_init(void);
extern void __iomem *davinci_intc_base;
extern int davinci_intc_type;
-/* parameters describe VBUS sourcing for host mode */
-extern void setup_usb(unsigned mA, unsigned potpgt_msec);
-
-/* parameters describe VBUS sourcing for host mode */
-extern void setup_usb(unsigned mA, unsigned potpgt_msec);
-
struct davinci_timer_instance {
void __iomem *base;
u32 bottom_irq;
@@ -77,5 +71,6 @@ extern void davinci_common_init(struct davinci_soc_info *soc_info);
/* standard place to map on-chip SRAMs; they *may* support DMA */
#define SRAM_VIRT 0xfffe0000
#define SRAM_SIZE SZ_128K
+#define DAVINCI_USB_OTG_BASE 0x01C64000
#endif /* __ARCH_ARM_MACH_DAVINCI_COMMON_H */
new file mode 100644
@@ -0,0 +1,41 @@
+/*
+ * This file contains the architecture specific USB definitions
+ * of the TI DaVinci platforms.
+ *
+ * Copyright (C) 2009 Texas Instruments.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#ifndef USB_MUSB_H_
+#define USB_MUSB_H_
+
+#include <linux/platform_device.h>
+#include <linux/usb/musb.h>
+
+struct plat_res_data {
+ struct musb_hdrc_platform_data *plat_data;
+ struct resource *res_data;
+ u8 num_res;
+};
+
+struct usb_plat_data {
+ struct plat_res_data *prdata;
+ u8 num_inst;
+};
+
+/* VBUS control fuction */
+extern void setup_usb(struct usb_plat_data *pdata);
+#endif
@@ -6,20 +6,12 @@
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/dma-mapping.h>
+#include <linux/string.h>
#include <linux/usb/musb.h>
#include <linux/usb/otg.h>
+#include <mach/usb_musb.h>
-#include <mach/common.h>
-#include <mach/hardware.h>
-#include <mach/irqs.h>
-#include <mach/cputype.h>
-#include <mach/usb.h>
-
-#define DAVINCI_USB_OTG_BASE 0x01c64000
-#define DA8XX_USB1_BASE 0x01e25000
-
-#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
static struct musb_hdrc_eps_bits musb_eps[] = {
{ "ep1_tx", 8, },
{ "ep1_rx", 8, },
@@ -43,103 +35,43 @@ static struct musb_hdrc_config musb_config = {
.eps_bits = musb_eps,
};
-static struct musb_hdrc_platform_data usb_data = {
-#if defined(CONFIG_USB_MUSB_OTG)
- /* OTG requires a Mini-AB connector */
- .mode = MUSB_OTG,
-#elif defined(CONFIG_USB_MUSB_PERIPHERAL)
- .mode = MUSB_PERIPHERAL,
-#elif defined(CONFIG_USB_MUSB_HOST)
- .mode = MUSB_HOST,
-#endif
- .clock = "usb",
- .config = &musb_config,
-};
-
-static struct resource usb_resources[] = {
- {
- /* physical address */
- .start = DAVINCI_USB_OTG_BASE,
- .end = DAVINCI_USB_OTG_BASE + 0x5ff,
- .flags = IORESOURCE_MEM,
- },
- {
- .start = IRQ_USBINT,
- .flags = IORESOURCE_IRQ,
- },
- {
- /* placeholder for the dedicated CPPI IRQ */
- .flags = IORESOURCE_IRQ,
- },
-};
-
static u64 usb_dmamask = DMA_BIT_MASK(32);
-static struct platform_device usb_dev = {
- .name = "musb_hdrc",
- .id = -1,
- .dev = {
- .platform_data = &usb_data,
- .dma_mask = &usb_dmamask,
- .coherent_dma_mask = DMA_BIT_MASK(32),
- },
- .resource = usb_resources,
- .num_resources = ARRAY_SIZE(usb_resources),
-};
-
-void __init setup_usb(unsigned mA, unsigned potpgt_msec)
-{
- usb_data.power = mA / 2;
- usb_data.potpgt = potpgt_msec / 2;
-
- if (cpu_is_davinci_dm646x()) {
- /* Override the defaults as DM6467 uses different IRQs. */
- usb_dev.resource[1].start = IRQ_DM646X_USBINT;
- usb_dev.resource[2].start = IRQ_DM646X_USBDMAINT;
- } else /* other devices don't have dedicated CPPI IRQ */
- usb_dev.num_resources = 2;
-
- platform_device_register(&usb_dev);
-}
-
-#else
-
-void __init setup_usb(unsigned mA, unsigned potpgt_msec)
-{
-}
-
-#endif /* CONFIG_USB_MUSB_HDRC */
-
-#ifdef CONFIG_ARCH_DAVINCI_DA8XX
-static struct resource da8xx_usb11_resources[] = {
- [0] = {
- .start = DA8XX_USB1_BASE,
- .end = DA8XX_USB1_BASE + SZ_4K - 1,
- .flags = IORESOURCE_MEM,
- },
- [1] = {
- .start = IRQ_DA8XX_IRQN,
- .end = IRQ_DA8XX_IRQN,
- .flags = IORESOURCE_IRQ,
- },
-};
-
-static u64 da8xx_usb11_dma_mask = DMA_BIT_MASK(32);
-
-static struct platform_device da8xx_usb11_device = {
- .name = "ohci",
- .id = 0,
- .dev = {
- .dma_mask = &da8xx_usb11_dma_mask,
- .coherent_dma_mask = DMA_BIT_MASK(32),
- },
- .num_resources = ARRAY_SIZE(da8xx_usb11_resources),
- .resource = da8xx_usb11_resources,
-};
-
-int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata)
+void __init setup_usb(struct usb_plat_data *pdata)
{
- da8xx_usb11_device.dev.platform_data = pdata;
- return platform_device_register(&da8xx_usb11_device);
+ u8 ninst = pdata->num_inst;
+ u8 inst, i = 0;
+ char name[20] = "musb_hdrc";
+ struct platform_device *pdev;
+ struct plat_res_data *plat_res_data;
+
+ do {
+ plat_res_data = &pdata->prdata[i++];
+ inst = plat_res_data->plat_data->inst;
+ if (pdata->num_inst > 1)
+ sprintf(name, "musb_hdrc%d", inst);
+
+ pdev = platform_device_alloc(name, -1);
+
+ if (!pdev) {
+ pr_warning("WARNING: USB platform Alloc Failed\n");
+ break;
+ }
+
+ /* Verify whether the clock information has already been
+ * specified if so do not override it with generic definition.
+ */
+ if (!plat_res_data->plat_data->clock)
+ plat_res_data->plat_data->clock = "usb";
+ pdev->dev.platform_data = plat_res_data->plat_data;
+ pdev->dev.dma_mask = &usb_dmamask,
+ pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+ pdev->resource = plat_res_data->res_data;
+ pdev->num_resources = plat_res_data->num_res;
+
+ /* Associate the default configuration if not specified */
+ if (!plat_res_data->plat_data->config)
+ plat_res_data->plat_data->config = &musb_config;
+ platform_device_add(pdev);
+ } while (--ninst);
}
-#endif /* CONFIG_DAVINCI_DA8XX */
@@ -58,6 +58,10 @@ struct musb_hdrc_config {
};
struct musb_hdrc_platform_data {
+
+ /* MUSB instance */
+ u8 inst;
+
/* MUSB_HOST, MUSB_PERIPHERAL, or MUSB_OTG */
u8 mode;
@@ -82,6 +86,9 @@ struct musb_hdrc_platform_data {
/* Turn device clock on or off */
int (*set_clock)(struct clk *clock, int is_on);
+ /* Configure the USB Phy */
+ int (*phy_config)(struct device *dev, u8 mode, int is_on);
+
/* MUSB configuration-specific details */
struct musb_hdrc_config *config;
};