Skip to content

Commit 47625b0

Browse files
pawellcdnsgregkh
authored andcommitted
usb: cdnsp: fixed issue with incorrect detecting CDNSP family controllers
Cadence have several controllers from 0x000403xx family but current driver suuport detecting only one with DID equal 0x0004034E. It causes that if someone uses different CDNSP controller then driver will use incorrect version and register space. Patch fix this issue. cc: stable@vger.kernel.org Fixes: 3d82904 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver") Signed-off-by: Pawel Laszczak <pawell@cadence.com> Link: https://lore.kernel.org/r/20240215121609.259772-1-pawell@cadence.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 18a6be6 commit 47625b0

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

drivers/usb/cdns3/core.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,6 @@ static int cdns_role_set(struct usb_role_switch *sw, enum usb_role role)
395395
return ret;
396396
}
397397

398-
399398
/**
400399
* cdns_wakeup_irq - interrupt handler for wakeup events
401400
* @irq: irq number for cdns3/cdnsp core device

drivers/usb/cdns3/drd.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ bool cdns_is_device(struct cdns *cdns)
156156
*/
157157
static void cdns_otg_disable_irq(struct cdns *cdns)
158158
{
159-
writel(0, &cdns->otg_irq_regs->ien);
159+
if (cdns->version)
160+
writel(0, &cdns->otg_irq_regs->ien);
160161
}
161162

162163
/**
@@ -422,15 +423,20 @@ int cdns_drd_init(struct cdns *cdns)
422423

423424
cdns->otg_regs = (void __iomem *)&cdns->otg_v1_regs->cmd;
424425

425-
if (readl(&cdns->otg_cdnsp_regs->did) == OTG_CDNSP_DID) {
426+
state = readl(&cdns->otg_cdnsp_regs->did);
427+
428+
if (OTG_CDNSP_CHECK_DID(state)) {
426429
cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
427430
&cdns->otg_cdnsp_regs->ien;
428431
cdns->version = CDNSP_CONTROLLER_V2;
429-
} else {
432+
} else if (OTG_CDNS3_CHECK_DID(state)) {
430433
cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
431434
&cdns->otg_v1_regs->ien;
432435
writel(1, &cdns->otg_v1_regs->simulate);
433436
cdns->version = CDNS3_CONTROLLER_V1;
437+
} else {
438+
dev_err(cdns->dev, "not supporte DID=0x%08x\n", state);
439+
return -EINVAL;
434440
}
435441

436442
dev_dbg(cdns->dev, "DRD version v1 (ID: %08x, rev: %08x)\n",
@@ -483,7 +489,6 @@ int cdns_drd_exit(struct cdns *cdns)
483489
return 0;
484490
}
485491

486-
487492
/* Indicate the cdns3 core was power lost before */
488493
bool cdns_power_is_lost(struct cdns *cdns)
489494
{

drivers/usb/cdns3/drd.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ struct cdnsp_otg_regs {
7979
__le32 susp_timing_ctrl;
8080
};
8181

82-
#define OTG_CDNSP_DID 0x0004034E
82+
/* CDNSP driver supports 0x000403xx Cadence USB controller family. */
83+
#define OTG_CDNSP_CHECK_DID(did) (((did) & GENMASK(31, 8)) == 0x00040300)
84+
85+
/* CDNS3 driver supports 0x000402xx Cadence USB controller family. */
86+
#define OTG_CDNS3_CHECK_DID(did) (((did) & GENMASK(31, 8)) == 0x00040200)
8387

8488
/*
8589
* Common registers interface for both CDNS3 and CDNSP version of DRD.

0 commit comments

Comments
 (0)