034-v6.7-usb-dwc3-add-optional-PHY-interface-clocks.patch 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. From 97789b93b792fc97ad4476b79e0f38ffa8e7e0ee Mon Sep 17 00:00:00 2001
  2. From: Sebastian Reichel <[email protected]>
  3. Date: Fri, 20 Oct 2023 16:11:41 +0200
  4. Subject: [PATCH] usb: dwc3: add optional PHY interface clocks
  5. On Rockchip RK3588 one of the DWC3 cores is integrated weirdly and
  6. requires two extra clocks to be enabled. Without these extra clocks
  7. hot-plugging USB devices is broken.
  8. Signed-off-by: Sebastian Reichel <[email protected]>
  9. Acked-by: Thinh Nguyen <[email protected]>
  10. Link: https://lore.kernel.org/r/[email protected]
  11. Signed-off-by: Greg Kroah-Hartman <[email protected]>
  12. ---
  13. drivers/usb/dwc3/core.c | 28 ++++++++++++++++++++++++++++
  14. drivers/usb/dwc3/core.h | 4 ++++
  15. 2 files changed, 32 insertions(+)
  16. --- a/drivers/usb/dwc3/core.c
  17. +++ b/drivers/usb/dwc3/core.c
  18. @@ -845,8 +845,20 @@ static int dwc3_clk_enable(struct dwc3 *
  19. if (ret)
  20. goto disable_ref_clk;
  21. + ret = clk_prepare_enable(dwc->utmi_clk);
  22. + if (ret)
  23. + goto disable_susp_clk;
  24. +
  25. + ret = clk_prepare_enable(dwc->pipe_clk);
  26. + if (ret)
  27. + goto disable_utmi_clk;
  28. +
  29. return 0;
  30. +disable_utmi_clk:
  31. + clk_disable_unprepare(dwc->utmi_clk);
  32. +disable_susp_clk:
  33. + clk_disable_unprepare(dwc->susp_clk);
  34. disable_ref_clk:
  35. clk_disable_unprepare(dwc->ref_clk);
  36. disable_bus_clk:
  37. @@ -856,6 +868,8 @@ disable_bus_clk:
  38. static void dwc3_clk_disable(struct dwc3 *dwc)
  39. {
  40. + clk_disable_unprepare(dwc->pipe_clk);
  41. + clk_disable_unprepare(dwc->utmi_clk);
  42. clk_disable_unprepare(dwc->susp_clk);
  43. clk_disable_unprepare(dwc->ref_clk);
  44. clk_disable_unprepare(dwc->bus_clk);
  45. @@ -1884,6 +1898,20 @@ static int dwc3_get_clocks(struct dwc3 *
  46. }
  47. }
  48. + /* specific to Rockchip RK3588 */
  49. + dwc->utmi_clk = devm_clk_get_optional(dev, "utmi");
  50. + if (IS_ERR(dwc->utmi_clk)) {
  51. + return dev_err_probe(dev, PTR_ERR(dwc->utmi_clk),
  52. + "could not get utmi clock\n");
  53. + }
  54. +
  55. + /* specific to Rockchip RK3588 */
  56. + dwc->pipe_clk = devm_clk_get_optional(dev, "pipe");
  57. + if (IS_ERR(dwc->pipe_clk)) {
  58. + return dev_err_probe(dev, PTR_ERR(dwc->pipe_clk),
  59. + "could not get pipe clock\n");
  60. + }
  61. +
  62. return 0;
  63. }
  64. --- a/drivers/usb/dwc3/core.h
  65. +++ b/drivers/usb/dwc3/core.h
  66. @@ -1003,6 +1003,8 @@ struct dwc3_scratchpad_array {
  67. * @bus_clk: clock for accessing the registers
  68. * @ref_clk: reference clock
  69. * @susp_clk: clock used when the SS phy is in low power (S3) state
  70. + * @utmi_clk: clock used for USB2 PHY communication
  71. + * @pipe_clk: clock used for USB3 PHY communication
  72. * @reset: reset control
  73. * @regs: base address for our registers
  74. * @regs_size: address space size
  75. @@ -1175,6 +1177,8 @@ struct dwc3 {
  76. struct clk *bus_clk;
  77. struct clk *ref_clk;
  78. struct clk *susp_clk;
  79. + struct clk *utmi_clk;
  80. + struct clk *pipe_clk;
  81. struct reset_control *reset;