]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
USB: gadget: Separate out PCI bus code from ci13xxx_udc
authorPavankumar Kondeti <pkondeti@codeaurora.org>
Tue, 7 Dec 2010 12:23:59 +0000 (17:53 +0530)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 10 Dec 2010 22:23:32 +0000 (14:23 -0800)
Move PCI bus code from ci13xxx_udc to a new file ci13xxx_pci.  SoC's
which has MIPS USB core can include the ci13xxx_udc and keep bus glue
code in their respective gadget controller drivers.

Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/gadget/Kconfig
drivers/usb/gadget/Makefile
drivers/usb/gadget/ci13xxx_pci.c [new file with mode: 0644]
drivers/usb/gadget/ci13xxx_udc.c
drivers/usb/gadget/gadget_chips.h

index 23fac38574774e48bf4c609672d253c401ed2222..6bcbcb073e566b82bc073e3f16f97e1054acf87a 100644 (file)
@@ -427,8 +427,8 @@ config USB_FSL_QE
        default USB_GADGET
        select USB_GADGET_SELECTED
 
-config USB_GADGET_CI13XXX
-       boolean "MIPS USB CI13xxx"
+config USB_GADGET_CI13XXX_PCI
+       boolean "MIPS USB CI13xxx PCI UDC"
        depends on PCI
        select USB_GADGET_DUALSPEED
        help
@@ -439,9 +439,9 @@ config USB_GADGET_CI13XXX
          dynamically linked module called "ci13xxx_udc" and force all
          gadget drivers to also be dynamically linked.
 
-config USB_CI13XXX
+config USB_CI13XXX_PCI
        tristate
-       depends on USB_GADGET_CI13XXX
+       depends on USB_GADGET_CI13XXX_PCI
        default USB_GADGET
        select USB_GADGET_SELECTED
 
index a3e6b90c11d76afbe7d3db6bdd9731e411e6380d..f53fda7c2558a245961cf696b0967c17bf27c855 100644 (file)
@@ -21,7 +21,7 @@ fsl_usb2_udc-$(CONFIG_ARCH_MXC)       += fsl_mxc_udc.o
 obj-$(CONFIG_USB_M66592)       += m66592-udc.o
 obj-$(CONFIG_USB_R8A66597)     += r8a66597-udc.o
 obj-$(CONFIG_USB_FSL_QE)       += fsl_qe_udc.o
-obj-$(CONFIG_USB_CI13XXX)      += ci13xxx_udc.o
+obj-$(CONFIG_USB_CI13XXX_PCI)  += ci13xxx_pci.o
 obj-$(CONFIG_USB_S3C_HSOTG)    += s3c-hsotg.o
 obj-$(CONFIG_USB_LANGWELL)     += langwell_udc.o
 obj-$(CONFIG_USB_EG20T)                += pch_udc.o
diff --git a/drivers/usb/gadget/ci13xxx_pci.c b/drivers/usb/gadget/ci13xxx_pci.c
new file mode 100644 (file)
index 0000000..7a0f153
--- /dev/null
@@ -0,0 +1,172 @@
+/*
+ * ci13xxx_pci.c - MIPS USB IP core family device controller
+ *
+ * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved.
+ *
+ * Author: David Lopo
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/pci.h>
+
+#include "ci13xxx_udc.c"
+
+/* driver name */
+#define UDC_DRIVER_NAME   "ci13xxx_pci"
+
+/******************************************************************************
+ * PCI block
+ *****************************************************************************/
+/**
+ * ci13xxx_pci_irq: interrut handler
+ * @irq:  irq number
+ * @pdev: USB Device Controller interrupt source
+ *
+ * This function returns IRQ_HANDLED if the IRQ has been handled
+ * This is an ISR don't trace, use attribute interface instead
+ */
+static irqreturn_t ci13xxx_pci_irq(int irq, void *pdev)
+{
+       if (irq == 0) {
+               dev_err(&((struct pci_dev *)pdev)->dev, "Invalid IRQ0 usage!");
+               return IRQ_HANDLED;
+       }
+       return udc_irq();
+}
+
+/**
+ * ci13xxx_pci_probe: PCI probe
+ * @pdev: USB device controller being probed
+ * @id:   PCI hotplug ID connecting controller to UDC framework
+ *
+ * This function returns an error code
+ * Allocates basic PCI resources for this USB device controller, and then
+ * invokes the udc_probe() method to start the UDC associated with it
+ */
+static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev,
+                                      const struct pci_device_id *id)
+{
+       void __iomem *regs = NULL;
+       int retval = 0;
+
+       if (id == NULL)
+               return -EINVAL;
+
+       retval = pci_enable_device(pdev);
+       if (retval)
+               goto done;
+
+       if (!pdev->irq) {
+               dev_err(&pdev->dev, "No IRQ, check BIOS/PCI setup!");
+               retval = -ENODEV;
+               goto disable_device;
+       }
+
+       retval = pci_request_regions(pdev, UDC_DRIVER_NAME);
+       if (retval)
+               goto disable_device;
+
+       /* BAR 0 holds all the registers */
+       regs = pci_iomap(pdev, 0, 0);
+       if (!regs) {
+               dev_err(&pdev->dev, "Error mapping memory!");
+               retval = -EFAULT;
+               goto release_regions;
+       }
+       pci_set_drvdata(pdev, (__force void *)regs);
+
+       pci_set_master(pdev);
+       pci_try_set_mwi(pdev);
+
+       retval = udc_probe(&pdev->dev, regs, UDC_DRIVER_NAME);
+       if (retval)
+               goto iounmap;
+
+       /* our device does not have MSI capability */
+
+       retval = request_irq(pdev->irq, ci13xxx_pci_irq, IRQF_SHARED,
+                            UDC_DRIVER_NAME, pdev);
+       if (retval)
+               goto gadget_remove;
+
+       return 0;
+
+ gadget_remove:
+       udc_remove();
+ iounmap:
+       pci_iounmap(pdev, regs);
+ release_regions:
+       pci_release_regions(pdev);
+ disable_device:
+       pci_disable_device(pdev);
+ done:
+       return retval;
+}
+
+/**
+ * ci13xxx_pci_remove: PCI remove
+ * @pdev: USB Device Controller being removed
+ *
+ * Reverses the effect of ci13xxx_pci_probe(),
+ * first invoking the udc_remove() and then releases
+ * all PCI resources allocated for this USB device controller
+ */
+static void __devexit ci13xxx_pci_remove(struct pci_dev *pdev)
+{
+       free_irq(pdev->irq, pdev);
+       udc_remove();
+       pci_iounmap(pdev, (__force void __iomem *)pci_get_drvdata(pdev));
+       pci_release_regions(pdev);
+       pci_disable_device(pdev);
+}
+
+/**
+ * PCI device table
+ * PCI device structure
+ *
+ * Check "pci.h" for details
+ */
+static DEFINE_PCI_DEVICE_TABLE(ci13xxx_pci_id_table) = {
+       { PCI_DEVICE(0x153F, 0x1004) },
+       { PCI_DEVICE(0x153F, 0x1006) },
+       { 0, 0, 0, 0, 0, 0, 0 /* end: all zeroes */ }
+};
+MODULE_DEVICE_TABLE(pci, ci13xxx_pci_id_table);
+
+static struct pci_driver ci13xxx_pci_driver = {
+       .name         = UDC_DRIVER_NAME,
+       .id_table     = ci13xxx_pci_id_table,
+       .probe        = ci13xxx_pci_probe,
+       .remove       = __devexit_p(ci13xxx_pci_remove),
+};
+
+/**
+ * ci13xxx_pci_init: module init
+ *
+ * Driver load
+ */
+static int __init ci13xxx_pci_init(void)
+{
+       return pci_register_driver(&ci13xxx_pci_driver);
+}
+module_init(ci13xxx_pci_init);
+
+/**
+ * ci13xxx_pci_exit: module exit
+ *
+ * Driver unload
+ */
+static void __exit ci13xxx_pci_exit(void)
+{
+       pci_unregister_driver(&ci13xxx_pci_driver);
+}
+module_exit(ci13xxx_pci_exit);
+
+MODULE_AUTHOR("MIPS - David Lopo <dlopo@chipidea.mips.com>");
+MODULE_DESCRIPTION("MIPS CI13XXX USB Peripheral Controller");
+MODULE_LICENSE("GPL");
+MODULE_VERSION("June 2008");
index 98b36fc88c77d298bf4f8efb4c9dc2f773f1931a..4e9ec7d256fdca7c1a46efe5f362a9290d48877e 100644 (file)
@@ -22,7 +22,6 @@
  * - ENDPT:  endpoint operations (Gadget API)
  * - GADGET: gadget operations (Gadget API)
  * - BUS:    bus glue code, bus abstraction layer
- * - PCI:    PCI core interface and PCI resources (interrupts, memory...)
  *
  * Compile Options
  * - CONFIG_USB_GADGET_DEBUG_FILES: enable debug facilities
@@ -60,8 +59,6 @@
 #include <linux/io.h>
 #include <linux/irq.h>
 #include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/slab.h>
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
@@ -75,9 +72,6 @@
 /* ctrl register bank access */
 static DEFINE_SPINLOCK(udc_lock);
 
-/* driver name */
-#define UDC_DRIVER_NAME   "ci13xxx_udc"
-
 /* control endpoint description */
 static const struct usb_endpoint_descriptor
 ctrl_endpt_desc = {
@@ -2680,156 +2674,3 @@ static void udc_remove(void)
        kfree(udc);
        _udc = NULL;
 }
-
-/******************************************************************************
- * PCI block
- *****************************************************************************/
-/**
- * ci13xxx_pci_irq: interrut handler
- * @irq:  irq number
- * @pdev: USB Device Controller interrupt source
- *
- * This function returns IRQ_HANDLED if the IRQ has been handled
- * This is an ISR don't trace, use attribute interface instead
- */
-static irqreturn_t ci13xxx_pci_irq(int irq, void *pdev)
-{
-       if (irq == 0) {
-               dev_err(&((struct pci_dev *)pdev)->dev, "Invalid IRQ0 usage!");
-               return IRQ_HANDLED;
-       }
-       return udc_irq();
-}
-
-/**
- * ci13xxx_pci_probe: PCI probe
- * @pdev: USB device controller being probed
- * @id:   PCI hotplug ID connecting controller to UDC framework
- *
- * This function returns an error code
- * Allocates basic PCI resources for this USB device controller, and then
- * invokes the udc_probe() method to start the UDC associated with it
- */
-static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev,
-                                      const struct pci_device_id *id)
-{
-       void __iomem *regs = NULL;
-       int retval = 0;
-
-       if (id == NULL)
-               return -EINVAL;
-
-       retval = pci_enable_device(pdev);
-       if (retval)
-               goto done;
-
-       if (!pdev->irq) {
-               dev_err(&pdev->dev, "No IRQ, check BIOS/PCI setup!");
-               retval = -ENODEV;
-               goto disable_device;
-       }
-
-       retval = pci_request_regions(pdev, UDC_DRIVER_NAME);
-       if (retval)
-               goto disable_device;
-
-       /* BAR 0 holds all the registers */
-       regs = pci_iomap(pdev, 0, 0);
-       if (!regs) {
-               dev_err(&pdev->dev, "Error mapping memory!");
-               retval = -EFAULT;
-               goto release_regions;
-       }
-       pci_set_drvdata(pdev, (__force void *)regs);
-
-       pci_set_master(pdev);
-       pci_try_set_mwi(pdev);
-
-       retval = udc_probe(&pdev->dev, regs, UDC_DRIVER_NAME);
-       if (retval)
-               goto iounmap;
-
-       /* our device does not have MSI capability */
-
-       retval = request_irq(pdev->irq, ci13xxx_pci_irq, IRQF_SHARED,
-                            UDC_DRIVER_NAME, pdev);
-       if (retval)
-               goto gadget_remove;
-
-       return 0;
-
- gadget_remove:
-       udc_remove();
- iounmap:
-       pci_iounmap(pdev, regs);
- release_regions:
-       pci_release_regions(pdev);
- disable_device:
-       pci_disable_device(pdev);
- done:
-       return retval;
-}
-
-/**
- * ci13xxx_pci_remove: PCI remove
- * @pdev: USB Device Controller being removed
- *
- * Reverses the effect of ci13xxx_pci_probe(),
- * first invoking the udc_remove() and then releases
- * all PCI resources allocated for this USB device controller
- */
-static void __devexit ci13xxx_pci_remove(struct pci_dev *pdev)
-{
-       free_irq(pdev->irq, pdev);
-       udc_remove();
-       pci_iounmap(pdev, (__force void __iomem *)pci_get_drvdata(pdev));
-       pci_release_regions(pdev);
-       pci_disable_device(pdev);
-}
-
-/**
- * PCI device table
- * PCI device structure
- *
- * Check "pci.h" for details
- */
-static DEFINE_PCI_DEVICE_TABLE(ci13xxx_pci_id_table) = {
-       { PCI_DEVICE(0x153F, 0x1004) },
-       { PCI_DEVICE(0x153F, 0x1006) },
-       { 0, 0, 0, 0, 0, 0, 0 /* end: all zeroes */ }
-};
-MODULE_DEVICE_TABLE(pci, ci13xxx_pci_id_table);
-
-static struct pci_driver ci13xxx_pci_driver = {
-       .name         = UDC_DRIVER_NAME,
-       .id_table     = ci13xxx_pci_id_table,
-       .probe        = ci13xxx_pci_probe,
-       .remove       = __devexit_p(ci13xxx_pci_remove),
-};
-
-/**
- * ci13xxx_pci_init: module init
- *
- * Driver load
- */
-static int __init ci13xxx_pci_init(void)
-{
-       return pci_register_driver(&ci13xxx_pci_driver);
-}
-module_init(ci13xxx_pci_init);
-
-/**
- * ci13xxx_pci_exit: module exit
- *
- * Driver unload
- */
-static void __exit ci13xxx_pci_exit(void)
-{
-       pci_unregister_driver(&ci13xxx_pci_driver);
-}
-module_exit(ci13xxx_pci_exit);
-
-MODULE_AUTHOR("MIPS - David Lopo <dlopo@chipidea.mips.com>");
-MODULE_DESCRIPTION("MIPS CI13XXX USB Peripheral Controller");
-MODULE_LICENSE("GPL");
-MODULE_VERSION("June 2008");
index d7b3bbe56808828711431a9688b9ffe547300068..3093ebbea731235c3dc701897bde89ef8dae7a17 100644 (file)
 #define gadget_is_fsl_qe(g)    0
 #endif
 
-#ifdef CONFIG_USB_GADGET_CI13XXX
-#define gadget_is_ci13xxx(g)   (!strcmp("ci13xxx_udc", (g)->name))
+#ifdef CONFIG_USB_GADGET_CI13XXX_PCI
+#define gadget_is_ci13xxx_pci(g)       (!strcmp("ci13xxx_pci", (g)->name))
 #else
-#define gadget_is_ci13xxx(g)   0
+#define gadget_is_ci13xxx_pci(g)       0
 #endif
 
 // CONFIG_USB_GADGET_SX2
@@ -197,7 +197,7 @@ static inline int usb_gadget_controller_number(struct usb_gadget *gadget)
                return 0x21;
        else if (gadget_is_fsl_qe(gadget))
                return 0x22;
-       else if (gadget_is_ci13xxx(gadget))
+       else if (gadget_is_ci13xxx_pci(gadget))
                return 0x23;
        else if (gadget_is_langwell(gadget))
                return 0x24;