Hello people,

The attached trivial patch updates slave-mode parts in dwc otg usb driver for ramips target. It doesn't touch anything host-mode. The first 2 fragments correct an error in passing argument, this is immediately clear from comparing with (already correct) calls to dwc_otg_hcd_remove/dwc_otg_hcd_init of host-mode code around and/or looking at respective declarations. All other fragments just fix compatability with various kernel versions. Maybe a little bit too much of version mess, but there are still ifdefs for 2.6.19 in the trunk anyway and I have some reasons to compile it also for 2.6.34. At the moment, slave-mode parts are not used in openwrt but used by me (well, sort of, on ARM platform though). With the patch applied, the driver still does not actually work on my device yet but this is expected and will probably be addressed later. At least it compiles and loads.

[    8.930000] dwc_otg: version 2.72a 24-JUN-2008
[    8.930000] dwc_otg dwc_otg.0: request_mem_region failed

Posting as attachment to avoid line wrapping, please let me know how if this is inappropriate. Hopefully the patch is too simple for discussion anyway.

Thank you.
Nikolai




diff -ur trunk/target/linux/ramips/files/drivers/usb/dwc_otg/dwc_otg_driver.c 
trunk.test/target/linux/ramips/files/drivers/usb/dwc_otg/dwc_otg_driver.c
--- trunk/target/linux/ramips/files/drivers/usb/dwc_otg/dwc_otg_driver.c        
2012-01-10 00:33:03.000000000 +0300
+++ trunk.test/target/linux/ramips/files/drivers/usb/dwc_otg/dwc_otg_driver.c   
2012-01-13 04:18:17.000000000 +0300
@@ -634,7 +634,7 @@
 
 #ifndef DWC_HOST_ONLY
        if (otg_dev->pcd) {
-               dwc_otg_pcd_remove(pdev);
+               dwc_otg_pcd_remove(&pdev->dev);
        }
 #endif
        if (otg_dev->core_if) {
@@ -823,7 +823,7 @@
        /*
         * Initialize the PCD
         */
-       retval = dwc_otg_pcd_init(pdev);
+       retval = dwc_otg_pcd_init(&pdev->dev);
        if (retval != 0) {
                DWC_ERROR("dwc_otg_pcd_init failed\n");
                otg_dev->pcd = NULL;
diff -ur trunk/target/linux/ramips/files/drivers/usb/dwc_otg/dwc_otg_hcd.c 
trunk.test/target/linux/ramips/files/drivers/usb/dwc_otg/dwc_otg_hcd.c
--- trunk/target/linux/ramips/files/drivers/usb/dwc_otg/dwc_otg_hcd.c   
2012-01-10 00:33:03.000000000 +0300
+++ trunk.test/target/linux/ramips/files/drivers/usb/dwc_otg/dwc_otg_hcd.c      
2012-01-07 02:15:54.000000000 +0300
@@ -1781,8 +1781,10 @@
                desc->wHubCharacteristics = 0x08;
                desc->bPwrOn2PwrGood = 1;
                desc->bHubContrCurrent = 0;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
                desc->u.hs.DeviceRemovable[0] = 0;
                desc->u.hs.DeviceRemovable[1] = 0xff;
+#endif
                break;
        case GetHubStatus:
                DWC_DEBUGPL(DBG_HCD, "DWC OTG HCD HUB CONTROL - "
diff -ur trunk/target/linux/ramips/files/drivers/usb/dwc_otg/dwc_otg_hcd.h 
trunk.test/target/linux/ramips/files/drivers/usb/dwc_otg/dwc_otg_hcd.h
--- trunk/target/linux/ramips/files/drivers/usb/dwc_otg/dwc_otg_hcd.h   
2012-01-10 00:33:03.000000000 +0300
+++ trunk.test/target/linux/ramips/files/drivers/usb/dwc_otg/dwc_otg_hcd.h      
2012-01-13 00:40:18.000000000 +0300
@@ -36,7 +36,11 @@
 
 #include <linux/list.h>
 #include <linux/usb.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
 #include <linux/usb/hcd.h>
+#else
+#include <../drivers/usb/core/hcd.h>
+#endif
 
 struct dwc_otg_device;
 
diff -ur trunk/target/linux/ramips/files/drivers/usb/dwc_otg/dwc_otg_pcd.c 
trunk.test/target/linux/ramips/files/drivers/usb/dwc_otg/dwc_otg_pcd.c
--- trunk/target/linux/ramips/files/drivers/usb/dwc_otg/dwc_otg_pcd.c   
2012-01-10 00:33:03.000000000 +0300
+++ trunk.test/target/linux/ramips/files/drivers/usb/dwc_otg/dwc_otg_pcd.c      
2012-01-13 03:56:36.000000000 +0300
@@ -80,7 +80,11 @@
 # include <linux/usb_ch9.h>
 #endif
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
+#include <linux/usb/gadget.h>
+#else
 #include <linux/usb_gadget.h>
+#endif
 
 #include "dwc_otg_driver.h"
 #include "dwc_otg_pcd.h"
@@ -412,6 +416,7 @@
        kfree(request);
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
 /**
  * This function allocates an I/O buffer to be used for a transfer
  * to/from the specified endpoint.
@@ -489,6 +494,7 @@
                kfree(buf);
        }
 }
+#endif
 
 
 /**
@@ -571,8 +577,10 @@
 
                if(ep->dwc_ep.is_in)
                {
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) || defined(CONFIG_MIPS)
                        if(usb_req->length)
                                dma_cache_wback_inv((unsigned 
long)usb_req->buf, usb_req->length + 2);
+#endif
                }
        }
 
@@ -1518,8 +1526,10 @@
                .alloc_request  = dwc_otg_pcd_alloc_request,
                .free_request   = dwc_otg_pcd_free_request,
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
                .alloc_buffer   = dwc_otg_pcd_alloc_buffer,
                .free_buffer    = dwc_otg_pcd_free_buffer,
+#endif
 
                .queue          = dwc_otg_pcd_ep_queue,
                .dequeue        = dwc_otg_pcd_ep_dequeue,
@@ -1545,8 +1555,10 @@
        .alloc_request  = dwc_otg_pcd_alloc_request,
        .free_request   = dwc_otg_pcd_free_request,
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
        .alloc_buffer   = dwc_otg_pcd_alloc_buffer,
        .free_buffer    = dwc_otg_pcd_free_buffer,
+#endif
 
        .queue          = dwc_otg_pcd_ep_queue,
        .dequeue        = dwc_otg_pcd_ep_dequeue,
@@ -2201,7 +2213,11 @@
        otg_dev->pcd = pcd;
        s_pcd = pcd;
        pcd->gadget.name = pcd_name;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
        strcpy(pcd->gadget.dev.bus_id, "gadget");
+#else
+       dev_set_name(&pcd->gadget.dev, "%s", "gadget");
+#endif
 
        pcd->otg_dev = dev_get_drvdata(dev);
 
@@ -2276,7 +2292,7 @@
         */
        DWC_DEBUGPL(DBG_ANY, "registering handler for irq%d\n", otg_dev->irq);
        retval = request_irq(otg_dev->irq, dwc_otg_pcd_irq,
-                               SA_SHIRQ, pcd->gadget.name, pcd);
+                               IRQF_SHARED, pcd->gadget.name, pcd);
        if (retval != 0) {
                DWC_ERROR("request of irq%d failed\n", otg_dev->irq);
                device_unregister(&pcd->gadget.dev);
@@ -2418,14 +2434,24 @@
  *
  * @param driver The driver being registered
  */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver, int 
(*bind)(struct usb_gadget *))
+#else
 int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+#endif
 {
        int retval;
+       int (*d_bind)(struct usb_gadget *);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)
+       d_bind = bind;
+#else
+       d_bind = driver->bind;
+#endif
 
        DWC_DEBUGPL(DBG_PCD, "registering gadget driver '%s'\n", 
driver->driver.name);
 
        if (!driver || driver->speed == USB_SPEED_UNKNOWN ||
-               !driver->bind ||
+               !d_bind ||
                !driver->unbind ||
                !driver->disconnect ||
                !driver->setup) {
@@ -2446,7 +2472,7 @@
        s_pcd->gadget.dev.driver = &driver->driver;
 
        DWC_DEBUGPL(DBG_PCD, "bind to driver %s\n", driver->driver.name);
-       retval = driver->bind(&s_pcd->gadget);
+       retval = d_bind(&s_pcd->gadget);
        if (retval) {
                DWC_ERROR("bind to driver %s --> error %d\n",
                                        driver->driver.name, retval);
@@ -2459,7 +2485,11 @@
        return 0;
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)
+EXPORT_SYMBOL(usb_gadget_probe_driver);
+#else
 EXPORT_SYMBOL(usb_gadget_register_driver);
+#endif
 
 /**
  * This function unregisters a gadget driver
diff -ur trunk/target/linux/ramips/files/drivers/usb/dwc_otg/dwc_otg_pcd.h 
trunk.test/target/linux/ramips/files/drivers/usb/dwc_otg/dwc_otg_pcd.h
--- trunk/target/linux/ramips/files/drivers/usb/dwc_otg/dwc_otg_pcd.h   
2012-01-10 00:33:03.000000000 +0300
+++ trunk.test/target/linux/ramips/files/drivers/usb/dwc_otg/dwc_otg_pcd.h      
2012-01-12 22:27:38.000000000 +0300
@@ -45,7 +45,11 @@
 # include <linux/usb_ch9.h>
 #endif
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
+#include <linux/usb/gadget.h>
+#else
 #include <linux/usb_gadget.h>
+#endif
 #include <linux/interrupt.h>
 #include <linux/dma-mapping.h>
 




_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to