aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorPavankumar Kondeti <pkondeti@codeaurora.org>2010-12-07 07:23:59 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-12-10 17:23:32 -0500
commit409a15da9851b6e6a5e1c5787be31a987184b7cf (patch)
treeade8d523b7c9b04a48523ebc4a39b8d3401918ad /drivers/usb
parent87c0104af742af2acfcbd685f2b9a40f33770dc0 (diff)
USB: gadget: Separate out PCI bus code from ci13xxx_udc
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>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/Kconfig8
-rw-r--r--drivers/usb/gadget/Makefile2
-rw-r--r--drivers/usb/gadget/ci13xxx_pci.c172
-rw-r--r--drivers/usb/gadget/ci13xxx_udc.c159
-rw-r--r--drivers/usb/gadget/gadget_chips.h8
5 files changed, 181 insertions, 168 deletions
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 23fac3857477..6bcbcb073e56 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -427,8 +427,8 @@ config USB_FSL_QE
427 default USB_GADGET 427 default USB_GADGET
428 select USB_GADGET_SELECTED 428 select USB_GADGET_SELECTED
429 429
430config USB_GADGET_CI13XXX 430config USB_GADGET_CI13XXX_PCI
431 boolean "MIPS USB CI13xxx" 431 boolean "MIPS USB CI13xxx PCI UDC"
432 depends on PCI 432 depends on PCI
433 select USB_GADGET_DUALSPEED 433 select USB_GADGET_DUALSPEED
434 help 434 help
@@ -439,9 +439,9 @@ config USB_GADGET_CI13XXX
439 dynamically linked module called "ci13xxx_udc" and force all 439 dynamically linked module called "ci13xxx_udc" and force all
440 gadget drivers to also be dynamically linked. 440 gadget drivers to also be dynamically linked.
441 441
442config USB_CI13XXX 442config USB_CI13XXX_PCI
443 tristate 443 tristate
444 depends on USB_GADGET_CI13XXX 444 depends on USB_GADGET_CI13XXX_PCI
445 default USB_GADGET 445 default USB_GADGET
446 select USB_GADGET_SELECTED 446 select USB_GADGET_SELECTED
447 447
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index a3e6b90c11d7..f53fda7c2558 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -21,7 +21,7 @@ fsl_usb2_udc-$(CONFIG_ARCH_MXC) += fsl_mxc_udc.o
21obj-$(CONFIG_USB_M66592) += m66592-udc.o 21obj-$(CONFIG_USB_M66592) += m66592-udc.o
22obj-$(CONFIG_USB_R8A66597) += r8a66597-udc.o 22obj-$(CONFIG_USB_R8A66597) += r8a66597-udc.o
23obj-$(CONFIG_USB_FSL_QE) += fsl_qe_udc.o 23obj-$(CONFIG_USB_FSL_QE) += fsl_qe_udc.o
24obj-$(CONFIG_USB_CI13XXX) += ci13xxx_udc.o 24obj-$(CONFIG_USB_CI13XXX_PCI) += ci13xxx_pci.o
25obj-$(CONFIG_USB_S3C_HSOTG) += s3c-hsotg.o 25obj-$(CONFIG_USB_S3C_HSOTG) += s3c-hsotg.o
26obj-$(CONFIG_USB_LANGWELL) += langwell_udc.o 26obj-$(CONFIG_USB_LANGWELL) += langwell_udc.o
27obj-$(CONFIG_USB_EG20T) += pch_udc.o 27obj-$(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
index 000000000000..7a0f153e33c0
--- /dev/null
+++ b/drivers/usb/gadget/ci13xxx_pci.c
@@ -0,0 +1,172 @@
1/*
2 * ci13xxx_pci.c - MIPS USB IP core family device controller
3 *
4 * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved.
5 *
6 * Author: David Lopo
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/module.h>
14#include <linux/pci.h>
15
16#include "ci13xxx_udc.c"
17
18/* driver name */
19#define UDC_DRIVER_NAME "ci13xxx_pci"
20
21/******************************************************************************
22 * PCI block
23 *****************************************************************************/
24/**
25 * ci13xxx_pci_irq: interrut handler
26 * @irq: irq number
27 * @pdev: USB Device Controller interrupt source
28 *
29 * This function returns IRQ_HANDLED if the IRQ has been handled
30 * This is an ISR don't trace, use attribute interface instead
31 */
32static irqreturn_t ci13xxx_pci_irq(int irq, void *pdev)
33{
34 if (irq == 0) {
35 dev_err(&((struct pci_dev *)pdev)->dev, "Invalid IRQ0 usage!");
36 return IRQ_HANDLED;
37 }
38 return udc_irq();
39}
40
41/**
42 * ci13xxx_pci_probe: PCI probe
43 * @pdev: USB device controller being probed
44 * @id: PCI hotplug ID connecting controller to UDC framework
45 *
46 * This function returns an error code
47 * Allocates basic PCI resources for this USB device controller, and then
48 * invokes the udc_probe() method to start the UDC associated with it
49 */
50static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev,
51 const struct pci_device_id *id)
52{
53 void __iomem *regs = NULL;
54 int retval = 0;
55
56 if (id == NULL)
57 return -EINVAL;
58
59 retval = pci_enable_device(pdev);
60 if (retval)
61 goto done;
62
63 if (!pdev->irq) {
64 dev_err(&pdev->dev, "No IRQ, check BIOS/PCI setup!");
65 retval = -ENODEV;
66 goto disable_device;
67 }
68
69 retval = pci_request_regions(pdev, UDC_DRIVER_NAME);
70 if (retval)
71 goto disable_device;
72
73 /* BAR 0 holds all the registers */
74 regs = pci_iomap(pdev, 0, 0);
75 if (!regs) {
76 dev_err(&pdev->dev, "Error mapping memory!");
77 retval = -EFAULT;
78 goto release_regions;
79 }
80 pci_set_drvdata(pdev, (__force void *)regs);
81
82 pci_set_master(pdev);
83 pci_try_set_mwi(pdev);
84
85 retval = udc_probe(&pdev->dev, regs, UDC_DRIVER_NAME);
86 if (retval)
87 goto iounmap;
88
89 /* our device does not have MSI capability */
90
91 retval = request_irq(pdev->irq, ci13xxx_pci_irq, IRQF_SHARED,
92 UDC_DRIVER_NAME, pdev);
93 if (retval)
94 goto gadget_remove;
95
96 return 0;
97
98 gadget_remove:
99 udc_remove();
100 iounmap:
101 pci_iounmap(pdev, regs);
102 release_regions:
103 pci_release_regions(pdev);
104 disable_device:
105 pci_disable_device(pdev);
106 done:
107 return retval;
108}
109
110/**
111 * ci13xxx_pci_remove: PCI remove
112 * @pdev: USB Device Controller being removed
113 *
114 * Reverses the effect of ci13xxx_pci_probe(),
115 * first invoking the udc_remove() and then releases
116 * all PCI resources allocated for this USB device controller
117 */
118static void __devexit ci13xxx_pci_remove(struct pci_dev *pdev)
119{
120 free_irq(pdev->irq, pdev);
121 udc_remove();
122 pci_iounmap(pdev, (__force void __iomem *)pci_get_drvdata(pdev));
123 pci_release_regions(pdev);
124 pci_disable_device(pdev);
125}
126
127/**
128 * PCI device table
129 * PCI device structure
130 *
131 * Check "pci.h" for details
132 */
133static DEFINE_PCI_DEVICE_TABLE(ci13xxx_pci_id_table) = {
134 { PCI_DEVICE(0x153F, 0x1004) },
135 { PCI_DEVICE(0x153F, 0x1006) },
136 { 0, 0, 0, 0, 0, 0, 0 /* end: all zeroes */ }
137};
138MODULE_DEVICE_TABLE(pci, ci13xxx_pci_id_table);
139
140static struct pci_driver ci13xxx_pci_driver = {
141 .name = UDC_DRIVER_NAME,
142 .id_table = ci13xxx_pci_id_table,
143 .probe = ci13xxx_pci_probe,
144 .remove = __devexit_p(ci13xxx_pci_remove),
145};
146
147/**
148 * ci13xxx_pci_init: module init
149 *
150 * Driver load
151 */
152static int __init ci13xxx_pci_init(void)
153{
154 return pci_register_driver(&ci13xxx_pci_driver);
155}
156module_init(ci13xxx_pci_init);
157
158/**
159 * ci13xxx_pci_exit: module exit
160 *
161 * Driver unload
162 */
163static void __exit ci13xxx_pci_exit(void)
164{
165 pci_unregister_driver(&ci13xxx_pci_driver);
166}
167module_exit(ci13xxx_pci_exit);
168
169MODULE_AUTHOR("MIPS - David Lopo <dlopo@chipidea.mips.com>");
170MODULE_DESCRIPTION("MIPS CI13XXX USB Peripheral Controller");
171MODULE_LICENSE("GPL");
172MODULE_VERSION("June 2008");
diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c
index 98b36fc88c77..4e9ec7d256fd 100644
--- a/drivers/usb/gadget/ci13xxx_udc.c
+++ b/drivers/usb/gadget/ci13xxx_udc.c
@@ -22,7 +22,6 @@
22 * - ENDPT: endpoint operations (Gadget API) 22 * - ENDPT: endpoint operations (Gadget API)
23 * - GADGET: gadget operations (Gadget API) 23 * - GADGET: gadget operations (Gadget API)
24 * - BUS: bus glue code, bus abstraction layer 24 * - BUS: bus glue code, bus abstraction layer
25 * - PCI: PCI core interface and PCI resources (interrupts, memory...)
26 * 25 *
27 * Compile Options 26 * Compile Options
28 * - CONFIG_USB_GADGET_DEBUG_FILES: enable debug facilities 27 * - CONFIG_USB_GADGET_DEBUG_FILES: enable debug facilities
@@ -60,8 +59,6 @@
60#include <linux/io.h> 59#include <linux/io.h>
61#include <linux/irq.h> 60#include <linux/irq.h>
62#include <linux/kernel.h> 61#include <linux/kernel.h>
63#include <linux/module.h>
64#include <linux/pci.h>
65#include <linux/slab.h> 62#include <linux/slab.h>
66#include <linux/usb/ch9.h> 63#include <linux/usb/ch9.h>
67#include <linux/usb/gadget.h> 64#include <linux/usb/gadget.h>
@@ -75,9 +72,6 @@
75/* ctrl register bank access */ 72/* ctrl register bank access */
76static DEFINE_SPINLOCK(udc_lock); 73static DEFINE_SPINLOCK(udc_lock);
77 74
78/* driver name */
79#define UDC_DRIVER_NAME "ci13xxx_udc"
80
81/* control endpoint description */ 75/* control endpoint description */
82static const struct usb_endpoint_descriptor 76static const struct usb_endpoint_descriptor
83ctrl_endpt_desc = { 77ctrl_endpt_desc = {
@@ -2680,156 +2674,3 @@ static void udc_remove(void)
2680 kfree(udc); 2674 kfree(udc);
2681 _udc = NULL; 2675 _udc = NULL;
2682} 2676}
2683
2684/******************************************************************************
2685 * PCI block
2686 *****************************************************************************/
2687/**
2688 * ci13xxx_pci_irq: interrut handler
2689 * @irq: irq number
2690 * @pdev: USB Device Controller interrupt source
2691 *
2692 * This function returns IRQ_HANDLED if the IRQ has been handled
2693 * This is an ISR don't trace, use attribute interface instead
2694 */
2695static irqreturn_t ci13xxx_pci_irq(int irq, void *pdev)
2696{
2697 if (irq == 0) {
2698 dev_err(&((struct pci_dev *)pdev)->dev, "Invalid IRQ0 usage!");
2699 return IRQ_HANDLED;
2700 }
2701 return udc_irq();
2702}
2703
2704/**
2705 * ci13xxx_pci_probe: PCI probe
2706 * @pdev: USB device controller being probed
2707 * @id: PCI hotplug ID connecting controller to UDC framework
2708 *
2709 * This function returns an error code
2710 * Allocates basic PCI resources for this USB device controller, and then
2711 * invokes the udc_probe() method to start the UDC associated with it
2712 */
2713static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev,
2714 const struct pci_device_id *id)
2715{
2716 void __iomem *regs = NULL;
2717 int retval = 0;
2718
2719 if (id == NULL)
2720 return -EINVAL;
2721
2722 retval = pci_enable_device(pdev);
2723 if (retval)
2724 goto done;
2725
2726 if (!pdev->irq) {
2727 dev_err(&pdev->dev, "No IRQ, check BIOS/PCI setup!");
2728 retval = -ENODEV;
2729 goto disable_device;
2730 }
2731
2732 retval = pci_request_regions(pdev, UDC_DRIVER_NAME);
2733 if (retval)
2734 goto disable_device;
2735
2736 /* BAR 0 holds all the registers */
2737 regs = pci_iomap(pdev, 0, 0);
2738 if (!regs) {
2739 dev_err(&pdev->dev, "Error mapping memory!");
2740 retval = -EFAULT;
2741 goto release_regions;
2742 }
2743 pci_set_drvdata(pdev, (__force void *)regs);
2744
2745 pci_set_master(pdev);
2746 pci_try_set_mwi(pdev);
2747
2748 retval = udc_probe(&pdev->dev, regs, UDC_DRIVER_NAME);
2749 if (retval)
2750 goto iounmap;
2751
2752 /* our device does not have MSI capability */
2753
2754 retval = request_irq(pdev->irq, ci13xxx_pci_irq, IRQF_SHARED,
2755 UDC_DRIVER_NAME, pdev);
2756 if (retval)
2757 goto gadget_remove;
2758
2759 return 0;
2760
2761 gadget_remove:
2762 udc_remove();
2763 iounmap:
2764 pci_iounmap(pdev, regs);
2765 release_regions:
2766 pci_release_regions(pdev);
2767 disable_device:
2768 pci_disable_device(pdev);
2769 done:
2770 return retval;
2771}
2772
2773/**
2774 * ci13xxx_pci_remove: PCI remove
2775 * @pdev: USB Device Controller being removed
2776 *
2777 * Reverses the effect of ci13xxx_pci_probe(),
2778 * first invoking the udc_remove() and then releases
2779 * all PCI resources allocated for this USB device controller
2780 */
2781static void __devexit ci13xxx_pci_remove(struct pci_dev *pdev)
2782{
2783 free_irq(pdev->irq, pdev);
2784 udc_remove();
2785 pci_iounmap(pdev, (__force void __iomem *)pci_get_drvdata(pdev));
2786 pci_release_regions(pdev);
2787 pci_disable_device(pdev);
2788}
2789
2790/**
2791 * PCI device table
2792 * PCI device structure
2793 *
2794 * Check "pci.h" for details
2795 */
2796static DEFINE_PCI_DEVICE_TABLE(ci13xxx_pci_id_table) = {
2797 { PCI_DEVICE(0x153F, 0x1004) },
2798 { PCI_DEVICE(0x153F, 0x1006) },
2799 { 0, 0, 0, 0, 0, 0, 0 /* end: all zeroes */ }
2800};
2801MODULE_DEVICE_TABLE(pci, ci13xxx_pci_id_table);
2802
2803static struct pci_driver ci13xxx_pci_driver = {
2804 .name = UDC_DRIVER_NAME,
2805 .id_table = ci13xxx_pci_id_table,
2806 .probe = ci13xxx_pci_probe,
2807 .remove = __devexit_p(ci13xxx_pci_remove),
2808};
2809
2810/**
2811 * ci13xxx_pci_init: module init
2812 *
2813 * Driver load
2814 */
2815static int __init ci13xxx_pci_init(void)
2816{
2817 return pci_register_driver(&ci13xxx_pci_driver);
2818}
2819module_init(ci13xxx_pci_init);
2820
2821/**
2822 * ci13xxx_pci_exit: module exit
2823 *
2824 * Driver unload
2825 */
2826static void __exit ci13xxx_pci_exit(void)
2827{
2828 pci_unregister_driver(&ci13xxx_pci_driver);
2829}
2830module_exit(ci13xxx_pci_exit);
2831
2832MODULE_AUTHOR("MIPS - David Lopo <dlopo@chipidea.mips.com>");
2833MODULE_DESCRIPTION("MIPS CI13XXX USB Peripheral Controller");
2834MODULE_LICENSE("GPL");
2835MODULE_VERSION("June 2008");
diff --git a/drivers/usb/gadget/gadget_chips.h b/drivers/usb/gadget/gadget_chips.h
index d7b3bbe56808..3093ebbea731 100644
--- a/drivers/usb/gadget/gadget_chips.h
+++ b/drivers/usb/gadget/gadget_chips.h
@@ -120,10 +120,10 @@
120#define gadget_is_fsl_qe(g) 0 120#define gadget_is_fsl_qe(g) 0
121#endif 121#endif
122 122
123#ifdef CONFIG_USB_GADGET_CI13XXX 123#ifdef CONFIG_USB_GADGET_CI13XXX_PCI
124#define gadget_is_ci13xxx(g) (!strcmp("ci13xxx_udc", (g)->name)) 124#define gadget_is_ci13xxx_pci(g) (!strcmp("ci13xxx_pci", (g)->name))
125#else 125#else
126#define gadget_is_ci13xxx(g) 0 126#define gadget_is_ci13xxx_pci(g) 0
127#endif 127#endif
128 128
129// CONFIG_USB_GADGET_SX2 129// CONFIG_USB_GADGET_SX2
@@ -197,7 +197,7 @@ static inline int usb_gadget_controller_number(struct usb_gadget *gadget)
197 return 0x21; 197 return 0x21;
198 else if (gadget_is_fsl_qe(gadget)) 198 else if (gadget_is_fsl_qe(gadget))
199 return 0x22; 199 return 0x22;
200 else if (gadget_is_ci13xxx(gadget)) 200 else if (gadget_is_ci13xxx_pci(gadget))
201 return 0x23; 201 return 0x23;
202 else if (gadget_is_langwell(gadget)) 202 else if (gadget_is_langwell(gadget))
203 return 0x24; 203 return 0x24;