OK guys,

Attached is my workaround for this issue. Implemented and tested against kernel from DVEVM 1.10.

Ivan


Ivan Tonchev wrote:
Hi Andy, Constantine,

We're interested in this item too.

Is this Kconfig change sufficient for what we want? I'm not sure, but I think there is more to be changed. It seems to me that Host/Peripheral mode is selected by Kconfig and hardcoded in kernel image. See arch/arm/mach-davinci/board-evm.c and drivers/usb/musb/davinci.c:

*board-evm.c:*

    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          = 255,          /* sustains 3.0+ Amps (!) */
            .potpgt         = 4,            /* ~8 msec */

/* REVISIT multipoint is a _chip_ capability; not board specific */
            .multipoint     = 1,
    };



*davinci.c:musb_init_controller()*

switch (plat->mode) { case MUSB_HOST: #ifdef CONFIG_USB_MUSB_HDRC_HCD break; #else goto bad_config; #endif case MUSB_PERIPHERAL: #ifdef CONFIG_USB_GADGET_MUSB_HDRC break; #else goto bad_config; #endif
    case MUSB_OTG:
#ifdef CONFIG_USB_MUSB_OTG break; #else bad_config:
#endif
    default:
dev_dbg(dev, "incompatible Kconfig role setting\n"); return -EINVAL; }
Shouldn't this be fixed too?

BR,
Ivan

Constantine Shulyupin wrote:
Yes, it is possibe.

You need to make a trick:
alter file drivers/usb/musb/Kconfig
comment a line:
config USB_MUSB_HDRC
    #depends on USB || USB_GADGET

(tested on v1.1)

Then configure, compile an use.

On Fri, 2007-03-23 at 18:18 -0700, Andy Ngo wrote:
Hi guys,
On a related USB item, can I built just "one" kernel image that can
support either host or peripheral modes?  Our hardware
engineer is planning to use a Xilinx FPGA register to select the
termination for the USB host/client configuration.  Hence
we can configure USB for host or client based on the value of the
register.  We're not using OTG, but just either host or
peripheral; we don't want 2 separate kernel images one for each mode.
Is this possible?  We're planning to compile the
USB-related drivers as modules and just load the ones we need to use
based on the mode.
Thanks. Regards,
Andy

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

------------------------------------------------------------------------

_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
--- ti-davinci/arch/arm/mach-davinci/board-evm.c	2006-08-01 22:08:53.000000000 +0300
+++ ti-davinci/arch/arm/mach-davinci/board-evm.c	2007-03-28 13:02:04.000000000 +0300
@@ -36,9 +36,7 @@
 #include <linux/major.h>
 #include <linux/root_dev.h>
 #include <linux/dma-mapping.h>
-#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
 #include <linux/usb_musb.h>
-#endif
 
 #include <asm/setup.h>
 #include <asm/io.h>
@@ -69,17 +67,21 @@
 /*
  * USB
  */
-#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
 
 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
+
+        /* Although part of platform_data, MUSB mode selection does not belong 
+         * in arch kernel code.
+         *
+         * We leave it MUSB_UNDEFINED here (and thus possible for 
+         * drivers/usb/musb/plat_uds.c:musb_init_controller() to properly 
+         * initialize it later.
+         *
+         * It can be MUSB_OTD or MUSB_PERIPHERAL or MUSB_HOST.
+         */
+
+        .mode = MUSB_UNDEFINED,
+
         /* irlml6401 switches 5V */
         .power          = 255,          /* sustains 3.0+ Amps (!) */
         .potpgt         = 4,            /* ~8 msec */
@@ -129,13 +131,6 @@
                 board_setup_psc(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_USB, 1);
 }
 
-#else
-static inline void setup_usb(void)
-{
-        /* NOP */
-}
-#endif  /* CONFIG_USB_MUSB_HDRC */
-
 static void board_init(void)
 {
 	board_setup_psc(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_VPSSMSTR, 1);
--- ti-davinci/drivers/usb/musb/plat_uds.c	2006-07-07 16:44:52.000000000 +0300
+++ ti-davinci/drivers/usb/musb/plat_uds.c	2007-03-28 14:24:34.000000000 +0300
@@ -1545,29 +1545,27 @@
 		dev_dbg(dev, "no platform_data?\n");
 		return -ENODEV;
 	}
-	switch (plat->mode) {
-	case MUSB_HOST:
-#ifdef CONFIG_USB_MUSB_HDRC_HCD
-		break;
-#else
-		goto bad_config;
-#endif
-	case MUSB_PERIPHERAL:
-#ifdef CONFIG_USB_GADGET_MUSB_HDRC
-		break;
-#else
-		goto bad_config;
-#endif
-	case MUSB_OTG:
-#ifdef CONFIG_USB_MUSB_OTG
-		break;
+
+    /* plat->mode select:
+     * Despite drivers/usb/musb/Kconfig advises us to use
+     * USB_MUSB_HDRC_HCD instead of USB_MUSB_HOST and
+     * USB_GADGET_MUSB_HDRC instead of USB_MUSB_PERIPHERAL,
+     * we use the latter here. This is intentional and we
+     * do it, because USB_MUSB_HDRC_HCD is defined not only when
+     * USB_MUSB_HOST is selected, but also when USB_MUSB_OTG,
+     * and hence we can't use it to detect what mode for musb, 
+     * user selected in Kconfig. Same for USB_GADGET_MUSB_HDRC.
+     */
+
+#ifdef CONFIG_USB_MUSB_HOST
+    plat->mode = MUSB_HOST;
+#elif defined(CONFIG_USB_MUSB_PERIPHERAL)
+    plat->mode = MUSB_PERIPHERAL;
+#elif defined(CONFIG_USB_MUSB_OTG)
+    plat->mode = MUSB_OTG;
 #else
-	bad_config:
+#error "Your kernel config is broken"
 #endif
-	default:
-		dev_dbg(dev, "incompatible Kconfig role setting\n");
-		return -EINVAL;
-	}
 
 	/* allocate */
 	pThis = allocate_instance(ctrl);
_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to