reset-starfive-jh7100.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Reset driver for the StarFive JH7100 SoC
  4. *
  5. * Copyright (C) 2021 Emil Renner Berthing <kernel@esmil.dk>
  6. */
  7. #include <linux/mod_devicetable.h>
  8. #include <linux/platform_device.h>
  9. #include "reset-starfive-jh71x0.h"
  10. #include <dt-bindings/reset/starfive-jh7100.h>
  11. /* register offsets */
  12. #define JH7100_RESET_ASSERT0 0x00
  13. #define JH7100_RESET_ASSERT1 0x04
  14. #define JH7100_RESET_ASSERT2 0x08
  15. #define JH7100_RESET_ASSERT3 0x0c
  16. #define JH7100_RESET_STATUS0 0x10
  17. #define JH7100_RESET_STATUS1 0x14
  18. #define JH7100_RESET_STATUS2 0x18
  19. #define JH7100_RESET_STATUS3 0x1c
  20. /*
  21. * Writing a 1 to the n'th bit of the m'th ASSERT register asserts
  22. * line 32m + n, and writing a 0 deasserts the same line.
  23. * Most reset lines have their status inverted so a 0 bit in the STATUS
  24. * register means the line is asserted and a 1 means it's deasserted. A few
  25. * lines don't though, so store the expected value of the status registers when
  26. * all lines are asserted.
  27. */
  28. static const u32 jh7100_reset_asserted[4] = {
  29. /* STATUS0 */
  30. BIT(JH7100_RST_U74 % 32) |
  31. BIT(JH7100_RST_VP6_DRESET % 32) |
  32. BIT(JH7100_RST_VP6_BRESET % 32),
  33. /* STATUS1 */
  34. BIT(JH7100_RST_HIFI4_DRESET % 32) |
  35. BIT(JH7100_RST_HIFI4_BRESET % 32),
  36. /* STATUS2 */
  37. BIT(JH7100_RST_E24 % 32),
  38. /* STATUS3 */
  39. 0,
  40. };
  41. static int __init jh7100_reset_probe(struct platform_device *pdev)
  42. {
  43. void __iomem *base = devm_platform_ioremap_resource(pdev, 0);
  44. if (IS_ERR(base))
  45. return PTR_ERR(base);
  46. return reset_starfive_jh71x0_register(&pdev->dev, pdev->dev.of_node,
  47. base + JH7100_RESET_ASSERT0,
  48. base + JH7100_RESET_STATUS0,
  49. jh7100_reset_asserted,
  50. JH7100_RSTN_END,
  51. THIS_MODULE);
  52. }
  53. static const struct of_device_id jh7100_reset_dt_ids[] = {
  54. { .compatible = "starfive,jh7100-reset" },
  55. { /* sentinel */ }
  56. };
  57. static struct platform_driver jh7100_reset_driver = {
  58. .driver = {
  59. .name = "jh7100-reset",
  60. .of_match_table = jh7100_reset_dt_ids,
  61. .suppress_bind_attrs = true,
  62. },
  63. };
  64. builtin_platform_driver_probe(jh7100_reset_driver, jh7100_reset_probe);