Merge tag 'v3.3.7' into 3.3/master
[zen-stable.git] / arch / arm / mach-tegra / platsmp.c
blob7d2b5d03c1dff6385ec08125e4ffa9d12f2cf8fd
1 /*
2 * linux/arch/arm/mach-tegra/platsmp.c
4 * Copyright (C) 2002 ARM Ltd.
5 * All Rights Reserved
7 * Copyright (C) 2009 Palm
8 * All Rights Reserved
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
14 #include <linux/init.h>
15 #include <linux/errno.h>
16 #include <linux/delay.h>
17 #include <linux/device.h>
18 #include <linux/jiffies.h>
19 #include <linux/smp.h>
20 #include <linux/io.h>
22 #include <asm/cacheflush.h>
23 #include <asm/hardware/gic.h>
24 #include <asm/mach-types.h>
25 #include <asm/smp_scu.h>
27 #include <mach/iomap.h>
29 extern void tegra_secondary_startup(void);
31 static DEFINE_SPINLOCK(boot_lock);
32 static void __iomem *scu_base = IO_ADDRESS(TEGRA_ARM_PERIF_BASE);
34 #define EVP_CPU_RESET_VECTOR \
35 (IO_ADDRESS(TEGRA_EXCEPTION_VECTORS_BASE) + 0x100)
36 #define CLK_RST_CONTROLLER_CLK_CPU_CMPLX \
37 (IO_ADDRESS(TEGRA_CLK_RESET_BASE) + 0x4c)
38 #define CLK_RST_CONTROLLER_RST_CPU_CMPLX_CLR \
39 (IO_ADDRESS(TEGRA_CLK_RESET_BASE) + 0x344)
41 void __cpuinit platform_secondary_init(unsigned int cpu)
44 * if any interrupts are already enabled for the primary
45 * core (e.g. timer irq), then they will not have been enabled
46 * for us: do so
48 gic_secondary_init(0);
51 * Synchronise with the boot thread.
53 spin_lock(&boot_lock);
54 spin_unlock(&boot_lock);
57 int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
59 unsigned long old_boot_vector;
60 unsigned long boot_vector;
61 unsigned long timeout;
62 u32 reg;
65 * set synchronisation state between this boot processor
66 * and the secondary one
68 spin_lock(&boot_lock);
71 /* set the reset vector to point to the secondary_startup routine */
73 boot_vector = virt_to_phys(tegra_secondary_startup);
74 old_boot_vector = readl(EVP_CPU_RESET_VECTOR);
75 writel(boot_vector, EVP_CPU_RESET_VECTOR);
77 /* enable cpu clock on cpu1 */
78 reg = readl(CLK_RST_CONTROLLER_CLK_CPU_CMPLX);
79 writel(reg & ~(1<<9), CLK_RST_CONTROLLER_CLK_CPU_CMPLX);
81 reg = (1<<13) | (1<<9) | (1<<5) | (1<<1);
82 writel(reg, CLK_RST_CONTROLLER_RST_CPU_CMPLX_CLR);
84 smp_wmb();
85 flush_cache_all();
87 /* unhalt the cpu */
88 writel(0, IO_ADDRESS(TEGRA_FLOW_CTRL_BASE) + 0x14);
90 timeout = jiffies + (1 * HZ);
91 while (time_before(jiffies, timeout)) {
92 if (readl(EVP_CPU_RESET_VECTOR) != boot_vector)
93 break;
94 udelay(10);
97 /* put the old boot vector back */
98 writel(old_boot_vector, EVP_CPU_RESET_VECTOR);
101 * now the secondary core is starting up let it run its
102 * calibrations, then wait for it to finish
104 spin_unlock(&boot_lock);
106 return 0;
110 * Initialise the CPU possible map early - this describes the CPUs
111 * which may be present or become present in the system.
113 void __init smp_init_cpus(void)
115 unsigned int i, ncores = scu_get_core_count(scu_base);
117 if (ncores > nr_cpu_ids) {
118 pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
119 ncores, nr_cpu_ids);
120 ncores = nr_cpu_ids;
123 for (i = 0; i < ncores; i++)
124 set_cpu_possible(i, true);
126 set_smp_cross_call(gic_raise_softirq);
129 void __init platform_smp_prepare_cpus(unsigned int max_cpus)
132 scu_enable(scu_base);