tegra186-reset.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 <log.h>
  8. #include <malloc.h>
  9. #include <misc.h>
  10. #include <reset-uclass.h>
  11. #include <asm/arch-tegra/bpmp_abi.h>
  12. static int tegra186_reset_common(struct reset_ctl *reset_ctl,
  13. enum mrq_reset_commands cmd)
  14. {
  15. struct mrq_reset_request req;
  16. int ret;
  17. req.cmd = cmd;
  18. req.reset_id = reset_ctl->id;
  19. ret = misc_call(reset_ctl->dev->parent, MRQ_RESET, &req, sizeof(req),
  20. NULL, 0);
  21. if (ret < 0)
  22. return ret;
  23. return 0;
  24. }
  25. static int tegra186_reset_assert(struct reset_ctl *reset_ctl)
  26. {
  27. debug("%s(reset_ctl=%p) (dev=%p, id=%lu)\n", __func__, reset_ctl,
  28. reset_ctl->dev, reset_ctl->id);
  29. return tegra186_reset_common(reset_ctl, CMD_RESET_ASSERT);
  30. }
  31. static int tegra186_reset_deassert(struct reset_ctl *reset_ctl)
  32. {
  33. debug("%s(reset_ctl=%p) (dev=%p, id=%lu)\n", __func__, reset_ctl,
  34. reset_ctl->dev, reset_ctl->id);
  35. return tegra186_reset_common(reset_ctl, CMD_RESET_DEASSERT);
  36. }
  37. struct reset_ops tegra186_reset_ops = {
  38. .rst_assert = tegra186_reset_assert,
  39. .rst_deassert = tegra186_reset_deassert,
  40. };
  41. U_BOOT_DRIVER(tegra186_reset) = {
  42. .name = "tegra186_reset",
  43. .id = UCLASS_RESET,
  44. .ops = &tegra186_reset_ops,
  45. };