blob: e0b9e1b9cf303f9f91c8ff4bcff10cd0ab6d0f3c [file] [log] [blame]
Santosh Shilimkar828989a2013-06-10 11:27:13 -04001/*
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>
Santosh Shilimkarf07cb6a02013-06-10 12:20:17 -040022#include <asm/smp_plat.h>
23
24#include "keystone.h"
Santosh Shilimkar828989a2013-06-10 11:27:13 -040025
26#define PLL_RESET_WRITE_KEY_MASK 0xffff0000
27#define PLL_RESET_WRITE_KEY 0x5a69
28#define PLL_RESET BIT(16)
29
30static void __iomem *keystone_rstctrl;
31
32static void __init keystone_init(void)
33{
34 struct device_node *node;
35
36 node = of_find_compatible_node(NULL, NULL, "ti,keystone-reset");
37 if (WARN_ON(!node))
38 pr_warn("ti,keystone-reset node undefined\n");
39
40 keystone_rstctrl = of_iomap(node, 0);
41 if (WARN_ON(!keystone_rstctrl))
42 pr_warn("ti,keystone-reset iomap error\n");
43
Santosh Shilimkar8308a782013-11-23 17:08:03 -050044 keystone_pm_runtime_init();
Santosh Shilimkar828989a2013-06-10 11:27:13 -040045 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
46}
47
48static const char *keystone_match[] __initconst = {
Ivan Khoronzhuk3babe302014-03-20 17:00:27 -040049 "ti,keystone",
Santosh Shilimkar828989a2013-06-10 11:27:13 -040050 NULL,
51};
52
Vincent Stehléed882c32013-06-27 14:49:27 +020053void keystone_restart(enum reboot_mode mode, const char *cmd)
Santosh Shilimkar828989a2013-06-10 11:27:13 -040054{
55 u32 val;
56
57 BUG_ON(!keystone_rstctrl);
58
59 /* Enable write access to RSTCTRL */
60 val = readl(keystone_rstctrl);
61 val &= PLL_RESET_WRITE_KEY_MASK;
62 val |= PLL_RESET_WRITE_KEY;
63 writel(val, keystone_rstctrl);
64
65 /* Reset the SOC */
66 val = readl(keystone_rstctrl);
67 val &= ~PLL_RESET;
68 writel(val, keystone_rstctrl);
69}
70
71DT_MACHINE_START(KEYSTONE, "Keystone")
Santosh Shilimkardf595a92013-11-23 16:58:03 -050072#if defined(CONFIG_ZONE_DMA) && defined(CONFIG_ARM_LPAE)
73 .dma_zone_size = SZ_2G,
74#endif
Santosh Shilimkarf07cb6a02013-06-10 12:20:17 -040075 .smp = smp_ops(keystone_smp_ops),
Santosh Shilimkar828989a2013-06-10 11:27:13 -040076 .init_machine = keystone_init,
77 .dt_compat = keystone_match,
78 .restart = keystone_restart,
79MACHINE_END