blob: 661a912f1527dce3fc263d166c002c12015a4e07 [file] [log] [blame]
Kevin Hilmana9434e92013-12-17 16:23:49 -08001/*
Haojian Zhuang2c7268c2013-12-11 15:54:50 +08002 * (Hisilicon's Hi36xx/Hi37xx SoC based) flattened device tree enabled machine
3 *
4 * Copyright (c) 2012-2013 Hisilicon Ltd.
5 * Copyright (c) 2012-2013 Linaro Ltd.
6 *
7 * Author: Haojian Zhuang <haojian.zhuang@linaro.org>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12*/
13
14#include <linux/clk-provider.h>
15#include <linux/clocksource.h>
16#include <linux/irqchip.h>
Kevin Hilmana9434e92013-12-17 16:23:49 -080017#include <linux/of_address.h>
Haojian Zhuang2c7268c2013-12-11 15:54:50 +080018#include <linux/of_platform.h>
19
Kevin Hilmana9434e92013-12-17 16:23:49 -080020#include <asm/proc-fns.h>
21
Haojian Zhuang2c7268c2013-12-11 15:54:50 +080022#include <asm/mach/arch.h>
23#include <asm/mach/map.h>
24
Kevin Hilmana9434e92013-12-17 16:23:49 -080025#include "core.h"
26
27#define HI3620_SYSCTRL_PHYS_BASE 0xfc802000
28#define HI3620_SYSCTRL_VIRT_BASE 0xfe802000
29
Haojian Zhuang2c7268c2013-12-11 15:54:50 +080030/*
31 * This table is only for optimization. Since ioremap() could always share
32 * the same mapping if it's defined as static IO mapping.
33 *
34 * Without this table, system could also work. The cost is some virtual address
35 * spaces wasted since ioremap() may be called multi times for the same
36 * IO space.
37 */
38static struct map_desc hi3620_io_desc[] __initdata = {
39 {
Kevin Hilmana9434e92013-12-17 16:23:49 -080040 /* sysctrl */
41 .pfn = __phys_to_pfn(HI3620_SYSCTRL_PHYS_BASE),
42 .virtual = HI3620_SYSCTRL_VIRT_BASE,
Haojian Zhuang2c7268c2013-12-11 15:54:50 +080043 .length = 0x1000,
44 .type = MT_DEVICE,
45 },
46};
47
48static void __init hi3620_map_io(void)
49{
50 debug_ll_io_init();
51 iotable_init(hi3620_io_desc, ARRAY_SIZE(hi3620_io_desc));
52}
53
54static void __init hi3xxx_timer_init(void)
55{
56 of_clk_init(NULL);
57 clocksource_of_init();
58}
59
Kevin Hilmana9434e92013-12-17 16:23:49 -080060static void hi3xxx_restart(enum reboot_mode mode, const char *cmd)
61{
62 struct device_node *np;
63 void __iomem *base;
64 int offset;
65
66 np = of_find_compatible_node(NULL, NULL, "hisilicon,sysctrl");
67 if (!np) {
68 pr_err("failed to find hisilicon,sysctrl node\n");
69 return;
70 }
71 base = of_iomap(np, 0);
72 if (!base) {
73 pr_err("failed to map address in hisilicon,sysctrl node\n");
74 return;
75 }
76 if (of_property_read_u32(np, "reboot-offset", &offset) < 0) {
77 pr_err("failed to find reboot-offset property\n");
78 return;
79 }
80 writel_relaxed(0xdeadbeef, base + offset);
81
82 while (1)
83 cpu_do_idle();
84}
85
Haojian Zhuang2c7268c2013-12-11 15:54:50 +080086static const char *hi3xxx_compat[] __initconst = {
87 "hisilicon,hi3620-hi4511",
88 NULL,
89};
90
91DT_MACHINE_START(HI3620, "Hisilicon Hi3620 (Flattened Device Tree)")
92 .map_io = hi3620_map_io,
93 .init_time = hi3xxx_timer_init,
94 .dt_compat = hi3xxx_compat,
Kevin Hilmana9434e92013-12-17 16:23:49 -080095 .smp = smp_ops(hi3xxx_smp_ops),
96 .restart = hi3xxx_restart,
Haojian Zhuang2c7268c2013-12-11 15:54:50 +080097MACHINE_END