mvebu: backport mainline patches from kernel 3.11
[openwrt/svn-archive/archive.git] / target / linux / mvebu / patches-3.10 / 0024-arm-mvebu-remove-dependency-of-SMP-init-on-static-I-.patch
1 From 9398729313b826469fede3acda5fedd1eb21cb3e Mon Sep 17 00:00:00 2001
2 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3 Date: Wed, 5 Jun 2013 09:04:54 +0200
4 Subject: [PATCH 024/203] arm: mvebu: remove dependency of SMP init on static
5 I/O mapping
6
7 The ->smp_init_cpus() function is called very early during boot, at a
8 point where dynamic I/O mappings are not yet possible. However, in the
9 Armada 370/XP implementation of this function, we have to get the
10 number of CPUs. We used to do that by accessing a hardware register,
11 which requires relying on a static I/O mapping set up by
12 ->map_io(). Not only this requires hardcoding a virtual address, but
13 it also prevents us from removing the static I/O mapping.
14
15 So this commit changes the way used to get the number of CPUs: we now
16 use the Device Tree, which is a representation of the hardware, and
17 provides us the number of available CPUs. This is also more accurate,
18 because it potentially allows to boot the Linux kernel on only a
19 number of CPUs given by the Device Tree, instead of unconditionally on
20 all CPUs.
21
22 As a consequence, the coherency_get_cpu_count() function becomes no
23 longer used, so we remove it.
24
25 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
26 Acked-by: Arnd Bergmann <arnd@arndb.de>
27 Signed-off-by: Jason Cooper <jason@lakedaemon.net>
28 ---
29 arch/arm/mach-mvebu/coherency.c | 12 ------------
30 arch/arm/mach-mvebu/coherency.h | 4 ----
31 arch/arm/mach-mvebu/common.h | 2 ++
32 arch/arm/mach-mvebu/platsmp.c | 10 +++++++++-
33 4 files changed, 11 insertions(+), 17 deletions(-)
34
35 --- a/arch/arm/mach-mvebu/coherency.c
36 +++ b/arch/arm/mach-mvebu/coherency.c
37 @@ -47,18 +47,6 @@ static struct of_device_id of_coherency_
38 { /* end of list */ },
39 };
40
41 -#ifdef CONFIG_SMP
42 -int coherency_get_cpu_count(void)
43 -{
44 - int reg, cnt;
45 -
46 - reg = readl(coherency_base + COHERENCY_FABRIC_CFG_OFFSET);
47 - cnt = (reg & 0xF) + 1;
48 -
49 - return cnt;
50 -}
51 -#endif
52 -
53 /* Function defined in coherency_ll.S */
54 int ll_set_cpu_coherent(void __iomem *base_addr, unsigned int hw_cpu_id);
55
56 --- a/arch/arm/mach-mvebu/coherency.h
57 +++ b/arch/arm/mach-mvebu/coherency.h
58 @@ -14,10 +14,6 @@
59 #ifndef __MACH_370_XP_COHERENCY_H
60 #define __MACH_370_XP_COHERENCY_H
61
62 -#ifdef CONFIG_SMP
63 -int coherency_get_cpu_count(void);
64 -#endif
65 -
66 int set_cpu_coherent(int cpu_id, int smp_group_id);
67 int coherency_init(void);
68
69 --- a/arch/arm/mach-mvebu/common.h
70 +++ b/arch/arm/mach-mvebu/common.h
71 @@ -15,6 +15,8 @@
72 #ifndef __ARCH_MVEBU_COMMON_H
73 #define __ARCH_MVEBU_COMMON_H
74
75 +#define ARMADA_XP_MAX_CPUS 4
76 +
77 void mvebu_restart(char mode, const char *cmd);
78
79 void armada_370_xp_init_irq(void);
80 --- a/arch/arm/mach-mvebu/platsmp.c
81 +++ b/arch/arm/mach-mvebu/platsmp.c
82 @@ -88,8 +88,16 @@ static int __cpuinit armada_xp_boot_seco
83
84 static void __init armada_xp_smp_init_cpus(void)
85 {
86 + struct device_node *np;
87 unsigned int i, ncores;
88 - ncores = coherency_get_cpu_count();
89 +
90 + np = of_find_node_by_name(NULL, "cpus");
91 + if (!np)
92 + panic("No 'cpus' node found\n");
93 +
94 + ncores = of_get_child_count(np);
95 + if (ncores == 0 || ncores > ARMADA_XP_MAX_CPUS)
96 + panic("Invalid number of CPUs in DT\n");
97
98 /* Limit possible CPUs to defconfig */
99 if (ncores > nr_cpu_ids) {