reset-starfive-jh7110.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Reset driver for the StarFive JH7110 SoC
  4. *
  5. * Copyright (C) 2022 StarFive Technology Co., Ltd.
  6. */
  7. #include <linux/auxiliary_bus.h>
  8. #include <soc/starfive/reset-starfive-jh71x0.h>
  9. #include "reset-starfive-jh71x0.h"
  10. #include <dt-bindings/reset/starfive,jh7110-crg.h>
  11. struct jh7110_reset_info {
  12. unsigned int nr_resets;
  13. unsigned int assert_offset;
  14. unsigned int status_offset;
  15. };
  16. static const struct jh7110_reset_info jh7110_sys_info = {
  17. .nr_resets = JH7110_SYSRST_END,
  18. .assert_offset = 0x2F8,
  19. .status_offset = 0x308,
  20. };
  21. static const struct jh7110_reset_info jh7110_aon_info = {
  22. .nr_resets = JH7110_AONRST_END,
  23. .assert_offset = 0x38,
  24. .status_offset = 0x3C,
  25. };
  26. static const struct jh7110_reset_info jh7110_stg_info = {
  27. .nr_resets = JH7110_STGRST_END,
  28. .assert_offset = 0x74,
  29. .status_offset = 0x78,
  30. };
  31. static const struct jh7110_reset_info jh7110_isp_info = {
  32. .nr_resets = JH7110_ISPRST_END,
  33. .assert_offset = 0x38,
  34. .status_offset = 0x3C,
  35. };
  36. static const struct jh7110_reset_info jh7110_vout_info = {
  37. .nr_resets = JH7110_VOUTRST_END,
  38. .assert_offset = 0x48,
  39. .status_offset = 0x4C,
  40. };
  41. static int jh7110_reset_probe(struct auxiliary_device *adev,
  42. const struct auxiliary_device_id *id)
  43. {
  44. struct jh7110_reset_info *info = (struct jh7110_reset_info *)(id->driver_data);
  45. struct jh71x0_reset_adev *rdev = to_jh71x0_reset_adev(adev);
  46. void __iomem *base = rdev->base;
  47. if (!info || !base)
  48. return -ENODEV;
  49. return reset_starfive_jh71x0_register(&adev->dev, adev->dev.parent->of_node,
  50. base + info->assert_offset,
  51. base + info->status_offset,
  52. NULL,
  53. info->nr_resets,
  54. NULL);
  55. }
  56. static const struct auxiliary_device_id jh7110_reset_ids[] = {
  57. {
  58. .name = "clk_starfive_jh7110_sys.rst-sys",
  59. .driver_data = (kernel_ulong_t)&jh7110_sys_info,
  60. },
  61. {
  62. .name = "clk_starfive_jh7110_sys.rst-aon",
  63. .driver_data = (kernel_ulong_t)&jh7110_aon_info,
  64. },
  65. {
  66. .name = "clk_starfive_jh7110_sys.rst-stg",
  67. .driver_data = (kernel_ulong_t)&jh7110_stg_info,
  68. },
  69. {
  70. .name = "clk_starfive_jh7110_sys.rst-isp",
  71. .driver_data = (kernel_ulong_t)&jh7110_isp_info,
  72. },
  73. {
  74. .name = "clk_starfive_jh7110_sys.rst-vo",
  75. .driver_data = (kernel_ulong_t)&jh7110_vout_info,
  76. },
  77. { /* sentinel */ }
  78. };
  79. MODULE_DEVICE_TABLE(auxiliary, jh7110_reset_ids);
  80. static struct auxiliary_driver jh7110_reset_driver = {
  81. .probe = jh7110_reset_probe,
  82. .id_table = jh7110_reset_ids,
  83. };
  84. module_auxiliary_driver(jh7110_reset_driver);
  85. MODULE_AUTHOR("Hal Feng <hal.feng@starfivetech.com>");
  86. MODULE_DESCRIPTION("StarFive JH7110 reset driver");
  87. MODULE_LICENSE("GPL");