aboutsummaryrefslogtreecommitdiff
path: root/arch/arm/mach-vt8500/restart.c
blob: 497e89a5e130db74fd50b519b2fbedb660733cb7 (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
/* linux/arch/arm/mach-vt8500/restart.c
 *
 * Copyright (C) 2012 Tony Prisk <linux@prisktech.co.nz>
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * This program is distributed in the hope that 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.
 *
 */
#include <asm/io.h>
#include <linux/of.h>
#include <linux/of_address.h>

#define LEGACY_PMC_BASE		0xD8130000
#define WMT_PRIZM_PMSR_REG	0x60

static void __iomem *pmc_base;

void wmt_setup_restart(void)
{
	struct device_node *np;

	/*
	 * Check if Power Mgmt Controller node is present in device tree. If no
	 * device tree node, use the legacy PMSR value (valid for all current
	 * SoCs).
	 */
	np = of_find_compatible_node(NULL, NULL, "wmt,prizm-pmc");
	if (np) {
		pmc_base = of_iomap(np, 0);

		if (!pmc_base)
			pr_err("%s:of_iomap(pmc) failed\n", __func__);

		of_node_put(np);
	} else {
		pmc_base = ioremap(LEGACY_PMC_BASE, 0x1000);
		if (!pmc_base) {
			pr_err("%s:ioremap(rstc) failed\n", __func__);
			return;
		}
	}
}

void wmt_restart(char mode, const char *cmd)
{
	if (pmc_base)
		writel(1, pmc_base + WMT_PRIZM_PMSR_REG);
}