summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-tegra/tegra20-pmc.c
blob: 94167d68fc2315a52f61d4c1a6cf96804cf50984 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
 * Copyright (C) 2013 Lucas Stach <l.stach@pengutronix.de>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * @file
 * @brief Device driver for the Tegra 20 power management controller.
 */

#include <common.h>
#include <command.h>
#include <init.h>
#include <io.h>

#include <mach/tegra20-pmc.h>

static void __iomem *pmc_base;

/* main SoC reset trigger */
void __noreturn reset_cpu(ulong addr)
{
	writel(PMC_CNTRL_MAIN_RST, pmc_base + PMC_CNTRL);

	unreachable();
}
EXPORT_SYMBOL(reset_cpu);

static int tegra20_pmc_probe(struct device_d *dev)
{
	pmc_base = dev_request_mem_region(dev, 0);
	if (!pmc_base) {
		dev_err(dev, "could not get memory region\n");
		return -ENODEV;
	}

	return 0;
}

static int do_tegrarcm(int argc, char *argv[])
{
	writel(2, pmc_base + PMC_SCRATCH(0));
	reset_cpu(0);

	return 0;
}

static __maybe_unused struct of_device_id tegra20_pmc_dt_ids[] = {
	{
		.compatible = "nvidia,tegra20-pmc",
	}, {
		.compatible = "nvidia,tegra30-pmc",
	}, {
		.compatible = "nvidia,tegra124-pmc",
	}, {
		/* sentinel */
	}
};

static struct driver_d tegra20_pmc_driver = {
	.probe	= tegra20_pmc_probe,
	.name	= "tegra20-pmc",
	.of_compatible = DRV_OF_COMPAT(tegra20_pmc_dt_ids),
};

static int tegra20_pmc_init(void)
{
	return platform_driver_register(&tegra20_pmc_driver);
}
coredevice_initcall(tegra20_pmc_init);

BAREBOX_CMD_HELP_START(tegrarcm)
BAREBOX_CMD_HELP_TEXT("Get into recovery mode without using a physical switch\n")
BAREBOX_CMD_HELP_END

BAREBOX_CMD_START(tegrarcm)
	.cmd		= do_tegrarcm,
	BAREBOX_CMD_DESC("Usage: tegrarcm")
	BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP)
	BAREBOX_CMD_HELP(cmd_tegrarcm_help)
BAREBOX_CMD_END