2 * linux/arch/arm/mach-tegra/platsmp.c
4 * Copyright (C) 2002 ARM Ltd.
7 * Copyright (C) 2009 Palm
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>
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>
33 extern void tegra_secondary_startup(void);
35 static void __iomem *scu_base = IO_ADDRESS(TEGRA_ARM_PERIF_BASE);
37 #define EVP_CPU_RESET_VECTOR \
38 (IO_ADDRESS(TEGRA_EXCEPTION_VECTORS_BASE) + 0x100)
39 #define CLK_RST_CONTROLLER_CLK_CPU_CMPLX \
40 (IO_ADDRESS(TEGRA_CLK_RESET_BASE) + 0x4c)
41 #define CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET \
42 (IO_ADDRESS(TEGRA_CLK_RESET_BASE) + 0x340)
43 #define CLK_RST_CONTROLLER_RST_CPU_CMPLX_CLR \
44 (IO_ADDRESS(TEGRA_CLK_RESET_BASE) + 0x344)
46 #define CPU_CLOCK(cpu) (0x1<<(8+cpu))
47 #define CPU_RESET(cpu) (0x1111ul<<(cpu))
49 void __cpuinit platform_secondary_init(unsigned int cpu)
52 * if any interrupts are already enabled for the primary
53 * core (e.g. timer irq), then they will not have been enabled
56 gic_secondary_init(0);
60 static int tegra20_power_up_cpu(unsigned int cpu)
64 /* Enable the CPU clock. */
65 reg = readl(CLK_RST_CONTROLLER_CLK_CPU_CMPLX);
66 writel(reg & ~CPU_CLOCK(cpu), CLK_RST_CONTROLLER_CLK_CPU_CMPLX);
68 reg = readl(CLK_RST_CONTROLLER_CLK_CPU_CMPLX);
70 /* Clear flow controller CSR. */
71 flowctrl_write_cpu_csr(cpu, 0);
76 int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
80 /* Force the CPU into reset. The CPU must remain in reset when the
81 * flow controller state is cleared (which will cause the flow
82 * controller to stop driving reset if the CPU has been power-gated
83 * via the flow controller). This will have no effect on first boot
84 * of the CPU since it should already be in reset.
86 writel(CPU_RESET(cpu), CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET);
90 * Unhalt the CPU. If the flow controller was used to power-gate the
91 * CPU this will cause the flow controller to stop driving reset.
92 * The CPU will remain in reset because the clock and reset block
93 * is now driving reset.
95 flowctrl_write_cpu_halt(cpu, 0);
97 switch (tegra_chip_id) {
99 status = tegra20_power_up_cpu(cpu);
109 /* Take the CPU out of reset. */
110 writel(CPU_RESET(cpu), CLK_RST_CONTROLLER_RST_CPU_CMPLX_CLR);
117 * Initialise the CPU possible map early - this describes the CPUs
118 * which may be present or become present in the system.
120 void __init smp_init_cpus(void)
122 unsigned int i, ncores = scu_get_core_count(scu_base);
124 if (ncores > nr_cpu_ids) {
125 pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
130 for (i = 0; i < ncores; i++)
131 set_cpu_possible(i, true);
133 set_smp_cross_call(gic_raise_softirq);
136 void __init platform_smp_prepare_cpus(unsigned int max_cpus)
138 tegra_cpu_reset_handler_init();
139 scu_enable(scu_base);