1 /* 2 * (Hisilicon's 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> 17 #include <linux/of_address.h> 18 #include <linux/of_platform.h> 19 20 #include <asm/proc-fns.h> 21 22 #include <asm/mach/arch.h> 23 #include <asm/mach/map.h> 24 25 #include "core.h" 26 27 #define HI3620_SYSCTRL_PHYS_BASE 0xfc802000 28 #define HI3620_SYSCTRL_VIRT_BASE 0xfe802000 29 30 /* 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 */ 38 static struct map_desc hi3620_io_desc[] __initdata = { 39 { 40 /* sysctrl */ 41 .pfn = __phys_to_pfn(HI3620_SYSCTRL_PHYS_BASE), 42 .virtual = HI3620_SYSCTRL_VIRT_BASE, 43 .length = 0x1000, 44 .type = MT_DEVICE, 45 }, 46 }; 47 48 static 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 54 static void __init hi3xxx_timer_init(void) 55 { 56 of_clk_init(NULL); 57 clocksource_of_init(); 58 } 59 60 static 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 86 static const char *hi3xxx_compat[] __initconst = { 87 "hisilicon,hi3620-hi4511", 88 NULL, 89 }; 90 91 DT_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, 95 .smp = smp_ops(hi3xxx_smp_ops), 96 .restart = hi3xxx_restart, 97 MACHINE_END 98