aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/of-generic.c
diff options
context:
space:
mode:
authorRich Felker <dalias@libc.org>2016-01-22 19:45:41 -0500
committerRich Felker <dalias@libc.org>2016-03-17 15:46:11 -0400
commit7480e0aabd5f9e6c3e3b72ed206e89284e90f11f (patch)
treeafcdb346dbec13ea4be79f062e9f849caedceaae /arch/sh/boards/of-generic.c
parent45624ac38926c8c2f1a63b4a39e7b1997743e1b3 (diff)
sh: add device tree support and generic board using device tree
Add a new pseudo-board, within the existing SH boards/machine-vectors framework, which does not represent any actual hardware but instead requires all hardware to be described by the device tree blob provided by the boot loader. Changes made are thus non-invasive and do not risk breaking support for legacy boards. New hardware, including the open-hardware J2 and associated SoC devices, will use device free from the outset. Legacy SH boards can transition to device tree once all their hardware has device tree bindings, driver support for device tree, and a dts file for the board. It is intented that, once all boards are supported in the new framework, the existing machine-vectors framework should be removed and the new device tree setup code integrated directly. Signed-off-by: Rich Felker <dalias@libc.org>
Diffstat (limited to 'arch/sh/boards/of-generic.c')
-rw-r--r--arch/sh/boards/of-generic.c113
1 files changed, 113 insertions, 0 deletions
diff --git a/arch/sh/boards/of-generic.c b/arch/sh/boards/of-generic.c
new file mode 100644
index 000000000000..71d890932151
--- /dev/null
+++ b/arch/sh/boards/of-generic.c
@@ -0,0 +1,113 @@
1/*
2 * SH generic board support, using device tree
3 *
4 * Copyright (C) 2015-2016 Smart Energy Instruments, Inc.
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/of.h>
12#include <linux/of_platform.h>
13#include <linux/of_fdt.h>
14#include <linux/of_iommu.h>
15#include <linux/clocksource.h>
16#include <linux/irqchip.h>
17#include <linux/clk-provider.h>
18#include <asm/machvec.h>
19#include <asm/rtc.h>
20
21static void noop(void)
22{
23}
24
25static int noopi(void)
26{
27 return 0;
28}
29
30static void __init sh_of_mem_reserve(void)
31{
32 early_init_fdt_reserve_self();
33 early_init_fdt_scan_reserved_mem();
34}
35
36static void __init sh_of_time_init(void)
37{
38 pr_info("SH generic board support: scanning for clocksource devices\n");
39 clocksource_probe();
40}
41
42static void __init sh_of_setup(char **cmdline_p)
43{
44 unflatten_device_tree();
45
46 board_time_init = sh_of_time_init;
47
48 sh_mv.mv_name = of_flat_dt_get_machine_name();
49 if (!sh_mv.mv_name)
50 sh_mv.mv_name = "Unknown SH model";
51
52 /* FIXME: register smp ops to use dt to find cpus, use
53 * cpu enable-method, and use irq controller's ipi
54 * functions. */
55}
56
57static int sh_of_irq_demux(int irq)
58{
59 /* FIXME: eventually this should not be used at all;
60 * the interrupt controller should set_handle_irq(). */
61 return irq;
62}
63
64static void __init sh_of_init_irq(void)
65{
66 pr_info("SH generic board support: scanning for interrupt controllers\n");
67 irqchip_init();
68}
69
70static int __init sh_of_clk_init(void)
71{
72#ifdef CONFIG_COMMON_CLK
73 /* Disabled pending move to COMMON_CLK framework. */
74 pr_info("SH generic board support: scanning for clk providers\n");
75 of_clk_init(NULL);
76#endif
77 return 0;
78}
79
80static struct sh_machine_vector __initmv sh_of_generic_mv = {
81 .mv_setup = sh_of_setup,
82 .mv_name = "devicetree", /* replaced by DT root's model */
83 .mv_irq_demux = sh_of_irq_demux,
84 .mv_init_irq = sh_of_init_irq,
85 .mv_clk_init = sh_of_clk_init,
86 .mv_mode_pins = noopi,
87 .mv_mem_init = noop,
88 .mv_mem_reserve = sh_of_mem_reserve,
89};
90
91struct sh_clk_ops;
92
93void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
94{
95}
96
97void __init plat_irq_setup(void)
98{
99}
100
101static int __init sh_of_device_init(void)
102{
103 pr_info("SH generic board support: populating platform devices\n");
104 if (of_have_populated_dt()) {
105 of_iommu_init();
106 of_platform_populate(NULL, of_default_bus_match_table,
107 NULL, NULL);
108 } else {
109 pr_crit("Device tree not populated\n");
110 }
111 return 0;
112}
113arch_initcall_sync(sh_of_device_init);