]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
usb: ehci: add spurious flag to disable overcurrent checking
authorFlorian Fainelli <florian@openwrt.org>
Tue, 23 Feb 2021 17:44:53 +0000 (18:44 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 23 Mar 2021 11:36:17 +0000 (12:36 +0100)
This patch adds an ignore_oc flag which can be set by EHCI controller
not supporting or wanting to disable overcurrent checking. The EHCI
platform data in include/linux/usb/ehci_pdriver.h is also augmented to
take advantage of this new flag.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Link: https://lore.kernel.org/r/20210223174455.1378-2-noltari@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/ehci-hcd.c
drivers/usb/host/ehci-hub.c
drivers/usb/host/ehci-platform.c
drivers/usb/host/ehci.h
include/linux/usb/ehci_pdriver.h

index 1926b328b6aa7a2e5a7726561cd44ae111f40d76..2237d22d292a3ee12e3ecdae3d7a1f0bbc77707c 100644 (file)
@@ -651,7 +651,7 @@ static int ehci_run (struct usb_hcd *hcd)
                "USB %x.%x started, EHCI %x.%02x%s\n",
                ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f),
                temp >> 8, temp & 0xff,
-               ignore_oc ? ", overcurrent ignored" : "");
+               (ignore_oc || ehci->spurious_oc) ? ", overcurrent ignored" : "");
 
        ehci_writel(ehci, INTR_MASK,
                    &ehci->regs->intr_enable); /* Turn On Interrupts */
index 9f9ab5ccea889df6e8aebf630d941a1c82c392c8..159cc27b1a362beeecb35ba3755bea8bc427b963 100644 (file)
@@ -643,7 +643,7 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf)
         * always set, seem to clear PORT_OCC and PORT_CSC when writing to
         * PORT_POWER; that's surprising, but maybe within-spec.
         */
-       if (!ignore_oc)
+       if (!ignore_oc && !ehci->spurious_oc)
                mask = PORT_CSC | PORT_PEC | PORT_OCC;
        else
                mask = PORT_CSC | PORT_PEC;
@@ -1013,7 +1013,7 @@ int ehci_hub_control(
                if (temp & PORT_PEC)
                        status |= USB_PORT_STAT_C_ENABLE << 16;
 
-               if ((temp & PORT_OCC) && !ignore_oc){
+               if ((temp & PORT_OCC) && (!ignore_oc && !ehci->spurious_oc)){
                        status |= USB_PORT_STAT_C_OVERCURRENT << 16;
 
                        /*
index a48dd3fac15373e6287242bc43c26a7fade3f7cf..4d7b17f4f82bfcbd1767a209307f709cee8dc479 100644 (file)
@@ -327,6 +327,8 @@ static int ehci_platform_probe(struct platform_device *dev)
                hcd->has_tt = 1;
        if (pdata->reset_on_resume)
                priv->reset_on_resume = true;
+       if (pdata->spurious_oc)
+               ehci->spurious_oc = 1;
 
 #ifndef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO
        if (ehci->big_endian_mmio) {
index eabf22a78eae037ca51d7041d7d8ea42b2e07e42..80bb823aa9fe8fe3fb49c4d6e6ffe5c7fd744e7f 100644 (file)
@@ -218,6 +218,7 @@ struct ehci_hcd {                   /* one per controller */
        unsigned                frame_index_bug:1; /* MosChip (AKA NetMos) */
        unsigned                need_oc_pp_cycle:1; /* MPC834X port power */
        unsigned                imx28_write_fix:1; /* For Freescale i.MX28 */
+       unsigned                spurious_oc:1;
 
        /* required for usb32 quirk */
        #define OHCI_CTRL_HCFS          (3 << 6)
index dd742afdc03fa8a84959fc006020e0aef8b42064..89fc901e778fd8baf22030e1cdb9a6031ab1d3d2 100644 (file)
@@ -50,6 +50,7 @@ struct usb_ehci_pdata {
        unsigned        no_io_watchdog:1;
        unsigned        reset_on_resume:1;
        unsigned        dma_mask_64:1;
+       unsigned        spurious_oc:1;
 
        /* Turn on all power and clocks */
        int (*power_on)(struct platform_device *pdev);