Linux Audio

Check our new training course

Loading...
v4.6
 
  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
 21#ifdef CONFIG_SMP
 22
 23static void dummy_smp_setup(void)
 24{
 25}
 26
 27static void dummy_prepare_cpus(unsigned int max_cpus)
 28{
 29}
 30
 31static void dummy_start_cpu(unsigned int cpu, unsigned long entry_point)
 32{
 33}
 34
 35static unsigned int dummy_smp_processor_id(void)
 36{
 37	return 0;
 38}
 39
 40static void dummy_send_ipi(unsigned int cpu, unsigned int message)
 41{
 42}
 43
 44static 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,
 53};
 54
 55extern const struct of_cpu_method __cpu_method_of_table[];
 56const struct of_cpu_method __cpu_method_of_table_sentinel
 57	__section(__cpu_method_of_table_end);
 58
 59static void sh_of_smp_probe(void)
 60{
 61	struct device_node *np = 0;
 62	const char *method = 0;
 63	const struct of_cpu_method *m = __cpu_method_of_table;
 64
 65	pr_info("SH generic board support: scanning for cpus\n");
 66
 67	init_cpu_possible(cpumask_of(0));
 68
 69	while ((np = of_find_node_by_type(np, "cpu"))) {
 70		const __be32 *cell = of_get_property(np, "reg", NULL);
 71		u64 id = -1;
 72		if (cell) id = of_read_number(cell, of_n_addr_cells(np));
 73		if (id < NR_CPUS) {
 74			if (!method)
 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;
 80		}
 81	}
 82	if (!method) {
 83		np = of_find_node_by_name(NULL, "cpus");
 84		of_property_read_string(np, "enable-method", &method);
 
 85	}
 86
 87	pr_info("CPU enable method: %s\n", method);
 88	if (method)
 89		for (; m->method; m++)
 90			if (!strcmp(m->method, method)) {
 91				register_smp_ops(m->ops);
 92				return;
 93			}
 94
 95	register_smp_ops(&dummy_smp_ops);
 96}
 97
 98#else
 99
100static void sh_of_smp_probe(void)
101{
102}
103
104#endif
105
106static void noop(void)
107{
108}
109
110static int noopi(void)
111{
112	return 0;
113}
114
115static void __init sh_of_mem_reserve(void)
116{
117	early_init_fdt_reserve_self();
118	early_init_fdt_scan_reserved_mem();
119}
120
121static void __init sh_of_time_init(void)
122{
123	pr_info("SH generic board support: scanning for clocksource devices\n");
124	clocksource_probe();
125}
126
127static void __init sh_of_setup(char **cmdline_p)
128{
129	unflatten_device_tree();
130
131	board_time_init = sh_of_time_init;
132
133	sh_mv.mv_name = of_flat_dt_get_machine_name();
134	if (!sh_mv.mv_name)
135		sh_mv.mv_name = "Unknown SH model";
 
 
 
136
137	sh_of_smp_probe();
138}
139
140static int sh_of_irq_demux(int irq)
141{
142	/* FIXME: eventually this should not be used at all;
143	 * the interrupt controller should set_handle_irq(). */
144	return irq;
145}
146
147static void __init sh_of_init_irq(void)
148{
149	pr_info("SH generic board support: scanning for interrupt controllers\n");
150	irqchip_init();
151}
152
153static int __init sh_of_clk_init(void)
154{
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");
158	of_clk_init(NULL);
159#endif
160	return 0;
161}
162
163static 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,
170	.mv_mem_init	= noop,
171	.mv_mem_reserve	= sh_of_mem_reserve,
172};
173
174struct sh_clk_ops;
175
176void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
177{
178}
179
180void __init plat_irq_setup(void)
181{
182}
183
184static int __init sh_of_device_init(void)
185{
186	pr_info("SH generic board support: populating platform devices\n");
187	if (of_have_populated_dt()) {
188		of_iommu_init();
189		of_platform_populate(NULL, of_default_bus_match_table,
190				     NULL, NULL);
191	} else {
192		pr_crit("Device tree not populated\n");
193	}
194	return 0;
195}
196arch_initcall_sync(sh_of_device_init);
v6.8
  1// SPDX-License-Identifier: GPL-2.0
  2/*
  3 * SH generic board support, using device tree
  4 *
  5 * Copyright (C) 2015-2016 Smart Energy Instruments, Inc.
 
 
 
 
  6 */
  7
  8#include <linux/of.h>
  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>
 14#include <asm/rtc.h>
 15
 16#ifdef CONFIG_SMP
 17
 18static void dummy_smp_setup(void)
 19{
 20}
 21
 22static void dummy_prepare_cpus(unsigned int max_cpus)
 23{
 24}
 25
 26static void dummy_start_cpu(unsigned int cpu, unsigned long entry_point)
 27{
 28}
 29
 30static unsigned int dummy_smp_processor_id(void)
 31{
 32	return 0;
 33}
 34
 35static void dummy_send_ipi(unsigned int cpu, unsigned int message)
 36{
 37}
 38
 39static 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,
 48};
 49
 50extern const struct of_cpu_method __cpu_method_of_table[];
 51const struct of_cpu_method __cpu_method_of_table_sentinel
 52	__section("__cpu_method_of_table_end");
 53
 54static void sh_of_smp_probe(void)
 55{
 56	struct device_node *np;
 57	const char *method = NULL;
 58	const struct of_cpu_method *m = __cpu_method_of_table;
 59
 60	pr_info("SH generic board support: scanning for cpus\n");
 61
 62	init_cpu_possible(cpumask_of(0));
 63
 64	for_each_of_cpu_node(np) {
 65		u64 id = of_get_cpu_hwid(np, 0);
 66
 
 67		if (id < NR_CPUS) {
 68			if (!method)
 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;
 74		}
 75	}
 76	if (!method) {
 77		np = of_find_node_by_name(NULL, "cpus");
 78		of_property_read_string(np, "enable-method", &method);
 79		of_node_put(np);
 80	}
 81
 82	pr_info("CPU enable method: %s\n", method);
 83	if (method)
 84		for (; m->method; m++)
 85			if (!strcmp(m->method, method)) {
 86				register_smp_ops(m->ops);
 87				return;
 88			}
 89
 90	register_smp_ops(&dummy_smp_ops);
 91}
 92
 93#else
 94
 95static void sh_of_smp_probe(void)
 96{
 97}
 98
 99#endif
100
101static void noop(void)
102{
103}
104
105static int noopi(void)
106{
107	return 0;
108}
109
110static void __init sh_of_mem_reserve(void)
111{
112	early_init_fdt_reserve_self();
113	early_init_fdt_scan_reserved_mem();
114}
115
 
 
 
 
 
 
116static void __init sh_of_setup(char **cmdline_p)
117{
118	struct device_node *root;
 
 
119
120	sh_mv.mv_name = "Unknown SH model";
121	root = of_find_node_by_path("/");
122	if (root) {
123		of_property_read_string(root, "model", &sh_mv.mv_name);
124		of_node_put(root);
125	}
126
127	sh_of_smp_probe();
128}
129
130static int sh_of_irq_demux(int irq)
131{
132	/* FIXME: eventually this should not be used at all;
133	 * the interrupt controller should set_handle_irq(). */
134	return irq;
135}
136
137static void __init sh_of_init_irq(void)
138{
139	pr_info("SH generic board support: scanning for interrupt controllers\n");
140	irqchip_init();
141}
142
143static int __init sh_of_clk_init(void)
144{
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");
148	of_clk_init(NULL);
149#endif
150	return 0;
151}
152
153static 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,
160	.mv_mem_init	= noop,
161	.mv_mem_reserve	= sh_of_mem_reserve,
162};
163
164struct sh_clk_ops;
165
166void __init __weak arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
 
 
 
 
167{
168}
169
170void __init __weak plat_irq_setup(void)
171{
 
 
 
 
 
 
 
 
 
172}