From 4eaf7f525a0874a1eff0f5666004896cc5c89fa3 Mon Sep 17 00:00:00 2001 From: Chris Packham Date: Thu, 4 Oct 2018 20:03:53 +1300 Subject: fsl/usb: Workaround for USB erratum-A005275 Workaround makes FS as default mode on all affected socs. Add support to check erratum-A005275 validity for an soc. This info is required to determine whether a given soc is affected by this erratum. Add quirk for this erratum "has_fsl_erratum_a005275" . This quirk is used to enable workaround for the errata Force FS mode as default by: - making EPS as FS - setting PFSC bit to disable HS chirping This workaround can be disabled by mentioning "no_erratum_a005275" in hwconfig string Signed-off-by: Chris Packham Reviewed-by: York Sun --- drivers/usb/host/ehci-fsl.c | 7 +++++++ drivers/usb/host/ehci-hcd.c | 12 +++++++++++- drivers/usb/host/ehci.h | 4 ++++ 3 files changed, 22 insertions(+), 1 deletion(-) (limited to 'drivers/usb/host') diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index a04f6a31c8..a8fb2b8ac3 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c @@ -93,6 +93,7 @@ static int ehci_fsl_probe(struct udevice *dev) struct usb_ehci *ehci = NULL; struct ehci_hccr *hccr; struct ehci_hcor *hcor; + struct ehci_ctrl *ehci_ctrl = &priv->ehci; /* * Get the base address for EHCI controller from the device node @@ -107,6 +108,8 @@ static int ehci_fsl_probe(struct udevice *dev) hcor = (struct ehci_hcor *) ((void *)hccr + HC_LENGTH(ehci_readl(&hccr->cr_capbase))); + ehci_ctrl->has_fsl_erratum_a005275 = has_erratum_a005275(); + if (ehci_fsl_init(priv, ehci, hccr, hcor) < 0) return -ENXIO; @@ -145,6 +148,8 @@ U_BOOT_DRIVER(ehci_fsl) = { int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr, struct ehci_hcor **hcor) { + struct ehci_ctrl *ehci_ctrl = container_of(hccr, + struct ehci_ctrl, hccr); struct usb_ehci *ehci = NULL; switch (index) { @@ -163,6 +168,8 @@ int ehci_hcd_init(int index, enum usb_init_type init, *hcor = (struct ehci_hcor *)((uint32_t) *hccr + HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase))); + ehci_ctrl->has_fsl_erratum_a005275 = has_erratum_a005275(); + return ehci_fsl_init(index, ehci, *hccr, *hcor); } diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 199b3a8b26..d1d8f08d98 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -409,9 +409,15 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, endpt = QH_ENDPT1_RL(8) | QH_ENDPT1_C(c) | QH_ENDPT1_MAXPKTLEN(maxpacket) | QH_ENDPT1_H(0) | QH_ENDPT1_DTC(QH_ENDPT1_DTC_DT_FROM_QTD) | - QH_ENDPT1_EPS(ehci_encode_speed(dev->speed)) | QH_ENDPT1_ENDPT(usb_pipeendpoint(pipe)) | QH_ENDPT1_I(0) | QH_ENDPT1_DEVADDR(usb_pipedevice(pipe)); + + /* Force FS for fsl HS quirk */ + if (!ctrl->has_fsl_erratum_a005275) + endpt |= QH_ENDPT1_EPS(ehci_encode_speed(dev->speed)); + else + endpt |= QH_ENDPT1_EPS(ehci_encode_speed(QH_FULL_SPEED)); + qh->qh_endpt1 = cpu_to_hc32(endpt); endpt = QH_ENDPT2_MULT(1) | QH_ENDPT2_UFCMASK(0) | QH_ENDPT2_UFSMASK(0); qh->qh_endpt2 = cpu_to_hc32(endpt); @@ -832,6 +838,10 @@ static int ehci_submit_root(struct usb_device *dev, unsigned long pipe, } else { int ret; + /* Disable chirp for HS erratum */ + if (ctrl->has_fsl_erratum_a005275) + reg |= PORTSC_FSL_PFSC; + reg |= EHCI_PS_PR; reg &= ~EHCI_PS_PE; ehci_writel(status_reg, reg); diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 7945016624..6c359af90c 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -8,6 +8,7 @@ #ifndef USB_EHCI_H #define USB_EHCI_H +#include #include #include @@ -66,6 +67,8 @@ struct ehci_hcor { #define PORTSC_PSPD_FS 0x0 #define PORTSC_PSPD_LS 0x1 #define PORTSC_PSPD_HS 0x2 +#define PORTSC_FSL_PFSC BIT(24) /* PFSC bit to disable HS chirping */ + uint32_t or_systune; } __attribute__ ((packed, aligned(4))); @@ -251,6 +254,7 @@ struct ehci_ctrl { uint32_t *periodic_list; int periodic_schedules; int ntds; + bool has_fsl_erratum_a005275; /* Freescale HS silicon quirk */ struct ehci_ops ops; void *priv; /* client's private data */ }; -- cgit