Skip to content

Commit b31a3bc

Browse files
committed
Merge tag 'tag-sh-for-4.6' of git://git.libc.org/linux-sh
Pull arch/sh updates from Rich Felker: "This includes minor cleanups, a fix for a crash that likely affects all sh models with MMU, and introduction of a framework for boards described by device tree, which sets the stage for future J2 support" * tag 'tag-sh-for-4.6' of git://git.libc.org/linux-sh: sched/preempt, sh: kmap_coherent relies on disabled preemption sh: add SMP method selection to device tree pseudo-board sh: add device tree support and generic board using device tree sh: remove arch-specific localtimer and use generic one sh: make MMU-specific SMP code conditional on CONFIG_MMU sh: provide unified syscall trap compatible with all SH models sh: New gcc support sh: Disable trace for kernel uncompressing. sh: Use generic clkdev.h header
2 parents d5e2d00 + b15d53d commit b31a3bc

File tree

22 files changed

+397
-145
lines changed

22 files changed

+397
-145
lines changed

Documentation/devicetree/booting-without-of.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Table of Contents
1616
2) Entry point for arch/powerpc
1717
3) Entry point for arch/x86
1818
4) Entry point for arch/mips/bmips
19+
5) Entry point for arch/sh
1920

2021
II - The DT block format
2122
1) Header
@@ -316,6 +317,18 @@ it with special cases.
316317
This convention is defined for 32-bit systems only, as there are not
317318
currently any 64-bit BMIPS implementations.
318319

320+
5) Entry point for arch/sh
321+
--------------------------
322+
323+
Device-tree-compatible SH bootloaders are expected to provide the physical
324+
address of the device tree blob in r4. Since legacy bootloaders did not
325+
guarantee any particular initial register state, kernels built to
326+
inter-operate with old bootloaders must either use a builtin DTB or
327+
select a legacy board option (something other than CONFIG_SH_DEVICE_TREE)
328+
that does not use device tree. Support for the latter is being phased out
329+
in favor of device tree.
330+
331+
319332
II - The DT block format
320333
========================
321334

arch/sh/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
config SUPERH
22
def_bool y
3+
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
34
select ARCH_MIGHT_HAVE_PC_PARPORT
45
select HAVE_PATA_PLATFORM
56
select CLKDEV_LOOKUP

arch/sh/boards/Kconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ config SOLUTION_ENGINE
66
config SH_ALPHA_BOARD
77
bool
88

9+
config SH_DEVICE_TREE
10+
bool "Board Described by Device Tree"
11+
select OF
12+
select OF_EARLY_FLATTREE
13+
select CLKSRC_OF
14+
select GENERIC_CALIBRATE_DELAY
15+
help
16+
Select Board Described by Device Tree to build a kernel that
17+
does not hard-code any board-specific knowledge but instead uses
18+
a device tree blob provided by the boot-loader. You must enable
19+
drivers for any hardware you want to use separately. At this
20+
time, only boards based on the open-hardware J-Core processors
21+
have sufficient driver coverage to use this option; do not
22+
select it if you are using original SuperH hardware.
23+
924
config SH_SOLUTION_ENGINE
1025
bool "SolutionEngine"
1126
select SOLUTION_ENGINE

arch/sh/boards/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ obj-$(CONFIG_SH_TITAN) += board-titan.o
1515
obj-$(CONFIG_SH_SH7757LCR) += board-sh7757lcr.o
1616
obj-$(CONFIG_SH_APSH4A3A) += board-apsh4a3a.o
1717
obj-$(CONFIG_SH_APSH4AD0A) += board-apsh4ad0a.o
18+
19+
obj-$(CONFIG_SH_DEVICE_TREE) += of-generic.o

arch/sh/boards/of-generic.c

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
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+
23+
static void dummy_smp_setup(void)
24+
{
25+
}
26+
27+
static void dummy_prepare_cpus(unsigned int max_cpus)
28+
{
29+
}
30+
31+
static void dummy_start_cpu(unsigned int cpu, unsigned long entry_point)
32+
{
33+
}
34+
35+
static unsigned int dummy_smp_processor_id(void)
36+
{
37+
return 0;
38+
}
39+
40+
static void dummy_send_ipi(unsigned int cpu, unsigned int message)
41+
{
42+
}
43+
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,
53+
};
54+
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);
58+
59+
static 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+
100+
static void sh_of_smp_probe(void)
101+
{
102+
}
103+
104+
#endif
105+
106+
static void noop(void)
107+
{
108+
}
109+
110+
static int noopi(void)
111+
{
112+
return 0;
113+
}
114+
115+
static void __init sh_of_mem_reserve(void)
116+
{
117+
early_init_fdt_reserve_self();
118+
early_init_fdt_scan_reserved_mem();
119+
}
120+
121+
static 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+
127+
static 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+
140+
static 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+
147+
static 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+
153+
static 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+
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,
170+
.mv_mem_init = noop,
171+
.mv_mem_reserve = sh_of_mem_reserve,
172+
};
173+
174+
struct sh_clk_ops;
175+
176+
void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
177+
{
178+
}
179+
180+
void __init plat_irq_setup(void)
181+
{
182+
}
183+
184+
static 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+
}
196+
arch_initcall_sync(sh_of_device_init);

arch/sh/boot/compressed/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ ifeq ($(BITS),64)
4848
lib1funcs-dir := $(addsuffix $(BITS), $(lib1funcs-dir))
4949
endif
5050

51-
KBUILD_CFLAGS += -I$(lib1funcs-dir)
51+
KBUILD_CFLAGS += -I$(lib1funcs-dir) -DDISABLE_BRANCH_PROFILING
5252

5353
$(addprefix $(obj)/,$(lib1funcs-y)): $(obj)/%: $(lib1funcs-dir)/% FORCE
5454
$(call cmd,shipped)

arch/sh/include/asm/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
generic-y += bitsperlong.h
3+
generic-y += clkdev.h
34
generic-y += cputime.h
45
generic-y += current.h
56
generic-y += delay.h

arch/sh/include/asm/clkdev.h

Lines changed: 0 additions & 33 deletions
This file was deleted.

arch/sh/include/asm/smp.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ static inline int hard_smp_processor_id(void)
6969
return mp_ops->smp_processor_id();
7070
}
7171

72+
struct of_cpu_method {
73+
const char *method;
74+
struct plat_smp_ops *ops;
75+
};
76+
77+
#define CPU_METHOD_OF_DECLARE(name, _method, _ops) \
78+
static const struct of_cpu_method __cpu_method_of_table_##name \
79+
__used __section(__cpu_method_of_table) \
80+
= { .method = _method, .ops = _ops }
81+
7282
#else
7383

7484
#define hard_smp_processor_id() (0)

arch/sh/kernel/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,5 @@ obj-$(CONFIG_DWARF_UNWINDER) += dwarf.o
4646
obj-$(CONFIG_PERF_EVENTS) += perf_event.o perf_callchain.o
4747

4848
obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
49-
obj-$(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) += localtimer.o
5049

5150
ccflags-y := -Werror

arch/sh/kernel/cpu/sh2/entry.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ ENTRY(exception_handler)
144144
mov #64,r8
145145
cmp/hs r8,r9
146146
bt interrupt_entry ! vec >= 64 is interrupt
147-
mov #32,r8
147+
mov #31,r8
148148
cmp/hs r8,r9
149-
bt trap_entry ! 64 > vec >= 32 is trap
149+
bt trap_entry ! 64 > vec >= 31 is trap
150150

151151
mov.l 4f,r8
152152
mov r9,r4
@@ -178,9 +178,9 @@ interrupt_entry:
178178

179179
trap_entry:
180180
mov #0x30,r8
181-
cmp/ge r8,r9 ! vector 0x20-0x2f is systemcall
181+
cmp/ge r8,r9 ! vector 0x1f-0x2f is systemcall
182182
bt 1f
183-
add #-0x10,r9 ! convert SH2 to SH3/4 ABI
183+
mov #0x1f,r9 ! convert to unified SH2/3/4 trap number
184184
1:
185185
shll2 r9 ! TRA
186186
bra system_call ! jump common systemcall entry

arch/sh/kernel/cpu/sh2a/entry.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ ENTRY(exception_handler)
109109
mov #64,r8
110110
cmp/hs r8,r9
111111
bt interrupt_entry ! vec >= 64 is interrupt
112-
mov #32,r8
112+
mov #31,r8
113113
cmp/hs r8,r9
114-
bt trap_entry ! 64 > vec >= 32 is trap
114+
bt trap_entry ! 64 > vec >= 31 is trap
115115

116116
mov.l 4f,r8
117117
mov r9,r4
@@ -143,9 +143,9 @@ interrupt_entry:
143143

144144
trap_entry:
145145
mov #0x30,r8
146-
cmp/ge r8,r9 ! vector 0x20-0x2f is systemcall
146+
cmp/ge r8,r9 ! vector 0x1f-0x2f is systemcall
147147
bt 1f
148-
add #-0x10,r9 ! convert SH2 to SH3/4 ABI
148+
mov #0x1f,r9 ! convert to unified SH2/3/4 trap number
149149
1:
150150
shll2 r9 ! TRA
151151
bra system_call ! jump common systemcall entry

0 commit comments

Comments
 (0)