brcm63xx: rename target to bcm63xx
[openwrt/staging/stintel.git] / target / linux / brcm2708 / patches-4.19 / 950-0428-usb-dwc_otg-Clean-up-interrupt-claiming-code.patch
1 From efb54d0f0445f3d279a7eae7395b566c96d080de Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Tue, 7 May 2019 17:23:41 +0100
4 Subject: [PATCH] usb: dwc_otg: Clean up interrupt claiming code
5
6 The FIQ/IRQ interrupt number identification code is scattered through
7 the dwc_otg driver. Rationalise it, simplifying the code and solving
8 an existing issue.
9
10 See: https://github.com/raspberrypi/linux/issues/2612
11
12 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
13 ---
14 drivers/usb/host/dwc_otg/dwc_otg_driver.c | 18 +++++++++-----
15 drivers/usb/host/dwc_otg/dwc_otg_hcd_linux.c | 10 +++-----
16 drivers/usb/host/dwc_otg/dwc_otg_os_dep.h | 6 +++++
17 drivers/usb/host/dwc_otg/dwc_otg_pcd_linux.c | 26 +++-----------------
18 4 files changed, 25 insertions(+), 35 deletions(-)
19
20 --- a/drivers/usb/host/dwc_otg/dwc_otg_driver.c
21 +++ b/drivers/usb/host/dwc_otg/dwc_otg_driver.c
22 @@ -624,11 +624,7 @@ static int dwc_otg_driver_remove(
23 * Free the IRQ
24 */
25 if (otg_dev->common_irq_installed) {
26 -#ifdef PLATFORM_INTERFACE
27 - free_irq(platform_get_irq(_dev, 0), otg_dev);
28 -#else
29 - free_irq(_dev->irq, otg_dev);
30 -#endif
31 + free_irq(otg_dev->os_dep.irq_num, otg_dev);
32 } else {
33 DWC_DEBUGPL(DBG_ANY, "%s: There is no installed irq!\n", __func__);
34 return REM_RETVAL(-ENXIO);
35 @@ -905,7 +901,9 @@ static int dwc_otg_driver_probe(
36 */
37
38 #if defined(PLATFORM_INTERFACE)
39 - devirq = platform_get_irq(_dev, fiq_enable ? 0 : 1);
40 + devirq = platform_get_irq_byname(_dev, fiq_enable ? "soft" : "usb");
41 + if (devirq < 0)
42 + devirq = platform_get_irq(_dev, fiq_enable ? 0 : 1);
43 #else
44 devirq = _dev->irq;
45 #endif
46 @@ -922,6 +920,14 @@ static int dwc_otg_driver_probe(
47 } else {
48 dwc_otg_device->common_irq_installed = 1;
49 }
50 + dwc_otg_device->os_dep.irq_num = devirq;
51 + dwc_otg_device->os_dep.fiq_num = -EINVAL;
52 + if (fiq_enable) {
53 + int devfiq = platform_get_irq_byname(_dev, "usb");
54 + if (devfiq < 0)
55 + devfiq = platform_get_irq(_dev, 1);
56 + dwc_otg_device->os_dep.fiq_num = devfiq;
57 + }
58
59 #ifndef IRQF_TRIGGER_LOW
60 #if defined(LM_INTERFACE) || defined(PLATFORM_INTERFACE)
61 --- a/drivers/usb/host/dwc_otg/dwc_otg_hcd_linux.c
62 +++ b/drivers/usb/host/dwc_otg/dwc_otg_hcd_linux.c
63 @@ -492,7 +492,7 @@ static void hcd_init_fiq(void *cookie)
64 #endif
65 // Enable FIQ interrupt from USB peripheral
66 #ifdef CONFIG_ARM64
67 - irq = platform_get_irq(otg_dev->os_dep.platformdev, 1);
68 + irq = otg_dev->os_dep.fiq_num;
69
70 if (irq < 0) {
71 DWC_ERROR("Can't get SIM-FIQ irq");
72 @@ -509,7 +509,7 @@ static void hcd_init_fiq(void *cookie)
73 simfiq_irq = irq;
74 #else
75 #ifdef CONFIG_GENERIC_IRQ_MULTI_HANDLER
76 - irq = platform_get_irq(otg_dev->os_dep.platformdev, 1);
77 + irq = otg_dev->os_dep.fiq_num;
78 #else
79 irq = INTERRUPT_VC_USB;
80 #endif
81 @@ -626,11 +626,7 @@ int hcd_init(dwc_bus_dev_t *_dev)
82 * allocates the DMA buffer pool, registers the USB bus, requests the
83 * IRQ line, and calls hcd_start method.
84 */
85 -#ifdef PLATFORM_INTERFACE
86 - retval = usb_add_hcd(hcd, platform_get_irq(_dev, fiq_enable ? 0 : 1), IRQF_SHARED);
87 -#else
88 - retval = usb_add_hcd(hcd, _dev->irq, IRQF_SHARED);
89 -#endif
90 + retval = usb_add_hcd(hcd, otg_dev->os_dep.irq_num, IRQF_SHARED);
91 if (retval < 0) {
92 goto error2;
93 }
94 --- a/drivers/usb/host/dwc_otg/dwc_otg_os_dep.h
95 +++ b/drivers/usb/host/dwc_otg/dwc_otg_os_dep.h
96 @@ -102,6 +102,12 @@ typedef struct os_dependent {
97 /** Base address for MPHI peripheral */
98 void *mphi_base;
99
100 + /** IRQ number (<0 if not valid) */
101 + int irq_num;
102 +
103 + /** FIQ number (<0 if not valid) */
104 + int fiq_num;
105 +
106 #ifdef LM_INTERFACE
107 struct lm_device *lmdev;
108 #elif defined(PCI_INTERFACE)
109 --- a/drivers/usb/host/dwc_otg/dwc_otg_pcd_linux.c
110 +++ b/drivers/usb/host/dwc_otg/dwc_otg_pcd_linux.c
111 @@ -1224,30 +1224,16 @@ int pcd_init(dwc_bus_dev_t *_dev)
112 /*
113 * Setup interupt handler
114 */
115 -#ifdef PLATFORM_INTERFACE
116 DWC_DEBUGPL(DBG_ANY, "registering handler for irq%d\n",
117 - platform_get_irq(_dev, fiq_enable ? 0 : 1));
118 - retval = request_irq(platform_get_irq(_dev, fiq_enable ? 0 : 1), dwc_otg_pcd_irq,
119 + otg_dev->os_dep.irq_num);
120 + retval = request_irq(otg_dev->os_dep.irq_num, dwc_otg_pcd_irq,
121 IRQF_SHARED, gadget_wrapper->gadget.name,
122 otg_dev->pcd);
123 if (retval != 0) {
124 - DWC_ERROR("request of irq%d failed\n",
125 - platform_get_irq(_dev, fiq_enable ? 0 : 1));
126 + DWC_ERROR("request of irq%d failed\n", otg_dev->os_dep.irq_num);
127 free_wrapper(gadget_wrapper);
128 return -EBUSY;
129 }
130 -#else
131 - DWC_DEBUGPL(DBG_ANY, "registering handler for irq%d\n",
132 - _dev->irq);
133 - retval = request_irq(_dev->irq, dwc_otg_pcd_irq,
134 - IRQF_SHARED | IRQF_DISABLED,
135 - gadget_wrapper->gadget.name, otg_dev->pcd);
136 - if (retval != 0) {
137 - DWC_ERROR("request of irq%d failed\n", _dev->irq);
138 - free_wrapper(gadget_wrapper);
139 - return -EBUSY;
140 - }
141 -#endif
142
143 dwc_otg_pcd_start(gadget_wrapper->pcd, &fops);
144
145 @@ -1267,11 +1253,7 @@ void pcd_remove(dwc_bus_dev_t *_dev)
146 /*
147 * Free the IRQ
148 */
149 -#ifdef PLATFORM_INTERFACE
150 - free_irq(platform_get_irq(_dev, 0), pcd);
151 -#else
152 - free_irq(_dev->irq, pcd);
153 -#endif
154 + free_irq(otg_dev->os_dep.irq_num, pcd);
155 dwc_otg_pcd_remove(otg_dev->pcd);
156 free_wrapper(gadget_wrapper);
157 otg_dev->pcd = 0;