1
0

490-usb-ehci-add-quirks-for-qca-socs.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. --- a/drivers/usb/host/ehci-hcd.c
  2. +++ b/drivers/usb/host/ehci-hcd.c
  3. @@ -253,6 +253,37 @@ int ehci_reset(struct ehci_hcd *ehci)
  4. command |= CMD_RESET;
  5. dbg_cmd (ehci, "reset", command);
  6. ehci_writel(ehci, command, &ehci->regs->command);
  7. +
  8. + if (ehci->qca_force_host_mode) {
  9. + u32 usbmode;
  10. +
  11. + udelay(1000);
  12. +
  13. + usbmode = ehci_readl(ehci, &ehci->regs->usbmode);
  14. + usbmode |= USBMODE_CM_HC | (1 << 4);
  15. + ehci_writel(ehci, usbmode, &ehci->regs->usbmode);
  16. +
  17. + ehci_dbg(ehci, "forced host mode, usbmode: %08x\n",
  18. + ehci_readl(ehci, &ehci->regs->usbmode));
  19. + }
  20. +
  21. + if (ehci->qca_force_16bit_ptw) {
  22. + u32 port_status;
  23. +
  24. + udelay(1000);
  25. +
  26. + /* enable 16-bit UTMI interface */
  27. + port_status = ehci_readl(ehci, &ehci->regs->port_status[0]);
  28. + port_status |= BIT(28);
  29. + ehci_writel(ehci, port_status, &ehci->regs->port_status[0]);
  30. +
  31. + ehci_dbg(ehci, "16-bit UTMI interface enabled, status: %08x\n",
  32. + ehci_readl(ehci, &ehci->regs->port_status[0]));
  33. + }
  34. +
  35. + if (ehci->reset_notifier)
  36. + ehci->reset_notifier(ehci_to_hcd(ehci));
  37. +
  38. ehci->rh_state = EHCI_RH_HALTED;
  39. ehci->next_statechange = jiffies;
  40. retval = ehci_handshake(ehci, &ehci->regs->command,
  41. --- a/drivers/usb/host/ehci.h
  42. +++ b/drivers/usb/host/ehci.h
  43. @@ -232,6 +232,10 @@ struct ehci_hcd { /* one per controlle
  44. unsigned need_oc_pp_cycle:1; /* MPC834X port power */
  45. unsigned imx28_write_fix:1; /* For Freescale i.MX28 */
  46. unsigned ignore_oc:1;
  47. + unsigned qca_force_host_mode:1;
  48. + unsigned qca_force_16bit_ptw:1; /* force 16 bit UTMI */
  49. +
  50. + void (*reset_notifier)(struct usb_hcd *hcd);
  51. /* required for usb32 quirk */
  52. #define OHCI_CTRL_HCFS (3 << 6)
  53. --- a/include/linux/usb/ehci_pdriver.h
  54. +++ b/include/linux/usb/ehci_pdriver.h
  55. @@ -50,6 +50,8 @@ struct usb_ehci_pdata {
  56. unsigned reset_on_resume:1;
  57. unsigned dma_mask_64:1;
  58. unsigned ignore_oc:1;
  59. + unsigned qca_force_host_mode:1;
  60. + unsigned qca_force_16bit_ptw:1;
  61. /* Turn on all power and clocks */
  62. int (*power_on)(struct platform_device *pdev);
  63. @@ -59,6 +61,7 @@ struct usb_ehci_pdata {
  64. * turn off everything else */
  65. void (*power_suspend)(struct platform_device *pdev);
  66. int (*pre_setup)(struct usb_hcd *hcd);
  67. + void (*reset_notifier)(struct platform_device *pdev);
  68. };
  69. #endif /* __USB_CORE_EHCI_PDRIVER_H */
  70. --- a/drivers/usb/host/ehci-platform.c
  71. +++ b/drivers/usb/host/ehci-platform.c
  72. @@ -53,6 +53,14 @@ struct ehci_platform_priv {
  73. static const char hcd_name[] = "ehci-platform";
  74. +static void ehci_platform_reset_notifier(struct usb_hcd *hcd)
  75. +{
  76. + struct platform_device *pdev = to_platform_device(hcd->self.controller);
  77. + struct usb_ehci_pdata *pdata = pdev->dev.platform_data;
  78. +
  79. + pdata->reset_notifier(pdev);
  80. +}
  81. +
  82. static int ehci_platform_reset(struct usb_hcd *hcd)
  83. {
  84. struct platform_device *pdev = to_platform_device(hcd->self.controller);
  85. @@ -270,6 +278,13 @@ static int ehci_platform_probe(struct pl
  86. priv->reset_on_resume = true;
  87. if (pdata->ignore_oc)
  88. ehci->ignore_oc = 1;
  89. + if (pdata->qca_force_host_mode)
  90. + ehci->qca_force_host_mode = 1;
  91. + if (pdata->qca_force_16bit_ptw)
  92. + ehci->qca_force_16bit_ptw = 1;
  93. +
  94. + if (pdata->reset_notifier)
  95. + ehci->reset_notifier = ehci_platform_reset_notifier;
  96. #ifndef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO
  97. if (ehci->big_endian_mmio) {