summaryrefslogtreecommitdiffstats
path: root/plat/mediatek/lib/system_reset/reset_cros.c
blob: 40e68ba9fe3de69881c9d276bae602ff32d912d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * Copyright (c) 2022, MediaTek Inc. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <assert.h>
#include <arch_helpers.h>
#include <common/debug.h>
#include <drivers/gpio.h>
#include <lib/mtk_init/mtk_init.h>
#include <lib/pm/mtk_pm.h>
#include <plat_params.h>
#include <pmic.h>
#include <rtc.h>

static void __dead2 mtk_system_reset_cros(void)
{
	struct bl_aux_gpio_info *gpio_reset = plat_get_mtk_gpio_reset();

	INFO("MTK System Reset\n");

	gpio_set_value(gpio_reset->index, gpio_reset->polarity);

	wfi();
	ERROR("MTK System Reset: operation not handled.\n");
	panic();
}

static void __dead2 mtk_system_off_cros(void)
{
	INFO("MTK System Off\n");

	rtc_power_off_sequence();
	pmic_power_off();

	wfi();
	ERROR("MTK System Off: operation not handled.\n");
	panic();
}

static struct plat_pm_reset_ctrl lib_reset_ctrl = {
	.system_off = mtk_system_off_cros,
	.system_reset = mtk_system_reset_cros,
	.system_reset2 = NULL,
};

static int lib_reset_ctrl_init(void)
{
	INFO("Reset init\n");

	plat_pm_ops_setup_reset(&lib_reset_ctrl);

	return 0;
}
MTK_ARCH_INIT(lib_reset_ctrl_init);