reset-meson-aux.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
  2. /*
  3. * Amlogic Meson Reset Auxiliary driver
  4. *
  5. * Copyright (c) 2024 BayLibre, SAS.
  6. * Author: Jerome Brunet <jbrunet@baylibre.com>
  7. */
  8. #include <linux/err.h>
  9. #include <linux/module.h>
  10. #include <linux/auxiliary_bus.h>
  11. #include <linux/regmap.h>
  12. #include <linux/reset-controller.h>
  13. #include "reset-meson.h"
  14. static const struct meson_reset_param meson_a1_audio_param = {
  15. .reset_ops = &meson_reset_toggle_ops,
  16. .reset_num = 32,
  17. .level_offset = 0x28,
  18. };
  19. static const struct meson_reset_param meson_a1_audio_vad_param = {
  20. .reset_ops = &meson_reset_toggle_ops,
  21. .reset_num = 6,
  22. .level_offset = 0x8,
  23. };
  24. static const struct meson_reset_param meson_g12a_audio_param = {
  25. .reset_ops = &meson_reset_toggle_ops,
  26. .reset_num = 26,
  27. .level_offset = 0x24,
  28. };
  29. static const struct meson_reset_param meson_sm1_audio_param = {
  30. .reset_ops = &meson_reset_toggle_ops,
  31. .reset_num = 39,
  32. .level_offset = 0x28,
  33. };
  34. static const struct auxiliary_device_id meson_reset_aux_ids[] = {
  35. {
  36. .name = "a1-audio-clkc.rst-a1",
  37. .driver_data = (kernel_ulong_t)&meson_a1_audio_param,
  38. }, {
  39. .name = "a1-audio-clkc.rst-a1-vad",
  40. .driver_data = (kernel_ulong_t)&meson_a1_audio_vad_param,
  41. }, {
  42. .name = "axg-audio-clkc.rst-g12a",
  43. .driver_data = (kernel_ulong_t)&meson_g12a_audio_param,
  44. }, {
  45. .name = "axg-audio-clkc.rst-sm1",
  46. .driver_data = (kernel_ulong_t)&meson_sm1_audio_param,
  47. }, {}
  48. };
  49. MODULE_DEVICE_TABLE(auxiliary, meson_reset_aux_ids);
  50. static int meson_reset_aux_probe(struct auxiliary_device *adev,
  51. const struct auxiliary_device_id *id)
  52. {
  53. const struct meson_reset_param *param =
  54. (const struct meson_reset_param *)(id->driver_data);
  55. struct regmap *map;
  56. map = dev_get_regmap(adev->dev.parent, NULL);
  57. if (!map)
  58. return -EINVAL;
  59. return meson_reset_controller_register(&adev->dev, map, param);
  60. }
  61. static struct auxiliary_driver meson_reset_aux_driver = {
  62. .probe = meson_reset_aux_probe,
  63. .id_table = meson_reset_aux_ids,
  64. };
  65. module_auxiliary_driver(meson_reset_aux_driver);
  66. MODULE_DESCRIPTION("Amlogic Meson Reset Auxiliary driver");
  67. MODULE_AUTHOR("Jerome Brunet <jbrunet@baylibre.com>");
  68. MODULE_LICENSE("Dual BSD/GPL");
  69. MODULE_IMPORT_NS("MESON_RESET");