Skip to content

Commit 17fd0be

Browse files
Phil ElwellTiejunChina
Phil Elwell
authored andcommitted
usb: dwc_otg: Clean up interrupt claiming code
The FIQ/IRQ interrupt number identification code is scattered through the dwc_otg driver. Rationalise it, simplifying the code and solving an existing issue. See: #2612 Signed-off-by: Phil Elwell <[email protected]>
1 parent b73959a commit 17fd0be

File tree

4 files changed

+25
-35
lines changed

4 files changed

+25
-35
lines changed

drivers/usb/host/dwc_otg/dwc_otg_driver.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -624,11 +624,7 @@ static int dwc_otg_driver_remove( struct platform_device *_dev )
624624
* Free the IRQ
625625
*/
626626
if (otg_dev->common_irq_installed) {
627-
#ifdef PLATFORM_INTERFACE
628-
free_irq(platform_get_irq(_dev, 0), otg_dev);
629-
#else
630-
free_irq(_dev->irq, otg_dev);
631-
#endif
627+
free_irq(otg_dev->os_dep.irq_num, otg_dev);
632628
} else {
633629
DWC_DEBUGPL(DBG_ANY, "%s: There is no installed irq!\n", __func__);
634630
return REM_RETVAL(-ENXIO);
@@ -905,7 +901,9 @@ static int dwc_otg_driver_probe(
905901
*/
906902

907903
#if defined(PLATFORM_INTERFACE)
908-
devirq = platform_get_irq(_dev, fiq_enable ? 0 : 1);
904+
devirq = platform_get_irq_byname(_dev, fiq_enable ? "soft" : "usb");
905+
if (devirq < 0)
906+
devirq = platform_get_irq(_dev, fiq_enable ? 0 : 1);
909907
#else
910908
devirq = _dev->irq;
911909
#endif
@@ -922,6 +920,14 @@ static int dwc_otg_driver_probe(
922920
} else {
923921
dwc_otg_device->common_irq_installed = 1;
924922
}
923+
dwc_otg_device->os_dep.irq_num = devirq;
924+
dwc_otg_device->os_dep.fiq_num = -EINVAL;
925+
if (fiq_enable) {
926+
int devfiq = platform_get_irq_byname(_dev, "usb");
927+
if (devfiq < 0)
928+
devfiq = platform_get_irq(_dev, 1);
929+
dwc_otg_device->os_dep.fiq_num = devfiq;
930+
}
925931

926932
#ifndef IRQF_TRIGGER_LOW
927933
#if defined(LM_INTERFACE) || defined(PLATFORM_INTERFACE)

drivers/usb/host/dwc_otg/dwc_otg_hcd_linux.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ static void hcd_init_fiq(void *cookie)
492492
#endif
493493
// Enable FIQ interrupt from USB peripheral
494494
#ifdef CONFIG_ARM64
495-
irq = platform_get_irq(otg_dev->os_dep.platformdev, 1);
495+
irq = otg_dev->os_dep.fiq_num;
496496

497497
if (irq < 0) {
498498
DWC_ERROR("Can't get SIM-FIQ irq");
@@ -509,7 +509,7 @@ static void hcd_init_fiq(void *cookie)
509509
simfiq_irq = irq;
510510
#else
511511
#ifdef CONFIG_GENERIC_IRQ_MULTI_HANDLER
512-
irq = platform_get_irq(otg_dev->os_dep.platformdev, 1);
512+
irq = otg_dev->os_dep.fiq_num;
513513
#else
514514
irq = INTERRUPT_VC_USB;
515515
#endif
@@ -626,11 +626,7 @@ int hcd_init(dwc_bus_dev_t *_dev)
626626
* allocates the DMA buffer pool, registers the USB bus, requests the
627627
* IRQ line, and calls hcd_start method.
628628
*/
629-
#ifdef PLATFORM_INTERFACE
630-
retval = usb_add_hcd(hcd, platform_get_irq(_dev, fiq_enable ? 0 : 1), IRQF_SHARED);
631-
#else
632-
retval = usb_add_hcd(hcd, _dev->irq, IRQF_SHARED);
633-
#endif
629+
retval = usb_add_hcd(hcd, otg_dev->os_dep.irq_num, IRQF_SHARED);
634630
if (retval < 0) {
635631
goto error2;
636632
}

drivers/usb/host/dwc_otg/dwc_otg_os_dep.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ typedef struct os_dependent {
102102
/** Base address for MPHI peripheral */
103103
void *mphi_base;
104104

105+
/** IRQ number (<0 if not valid) */
106+
int irq_num;
107+
108+
/** FIQ number (<0 if not valid) */
109+
int fiq_num;
110+
105111
#ifdef LM_INTERFACE
106112
struct lm_device *lmdev;
107113
#elif defined(PCI_INTERFACE)

drivers/usb/host/dwc_otg/dwc_otg_pcd_linux.c

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,30 +1224,16 @@ int pcd_init(dwc_bus_dev_t *_dev)
12241224
/*
12251225
* Setup interupt handler
12261226
*/
1227-
#ifdef PLATFORM_INTERFACE
12281227
DWC_DEBUGPL(DBG_ANY, "registering handler for irq%d\n",
1229-
platform_get_irq(_dev, fiq_enable ? 0 : 1));
1230-
retval = request_irq(platform_get_irq(_dev, fiq_enable ? 0 : 1), dwc_otg_pcd_irq,
1228+
otg_dev->os_dep.irq_num);
1229+
retval = request_irq(otg_dev->os_dep.irq_num, dwc_otg_pcd_irq,
12311230
IRQF_SHARED, gadget_wrapper->gadget.name,
12321231
otg_dev->pcd);
12331232
if (retval != 0) {
1234-
DWC_ERROR("request of irq%d failed\n",
1235-
platform_get_irq(_dev, fiq_enable ? 0 : 1));
1233+
DWC_ERROR("request of irq%d failed\n", otg_dev->os_dep.irq_num);
12361234
free_wrapper(gadget_wrapper);
12371235
return -EBUSY;
12381236
}
1239-
#else
1240-
DWC_DEBUGPL(DBG_ANY, "registering handler for irq%d\n",
1241-
_dev->irq);
1242-
retval = request_irq(_dev->irq, dwc_otg_pcd_irq,
1243-
IRQF_SHARED | IRQF_DISABLED,
1244-
gadget_wrapper->gadget.name, otg_dev->pcd);
1245-
if (retval != 0) {
1246-
DWC_ERROR("request of irq%d failed\n", _dev->irq);
1247-
free_wrapper(gadget_wrapper);
1248-
return -EBUSY;
1249-
}
1250-
#endif
12511237

12521238
dwc_otg_pcd_start(gadget_wrapper->pcd, &fops);
12531239

@@ -1267,11 +1253,7 @@ void pcd_remove(dwc_bus_dev_t *_dev)
12671253
/*
12681254
* Free the IRQ
12691255
*/
1270-
#ifdef PLATFORM_INTERFACE
1271-
free_irq(platform_get_irq(_dev, 0), pcd);
1272-
#else
1273-
free_irq(_dev->irq, pcd);
1274-
#endif
1256+
free_irq(otg_dev->os_dep.irq_num, pcd);
12751257
dwc_otg_pcd_remove(otg_dev->pcd);
12761258
free_wrapper(gadget_wrapper);
12771259
otg_dev->pcd = 0;

0 commit comments

Comments
 (0)