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 498/806] usb: dwc_otg: Clean up interrupt claiming code
6 The FIQ/IRQ interrupt number identification code is scattered through
7 the dwc_otg driver. Rationalise it, simplifying the code and solving
10 See: https://github.com/raspberrypi/linux/issues/2612
12 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
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(-)
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(
25 if (otg_dev->common_irq_installed) {
26 -#ifdef PLATFORM_INTERFACE
27 - free_irq(platform_get_irq(_dev, 0), otg_dev);
29 - free_irq(_dev->irq, otg_dev);
31 + free_irq(otg_dev->os_dep.irq_num, otg_dev);
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(
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");
42 + devirq = platform_get_irq(_dev, fiq_enable ? 0 : 1);
46 @@ -922,6 +920,14 @@ static int dwc_otg_driver_probe(
48 dwc_otg_device->common_irq_installed = 1;
50 + dwc_otg_device->os_dep.irq_num = devirq;
51 + dwc_otg_device->os_dep.fiq_num = -EINVAL;
53 + int devfiq = platform_get_irq_byname(_dev, "usb");
55 + devfiq = platform_get_irq(_dev, 1);
56 + dwc_otg_device->os_dep.fiq_num = devfiq;
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)
65 // Enable FIQ interrupt from USB peripheral
67 - irq = platform_get_irq(otg_dev->os_dep.platformdev, 1);
68 + irq = otg_dev->os_dep.fiq_num;
71 DWC_ERROR("Can't get SIM-FIQ irq");
72 @@ -509,7 +509,7 @@ static void hcd_init_fiq(void *cookie)
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;
79 irq = INTERRUPT_VC_USB;
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.
85 -#ifdef PLATFORM_INTERFACE
86 - retval = usb_add_hcd(hcd, platform_get_irq(_dev, fiq_enable ? 0 : 1), IRQF_SHARED);
88 - retval = usb_add_hcd(hcd, _dev->irq, IRQF_SHARED);
90 + retval = usb_add_hcd(hcd, otg_dev->os_dep.irq_num, IRQF_SHARED);
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 */
100 + /** IRQ number (<0 if not valid) */
103 + /** FIQ number (<0 if not valid) */
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)
113 * Setup interupt handler
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,
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);
131 - DWC_DEBUGPL(DBG_ANY, "registering handler for irq%d\n",
133 - retval = request_irq(_dev->irq, dwc_otg_pcd_irq,
134 - IRQF_SHARED | IRQF_DISABLED,
135 - gadget_wrapper->gadget.name, otg_dev->pcd);
137 - DWC_ERROR("request of irq%d failed\n", _dev->irq);
138 - free_wrapper(gadget_wrapper);
143 dwc_otg_pcd_start(gadget_wrapper->pcd, &fops);
145 @@ -1267,11 +1253,7 @@ void pcd_remove(dwc_bus_dev_t *_dev)
149 -#ifdef PLATFORM_INTERFACE
150 - free_irq(platform_get_irq(_dev, 0), pcd);
152 - free_irq(_dev->irq, pcd);
154 + free_irq(otg_dev->os_dep.irq_num, pcd);
155 dwc_otg_pcd_remove(otg_dev->pcd);
156 free_wrapper(gadget_wrapper);