diff options
author | Paul Mundt <lethal@linux-sh.org> | 2012-01-11 22:20:18 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2012-01-11 22:20:18 -0500 |
commit | e64e1b11b14d363ac70fd13ab809969a6d7e42a8 (patch) | |
tree | 809dd1350f39b795e9bbce21db18d521e7844533 /arch | |
parent | 20052462948795914011f2fea0e77767d55cb48b (diff) | |
parent | f40aaf6da14a4043d6361e0c7d74ada18e866059 (diff) |
Merge branch 'rmobile/smp' into rmobile-latest
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-shmobile/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/mach-shmobile/include/mach/common.h | 6 | ||||
-rw-r--r-- | arch/arm/mach-shmobile/include/mach/r8a7779.h | 3 | ||||
-rw-r--r-- | arch/arm/mach-shmobile/platsmp.c | 16 | ||||
-rw-r--r-- | arch/arm/mach-shmobile/pm-r8a7779.c | 30 | ||||
-rw-r--r-- | arch/arm/mach-shmobile/smp-r8a7779.c | 153 |
6 files changed, 201 insertions, 8 deletions
diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile index 997bd2bcd5f6..7ad6954c46cd 100644 --- a/arch/arm/mach-shmobile/Makefile +++ b/arch/arm/mach-shmobile/Makefile | |||
@@ -18,6 +18,7 @@ smp-y := platsmp.o headsmp.o | |||
18 | smp-$(CONFIG_HOTPLUG_CPU) += hotplug.o | 18 | smp-$(CONFIG_HOTPLUG_CPU) += hotplug.o |
19 | smp-$(CONFIG_LOCAL_TIMERS) += localtimer.o | 19 | smp-$(CONFIG_LOCAL_TIMERS) += localtimer.o |
20 | smp-$(CONFIG_ARCH_SH73A0) += smp-sh73a0.o | 20 | smp-$(CONFIG_ARCH_SH73A0) += smp-sh73a0.o |
21 | smp-$(CONFIG_ARCH_R8A7779) += smp-r8a7779.o | ||
21 | 22 | ||
22 | # Pinmux setup | 23 | # Pinmux setup |
23 | pfc-y := | 24 | pfc-y := |
diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h index 44ce124bfdec..e4b945e271e7 100644 --- a/arch/arm/mach-shmobile/include/mach/common.h +++ b/arch/arm/mach-shmobile/include/mach/common.h | |||
@@ -68,4 +68,10 @@ extern void r8a7779_clock_init(void); | |||
68 | extern void r8a7779_pinmux_init(void); | 68 | extern void r8a7779_pinmux_init(void); |
69 | extern void r8a7779_pm_init(void); | 69 | extern void r8a7779_pm_init(void); |
70 | 70 | ||
71 | extern unsigned int r8a7779_get_core_count(void); | ||
72 | extern int r8a7779_platform_cpu_kill(unsigned int cpu); | ||
73 | extern void r8a7779_secondary_init(unsigned int cpu); | ||
74 | extern int r8a7779_boot_secondary(unsigned int cpu); | ||
75 | extern void r8a7779_smp_prepare_cpus(void); | ||
76 | |||
71 | #endif /* __ARCH_MACH_COMMON_H */ | 77 | #endif /* __ARCH_MACH_COMMON_H */ |
diff --git a/arch/arm/mach-shmobile/include/mach/r8a7779.h b/arch/arm/mach-shmobile/include/mach/r8a7779.h index e6a6166fdf22..b07ad318eb2e 100644 --- a/arch/arm/mach-shmobile/include/mach/r8a7779.h +++ b/arch/arm/mach-shmobile/include/mach/r8a7779.h | |||
@@ -343,6 +343,9 @@ static inline struct r8a7779_pm_ch *to_r8a7779_ch(struct generic_pm_domain *d) | |||
343 | return &container_of(d, struct r8a7779_pm_domain, genpd)->ch; | 343 | return &container_of(d, struct r8a7779_pm_domain, genpd)->ch; |
344 | } | 344 | } |
345 | 345 | ||
346 | extern int r8a7779_sysc_power_down(struct r8a7779_pm_ch *r8a7779_ch); | ||
347 | extern int r8a7779_sysc_power_up(struct r8a7779_pm_ch *r8a7779_ch); | ||
348 | |||
346 | #ifdef CONFIG_PM | 349 | #ifdef CONFIG_PM |
347 | extern struct r8a7779_pm_domain r8a7779_sh4a; | 350 | extern struct r8a7779_pm_domain r8a7779_sh4a; |
348 | extern struct r8a7779_pm_domain r8a7779_sgx; | 351 | extern struct r8a7779_pm_domain r8a7779_sgx; |
diff --git a/arch/arm/mach-shmobile/platsmp.c b/arch/arm/mach-shmobile/platsmp.c index 3f3325d4206d..993381257f69 100644 --- a/arch/arm/mach-shmobile/platsmp.c +++ b/arch/arm/mach-shmobile/platsmp.c | |||
@@ -22,12 +22,16 @@ | |||
22 | #include <mach/common.h> | 22 | #include <mach/common.h> |
23 | 23 | ||
24 | #define is_sh73a0() (machine_is_ag5evm() || machine_is_kota2()) | 24 | #define is_sh73a0() (machine_is_ag5evm() || machine_is_kota2()) |
25 | #define is_r8a7779() machine_is_marzen() | ||
25 | 26 | ||
26 | static unsigned int __init shmobile_smp_get_core_count(void) | 27 | static unsigned int __init shmobile_smp_get_core_count(void) |
27 | { | 28 | { |
28 | if (is_sh73a0()) | 29 | if (is_sh73a0()) |
29 | return sh73a0_get_core_count(); | 30 | return sh73a0_get_core_count(); |
30 | 31 | ||
32 | if (is_r8a7779()) | ||
33 | return r8a7779_get_core_count(); | ||
34 | |||
31 | return 1; | 35 | return 1; |
32 | } | 36 | } |
33 | 37 | ||
@@ -35,10 +39,16 @@ static void __init shmobile_smp_prepare_cpus(void) | |||
35 | { | 39 | { |
36 | if (is_sh73a0()) | 40 | if (is_sh73a0()) |
37 | sh73a0_smp_prepare_cpus(); | 41 | sh73a0_smp_prepare_cpus(); |
42 | |||
43 | if (is_r8a7779()) | ||
44 | r8a7779_smp_prepare_cpus(); | ||
38 | } | 45 | } |
39 | 46 | ||
40 | int shmobile_platform_cpu_kill(unsigned int cpu) | 47 | int shmobile_platform_cpu_kill(unsigned int cpu) |
41 | { | 48 | { |
49 | if (is_r8a7779()) | ||
50 | return r8a7779_platform_cpu_kill(cpu); | ||
51 | |||
42 | return 1; | 52 | return 1; |
43 | } | 53 | } |
44 | 54 | ||
@@ -48,6 +58,9 @@ void __cpuinit platform_secondary_init(unsigned int cpu) | |||
48 | 58 | ||
49 | if (is_sh73a0()) | 59 | if (is_sh73a0()) |
50 | sh73a0_secondary_init(cpu); | 60 | sh73a0_secondary_init(cpu); |
61 | |||
62 | if (is_r8a7779()) | ||
63 | r8a7779_secondary_init(cpu); | ||
51 | } | 64 | } |
52 | 65 | ||
53 | int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle) | 66 | int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle) |
@@ -55,6 +68,9 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle) | |||
55 | if (is_sh73a0()) | 68 | if (is_sh73a0()) |
56 | return sh73a0_boot_secondary(cpu); | 69 | return sh73a0_boot_secondary(cpu); |
57 | 70 | ||
71 | if (is_r8a7779()) | ||
72 | return r8a7779_boot_secondary(cpu); | ||
73 | |||
58 | return -ENOSYS; | 74 | return -ENOSYS; |
59 | } | 75 | } |
60 | 76 | ||
diff --git a/arch/arm/mach-shmobile/pm-r8a7779.c b/arch/arm/mach-shmobile/pm-r8a7779.c index d9c56fe067a5..c38ba7b43ef8 100644 --- a/arch/arm/mach-shmobile/pm-r8a7779.c +++ b/arch/arm/mach-shmobile/pm-r8a7779.c | |||
@@ -48,7 +48,9 @@ static void __iomem *r8a7779_sysc_base; | |||
48 | #define SYSCISR_RETRIES 1000 | 48 | #define SYSCISR_RETRIES 1000 |
49 | #define SYSCISR_DELAY_US 1 | 49 | #define SYSCISR_DELAY_US 1 |
50 | 50 | ||
51 | #ifdef CONFIG_PM | 51 | #if defined(CONFIG_PM) || defined(CONFIG_SMP) |
52 | |||
53 | static DEFINE_SPINLOCK(r8a7779_sysc_lock); /* SMP CPUs + I/O devices */ | ||
52 | 54 | ||
53 | static int r8a7779_sysc_pwr_on_off(struct r8a7779_pm_ch *r8a7779_ch, | 55 | static int r8a7779_sysc_pwr_on_off(struct r8a7779_pm_ch *r8a7779_ch, |
54 | int sr_bit, int reg_offs) | 56 | int sr_bit, int reg_offs) |
@@ -86,9 +88,12 @@ static int r8a7779_sysc_update(struct r8a7779_pm_ch *r8a7779_ch, | |||
86 | unsigned int isr_mask = 1 << r8a7779_ch->isr_bit; | 88 | unsigned int isr_mask = 1 << r8a7779_ch->isr_bit; |
87 | unsigned int chan_mask = 1 << r8a7779_ch->chan_bit; | 89 | unsigned int chan_mask = 1 << r8a7779_ch->chan_bit; |
88 | unsigned int status; | 90 | unsigned int status; |
91 | unsigned long flags; | ||
89 | int ret = 0; | 92 | int ret = 0; |
90 | int k; | 93 | int k; |
91 | 94 | ||
95 | spin_lock_irqsave(&r8a7779_sysc_lock, flags); | ||
96 | |||
92 | iowrite32(isr_mask, r8a7779_sysc_base + SYSCISCR); | 97 | iowrite32(isr_mask, r8a7779_sysc_base + SYSCISCR); |
93 | 98 | ||
94 | do { | 99 | do { |
@@ -112,6 +117,8 @@ static int r8a7779_sysc_update(struct r8a7779_pm_ch *r8a7779_ch, | |||
112 | iowrite32(isr_mask, r8a7779_sysc_base + SYSCISCR); | 117 | iowrite32(isr_mask, r8a7779_sysc_base + SYSCISCR); |
113 | 118 | ||
114 | out: | 119 | out: |
120 | spin_unlock_irqrestore(&r8a7779_sysc_lock, flags); | ||
121 | |||
115 | pr_debug("r8a7779 power domain %d: %02x %02x %02x %02x %02x -> %d\n", | 122 | pr_debug("r8a7779 power domain %d: %02x %02x %02x %02x %02x -> %d\n", |
116 | r8a7779_ch->isr_bit, ioread32(r8a7779_sysc_base + PWRSR0), | 123 | r8a7779_ch->isr_bit, ioread32(r8a7779_sysc_base + PWRSR0), |
117 | ioread32(r8a7779_sysc_base + PWRSR1), | 124 | ioread32(r8a7779_sysc_base + PWRSR1), |
@@ -121,12 +128,12 @@ static int r8a7779_sysc_update(struct r8a7779_pm_ch *r8a7779_ch, | |||
121 | return ret; | 128 | return ret; |
122 | } | 129 | } |
123 | 130 | ||
124 | static int r8a7779_sysc_power_down(struct r8a7779_pm_ch *r8a7779_ch) | 131 | int r8a7779_sysc_power_down(struct r8a7779_pm_ch *r8a7779_ch) |
125 | { | 132 | { |
126 | return r8a7779_sysc_update(r8a7779_ch, r8a7779_sysc_pwr_off); | 133 | return r8a7779_sysc_update(r8a7779_ch, r8a7779_sysc_pwr_off); |
127 | } | 134 | } |
128 | 135 | ||
129 | static int r8a7779_sysc_power_up(struct r8a7779_pm_ch *r8a7779_ch) | 136 | int r8a7779_sysc_power_up(struct r8a7779_pm_ch *r8a7779_ch) |
130 | { | 137 | { |
131 | return r8a7779_sysc_update(r8a7779_ch, r8a7779_sysc_pwr_on); | 138 | return r8a7779_sysc_update(r8a7779_ch, r8a7779_sysc_pwr_on); |
132 | } | 139 | } |
@@ -142,6 +149,14 @@ static void __init r8a7779_sysc_init(void) | |||
142 | iowrite32(0, r8a7779_sysc_base + SYSCIMR); | 149 | iowrite32(0, r8a7779_sysc_base + SYSCIMR); |
143 | } | 150 | } |
144 | 151 | ||
152 | #else /* CONFIG_PM || CONFIG_SMP */ | ||
153 | |||
154 | static inline void r8a7779_sysc_init(void) {} | ||
155 | |||
156 | #endif /* CONFIG_PM || CONFIG_SMP */ | ||
157 | |||
158 | #ifdef CONFIG_PM | ||
159 | |||
145 | static int pd_power_down(struct generic_pm_domain *genpd) | 160 | static int pd_power_down(struct generic_pm_domain *genpd) |
146 | { | 161 | { |
147 | return r8a7779_sysc_power_down(to_r8a7779_ch(genpd)); | 162 | return r8a7779_sysc_power_down(to_r8a7779_ch(genpd)); |
@@ -223,13 +238,12 @@ struct r8a7779_pm_domain r8a7779_impx3 = { | |||
223 | } | 238 | } |
224 | }; | 239 | }; |
225 | 240 | ||
226 | #else /* CONFIG_PM */ | ||
227 | |||
228 | static inline void r8a7779_sysc_init(void) {} | ||
229 | |||
230 | #endif /* CONFIG_PM */ | 241 | #endif /* CONFIG_PM */ |
231 | 242 | ||
232 | void __init r8a7779_pm_init(void) | 243 | void __init r8a7779_pm_init(void) |
233 | { | 244 | { |
234 | r8a7779_sysc_init(); | 245 | static int once; |
246 | |||
247 | if (!once++) | ||
248 | r8a7779_sysc_init(); | ||
235 | } | 249 | } |
diff --git a/arch/arm/mach-shmobile/smp-r8a7779.c b/arch/arm/mach-shmobile/smp-r8a7779.c new file mode 100644 index 000000000000..cc97ef892d1b --- /dev/null +++ b/arch/arm/mach-shmobile/smp-r8a7779.c | |||
@@ -0,0 +1,153 @@ | |||
1 | /* | ||
2 | * SMP support for R-Mobile / SH-Mobile - r8a7779 portion | ||
3 | * | ||
4 | * Copyright (C) 2011 Renesas Solutions Corp. | ||
5 | * Copyright (C) 2011 Magnus Damm | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; version 2 of the License. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/smp.h> | ||
23 | #include <linux/spinlock.h> | ||
24 | #include <linux/io.h> | ||
25 | #include <linux/delay.h> | ||
26 | #include <mach/common.h> | ||
27 | #include <mach/r8a7779.h> | ||
28 | #include <asm/smp_scu.h> | ||
29 | #include <asm/smp_twd.h> | ||
30 | #include <asm/hardware/gic.h> | ||
31 | |||
32 | #define AVECR 0xfe700040 | ||
33 | |||
34 | static struct r8a7779_pm_ch r8a7779_ch_cpu1 = { | ||
35 | .chan_offs = 0x40, /* PWRSR0 .. PWRER0 */ | ||
36 | .chan_bit = 1, /* ARM1 */ | ||
37 | .isr_bit = 1, /* ARM1 */ | ||
38 | }; | ||
39 | |||
40 | static struct r8a7779_pm_ch r8a7779_ch_cpu2 = { | ||
41 | .chan_offs = 0x40, /* PWRSR0 .. PWRER0 */ | ||
42 | .chan_bit = 2, /* ARM2 */ | ||
43 | .isr_bit = 2, /* ARM2 */ | ||
44 | }; | ||
45 | |||
46 | static struct r8a7779_pm_ch r8a7779_ch_cpu3 = { | ||
47 | .chan_offs = 0x40, /* PWRSR0 .. PWRER0 */ | ||
48 | .chan_bit = 3, /* ARM3 */ | ||
49 | .isr_bit = 3, /* ARM3 */ | ||
50 | }; | ||
51 | |||
52 | static struct r8a7779_pm_ch *r8a7779_ch_cpu[4] = { | ||
53 | [1] = &r8a7779_ch_cpu1, | ||
54 | [2] = &r8a7779_ch_cpu2, | ||
55 | [3] = &r8a7779_ch_cpu3, | ||
56 | }; | ||
57 | |||
58 | static void __iomem *scu_base_addr(void) | ||
59 | { | ||
60 | return (void __iomem *)0xf0000000; | ||
61 | } | ||
62 | |||
63 | static DEFINE_SPINLOCK(scu_lock); | ||
64 | static unsigned long tmp; | ||
65 | |||
66 | static void modify_scu_cpu_psr(unsigned long set, unsigned long clr) | ||
67 | { | ||
68 | void __iomem *scu_base = scu_base_addr(); | ||
69 | |||
70 | spin_lock(&scu_lock); | ||
71 | tmp = __raw_readl(scu_base + 8); | ||
72 | tmp &= ~clr; | ||
73 | tmp |= set; | ||
74 | spin_unlock(&scu_lock); | ||
75 | |||
76 | /* disable cache coherency after releasing the lock */ | ||
77 | __raw_writel(tmp, scu_base + 8); | ||
78 | } | ||
79 | |||
80 | unsigned int __init r8a7779_get_core_count(void) | ||
81 | { | ||
82 | void __iomem *scu_base = scu_base_addr(); | ||
83 | |||
84 | #ifdef CONFIG_HAVE_ARM_TWD | ||
85 | /* twd_base needs to be initialized before percpu_timer_setup() */ | ||
86 | twd_base = (void __iomem *)0xf0000600; | ||
87 | #endif | ||
88 | |||
89 | return scu_get_core_count(scu_base); | ||
90 | } | ||
91 | |||
92 | int r8a7779_platform_cpu_kill(unsigned int cpu) | ||
93 | { | ||
94 | struct r8a7779_pm_ch *ch = NULL; | ||
95 | int ret = -EIO; | ||
96 | |||
97 | cpu = cpu_logical_map(cpu); | ||
98 | |||
99 | /* disable cache coherency */ | ||
100 | modify_scu_cpu_psr(3 << (cpu * 8), 0); | ||
101 | |||
102 | if (cpu < ARRAY_SIZE(r8a7779_ch_cpu)) | ||
103 | ch = r8a7779_ch_cpu[cpu]; | ||
104 | |||
105 | if (ch) | ||
106 | ret = r8a7779_sysc_power_down(ch); | ||
107 | |||
108 | return ret ? ret : 1; | ||
109 | } | ||
110 | |||
111 | void __cpuinit r8a7779_secondary_init(unsigned int cpu) | ||
112 | { | ||
113 | gic_secondary_init(0); | ||
114 | } | ||
115 | |||
116 | int __cpuinit r8a7779_boot_secondary(unsigned int cpu) | ||
117 | { | ||
118 | struct r8a7779_pm_ch *ch = NULL; | ||
119 | int ret = -EIO; | ||
120 | |||
121 | cpu = cpu_logical_map(cpu); | ||
122 | |||
123 | /* enable cache coherency */ | ||
124 | modify_scu_cpu_psr(0, 3 << (cpu * 8)); | ||
125 | |||
126 | if (cpu < ARRAY_SIZE(r8a7779_ch_cpu)) | ||
127 | ch = r8a7779_ch_cpu[cpu]; | ||
128 | |||
129 | if (ch) | ||
130 | ret = r8a7779_sysc_power_up(ch); | ||
131 | |||
132 | return ret; | ||
133 | } | ||
134 | |||
135 | void __init r8a7779_smp_prepare_cpus(void) | ||
136 | { | ||
137 | int cpu = cpu_logical_map(0); | ||
138 | |||
139 | scu_enable(scu_base_addr()); | ||
140 | |||
141 | /* Map the reset vector (in headsmp.S) */ | ||
142 | __raw_writel(__pa(shmobile_secondary_vector), __io(AVECR)); | ||
143 | |||
144 | /* enable cache coherency on CPU0 */ | ||
145 | modify_scu_cpu_psr(0, 3 << (cpu * 8)); | ||
146 | |||
147 | r8a7779_pm_init(); | ||
148 | |||
149 | /* power off secondary CPUs */ | ||
150 | r8a7779_platform_cpu_kill(1); | ||
151 | r8a7779_platform_cpu_kill(2); | ||
152 | r8a7779_platform_cpu_kill(3); | ||
153 | } | ||