1 // SPDX-License-Identifier: GPL-2.0
3 * SH generic board support, using device tree
5 * Copyright (C) 2015-2016 Smart Energy Instruments, Inc.
9 #include <linux/of_clk.h>
10 #include <linux/of_fdt.h>
11 #include <linux/clocksource.h>
12 #include <linux/irqchip.h>
13 #include <asm/machvec.h>
18 static void dummy_smp_setup(void)
22 static void dummy_prepare_cpus(unsigned int max_cpus)
26 static void dummy_start_cpu(unsigned int cpu, unsigned long entry_point)
30 static unsigned int dummy_smp_processor_id(void)
35 static void dummy_send_ipi(unsigned int cpu, unsigned int message)
39 static struct plat_smp_ops dummy_smp_ops = {
40 .smp_setup = dummy_smp_setup,
41 .prepare_cpus = dummy_prepare_cpus,
42 .start_cpu = dummy_start_cpu,
43 .smp_processor_id = dummy_smp_processor_id,
44 .send_ipi = dummy_send_ipi,
45 .cpu_die = native_cpu_die,
46 .cpu_disable = native_cpu_disable,
47 .play_dead = native_play_dead,
50 extern const struct of_cpu_method __cpu_method_of_table[];
51 const struct of_cpu_method __cpu_method_of_table_sentinel
52 __section("__cpu_method_of_table_end");
54 static void sh_of_smp_probe(void)
56 struct device_node *np;
57 const char *method = NULL;
58 const struct of_cpu_method *m = __cpu_method_of_table;
60 pr_info("SH generic board support: scanning for cpus\n");
62 init_cpu_possible(cpumask_of(0));
64 for_each_of_cpu_node(np) {
65 u64 id = of_get_cpu_hwid(np, 0);
69 of_property_read_string(np, "enable-method", &method);
70 set_cpu_possible(id, true);
71 set_cpu_present(id, true);
72 __cpu_number_map[id] = id;
73 __cpu_logical_map[id] = id;
77 np = of_find_node_by_name(NULL, "cpus");
78 of_property_read_string(np, "enable-method", &method);
82 pr_info("CPU enable method: %s\n", method);
84 for (; m->method; m++)
85 if (!strcmp(m->method, method)) {
86 register_smp_ops(m->ops);
90 register_smp_ops(&dummy_smp_ops);
95 static void sh_of_smp_probe(void)
101 static void noop(void)
105 static int noopi(void)
110 static void __init sh_of_mem_reserve(void)
112 early_init_fdt_reserve_self();
113 early_init_fdt_scan_reserved_mem();
116 static void __init sh_of_setup(char **cmdline_p)
118 struct device_node *root;
120 sh_mv.mv_name = "Unknown SH model";
121 root = of_find_node_by_path("/");
123 of_property_read_string(root, "model", &sh_mv.mv_name);
130 static int sh_of_irq_demux(int irq)
132 /* FIXME: eventually this should not be used at all;
133 * the interrupt controller should set_handle_irq(). */
137 static void __init sh_of_init_irq(void)
139 pr_info("SH generic board support: scanning for interrupt controllers\n");
143 static int __init sh_of_clk_init(void)
145 #ifdef CONFIG_COMMON_CLK
146 /* Disabled pending move to COMMON_CLK framework. */
147 pr_info("SH generic board support: scanning for clk providers\n");
153 static struct sh_machine_vector __initmv sh_of_generic_mv = {
154 .mv_setup = sh_of_setup,
155 .mv_name = "devicetree", /* replaced by DT root's model */
156 .mv_irq_demux = sh_of_irq_demux,
157 .mv_init_irq = sh_of_init_irq,
158 .mv_clk_init = sh_of_clk_init,
159 .mv_mode_pins = noopi,
161 .mv_mem_reserve = sh_of_mem_reserve,
166 void __init __weak arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
170 void __init __weak plat_irq_setup(void)