2 * SH generic board support, using device tree
4 * Copyright (C) 2015-2016 Smart Energy Instruments, Inc.
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
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>
23 static void dummy_smp_setup(void)
27 static void dummy_prepare_cpus(unsigned int max_cpus
)
31 static void dummy_start_cpu(unsigned int cpu
, unsigned long entry_point
)
35 static unsigned int dummy_smp_processor_id(void)
40 static void dummy_send_ipi(unsigned int cpu
, unsigned int message
)
44 static struct plat_smp_ops dummy_smp_ops
= {
45 .smp_setup
= dummy_smp_setup
,
46 .prepare_cpus
= dummy_prepare_cpus
,
47 .start_cpu
= dummy_start_cpu
,
48 .smp_processor_id
= dummy_smp_processor_id
,
49 .send_ipi
= dummy_send_ipi
,
50 .cpu_die
= native_cpu_die
,
51 .cpu_disable
= native_cpu_disable
,
52 .play_dead
= native_play_dead
,
55 extern const struct of_cpu_method __cpu_method_of_table
[];
56 const struct of_cpu_method __cpu_method_of_table_sentinel
57 __section(__cpu_method_of_table_end
);
59 static void sh_of_smp_probe(void)
61 struct device_node
*np
= 0;
62 const char *method
= 0;
63 const struct of_cpu_method
*m
= __cpu_method_of_table
;
65 pr_info("SH generic board support: scanning for cpus\n");
67 init_cpu_possible(cpumask_of(0));
69 while ((np
= of_find_node_by_type(np
, "cpu"))) {
70 const __be32
*cell
= of_get_property(np
, "reg", NULL
);
72 if (cell
) id
= of_read_number(cell
, of_n_addr_cells(np
));
75 of_property_read_string(np
, "enable-method", &method
);
76 set_cpu_possible(id
, true);
77 set_cpu_present(id
, true);
78 __cpu_number_map
[id
] = id
;
79 __cpu_logical_map
[id
] = id
;
83 np
= of_find_node_by_name(NULL
, "cpus");
84 of_property_read_string(np
, "enable-method", &method
);
87 pr_info("CPU enable method: %s\n", method
);
89 for (; m
->method
; m
++)
90 if (!strcmp(m
->method
, method
)) {
91 register_smp_ops(m
->ops
);
95 register_smp_ops(&dummy_smp_ops
);
100 static void sh_of_smp_probe(void)
106 static void noop(void)
110 static int noopi(void)
115 static void __init
sh_of_mem_reserve(void)
117 early_init_fdt_reserve_self();
118 early_init_fdt_scan_reserved_mem();
121 static void __init
sh_of_time_init(void)
123 pr_info("SH generic board support: scanning for clocksource devices\n");
127 static void __init
sh_of_setup(char **cmdline_p
)
129 unflatten_device_tree();
131 board_time_init
= sh_of_time_init
;
133 sh_mv
.mv_name
= of_flat_dt_get_machine_name();
135 sh_mv
.mv_name
= "Unknown SH model";
140 static int sh_of_irq_demux(int irq
)
142 /* FIXME: eventually this should not be used at all;
143 * the interrupt controller should set_handle_irq(). */
147 static void __init
sh_of_init_irq(void)
149 pr_info("SH generic board support: scanning for interrupt controllers\n");
153 static int __init
sh_of_clk_init(void)
155 #ifdef CONFIG_COMMON_CLK
156 /* Disabled pending move to COMMON_CLK framework. */
157 pr_info("SH generic board support: scanning for clk providers\n");
163 static struct sh_machine_vector __initmv sh_of_generic_mv
= {
164 .mv_setup
= sh_of_setup
,
165 .mv_name
= "devicetree", /* replaced by DT root's model */
166 .mv_irq_demux
= sh_of_irq_demux
,
167 .mv_init_irq
= sh_of_init_irq
,
168 .mv_clk_init
= sh_of_clk_init
,
169 .mv_mode_pins
= noopi
,
171 .mv_mem_reserve
= sh_of_mem_reserve
,
176 void __init
arch_init_clk_ops(struct sh_clk_ops
**ops
, int idx
)
180 void __init
plat_irq_setup(void)
184 static int __init
sh_of_device_init(void)
186 pr_info("SH generic board support: populating platform devices\n");
187 if (of_have_populated_dt()) {
189 of_platform_populate(NULL
, of_default_bus_match_table
,
192 pr_crit("Device tree not populated\n");
196 arch_initcall_sync(sh_of_device_init
);