From: David Brownell <[EMAIL PROTECTED]>

Also remove support for the manually modified EVM which tried
using a "real GPIO" for VBUS switching.

Signed-off-by: David Brownell <[EMAIL PROTECTED]>
---
 arch/arm/mach-davinci/Makefile                |    2 +-
 arch/arm/mach-davinci/board-evm.c             |   58 +--------
 arch/arm/mach-davinci/include/mach/common.h   |    3 +
 arch/arm/mach-davinci/include/mach/hdrc_cnf.h |  165 -------------------------
 arch/arm/mach-davinci/usb.c                   |  116 +++++++++++++++++
 drivers/usb/musb/cppi_dma.h                   |    4 +-
 drivers/usb/musb/davinci.c                    |   14 --
 7 files changed, 125 insertions(+), 237 deletions(-)
 delete mode 100644 arch/arm/mach-davinci/include/mach/hdrc_cnf.h
 create mode 100644 arch/arm/mach-davinci/usb.c

diff --git a/arch/arm/mach-davinci/Makefile b/arch/arm/mach-davinci/Makefile
index 8a6b664..7428e48 100644
--- a/arch/arm/mach-davinci/Makefile
+++ b/arch/arm/mach-davinci/Makefile
@@ -5,7 +5,7 @@
 
 # Common objects
 obj-y                  := time.o irq.o clock.o serial.o io.o id.o psc.o \
-                          gpio.o mux.o dma.o devices.o common.o
+                          gpio.o mux.o dma.o devices.o common.o usb.o
 
 # Board specific
 obj-$(CONFIG_MACH_DAVINCI_EVM)         += board-evm.o
diff --git a/arch/arm/mach-davinci/board-evm.c 
b/arch/arm/mach-davinci/board-evm.c
index 686593f..1b2a68e 100644
--- a/arch/arm/mach-davinci/board-evm.c
+++ b/arch/arm/mach-davinci/board-evm.c
@@ -151,57 +151,6 @@ static struct platform_device davinci_fb_device = {
 };
 #endif
 
-/*
- * USB
- */
-#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
-
-#include <linux/usb/musb.h>
-
-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
-       /* irlml6401 switches 5V */
-       .power          = 250,          /* sustains 3.0+ Amps (!) */
-       .potpgt         = 4,            /* ~8 msec */
-};
-
-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,
-       },
-};
-
-static u64 usb_dmamask = DMA_32BIT_MASK;
-
-static struct platform_device usb_dev = {
-       .name           = "musb_hdrc",
-       .id             = -1,
-       .dev = {
-               .platform_data          = &usb_data,
-               .dma_mask               = &usb_dmamask,
-               .coherent_dma_mask      = DMA_32BIT_MASK,
-        },
-       .resource       = usb_resources,
-       .num_resources  = ARRAY_SIZE(usb_resources),
-};
-
-#define setup_usb(void)        do {} while(0)
-#endif  /* CONFIG_USB_MUSB_HDRC */
-
 static struct platform_device rtc_dev = {
        .name           = "rtc_davinci_evm",
        .id             = -1,
@@ -477,9 +426,6 @@ static struct platform_device *davinci_evm_devices[] 
__initdata = {
 #if defined(CONFIG_FB_DAVINCI) || defined(CONFIG_FB_DAVINCI_MODULE)
        &davinci_fb_device,
 #endif
-#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
-       &usb_dev,
-#endif
        &rtc_dev,
 #if defined(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \
     defined(CONFIG_BLK_DEV_PALMCHIP_BK3710_MODULE)
@@ -520,7 +466,9 @@ static __init void davinci_evm_init(void)
        davinci_board_config = davinci_evm_config;
        davinci_board_config_size = ARRAY_SIZE(davinci_evm_config);
        davinci_serial_init();
-       setup_usb();
+
+       /* irlml6401 sustains over 3A, switches 5V in under 8 msec */
+       setup_usb(500, 8);
 }
 
 static __init void davinci_evm_irq_init(void)
diff --git a/arch/arm/mach-davinci/include/mach/common.h 
b/arch/arm/mach-davinci/include/mach/common.h
index 1eea01d..3f91b8c 100644
--- a/arch/arm/mach-davinci/include/mach/common.h
+++ b/arch/arm/mach-davinci/include/mach/common.h
@@ -17,4 +17,7 @@ struct sys_timer;
 extern struct sys_timer davinci_timer;
 extern void davinci_serial_init(void);
 
+/* parameters describe VBUS sourcing for host mode */
+extern void setup_usb(unsigned mA, unsigned potpgt_msec);
+
 #endif /* __ARCH_ARM_MACH_DAVINCI_COMMON_H */
diff --git a/arch/arm/mach-davinci/include/mach/hdrc_cnf.h 
b/arch/arm/mach-davinci/include/mach/hdrc_cnf.h
deleted file mode 100644
index 3811ce4..0000000
--- a/arch/arm/mach-davinci/include/mach/hdrc_cnf.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * USB High-Speed Multi-Point Dual-Role Controller Configuration
- *
- * Copyright Mentor Graphics Corporation and Licensors 2004
- * Copyright (C) 2005 by Texas Instruments
- *
- * This file contains configuration constants for the (m)hdrc
- * silicon as integrated into DaVinci CPUs.
- */
-
-#ifndef        __ARCH_MUSB_HDRC_CNF
-#define        __ARCH_MUSB_HDRC_CNF
-
-/* ** Number of Tx endpoints ** */
-/* Legal values are 1 - 16 (this value includes EP0) */
-#define MUSB_C_NUM_EPT 5
-
-/* ** Number of Rx endpoints ** */
-/* Legal values are 1 - 16 (this value includes EP0) */
-#define MUSB_C_NUM_EPR 5
-
-/* ** Endpoint 1 to 15 direction types ** */
-/* C_EP1_DEF is defined if either Tx endpoint 1 or Rx endpoint 1 are used */
-#define MUSB_C_EP1_DEF
-
-/* C_EP1_TX_DEF is defined if Tx endpoint 1 is used */
-#define MUSB_C_EP1_TX_DEF
-
-/* C_EP1_RX_DEF is defined if Rx endpoint 1 is used */
-#define MUSB_C_EP1_RX_DEF
-
-/* C_EP1_TOR_DEF is defined if Tx endpoint 1 and Rx endpoint 1 share a FIFO */
-/*`define C_EP1_TOR_DEF */
-
-/* C_EP1_TAR_DEF is defined if both Tx endpoint 1 and Rx endpoint 1 are used */
-/* and do not share a FIFO */
-#define MUSB_C_EP1_TAR_DEF
-
-/* Similarly for all other used endpoints */
-#define MUSB_C_EP2_DEF
-#define MUSB_C_EP2_TX_DEF
-#define MUSB_C_EP2_RX_DEF
-#define MUSB_C_EP2_TAR_DEF
-#define MUSB_C_EP3_DEF
-#define MUSB_C_EP3_TX_DEF
-#define MUSB_C_EP3_RX_DEF
-#define MUSB_C_EP3_TAR_DEF
-#define MUSB_C_EP4_DEF
-#define MUSB_C_EP4_TX_DEF
-#define MUSB_C_EP4_RX_DEF
-#define MUSB_C_EP4_TAR_DEF
-
-/* ** Endpoint 1 to 15 FIFO address bits ** */
-/* Legal values are 3 to 13 - corresponding to FIFO sizes of 8 to 8192 bytes. 
*/
-/* If an Tx endpoint shares a FIFO with an Rx endpoint then the Rx FIFO size */
-/* must be the same as the Tx FIFO size. */
-/* All endpoints 1 to 15 must be defined, unused endpoints should be set to 2. 
*/
-#define MUSB_C_EP1T_BITS 5
-#define MUSB_C_EP1R_BITS 5
-#define MUSB_C_EP2T_BITS 5
-#define MUSB_C_EP2R_BITS 5
-#define MUSB_C_EP3T_BITS 3
-#define MUSB_C_EP3R_BITS 3
-#define MUSB_C_EP4T_BITS 3
-#define MUSB_C_EP4R_BITS 3
-
-#define MUSB_C_EP5T_BITS 2
-#define MUSB_C_EP5R_BITS 2
-#define MUSB_C_EP6T_BITS 2
-#define MUSB_C_EP6R_BITS 2
-#define MUSB_C_EP7T_BITS 2
-#define MUSB_C_EP7R_BITS 2
-#define MUSB_C_EP8T_BITS 2
-#define MUSB_C_EP8R_BITS 2
-#define MUSB_C_EP9T_BITS 2
-#define MUSB_C_EP9R_BITS 2
-#define MUSB_C_EP10T_BITS 2
-#define MUSB_C_EP10R_BITS 2
-#define MUSB_C_EP11T_BITS 2
-#define MUSB_C_EP11R_BITS 2
-#define MUSB_C_EP12T_BITS 2
-#define MUSB_C_EP12R_BITS 2
-#define MUSB_C_EP13T_BITS 2
-#define MUSB_C_EP13R_BITS 2
-#define MUSB_C_EP14T_BITS 2
-#define MUSB_C_EP14R_BITS 2
-#define MUSB_C_EP15T_BITS 2
-#define MUSB_C_EP15R_BITS 2
-
-/* Define the following constant if the USB2.0 Transceiver Macrocell data 
width is 16-bits. */
-/* `define C_UTM_16 */
-
-/* Define this constant if the CPU uses big-endian byte ordering. */
-/*`define C_BIGEND */
-
-/* Define the following constant if any Tx endpoint is required to support 
multiple bulk packets. */
-/* `define C_MP_TX */
-
-/* Define the following constant if any Rx endpoint is required to support 
multiple bulk packets. */
-/* `define C_MP_RX */
-
-/* Define the following constant if any Tx endpoint is required to support 
high bandwidth ISO. */
-/* `define C_HB_TX */
-
-/* Define the following constant if any Rx endpoint is required to support 
high bandwidth ISO. */
-/* `define C_HB_RX */
-
-/* Define the following constant if software connect/disconnect control is 
required. */
-#define MUSB_C_SOFT_CON
-
-/* Define the following constant if Vendor Control Registers are required. */
-/* `define C_VEND_REG */
-
-/* Vendor control register widths. */
-#define MUSB_C_VCTL_BITS 4
-#define MUSB_C_VSTAT_BITS 8
-
-
-/* Define the following constant to include a DMA controller. */
-/*`define C_DMA */
-
-/* Define the following constant if 2 or more DMA channels are required. */
-/*`define C_DMA2 */
-
-/* Define the following constant if 3 or more DMA channels are required. */
-/*`define C_DMA3 */
-
-/* Define the following constant if 4 or more DMA channels are required. */
-/*`define C_DMA4 */
-
-/* Define the following constant if 5 or more DMA channels are required. */
-/*`define C_DMA5 */
-
-/* Define the following constant if 6 or more DMA channels are required. */
-/*`define C_DMA6 */
-
-/* Define the following constant if 7 or more DMA channels are required. */
-/*`define C_DMA7 */
-
-/* Define the following constant if 8 or more DMA channels are required. */
-/*`define C_DMA8 */
-
-
-/* ** Enable Dynamic FIFO Sizing ** */
-#define MUSB_C_DYNFIFO_DEF
-
-/* ** Derived constants ** */
-/* The following constants are derived from the previous configuration 
constants */
-
-/* Total number of endpoints
- * Legal values are 2 - 16
- * This must be equal to the larger of C_NUM_EPT, C_NUM_EPR
- */
-#define MUSB_C_NUM_EPS 5
-
-/* C_EPMAX_BITS is equal to the largest endpoint FIFO word address bits */
-#define MUSB_C_EPMAX_BITS 11
-
-/* C_RAM_BITS is the number of address bits required to address the RAM (32-bit
- * addresses).  It is defined as log2 of the sum of 2** of all the endpoint 
FIFO
- * dword address bits (rounded up).
- */
-#define MUSB_C_RAM_BITS 10
-
-#endif /* __ARCH_MUSB_HDRC_CNF */
diff --git a/arch/arm/mach-davinci/usb.c b/arch/arm/mach-davinci/usb.c
new file mode 100644
index 0000000..fe182a8
--- /dev/null
+++ b/arch/arm/mach-davinci/usb.c
@@ -0,0 +1,116 @@
+/*
+ * USB
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/dma-mapping.h>
+
+#include <linux/usb/musb.h>
+#include <linux/usb/otg.h>
+
+#include <mach/common.h>
+#include <mach/hardware.h>
+
+#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, },
+       { "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 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
+       .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,
+       },
+};
+
+static u64 usb_dmamask = DMA_32BIT_MASK;
+
+static struct platform_device usb_dev = {
+       .name           = "musb_hdrc",
+       .id             = -1,
+       .dev = {
+               .platform_data          = &usb_data,
+               .dma_mask               = &usb_dmamask,
+               .coherent_dma_mask      = DMA_32BIT_MASK,
+       },
+       .resource       = usb_resources,
+       .num_resources  = ARRAY_SIZE(usb_resources),
+};
+
+#ifdef CONFIG_USB_MUSB_OTG
+
+static struct otg_transceiver *xceiv;
+
+struct otg_transceiver *otg_get_transceiver(void)
+{
+       if (xceiv)
+               get_device(xceiv->dev);
+       return xceiv;
+}
+EXPORT_SYMBOL(otg_get_transceiver);
+
+int otg_set_transceiver(struct otg_transceiver *x)
+{
+       if (xceiv && x)
+               return -EBUSY;
+       xceiv = x;
+       return 0;
+}
+EXPORT_SYMBOL(otg_set_transceiver);
+
+#endif
+
+void __init setup_usb(unsigned mA, unsigned potpgt_msec)
+{
+       usb_data.power = mA / 2;
+       usb_data.potpgt = potpgt_msec / 2;
+       platform_device_register(&usb_dev);
+}
+
+#else
+
+void __init setup_usb(unsigned mA, unsigned potpgt_msec)
+{
+}
+
+#endif  /* CONFIG_USB_MUSB_HDRC */
+
diff --git a/drivers/usb/musb/cppi_dma.h b/drivers/usb/musb/cppi_dma.h
index fc5216b..729b407 100644
--- a/drivers/usb/musb/cppi_dma.h
+++ b/drivers/usb/musb/cppi_dma.h
@@ -119,8 +119,8 @@ struct cppi {
        void __iomem                    *mregs;         /* Mentor regs */
        void __iomem                    *tibase;        /* TI/CPPI regs */
 
-       struct cppi_channel             tx[MUSB_C_NUM_EPT - 1];
-       struct cppi_channel             rx[MUSB_C_NUM_EPR - 1];
+       struct cppi_channel             tx[4];
+       struct cppi_channel             rx[4];
 
        struct dma_pool                 *pool;
 
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 774c813..ec9e09e 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -36,7 +36,6 @@
 #include <mach/gpio.h>
 #include <asm/mach-types.h>
 
-#include <mach/hdrc_cnf.h>
 #include "musb_core.h"
 
 #ifdef CONFIG_MACH_DAVINCI_EVM
@@ -139,7 +138,6 @@ static int vbus_state = -1;
 /* VBUS SWITCHING IS BOARD-SPECIFIC */
 
 #ifdef CONFIG_MACH_DAVINCI_EVM
-#ifndef CONFIG_MACH_DAVINCI_EVM_OTG
 
 /* I2C operations are always synchronous, and require a task context.
  * With unloaded systems, using the shared workqueue seems to suffice
@@ -152,7 +150,6 @@ static void evm_deferred_drvvbus(struct work_struct 
*ignored)
 }
 static DECLARE_WORK(evm_vbus_work, evm_deferred_drvvbus);
 
-#endif /* modified board */
 #endif /* EVM */
 
 static void davinci_source_power(struct musb *musb, int is_on, int immediate)
@@ -166,21 +163,10 @@ static void davinci_source_power(struct musb *musb, int 
is_on, int immediate)
 
 #ifdef CONFIG_MACH_DAVINCI_EVM
        if (machine_is_davinci_evm()) {
-#ifdef CONFIG_MACH_DAVINCI_EVM_OTG
-               /* modified EVM board switching VBUS with GPIO(6) not I2C
-                * NOTE:  PINMUX0.RGB888 (bit23) must be clear
-                */
-               if (is_on)
-                       gpio_set(GPIO(6));
-               else
-                       gpio_clear(GPIO(6));
-               immediate = 1;
-#else
                if (immediate)
                        davinci_i2c_expander_op(0x3a, USB_DRVVBUS, !is_on);
                else
                        schedule_work(&evm_vbus_work);
-#endif
        }
 #endif
        if (immediate)
-- 
1.5.6.4


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

Reply via email to