Add the function to register the MUSB platform device.

Signed-off-by: Sergei Shtylyov <[email protected]>

---
The patch is against the recent DaVinci tree plus the OHCI platform patches
that I posted a week ago...

 arch/arm/mach-davinci/devices-da8xx.c      |   74 +++++++++++++++++++++++++++++
 arch/arm/mach-davinci/include/mach/da8xx.h |    1 
 2 files changed, 75 insertions(+)

Index: linux-davinci/arch/arm/mach-davinci/devices-da8xx.c
===================================================================
--- linux-davinci.orig/arch/arm/mach-davinci/devices-da8xx.c
+++ linux-davinci/arch/arm/mach-davinci/devices-da8xx.c
@@ -16,6 +16,7 @@
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
 #include <linux/serial_8250.h>
+#include <linux/usb/musb.h>
 
 #include <mach/cputype.h>
 #include <mach/common.h>
@@ -30,6 +31,7 @@
 #define DA8XX_TPTC1_BASE               0x01c08400
 #define DA8XX_WDOG_BASE                        0x01c21000 /* 
DA8XX_TIMER64P1_BASE */
 #define DA8XX_I2C0_BASE                        0x01c22000
+#define DA8XX_USB0_BASE                0x01e00000
 #define DA8XX_EMAC_CPPI_PORT_BASE      0x01e20000
 #define DA8XX_EMAC_CPGMACSS_BASE       0x01e22000
 #define DA8XX_EMAC_CPGMAC_BASE         0x01e23000
@@ -236,6 +238,78 @@ int __init da8xx_register_watchdog(void)
        return platform_device_register(&davinci_wdt_device);
 }
 
+static struct musb_hdrc_eps_bits musb_eps[] = {
+       { "ep1_tx", 8, },
+       { "ep1_rx", 8, },
+       { "ep2_tx", 8, },
+       { "ep2_rx", 8, },
+       { "ep3_tx", 5, },
+       { "ep3_rx", 5, },
+       { "ep4_tx", 5, },
+       { "ep4_rx", 5, },
+};
+
+static struct musb_hdrc_config musb_config = {
+       .multipoint     = true,
+       .dyn_fifo       = true,
+       .soft_con       = true,
+       .dma            = true,
+
+       .num_eps        = 5,
+       .dma_channels   = 8,
+       .ram_bits       = 10,
+       .eps_bits       = musb_eps,
+};
+
+static struct musb_hdrc_platform_data da8xx_usb20_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          = "usb20",
+       .config         = &musb_config,
+};
+
+static struct resource da8xx_usb20_resources[] = {
+       {
+               /* physical address */
+               .start          = DA8XX_USB0_BASE,
+               .end            = DA8XX_USB0_BASE + SZ_64K - 1,
+               .flags          = IORESOURCE_MEM,
+       },
+       {
+               .start          = IRQ_DA8XX_USB_INT,
+               .end            = IRQ_DA8XX_USB_INT,
+               .flags          = IORESOURCE_IRQ,
+       },
+};
+
+static u64 da8xx_usb20_dmamask = DMA_BIT_MASK(32);
+
+static struct platform_device da8xx_usb20_device = {
+       .name           = "musb_hdrc",
+       .id             = -1,
+       .dev = {
+               .platform_data          = &da8xx_usb20_data,
+               .dma_mask               = &da8xx_usb20_dmamask,
+               .coherent_dma_mask      = DMA_BIT_MASK(32),
+       },
+       .resource       = da8xx_usb20_resources,
+       .num_resources  = ARRAY_SIZE(da8xx_usb20_resources),
+};
+
+int __init da8xx_register_usb20(unsigned mA, unsigned potpgt)
+{
+       da8xx_usb20_data.power  = mA > 510 ? 255 : mA / 2;
+       da8xx_usb20_data.potpgt = (potpgt + 1) / 2;
+
+       return platform_device_register(&da8xx_usb20_device);
+}
+
 static struct resource da8xx_usb11_resources[] = {
        [0] = {
                .start  = DA8XX_USB1_BASE,
Index: linux-davinci/arch/arm/mach-davinci/include/mach/da8xx.h
===================================================================
--- linux-davinci.orig/arch/arm/mach-davinci/include/mach/da8xx.h
+++ linux-davinci/arch/arm/mach-davinci/include/mach/da8xx.h
@@ -73,6 +73,7 @@ void __init da850_init(void);
 int da8xx_register_edma(void);
 int da8xx_register_i2c(int instance, struct davinci_i2c_platform_data *pdata);
 int da8xx_register_watchdog(void);
+int da8xx_register_usb20(unsigned mA, unsigned potpgt);
 int da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata);
 int da8xx_register_emac(void);
 int da8xx_register_lcdc(void);


_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to