generic: 5.10: backport Treat IPv4 segment's lowest address as unicast
[openwrt/openwrt.git] / target / linux / generic / backport-5.10 / 810-v5.13-usb-ehci-add-spurious-flag-to-disable-overcurrent-ch.patch
1 From 2d5ba37461013253d2ff0a3641b727fd32ea97a9 Mon Sep 17 00:00:00 2001
2 From: Florian Fainelli <florian@openwrt.org>
3 Date: Tue, 23 Feb 2021 18:44:53 +0100
4 Subject: [PATCH 1/3] usb: ehci: add spurious flag to disable overcurrent
5 checking
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 This patch adds an ignore_oc flag which can be set by EHCI controller
11 not supporting or wanting to disable overcurrent checking. The EHCI
12 platform data in include/linux/usb/ehci_pdriver.h is also augmented to
13 take advantage of this new flag.
14
15 Signed-off-by: Florian Fainelli <florian@openwrt.org>
16 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
17 Link: https://lore.kernel.org/r/20210223174455.1378-2-noltari@gmail.com
18 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19 ---
20 drivers/usb/host/ehci-hcd.c | 2 +-
21 drivers/usb/host/ehci-hub.c | 4 ++--
22 drivers/usb/host/ehci-platform.c | 2 ++
23 drivers/usb/host/ehci.h | 1 +
24 include/linux/usb/ehci_pdriver.h | 1 +
25 5 files changed, 7 insertions(+), 3 deletions(-)
26
27 --- a/drivers/usb/host/ehci-hcd.c
28 +++ b/drivers/usb/host/ehci-hcd.c
29 @@ -660,7 +660,7 @@ static int ehci_run (struct usb_hcd *hcd
30 "USB %x.%x started, EHCI %x.%02x%s\n",
31 ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f),
32 temp >> 8, temp & 0xff,
33 - ignore_oc ? ", overcurrent ignored" : "");
34 + (ignore_oc || ehci->spurious_oc) ? ", overcurrent ignored" : "");
35
36 ehci_writel(ehci, INTR_MASK,
37 &ehci->regs->intr_enable); /* Turn On Interrupts */
38 --- a/drivers/usb/host/ehci-hub.c
39 +++ b/drivers/usb/host/ehci-hub.c
40 @@ -643,7 +643,7 @@ ehci_hub_status_data (struct usb_hcd *hc
41 * always set, seem to clear PORT_OCC and PORT_CSC when writing to
42 * PORT_POWER; that's surprising, but maybe within-spec.
43 */
44 - if (!ignore_oc)
45 + if (!ignore_oc && !ehci->spurious_oc)
46 mask = PORT_CSC | PORT_PEC | PORT_OCC;
47 else
48 mask = PORT_CSC | PORT_PEC;
49 @@ -1013,7 +1013,7 @@ int ehci_hub_control(
50 if (temp & PORT_PEC)
51 status |= USB_PORT_STAT_C_ENABLE << 16;
52
53 - if ((temp & PORT_OCC) && !ignore_oc){
54 + if ((temp & PORT_OCC) && (!ignore_oc && !ehci->spurious_oc)){
55 status |= USB_PORT_STAT_C_OVERCURRENT << 16;
56
57 /*
58 --- a/drivers/usb/host/ehci-platform.c
59 +++ b/drivers/usb/host/ehci-platform.c
60 @@ -333,6 +333,8 @@ static int ehci_platform_probe(struct pl
61 hcd->has_tt = 1;
62 if (pdata->reset_on_resume)
63 priv->reset_on_resume = true;
64 + if (pdata->spurious_oc)
65 + ehci->spurious_oc = 1;
66
67 #ifndef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO
68 if (ehci->big_endian_mmio) {
69 --- a/drivers/usb/host/ehci.h
70 +++ b/drivers/usb/host/ehci.h
71 @@ -219,6 +219,7 @@ struct ehci_hcd { /* one per controlle
72 unsigned need_oc_pp_cycle:1; /* MPC834X port power */
73 unsigned imx28_write_fix:1; /* For Freescale i.MX28 */
74 unsigned is_aspeed:1;
75 + unsigned spurious_oc:1;
76
77 /* required for usb32 quirk */
78 #define OHCI_CTRL_HCFS (3 << 6)
79 --- a/include/linux/usb/ehci_pdriver.h
80 +++ b/include/linux/usb/ehci_pdriver.h
81 @@ -50,6 +50,7 @@ struct usb_ehci_pdata {
82 unsigned no_io_watchdog:1;
83 unsigned reset_on_resume:1;
84 unsigned dma_mask_64:1;
85 + unsigned spurious_oc:1;
86
87 /* Turn on all power and clocks */
88 int (*power_on)(struct platform_device *pdev);