1 /* 2 * Copyright (c) 2022-2025, MediaTek Inc. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <assert.h> 8 9 #include <arch_helpers.h> 10 #include <common/debug.h> 11 #include <drivers/delay_timer.h> 12 #include <drivers/gpio.h> 13 #if CONFIG_MTK_PMIC_SHUTDOWN_CFG 14 #include <drivers/pmic/pmic_psc.h> 15 #endif 16 #include <lib/mtk_init/mtk_init.h> 17 #include <lib/pm/mtk_pm.h> 18 #include <plat_params.h> 19 #if !CONFIG_MTK_PMIC_SHUTDOWN_CFG 20 #include <pmic.h> 21 #include <rtc.h> 22 #endif 23 mtk_system_reset_cros(void)24static void __dead2 mtk_system_reset_cros(void) 25 { 26 struct bl_aux_gpio_info *gpio_reset = plat_get_mtk_gpio_reset(); 27 28 INFO("MTK System Reset\n"); 29 30 gpio_set_value(gpio_reset->index, gpio_reset->polarity); 31 32 wfi(); 33 ERROR("MTK System Reset: operation not handled.\n"); 34 panic(); 35 } 36 mtk_system_off_cros(void)37static void __dead2 mtk_system_off_cros(void) 38 { 39 INFO("MTK System Off\n"); 40 41 #if CONFIG_MTK_PMIC_SHUTDOWN_CFG 42 platform_power_hold(false); 43 mdelay(1000); 44 #else 45 rtc_power_off_sequence(); 46 pmic_power_off(); 47 #endif 48 49 wfi(); 50 ERROR("MTK System Off: operation not handled.\n"); 51 panic(); 52 } 53 54 static struct plat_pm_reset_ctrl lib_reset_ctrl = { 55 .system_off = mtk_system_off_cros, 56 .system_reset = mtk_system_reset_cros, 57 .system_reset2 = NULL, 58 }; 59 lib_reset_ctrl_init(void)60static int lib_reset_ctrl_init(void) 61 { 62 INFO("Reset init\n"); 63 64 plat_pm_ops_setup_reset(&lib_reset_ctrl); 65 66 return 0; 67 } 68 MTK_ARCH_INIT(lib_reset_ctrl_init); 69