Skip to content

Commit c25faac

Browse files
pawellcdnsroxanan1996
authored andcommitted
usb: cdnsp: fixed issue with incorrect detecting CDNSP family controllers
BugLink: https://bugs.launchpad.net/bugs/2060142 commit 47625b0 upstream. 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> Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com> Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
1 parent ee64cc3 commit c25faac

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
@@ -394,7 +394,6 @@ static int cdns_role_set(struct usb_role_switch *sw, enum usb_role role)
394394
return ret;
395395
}
396396

397-
398397
/**
399398
* cdns_wakeup_irq - interrupt handler for wakeup events
400399
* @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
/**
@@ -418,15 +419,20 @@ int cdns_drd_init(struct cdns *cdns)
418419

419420
cdns->otg_regs = (void __iomem *)&cdns->otg_v1_regs->cmd;
420421

421-
if (readl(&cdns->otg_cdnsp_regs->did) == OTG_CDNSP_DID) {
422+
state = readl(&cdns->otg_cdnsp_regs->did);
423+
424+
if (OTG_CDNSP_CHECK_DID(state)) {
422425
cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
423426
&cdns->otg_cdnsp_regs->ien;
424427
cdns->version = CDNSP_CONTROLLER_V2;
425-
} else {
428+
} else if (OTG_CDNS3_CHECK_DID(state)) {
426429
cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
427430
&cdns->otg_v1_regs->ien;
428431
writel(1, &cdns->otg_v1_regs->simulate);
429432
cdns->version = CDNS3_CONTROLLER_V1;
433+
} else {
434+
dev_err(cdns->dev, "not supporte DID=0x%08x\n", state);
435+
return -EINVAL;
430436
}
431437

432438
dev_dbg(cdns->dev, "DRD version v1 (ID: %08x, rev: %08x)\n",
@@ -479,7 +485,6 @@ int cdns_drd_exit(struct cdns *cdns)
479485
return 0;
480486
}
481487

482-
483488
/* Indicate the cdns3 core was power lost before */
484489
bool cdns_power_is_lost(struct cdns *cdns)
485490
{

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)