Commit | Line | Data |
---|---|---|
aaf9128a | 1 | // SPDX-License-Identifier: GPL-2.0 |
7480e0aa RF |
2 | /* |
3 | * SH generic board support, using device tree | |
4 | * | |
5 | * Copyright (C) 2015-2016 Smart Energy Instruments, Inc. | |
7480e0aa RF |
6 | */ |
7 | ||
8 | #include <linux/of.h> | |
16a30ba1 | 9 | #include <linux/of_clk.h> |
7480e0aa | 10 | #include <linux/of_fdt.h> |
7480e0aa RF |
11 | #include <linux/clocksource.h> |
12 | #include <linux/irqchip.h> | |
c98ca8a3 GU |
13 | |
14 | #include <asm/clock.h> | |
7480e0aa RF |
15 | #include <asm/machvec.h> |
16 | #include <asm/rtc.h> | |
17 | ||
044b81f8 RF |
18 | #ifdef CONFIG_SMP |
19 | ||
20 | static void dummy_smp_setup(void) | |
21 | { | |
22 | } | |
23 | ||
24 | static void dummy_prepare_cpus(unsigned int max_cpus) | |
25 | { | |
26 | } | |
27 | ||
28 | static void dummy_start_cpu(unsigned int cpu, unsigned long entry_point) | |
29 | { | |
30 | } | |
31 | ||
32 | static unsigned int dummy_smp_processor_id(void) | |
33 | { | |
34 | return 0; | |
35 | } | |
36 | ||
37 | static void dummy_send_ipi(unsigned int cpu, unsigned int message) | |
38 | { | |
39 | } | |
40 | ||
41 | static struct plat_smp_ops dummy_smp_ops = { | |
42 | .smp_setup = dummy_smp_setup, | |
43 | .prepare_cpus = dummy_prepare_cpus, | |
44 | .start_cpu = dummy_start_cpu, | |
45 | .smp_processor_id = dummy_smp_processor_id, | |
46 | .send_ipi = dummy_send_ipi, | |
47 | .cpu_die = native_cpu_die, | |
48 | .cpu_disable = native_cpu_disable, | |
49 | .play_dead = native_play_dead, | |
50 | }; | |
51 | ||
52 | extern const struct of_cpu_method __cpu_method_of_table[]; | |
53 | const struct of_cpu_method __cpu_method_of_table_sentinel | |
33def849 | 54 | __section("__cpu_method_of_table_end"); |
044b81f8 RF |
55 | |
56 | static void sh_of_smp_probe(void) | |
57 | { | |
82f7c510 DT |
58 | struct device_node *np; |
59 | const char *method = NULL; | |
044b81f8 RF |
60 | const struct of_cpu_method *m = __cpu_method_of_table; |
61 | ||
62 | pr_info("SH generic board support: scanning for cpus\n"); | |
63 | ||
64 | init_cpu_possible(cpumask_of(0)); | |
65 | ||
8cabf5bc | 66 | for_each_of_cpu_node(np) { |
ada03c68 RH |
67 | u64 id = of_get_cpu_hwid(np, 0); |
68 | ||
044b81f8 RF |
69 | if (id < NR_CPUS) { |
70 | if (!method) | |
71 | of_property_read_string(np, "enable-method", &method); | |
72 | set_cpu_possible(id, true); | |
73 | set_cpu_present(id, true); | |
74 | __cpu_number_map[id] = id; | |
75 | __cpu_logical_map[id] = id; | |
76 | } | |
77 | } | |
78 | if (!method) { | |
79 | np = of_find_node_by_name(NULL, "cpus"); | |
80 | of_property_read_string(np, "enable-method", &method); | |
82f7c510 | 81 | of_node_put(np); |
044b81f8 RF |
82 | } |
83 | ||
84 | pr_info("CPU enable method: %s\n", method); | |
85 | if (method) | |
86 | for (; m->method; m++) | |
87 | if (!strcmp(m->method, method)) { | |
88 | register_smp_ops(m->ops); | |
89 | return; | |
90 | } | |
91 | ||
92 | register_smp_ops(&dummy_smp_ops); | |
93 | } | |
94 | ||
95 | #else | |
96 | ||
97 | static void sh_of_smp_probe(void) | |
98 | { | |
99 | } | |
100 | ||
101 | #endif | |
102 | ||
7480e0aa RF |
103 | static void noop(void) |
104 | { | |
105 | } | |
106 | ||
107 | static int noopi(void) | |
108 | { | |
109 | return 0; | |
110 | } | |
111 | ||
112 | static void __init sh_of_mem_reserve(void) | |
113 | { | |
114 | early_init_fdt_reserve_self(); | |
115 | early_init_fdt_scan_reserved_mem(); | |
116 | } | |
117 | ||
7480e0aa RF |
118 | static void __init sh_of_setup(char **cmdline_p) |
119 | { | |
190fe191 RF |
120 | struct device_node *root; |
121 | ||
190fe191 RF |
122 | sh_mv.mv_name = "Unknown SH model"; |
123 | root = of_find_node_by_path("/"); | |
124 | if (root) { | |
125 | of_property_read_string(root, "model", &sh_mv.mv_name); | |
126 | of_node_put(root); | |
127 | } | |
7480e0aa | 128 | |
044b81f8 | 129 | sh_of_smp_probe(); |
7480e0aa RF |
130 | } |
131 | ||
132 | static int sh_of_irq_demux(int irq) | |
133 | { | |
134 | /* FIXME: eventually this should not be used at all; | |
135 | * the interrupt controller should set_handle_irq(). */ | |
136 | return irq; | |
137 | } | |
138 | ||
139 | static void __init sh_of_init_irq(void) | |
140 | { | |
141 | pr_info("SH generic board support: scanning for interrupt controllers\n"); | |
142 | irqchip_init(); | |
143 | } | |
144 | ||
145 | static int __init sh_of_clk_init(void) | |
146 | { | |
147 | #ifdef CONFIG_COMMON_CLK | |
148 | /* Disabled pending move to COMMON_CLK framework. */ | |
149 | pr_info("SH generic board support: scanning for clk providers\n"); | |
150 | of_clk_init(NULL); | |
151 | #endif | |
152 | return 0; | |
153 | } | |
154 | ||
155 | static struct sh_machine_vector __initmv sh_of_generic_mv = { | |
156 | .mv_setup = sh_of_setup, | |
157 | .mv_name = "devicetree", /* replaced by DT root's model */ | |
158 | .mv_irq_demux = sh_of_irq_demux, | |
159 | .mv_init_irq = sh_of_init_irq, | |
160 | .mv_clk_init = sh_of_clk_init, | |
161 | .mv_mode_pins = noopi, | |
162 | .mv_mem_init = noop, | |
163 | .mv_mem_reserve = sh_of_mem_reserve, | |
164 | }; | |
165 | ||
166 | struct sh_clk_ops; | |
167 | ||
acaf892e | 168 | void __init __weak arch_init_clk_ops(struct sh_clk_ops **ops, int idx) |
7480e0aa RF |
169 | { |
170 | } | |
171 | ||
acaf892e | 172 | void __init __weak plat_irq_setup(void) |
7480e0aa RF |
173 | { |
174 | } |