reset-raspberrypi.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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_assert(struct reset_ctl *reset_ctl)
  19. {
  20. switch (reset_ctl->id) {
  21. case RASPBERRYPI_FIRMWARE_RESET_ID_USB:
  22. bcm2711_notify_vl805_reset();
  23. return 0;
  24. default:
  25. return -EINVAL;
  26. }
  27. }
  28. struct reset_ops raspberrypi_reset_ops = {
  29. .request = raspberrypi_reset_request,
  30. .rst_assert = raspberrypi_reset_assert,
  31. };
  32. static const struct udevice_id raspberrypi_reset_ids[] = {
  33. { .compatible = "raspberrypi,firmware-reset" },
  34. { }
  35. };
  36. U_BOOT_DRIVER(raspberrypi_reset) = {
  37. .name = "raspberrypi-reset",
  38. .id = UCLASS_RESET,
  39. .of_match = raspberrypi_reset_ids,
  40. .ops = &raspberrypi_reset_ops,
  41. };