sandbox-reset.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2016, NVIDIA CORPORATION.
  4. */
  5. #include <common.h>
  6. #include <dm.h>
  7. #include <reset-uclass.h>
  8. #include <asm/io.h>
  9. #include <asm/reset.h>
  10. #define SANDBOX_RESET_SIGNALS 101
  11. struct sandbox_reset_signal {
  12. bool asserted;
  13. };
  14. struct sandbox_reset {
  15. struct sandbox_reset_signal signals[SANDBOX_RESET_SIGNALS];
  16. };
  17. static int sandbox_reset_request(struct reset_ctl *reset_ctl)
  18. {
  19. debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
  20. if (reset_ctl->id >= SANDBOX_RESET_SIGNALS)
  21. return -EINVAL;
  22. return 0;
  23. }
  24. static int sandbox_reset_free(struct reset_ctl *reset_ctl)
  25. {
  26. debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
  27. return 0;
  28. }
  29. static int sandbox_reset_assert(struct reset_ctl *reset_ctl)
  30. {
  31. struct sandbox_reset *sbr = dev_get_priv(reset_ctl->dev);
  32. debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
  33. sbr->signals[reset_ctl->id].asserted = true;
  34. return 0;
  35. }
  36. static int sandbox_reset_deassert(struct reset_ctl *reset_ctl)
  37. {
  38. struct sandbox_reset *sbr = dev_get_priv(reset_ctl->dev);
  39. debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
  40. sbr->signals[reset_ctl->id].asserted = false;
  41. return 0;
  42. }
  43. static int sandbox_reset_bind(struct udevice *dev)
  44. {
  45. debug("%s(dev=%p)\n", __func__, dev);
  46. return 0;
  47. }
  48. static int sandbox_reset_probe(struct udevice *dev)
  49. {
  50. debug("%s(dev=%p)\n", __func__, dev);
  51. return 0;
  52. }
  53. static const struct udevice_id sandbox_reset_ids[] = {
  54. { .compatible = "sandbox,reset-ctl" },
  55. { }
  56. };
  57. struct reset_ops sandbox_reset_reset_ops = {
  58. .request = sandbox_reset_request,
  59. .free = sandbox_reset_free,
  60. .rst_assert = sandbox_reset_assert,
  61. .rst_deassert = sandbox_reset_deassert,
  62. };
  63. U_BOOT_DRIVER(sandbox_reset) = {
  64. .name = "sandbox_reset",
  65. .id = UCLASS_RESET,
  66. .of_match = sandbox_reset_ids,
  67. .bind = sandbox_reset_bind,
  68. .probe = sandbox_reset_probe,
  69. .priv_auto_alloc_size = sizeof(struct sandbox_reset),
  70. .ops = &sandbox_reset_reset_ops,
  71. };
  72. int sandbox_reset_query(struct udevice *dev, unsigned long id)
  73. {
  74. struct sandbox_reset *sbr = dev_get_priv(dev);
  75. debug("%s(dev=%p, id=%ld)\n", __func__, dev, id);
  76. if (id >= SANDBOX_RESET_SIGNALS)
  77. return -EINVAL;
  78. return sbr->signals[id].asserted;
  79. }