1022-reset-starfive-Add-JH7100-audio-reset-driver.patch 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. From ff806bda9b04bcf73350e319f3efde5cd049b77a Mon Sep 17 00:00:00 2001
  2. From: Emil Renner Berthing <[email protected]>
  3. Date: Sat, 20 Nov 2021 19:30:49 +0100
  4. Subject: [PATCH 1022/1024] reset: starfive: Add JH7100 audio reset driver
  5. The audio resets are almost identical to the system resets, there are
  6. just fewer of them. So factor out and export a generic probe function,
  7. so most of the reset controller implementation can be shared.
  8. Signed-off-by: Emil Renner Berthing <[email protected]>
  9. ---
  10. MAINTAINERS | 2 +-
  11. drivers/reset/starfive/Kconfig | 7 ++
  12. drivers/reset/starfive/Makefile | 2 +
  13. .../starfive/reset-starfive-jh7100-audio.c | 66 +++++++++++++++++++
  14. .../reset/starfive/reset-starfive-jh7100.h | 16 +++++
  15. 5 files changed, 92 insertions(+), 1 deletion(-)
  16. create mode 100644 drivers/reset/starfive/reset-starfive-jh7100-audio.c
  17. create mode 100644 drivers/reset/starfive/reset-starfive-jh7100.h
  18. --- a/MAINTAINERS
  19. +++ b/MAINTAINERS
  20. @@ -19711,7 +19711,7 @@ STARFIVE JH71X0 RESET CONTROLLER DRIVERS
  21. M: Emil Renner Berthing <[email protected]>
  22. M: Hal Feng <[email protected]>
  23. S: Maintained
  24. -F: Documentation/devicetree/bindings/reset/starfive,jh7100-reset.yaml
  25. +F: Documentation/devicetree/bindings/reset/starfive,jh7100-*.yaml
  26. F: drivers/reset/starfive/reset-starfive-jh71*
  27. F: include/dt-bindings/reset/starfive?jh71*.h
  28. --- a/drivers/reset/starfive/Kconfig
  29. +++ b/drivers/reset/starfive/Kconfig
  30. @@ -11,6 +11,13 @@ config RESET_STARFIVE_JH7100
  31. help
  32. This enables the reset controller driver for the StarFive JH7100 SoC.
  33. +config RESET_STARFIVE_JH7100_AUDIO
  34. + tristate "StarFive JH7100 Audio Reset Driver"
  35. + depends on RESET_STARFIVE_JH7100
  36. + default m if SOC_STARFIVE
  37. + help
  38. + This enables the audio reset driver for the StarFive JH7100 SoC.
  39. +
  40. config RESET_STARFIVE_JH7110
  41. bool "StarFive JH7110 Reset Driver"
  42. depends on AUXILIARY_BUS && CLK_STARFIVE_JH7110_SYS
  43. --- a/drivers/reset/starfive/Makefile
  44. +++ b/drivers/reset/starfive/Makefile
  45. @@ -2,4 +2,6 @@
  46. obj-$(CONFIG_RESET_STARFIVE_JH71X0) += reset-starfive-jh71x0.o
  47. obj-$(CONFIG_RESET_STARFIVE_JH7100) += reset-starfive-jh7100.o
  48. +obj-$(CONFIG_RESET_STARFIVE_JH7100_AUDIO) += reset-starfive-jh7100-audio.o
  49. +
  50. obj-$(CONFIG_RESET_STARFIVE_JH7110) += reset-starfive-jh7110.o
  51. --- /dev/null
  52. +++ b/drivers/reset/starfive/reset-starfive-jh7100-audio.c
  53. @@ -0,0 +1,66 @@
  54. +// SPDX-License-Identifier: GPL-2.0-or-later
  55. +/*
  56. + * Audio reset driver for the StarFive JH7100 SoC
  57. + *
  58. + * Copyright (C) 2021 Emil Renner Berthing <[email protected]>
  59. + */
  60. +
  61. +#include <linux/mod_devicetable.h>
  62. +#include <linux/module.h>
  63. +#include <linux/platform_device.h>
  64. +
  65. +#include "reset-starfive-jh71x0.h"
  66. +
  67. +#include <dt-bindings/reset/starfive-jh7100-audio.h>
  68. +
  69. +/* register offsets */
  70. +#define JH7100_AUDRST_ASSERT0 0x00
  71. +#define JH7100_AUDRST_STATUS0 0x04
  72. +
  73. +/*
  74. + * Writing a 1 to the n'th bit of the ASSERT register asserts
  75. + * line n, and writing a 0 deasserts the same line.
  76. + * Most reset lines have their status inverted so a 0 bit in the STATUS
  77. + * register means the line is asserted and a 1 means it's deasserted. A few
  78. + * lines don't though, so store the expected value of the status registers when
  79. + * all lines are asserted.
  80. + */
  81. +static const u32 jh7100_audrst_asserted[1] = {
  82. + BIT(JH7100_AUDRST_USB_AXI) |
  83. + BIT(JH7100_AUDRST_USB_PWRUP_RST_N) |
  84. + BIT(JH7100_AUDRST_USB_PONRST)
  85. +};
  86. +
  87. +static int jh7100_audrst_probe(struct platform_device *pdev)
  88. +{
  89. + void __iomem *base = devm_platform_ioremap_resource(pdev, 0);
  90. +
  91. + if (IS_ERR(base))
  92. + return PTR_ERR(base);
  93. +
  94. + return reset_starfive_jh71x0_register(&pdev->dev, pdev->dev.of_node,
  95. + base + JH7100_AUDRST_ASSERT0,
  96. + base + JH7100_AUDRST_STATUS0,
  97. + jh7100_audrst_asserted,
  98. + JH7100_AUDRSTN_END,
  99. + THIS_MODULE);
  100. +}
  101. +
  102. +static const struct of_device_id jh7100_audrst_dt_ids[] = {
  103. + { .compatible = "starfive,jh7100-audrst" },
  104. + { /* sentinel */ }
  105. +};
  106. +MODULE_DEVICE_TABLE(of, jh7100_audrst_dt_ids);
  107. +
  108. +static struct platform_driver jh7100_audrst_driver = {
  109. + .probe = jh7100_audrst_probe,
  110. + .driver = {
  111. + .name = "jh7100-reset-audio",
  112. + .of_match_table = jh7100_audrst_dt_ids,
  113. + },
  114. +};
  115. +module_platform_driver(jh7100_audrst_driver);
  116. +
  117. +MODULE_AUTHOR("Emil Renner Berthing");
  118. +MODULE_DESCRIPTION("StarFive JH7100 audio reset driver");
  119. +MODULE_LICENSE("GPL");
  120. --- /dev/null
  121. +++ b/drivers/reset/starfive/reset-starfive-jh7100.h
  122. @@ -0,0 +1,16 @@
  123. +// SPDX-License-Identifier: GPL-2.0-or-later
  124. +/*
  125. + * Copyright (C) 2021 Emil Renner Berthing <[email protected]>
  126. + */
  127. +
  128. +#ifndef _RESET_STARFIVE_JH7100_H_
  129. +#define _RESET_STARFIVE_JH7100_H_
  130. +
  131. +#include <linux/platform_device.h>
  132. +
  133. +int reset_starfive_jh7100_generic_probe(struct platform_device *pdev,
  134. + const u32 *asserted,
  135. + unsigned int status_offset,
  136. + unsigned int nr_resets);
  137. +
  138. +#endif