Skip to content

Commit

Permalink
usb: cdnsp: fixed issue with incorrect detecting CDNSP family control…
Browse files Browse the repository at this point in the history
…lers

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: [email protected]
Fixes: 3d82904 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver")
Signed-off-by: Pawel Laszczak <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Manuel Diewald <[email protected]>
Signed-off-by: Roxana Nicolescu <[email protected]>
  • Loading branch information
pawellcdns authored and roxanan1996 committed Apr 26, 2024
1 parent ee64cc3 commit c25faac
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
1 change: 0 additions & 1 deletion drivers/usb/cdns3/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ static int cdns_role_set(struct usb_role_switch *sw, enum usb_role role)
return ret;
}


/**
* cdns_wakeup_irq - interrupt handler for wakeup events
* @irq: irq number for cdns3/cdnsp core device
Expand Down
13 changes: 9 additions & 4 deletions drivers/usb/cdns3/drd.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ bool cdns_is_device(struct cdns *cdns)
*/
static void cdns_otg_disable_irq(struct cdns *cdns)
{
writel(0, &cdns->otg_irq_regs->ien);
if (cdns->version)
writel(0, &cdns->otg_irq_regs->ien);
}

/**
Expand Down Expand Up @@ -418,15 +419,20 @@ int cdns_drd_init(struct cdns *cdns)

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

if (readl(&cdns->otg_cdnsp_regs->did) == OTG_CDNSP_DID) {
state = readl(&cdns->otg_cdnsp_regs->did);

if (OTG_CDNSP_CHECK_DID(state)) {
cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
&cdns->otg_cdnsp_regs->ien;
cdns->version = CDNSP_CONTROLLER_V2;
} else {
} else if (OTG_CDNS3_CHECK_DID(state)) {
cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
&cdns->otg_v1_regs->ien;
writel(1, &cdns->otg_v1_regs->simulate);
cdns->version = CDNS3_CONTROLLER_V1;
} else {
dev_err(cdns->dev, "not supporte DID=0x%08x\n", state);
return -EINVAL;
}

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


/* Indicate the cdns3 core was power lost before */
bool cdns_power_is_lost(struct cdns *cdns)
{
Expand Down
6 changes: 5 additions & 1 deletion drivers/usb/cdns3/drd.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ struct cdnsp_otg_regs {
__le32 susp_timing_ctrl;
};

#define OTG_CDNSP_DID 0x0004034E
/* CDNSP driver supports 0x000403xx Cadence USB controller family. */
#define OTG_CDNSP_CHECK_DID(did) (((did) & GENMASK(31, 8)) == 0x00040300)

/* CDNS3 driver supports 0x000402xx Cadence USB controller family. */
#define OTG_CDNS3_CHECK_DID(did) (((did) & GENMASK(31, 8)) == 0x00040200)

/*
* Common registers interface for both CDNS3 and CDNSP version of DRD.
Expand Down

0 comments on commit c25faac

Please sign in to comment.