Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2002 ARM Ltd. |
| 3 | * All Rights Reserved |
Syed Rameez Mustafa | 3971c14 | 2013-01-09 19:04:53 -0800 | [diff] [blame] | 4 | * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved. |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
| 10 | |
Syed Rameez Mustafa | 9de4634 | 2012-11-30 11:00:08 -0800 | [diff] [blame] | 11 | #include <linux/init.h> |
Joel King | 274621c | 2011-12-05 06:18:20 -0800 | [diff] [blame] | 12 | #include <linux/kernel.h> |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 13 | #include <linux/init.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 14 | #include <linux/cpumask.h> |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 15 | #include <linux/delay.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 16 | #include <linux/interrupt.h> |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 17 | #include <linux/io.h> |
Stepan Moskovchenko | 6b1d5df | 2012-08-11 22:33:20 -0700 | [diff] [blame] | 18 | #include <linux/regulator/krait-regulator.h> |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 19 | |
| 20 | #include <asm/hardware/gic.h> |
| 21 | #include <asm/cacheflush.h> |
Jeff Ohlstein | 41ff445 | 2011-04-07 17:41:09 -0700 | [diff] [blame] | 22 | #include <asm/cputype.h> |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 23 | #include <asm/mach-types.h> |
Will Deacon | eb50439 | 2012-01-20 12:01:12 +0100 | [diff] [blame] | 24 | #include <asm/smp_plat.h> |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 25 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 26 | #include <mach/socinfo.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 27 | #include <mach/hardware.h> |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 28 | #include <mach/msm_iomap.h> |
| 29 | |
Matt Wagantall | 7cca464 | 2012-02-01 16:43:24 -0800 | [diff] [blame] | 30 | #include "pm.h" |
Syed Rameez Mustafa | 9de4634 | 2012-11-30 11:00:08 -0800 | [diff] [blame] | 31 | #include "platsmp.h" |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 32 | #include "scm-boot.h" |
Stepan Moskovchenko | 9bbe585 | 2012-01-09 13:28:28 -0800 | [diff] [blame] | 33 | #include "spm.h" |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 34 | |
| 35 | #define VDD_SC1_ARRAY_CLAMP_GFS_CTL 0x15A0 |
| 36 | #define SCSS_CPU1CORE_RESET 0xD80 |
| 37 | #define SCSS_DBG_STATUS_CORE_PWRDUP 0xE64 |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 38 | |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 39 | /* |
| 40 | * control for which core is the next to come out of the secondary |
| 41 | * boot "holding pen". |
| 42 | */ |
| 43 | volatile int pen_release = -1; |
| 44 | |
Stephen Boyd | f5e9082 | 2012-08-08 13:36:15 -0700 | [diff] [blame] | 45 | /* |
| 46 | * Write pen_release in a way that is guaranteed to be visible to all |
| 47 | * observers, irrespective of whether they're taking part in coherency |
| 48 | * or not. This is necessary for the hotplug code to work reliably. |
| 49 | */ |
Syed Rameez Mustafa | 9de4634 | 2012-11-30 11:00:08 -0800 | [diff] [blame] | 50 | void __cpuinit write_pen_release(int val) |
Stephen Boyd | f5e9082 | 2012-08-08 13:36:15 -0700 | [diff] [blame] | 51 | { |
| 52 | pen_release = val; |
| 53 | smp_wmb(); |
| 54 | __cpuc_flush_dcache_area((void *)&pen_release, sizeof(pen_release)); |
| 55 | outer_clean_range(__pa(&pen_release), __pa(&pen_release + 1)); |
| 56 | } |
| 57 | |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 58 | static DEFINE_SPINLOCK(boot_lock); |
| 59 | |
| 60 | void __cpuinit platform_secondary_init(unsigned int cpu) |
| 61 | { |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 62 | WARN_ON(msm_platform_secondary_init(cpu)); |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 63 | |
| 64 | /* |
| 65 | * if any interrupts are already enabled for the primary |
| 66 | * core (e.g. timer irq), then they will not have been enabled |
| 67 | * for us: do so |
| 68 | */ |
| 69 | gic_secondary_init(0); |
| 70 | |
| 71 | /* |
Stephen Boyd | f5e9082 | 2012-08-08 13:36:15 -0700 | [diff] [blame] | 72 | * let the primary processor know we're out of the |
| 73 | * pen, then head off into the C entry point |
| 74 | */ |
| 75 | write_pen_release(-1); |
| 76 | |
| 77 | /* |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 78 | * Synchronise with the boot thread. |
| 79 | */ |
| 80 | spin_lock(&boot_lock); |
| 81 | spin_unlock(&boot_lock); |
| 82 | } |
| 83 | |
Syed Rameez Mustafa | 8386d53 | 2013-01-18 17:41:17 -0800 | [diff] [blame] | 84 | static int __cpuinit release_secondary_sim(unsigned long base, unsigned int cpu) |
Syed Rameez Mustafa | 9de4634 | 2012-11-30 11:00:08 -0800 | [diff] [blame] | 85 | { |
| 86 | void *base_ptr = ioremap_nocache(base + (cpu * 0x10000), SZ_4K); |
| 87 | if (!base_ptr) |
| 88 | return -ENODEV; |
| 89 | |
| 90 | writel_relaxed(0x800, base_ptr+0x04); |
| 91 | writel_relaxed(0x3FFF, base_ptr+0x14); |
| 92 | |
| 93 | mb(); |
| 94 | iounmap(base_ptr); |
| 95 | return 0; |
| 96 | } |
| 97 | |
Stepan Moskovchenko | 964e103 | 2012-01-06 18:16:10 -0800 | [diff] [blame] | 98 | static int __cpuinit scorpion_release_secondary(void) |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 99 | { |
Stepan Moskovchenko | 964e103 | 2012-01-06 18:16:10 -0800 | [diff] [blame] | 100 | void *base_ptr = ioremap_nocache(0x00902000, SZ_4K*2); |
| 101 | if (!base_ptr) |
| 102 | return -EINVAL; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 103 | |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 104 | writel_relaxed(0, base_ptr + VDD_SC1_ARRAY_CLAMP_GFS_CTL); |
Stepan Moskovchenko | 964e103 | 2012-01-06 18:16:10 -0800 | [diff] [blame] | 105 | dmb(); |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 106 | writel_relaxed(0, base_ptr + SCSS_CPU1CORE_RESET); |
| 107 | writel_relaxed(3, base_ptr + SCSS_DBG_STATUS_CORE_PWRDUP); |
Stepan Moskovchenko | 964e103 | 2012-01-06 18:16:10 -0800 | [diff] [blame] | 108 | mb(); |
| 109 | iounmap(base_ptr); |
| 110 | |
| 111 | return 0; |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 112 | } |
| 113 | |
Syed Rameez Mustafa | 8386d53 | 2013-01-18 17:41:17 -0800 | [diff] [blame] | 114 | static int __cpuinit msm8960_release_secondary(unsigned long base, |
| 115 | unsigned int cpu) |
Stepan Moskovchenko | 964e103 | 2012-01-06 18:16:10 -0800 | [diff] [blame] | 116 | { |
Sathish Ambley | 576a697 | 2012-03-20 12:38:45 -0700 | [diff] [blame] | 117 | void *base_ptr = ioremap_nocache(base + (cpu * 0x10000), SZ_4K); |
Stepan Moskovchenko | 964e103 | 2012-01-06 18:16:10 -0800 | [diff] [blame] | 118 | if (!base_ptr) |
| 119 | return -ENODEV; |
| 120 | |
Stepan Moskovchenko | 9bbe585 | 2012-01-09 13:28:28 -0800 | [diff] [blame] | 121 | msm_spm_turn_on_cpu_rail(cpu); |
| 122 | |
Stepan Moskovchenko | 986b515 | 2012-12-11 18:33:07 -0800 | [diff] [blame] | 123 | writel_relaxed(0x109, base_ptr+0x04); |
| 124 | writel_relaxed(0x101, base_ptr+0x04); |
| 125 | mb(); |
| 126 | ndelay(300); |
| 127 | |
| 128 | writel_relaxed(0x121, base_ptr+0x04); |
Stepan Moskovchenko | 121f75f | 2012-08-16 21:10:13 -0700 | [diff] [blame] | 129 | mb(); |
Stepan Moskovchenko | 964e103 | 2012-01-06 18:16:10 -0800 | [diff] [blame] | 130 | udelay(2); |
| 131 | |
Stepan Moskovchenko | 986b515 | 2012-12-11 18:33:07 -0800 | [diff] [blame] | 132 | writel_relaxed(0x120, base_ptr+0x04); |
Stepan Moskovchenko | 121f75f | 2012-08-16 21:10:13 -0700 | [diff] [blame] | 133 | mb(); |
Stepan Moskovchenko | 964e103 | 2012-01-06 18:16:10 -0800 | [diff] [blame] | 134 | udelay(2); |
| 135 | |
Stepan Moskovchenko | 986b515 | 2012-12-11 18:33:07 -0800 | [diff] [blame] | 136 | writel_relaxed(0x100, base_ptr+0x04); |
Stepan Moskovchenko | 121f75f | 2012-08-16 21:10:13 -0700 | [diff] [blame] | 137 | mb(); |
Stepan Moskovchenko | 964e103 | 2012-01-06 18:16:10 -0800 | [diff] [blame] | 138 | udelay(100); |
| 139 | |
Stepan Moskovchenko | 986b515 | 2012-12-11 18:33:07 -0800 | [diff] [blame] | 140 | writel_relaxed(0x180, base_ptr+0x04); |
Stepan Moskovchenko | 964e103 | 2012-01-06 18:16:10 -0800 | [diff] [blame] | 141 | mb(); |
| 142 | iounmap(base_ptr); |
| 143 | return 0; |
| 144 | } |
| 145 | |
Syed Rameez Mustafa | 8386d53 | 2013-01-18 17:41:17 -0800 | [diff] [blame] | 146 | static int __cpuinit msm8974_release_secondary(unsigned long base, |
| 147 | unsigned int cpu) |
Stepan Moskovchenko | 2517372 | 2012-08-09 13:43:02 -0700 | [diff] [blame] | 148 | { |
| 149 | void *base_ptr = ioremap_nocache(base + (cpu * 0x10000), SZ_4K); |
Abhijeet Dharmapurikar | dd16785 | 2013-02-14 16:46:48 -0800 | [diff] [blame] | 150 | |
Stepan Moskovchenko | 2517372 | 2012-08-09 13:43:02 -0700 | [diff] [blame] | 151 | if (!base_ptr) |
| 152 | return -ENODEV; |
| 153 | |
Abhijeet Dharmapurikar | dd16785 | 2013-02-14 16:46:48 -0800 | [diff] [blame] | 154 | secondary_cpu_hs_init(base_ptr, cpu); |
Stepan Moskovchenko | 6b1d5df | 2012-08-11 22:33:20 -0700 | [diff] [blame] | 155 | |
Stepan Moskovchenko | 2517372 | 2012-08-09 13:43:02 -0700 | [diff] [blame] | 156 | writel_relaxed(0x021, base_ptr+0x04); |
| 157 | mb(); |
| 158 | udelay(2); |
| 159 | |
| 160 | writel_relaxed(0x020, base_ptr+0x04); |
| 161 | mb(); |
| 162 | udelay(2); |
| 163 | |
| 164 | writel_relaxed(0x000, base_ptr+0x04); |
| 165 | mb(); |
| 166 | |
| 167 | writel_relaxed(0x080, base_ptr+0x04); |
| 168 | mb(); |
| 169 | iounmap(base_ptr); |
| 170 | return 0; |
| 171 | } |
| 172 | |
Syed Rameez Mustafa | 975329c | 2013-01-18 18:42:12 -0800 | [diff] [blame] | 173 | static int __cpuinit arm_release_secondary(unsigned long base, unsigned int cpu) |
| 174 | { |
| 175 | void *base_ptr = ioremap_nocache(base + (cpu * 0x10000), SZ_4K); |
| 176 | if (!base_ptr) |
| 177 | return -ENODEV; |
| 178 | |
| 179 | writel_relaxed(0x00000033, base_ptr+0x04); |
| 180 | mb(); |
| 181 | |
| 182 | writel_relaxed(0x10000001, base_ptr+0x14); |
| 183 | mb(); |
| 184 | udelay(2); |
| 185 | |
| 186 | writel_relaxed(0x00000031, base_ptr+0x04); |
| 187 | mb(); |
| 188 | |
| 189 | writel_relaxed(0x00000039, base_ptr+0x04); |
| 190 | mb(); |
| 191 | udelay(2); |
| 192 | |
| 193 | writel_relaxed(0x00020038, base_ptr+0x04); |
| 194 | mb(); |
| 195 | udelay(2); |
| 196 | |
| 197 | |
| 198 | writel_relaxed(0x00020008, base_ptr+0x04); |
| 199 | mb(); |
| 200 | |
| 201 | writel_relaxed(0x00020088, base_ptr+0x04); |
| 202 | mb(); |
| 203 | |
| 204 | iounmap(base_ptr); |
| 205 | return 0; |
| 206 | } |
| 207 | |
Syed Rameez Mustafa | 9de4634 | 2012-11-30 11:00:08 -0800 | [diff] [blame] | 208 | static int __cpuinit release_from_pen(unsigned int cpu) |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 209 | { |
| 210 | unsigned long timeout; |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 211 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 212 | /* Set preset_lpj to avoid subsequent lpj recalculations */ |
| 213 | preset_lpj = loops_per_jiffy; |
| 214 | |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 215 | /* |
| 216 | * set synchronisation state between this boot processor |
| 217 | * and the secondary one |
| 218 | */ |
| 219 | spin_lock(&boot_lock); |
| 220 | |
| 221 | /* |
| 222 | * The secondary processor is waiting to be released from |
| 223 | * the holding pen - release it, then wait for it to flag |
| 224 | * that it has been released by resetting pen_release. |
| 225 | * |
| 226 | * Note that "pen_release" is the hardware CPU ID, whereas |
| 227 | * "cpu" is Linux's internal ID. |
| 228 | */ |
Stephen Boyd | f5e9082 | 2012-08-08 13:36:15 -0700 | [diff] [blame] | 229 | write_pen_release(cpu_logical_map(cpu)); |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 230 | |
| 231 | /* |
| 232 | * Send the secondary CPU a soft interrupt, thereby causing |
| 233 | * the boot monitor to read the system wide flags register, |
| 234 | * and branch to the address found there. |
| 235 | */ |
Russell King | 0f7b332 | 2011-04-03 13:01:30 +0100 | [diff] [blame] | 236 | gic_raise_softirq(cpumask_of(cpu), 1); |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 237 | |
| 238 | timeout = jiffies + (1 * HZ); |
| 239 | while (time_before(jiffies, timeout)) { |
| 240 | smp_rmb(); |
| 241 | if (pen_release == -1) |
| 242 | break; |
| 243 | |
| 244 | udelay(10); |
| 245 | } |
| 246 | |
| 247 | /* |
| 248 | * now the secondary core is starting up let it run its |
| 249 | * calibrations, then wait for it to finish |
| 250 | */ |
| 251 | spin_unlock(&boot_lock); |
| 252 | |
| 253 | return pen_release != -1 ? -ENOSYS : 0; |
| 254 | } |
Syed Rameez Mustafa | 9de4634 | 2012-11-30 11:00:08 -0800 | [diff] [blame] | 255 | |
| 256 | DEFINE_PER_CPU(int, cold_boot_done); |
| 257 | |
| 258 | int __cpuinit scorpion_boot_secondary(unsigned int cpu, |
| 259 | struct task_struct *idle) |
| 260 | { |
| 261 | pr_debug("Starting secondary CPU %d\n", cpu); |
| 262 | |
| 263 | if (per_cpu(cold_boot_done, cpu) == false) { |
| 264 | scorpion_release_secondary(); |
| 265 | per_cpu(cold_boot_done, cpu) = true; |
| 266 | } |
| 267 | return release_from_pen(cpu); |
| 268 | } |
| 269 | |
| 270 | int __cpuinit msm8960_boot_secondary(unsigned int cpu, struct task_struct *idle) |
| 271 | { |
| 272 | pr_debug("Starting secondary CPU %d\n", cpu); |
| 273 | |
| 274 | if (per_cpu(cold_boot_done, cpu) == false) { |
| 275 | msm8960_release_secondary(0x02088000, cpu); |
| 276 | per_cpu(cold_boot_done, cpu) = true; |
| 277 | } |
| 278 | return release_from_pen(cpu); |
| 279 | } |
| 280 | |
| 281 | int __cpuinit msm8974_boot_secondary(unsigned int cpu, struct task_struct *idle) |
| 282 | { |
| 283 | pr_debug("Starting secondary CPU %d\n", cpu); |
| 284 | |
| 285 | if (per_cpu(cold_boot_done, cpu) == false) { |
Stepan Moskovchenko | 82f0eab | 2013-04-02 19:52:28 -0700 | [diff] [blame] | 286 | if (of_board_is_sim()) |
Syed Rameez Mustafa | 9de4634 | 2012-11-30 11:00:08 -0800 | [diff] [blame] | 287 | release_secondary_sim(0xf9088000, cpu); |
Stepan Moskovchenko | 82f0eab | 2013-04-02 19:52:28 -0700 | [diff] [blame] | 288 | else if (!of_board_is_rumi()) |
Syed Rameez Mustafa | 9de4634 | 2012-11-30 11:00:08 -0800 | [diff] [blame] | 289 | msm8974_release_secondary(0xf9088000, cpu); |
| 290 | |
| 291 | per_cpu(cold_boot_done, cpu) = true; |
| 292 | } |
| 293 | return release_from_pen(cpu); |
| 294 | } |
| 295 | |
| 296 | int __cpuinit arm_boot_secondary(unsigned int cpu, struct task_struct *idle) |
| 297 | { |
| 298 | pr_debug("Starting secondary CPU %d\n", cpu); |
| 299 | |
| 300 | if (per_cpu(cold_boot_done, cpu) == false) { |
Stepan Moskovchenko | 82f0eab | 2013-04-02 19:52:28 -0700 | [diff] [blame] | 301 | if (of_board_is_sim()) |
Syed Rameez Mustafa | 9de4634 | 2012-11-30 11:00:08 -0800 | [diff] [blame] | 302 | release_secondary_sim(0xf9088000, cpu); |
Stepan Moskovchenko | 82f0eab | 2013-04-02 19:52:28 -0700 | [diff] [blame] | 303 | else if (!of_board_is_rumi()) |
Syed Rameez Mustafa | 975329c | 2013-01-18 18:42:12 -0800 | [diff] [blame] | 304 | arm_release_secondary(0xf9088000, cpu); |
Syed Rameez Mustafa | 9de4634 | 2012-11-30 11:00:08 -0800 | [diff] [blame] | 305 | |
| 306 | per_cpu(cold_boot_done, cpu) = true; |
| 307 | } |
| 308 | return release_from_pen(cpu); |
| 309 | } |
| 310 | |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 311 | /* |
| 312 | * Initialise the CPU possible map early - this describes the CPUs |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 313 | * which may be present or become present in the system. |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 314 | */ |
Syed Rameez Mustafa | 9de4634 | 2012-11-30 11:00:08 -0800 | [diff] [blame] | 315 | static void __init msm_smp_init_cpus(void) |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 316 | { |
Jeff Ohlstein | 41ff445 | 2011-04-07 17:41:09 -0700 | [diff] [blame] | 317 | unsigned int i, ncores = get_core_count(); |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 318 | |
Russell King | a06f916 | 2011-10-20 22:04:18 +0100 | [diff] [blame] | 319 | if (ncores > nr_cpu_ids) { |
| 320 | pr_warn("SMP: %u cores greater than maximum (%u), clipping\n", |
| 321 | ncores, nr_cpu_ids); |
| 322 | ncores = nr_cpu_ids; |
| 323 | } |
| 324 | |
Jeff Ohlstein | 41ff445 | 2011-04-07 17:41:09 -0700 | [diff] [blame] | 325 | for (i = 0; i < ncores; i++) |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 326 | set_cpu_possible(i, true); |
Russell King | 0f7b332 | 2011-04-03 13:01:30 +0100 | [diff] [blame] | 327 | |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 328 | set_smp_cross_call(gic_raise_softirq); |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 329 | } |
| 330 | |
Syed Rameez Mustafa | 9de4634 | 2012-11-30 11:00:08 -0800 | [diff] [blame] | 331 | static void __init arm_smp_init_cpus(void) |
| 332 | { |
| 333 | unsigned int i, ncores; |
| 334 | |
| 335 | ncores = (__raw_readl(MSM_APCS_GCC_BASE + 0x30)) & 0xF; |
| 336 | |
| 337 | if (ncores > nr_cpu_ids) { |
| 338 | pr_warn("SMP: %u cores greater than maximum (%u), clipping\n", |
| 339 | ncores, nr_cpu_ids); |
| 340 | ncores = nr_cpu_ids; |
| 341 | } |
| 342 | |
| 343 | for (i = 0; i < ncores; i++) |
| 344 | set_cpu_possible(i, true); |
| 345 | |
| 346 | set_smp_cross_call(gic_raise_softirq); |
| 347 | } |
| 348 | |
Stephen Boyd | 8699b37 | 2012-08-08 15:22:04 -0700 | [diff] [blame] | 349 | static int cold_boot_flags[] __initdata = { |
| 350 | 0, |
| 351 | SCM_FLAG_COLDBOOT_CPU1, |
| 352 | SCM_FLAG_COLDBOOT_CPU2, |
| 353 | SCM_FLAG_COLDBOOT_CPU3, |
| 354 | }; |
| 355 | |
Syed Rameez Mustafa | 9de4634 | 2012-11-30 11:00:08 -0800 | [diff] [blame] | 356 | static void __init msm_platform_smp_prepare_cpus(unsigned int max_cpus) |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 357 | { |
Stephen Boyd | 8699b37 | 2012-08-08 15:22:04 -0700 | [diff] [blame] | 358 | int cpu, map; |
| 359 | unsigned int flags = 0; |
| 360 | |
| 361 | for_each_present_cpu(cpu) { |
| 362 | map = cpu_logical_map(cpu); |
| 363 | if (map > ARRAY_SIZE(cold_boot_flags)) { |
| 364 | set_cpu_present(cpu, false); |
| 365 | __WARN(); |
| 366 | continue; |
| 367 | } |
| 368 | flags |= cold_boot_flags[map]; |
| 369 | } |
| 370 | |
| 371 | if (scm_set_boot_addr(virt_to_phys(msm_secondary_startup), flags)) |
| 372 | pr_warn("Failed to set CPU boot address\n"); |
Jeff Ohlstein | e14411d | 2010-11-30 13:06:36 -0800 | [diff] [blame] | 373 | } |
Syed Rameez Mustafa | 9de4634 | 2012-11-30 11:00:08 -0800 | [diff] [blame] | 374 | |
Syed Rameez Mustafa | 9de4634 | 2012-11-30 11:00:08 -0800 | [diff] [blame] | 375 | struct smp_operations arm_smp_ops __initdata = { |
| 376 | .smp_init_cpus = arm_smp_init_cpus, |
Syed Rameez Mustafa | 4150458 | 2013-01-25 20:28:16 -0800 | [diff] [blame] | 377 | .smp_prepare_cpus = msm_platform_smp_prepare_cpus, |
Syed Rameez Mustafa | 9de4634 | 2012-11-30 11:00:08 -0800 | [diff] [blame] | 378 | .smp_secondary_init = platform_secondary_init, |
| 379 | .smp_boot_secondary = arm_boot_secondary, |
| 380 | .cpu_kill = platform_cpu_kill, |
| 381 | .cpu_die = platform_cpu_die, |
| 382 | .cpu_disable = platform_cpu_disable |
| 383 | }; |
| 384 | |
| 385 | struct smp_operations msm8974_smp_ops __initdata = { |
| 386 | .smp_init_cpus = msm_smp_init_cpus, |
| 387 | .smp_prepare_cpus = msm_platform_smp_prepare_cpus, |
| 388 | .smp_secondary_init = platform_secondary_init, |
| 389 | .smp_boot_secondary = msm8974_boot_secondary, |
| 390 | .cpu_kill = platform_cpu_kill, |
| 391 | .cpu_die = platform_cpu_die, |
| 392 | .cpu_disable = platform_cpu_disable |
| 393 | }; |
| 394 | |
| 395 | struct smp_operations msm8960_smp_ops __initdata = { |
| 396 | .smp_init_cpus = msm_smp_init_cpus, |
| 397 | .smp_prepare_cpus = msm_platform_smp_prepare_cpus, |
| 398 | .smp_secondary_init = platform_secondary_init, |
| 399 | .smp_boot_secondary = msm8960_boot_secondary, |
| 400 | .cpu_kill = platform_cpu_kill, |
| 401 | .cpu_die = platform_cpu_die, |
| 402 | .cpu_disable = platform_cpu_disable |
| 403 | }; |
| 404 | |
| 405 | struct smp_operations scorpion_smp_ops __initdata = { |
| 406 | .smp_init_cpus = msm_smp_init_cpus, |
| 407 | .smp_prepare_cpus = msm_platform_smp_prepare_cpus, |
| 408 | .smp_secondary_init = platform_secondary_init, |
| 409 | .smp_boot_secondary = scorpion_boot_secondary, |
| 410 | .cpu_kill = platform_cpu_kill, |
| 411 | .cpu_die = platform_cpu_die, |
| 412 | .cpu_disable = platform_cpu_disable |
| 413 | }; |