810-v5.13-usb-ehci-add-spurious-flag-to-disable-overcurrent-ch.patch 3.2 KB

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