summaryrefslogtreecommitdiff
path: root/drivers/sysreset/sysreset_tegra.c
blob: 10bcd3a18737e190e93b1e5616d7ca49e1f65662 (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
// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright(C) 2023 Svyatoslav Ryhel <clamor95@gmail.com>
 */

#include <dm.h>
#include <errno.h>
#include <sysreset.h>
#include <linux/err.h>
#include <asm/arch-tegra/pmc.h>

static int tegra_sysreset_request(struct udevice *dev,
				  enum sysreset_t type)
{
	u32 value;

	switch (type) {
	case SYSRESET_WARM:
	case SYSRESET_COLD:
		/* resets everything but scratch 0 and reset status */
		value = tegra_pmc_readl(PMC_CNTRL);
		value |= PMC_CNTRL_MAIN_RST;
		tegra_pmc_writel(value, PMC_CNTRL);
		break;
	default:
		return -EPROTONOSUPPORT;
	}

	return -EINPROGRESS;
}

static struct sysreset_ops tegra_sysreset = {
	.request = tegra_sysreset_request,
};

U_BOOT_DRIVER(sysreset_tegra) = {
	.id	= UCLASS_SYSRESET,
	.name	= "sysreset_tegra",
	.ops	= &tegra_sysreset,
};

/* Link to Tegra PMC once there is a driver */
U_BOOT_DRVINFO(sysreset_tegra) = {
	.name = "sysreset_tegra"
};