reset_cros.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2022, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <arch_helpers.h>
  8. #include <common/debug.h>
  9. #include <drivers/gpio.h>
  10. #include <lib/mtk_init/mtk_init.h>
  11. #include <lib/pm/mtk_pm.h>
  12. #include <plat_params.h>
  13. #include <pmic.h>
  14. #include <rtc.h>
  15. static void __dead2 mtk_system_reset_cros(void)
  16. {
  17. struct bl_aux_gpio_info *gpio_reset = plat_get_mtk_gpio_reset();
  18. INFO("MTK System Reset\n");
  19. gpio_set_value(gpio_reset->index, gpio_reset->polarity);
  20. wfi();
  21. ERROR("MTK System Reset: operation not handled.\n");
  22. panic();
  23. }
  24. static void __dead2 mtk_system_off_cros(void)
  25. {
  26. INFO("MTK System Off\n");
  27. rtc_power_off_sequence();
  28. pmic_power_off();
  29. wfi();
  30. ERROR("MTK System Off: operation not handled.\n");
  31. panic();
  32. }
  33. static struct plat_pm_reset_ctrl lib_reset_ctrl = {
  34. .system_off = mtk_system_off_cros,
  35. .system_reset = mtk_system_reset_cros,
  36. .system_reset2 = NULL,
  37. };
  38. static int lib_reset_ctrl_init(void)
  39. {
  40. INFO("Reset init\n");
  41. plat_pm_ops_setup_reset(&lib_reset_ctrl);
  42. return 0;
  43. }
  44. MTK_ARCH_INIT(lib_reset_ctrl_init);