ARM: keystone: Add minimal TI Keystone platform support
[linux-2.6-block.git] / arch / arm / mach-keystone / keystone.c
CommitLineData
828989ad
SS
1/*
2 * Keystone2 based boards and SOC related code.
3 *
4 * Copyright 2013 Texas Instruments, Inc.
5 * Cyril Chemparathy <cyril@ti.com>
6 * Santosh Shilimkar <santosh.shillimkar@ti.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2, as published by the Free Software Foundation.
11 */
12#include <linux/io.h>
13#include <linux/of.h>
14#include <linux/init.h>
15#include <linux/of_platform.h>
16#include <linux/of_address.h>
17
18#include <asm/setup.h>
19#include <asm/mach/map.h>
20#include <asm/mach/arch.h>
21#include <asm/mach/time.h>
22
23#define PLL_RESET_WRITE_KEY_MASK 0xffff0000
24#define PLL_RESET_WRITE_KEY 0x5a69
25#define PLL_RESET BIT(16)
26
27static void __iomem *keystone_rstctrl;
28
29static void __init keystone_init(void)
30{
31 struct device_node *node;
32
33 node = of_find_compatible_node(NULL, NULL, "ti,keystone-reset");
34 if (WARN_ON(!node))
35 pr_warn("ti,keystone-reset node undefined\n");
36
37 keystone_rstctrl = of_iomap(node, 0);
38 if (WARN_ON(!keystone_rstctrl))
39 pr_warn("ti,keystone-reset iomap error\n");
40
41 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
42}
43
44static const char *keystone_match[] __initconst = {
45 "ti,keystone-evm",
46 NULL,
47};
48
49void keystone_restart(char mode, const char *cmd)
50{
51 u32 val;
52
53 BUG_ON(!keystone_rstctrl);
54
55 /* Enable write access to RSTCTRL */
56 val = readl(keystone_rstctrl);
57 val &= PLL_RESET_WRITE_KEY_MASK;
58 val |= PLL_RESET_WRITE_KEY;
59 writel(val, keystone_rstctrl);
60
61 /* Reset the SOC */
62 val = readl(keystone_rstctrl);
63 val &= ~PLL_RESET;
64 writel(val, keystone_rstctrl);
65}
66
67DT_MACHINE_START(KEYSTONE, "Keystone")
68 .init_machine = keystone_init,
69 .dt_compat = keystone_match,
70 .restart = keystone_restart,
71MACHINE_END