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