reset-raspberrypi.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Raspberry Pi 4 firmware reset driver
  4. *
  5. * Copyright (C) 2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
  6. */
  7. #include <common.h>
  8. #include <dm.h>
  9. #include <reset-uclass.h>
  10. #include <asm/arch/msg.h>
  11. #include <dt-bindings/reset/raspberrypi,firmware-reset.h>
  12. static int raspberrypi_reset_request(struct reset_ctl *reset_ctl)
  13. {
  14. if (reset_ctl->id >= RASPBERRYPI_FIRMWARE_RESET_NUM_IDS)
  15. return -EINVAL;
  16. return 0;
  17. }
  18. static int raspberrypi_reset_free(struct reset_ctl *reset_ctl)
  19. {
  20. return 0;
  21. }
  22. static int raspberrypi_reset_assert(struct reset_ctl *reset_ctl)
  23. {
  24. switch (reset_ctl->id) {
  25. case RASPBERRYPI_FIRMWARE_RESET_ID_USB:
  26. bcm2711_notify_vl805_reset();
  27. return 0;
  28. default:
  29. return -EINVAL;
  30. }
  31. }
  32. static int raspberrypi_reset_deassert(struct reset_ctl *reset_ctl)
  33. {
  34. return 0;
  35. }
  36. struct reset_ops raspberrypi_reset_ops = {
  37. .request = raspberrypi_reset_request,
  38. .rfree = raspberrypi_reset_free,
  39. .rst_assert = raspberrypi_reset_assert,
  40. .rst_deassert = raspberrypi_reset_deassert,
  41. };
  42. static const struct udevice_id raspberrypi_reset_ids[] = {
  43. { .compatible = "raspberrypi,firmware-reset" },
  44. { }
  45. };
  46. U_BOOT_DRIVER(raspberrypi_reset) = {
  47. .name = "raspberrypi-reset",
  48. .id = UCLASS_RESET,
  49. .of_match = raspberrypi_reset_ids,
  50. .ops = &raspberrypi_reset_ops,
  51. };