1 From 8e843640b3c4a43b963332fdc7b233948ad25a5b Mon Sep 17 00:00:00 2001
2 From: Rohit Vaswani <rvaswani@codeaurora.org>
3 Date: Tue, 21 May 2013 19:13:50 -0700
4 Subject: [PATCH 013/182] ARM: qcom: Add SMP support for KPSSv1
6 Implement support for the Krait CPU release sequence when the
7 CPUs are part of the first version of the krait processor
10 Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
11 Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
12 Signed-off-by: Kumar Gala <galak@codeaurora.org>
14 arch/arm/mach-qcom/platsmp.c | 106 +++++++++++++++++++++++++++++++++++++++++
15 arch/arm/mach-qcom/scm-boot.h | 8 ++--
16 2 files changed, 111 insertions(+), 3 deletions(-)
18 --- a/arch/arm/mach-qcom/platsmp.c
19 +++ b/arch/arm/mach-qcom/platsmp.c
21 #define SCSS_CPU1CORE_RESET 0x2d80
22 #define SCSS_DBG_STATUS_CORE_PWRDUP 0x2e64
24 +#define APCS_CPU_PWR_CTL 0x04
25 +#define PLL_CLAMP BIT(8)
26 +#define CORE_PWRD_UP BIT(7)
27 +#define COREPOR_RST BIT(5)
28 +#define CORE_RST BIT(4)
29 +#define L2DT_SLP BIT(3)
32 +#define APCS_SAW2_VCTL 0x14
34 extern void secondary_startup(void);
36 static DEFINE_SPINLOCK(boot_lock);
37 @@ -71,6 +81,85 @@ static int scss_release_secondary(unsign
41 +static int kpssv1_release_secondary(unsigned int cpu)
44 + void __iomem *reg, *saw_reg;
45 + struct device_node *cpu_node, *acc_node, *saw_node;
48 + cpu_node = of_get_cpu_node(cpu, NULL);
52 + acc_node = of_parse_phandle(cpu_node, "qcom,acc", 0);
58 + saw_node = of_parse_phandle(cpu_node, "qcom,saw", 0);
64 + reg = of_iomap(acc_node, 0);
70 + saw_reg = of_iomap(saw_node, 0);
76 + /* Turn on CPU rail */
77 + writel_relaxed(0xA4, saw_reg + APCS_SAW2_VCTL);
81 + /* Krait bring-up sequence */
82 + val = PLL_CLAMP | L2DT_SLP | CLAMP;
83 + writel_relaxed(val, reg + APCS_CPU_PWR_CTL);
85 + writel_relaxed(val, reg + APCS_CPU_PWR_CTL);
90 + writel_relaxed(val, reg + APCS_CPU_PWR_CTL);
95 + writel_relaxed(val, reg + APCS_CPU_PWR_CTL);
99 + val &= ~COREPOR_RST;
100 + writel_relaxed(val, reg + APCS_CPU_PWR_CTL);
104 + val |= CORE_PWRD_UP;
105 + writel_relaxed(val, reg + APCS_CPU_PWR_CTL);
112 + of_node_put(saw_node);
114 + of_node_put(acc_node);
116 + of_node_put(cpu_node);
120 static DEFINE_PER_CPU(int, cold_boot_done);
122 static int qcom_boot_secondary(unsigned int cpu, int (*func)(unsigned int))
123 @@ -110,6 +199,11 @@ static int msm8660_boot_secondary(unsign
124 return qcom_boot_secondary(cpu, scss_release_secondary);
127 +static int kpssv1_boot_secondary(unsigned int cpu, struct task_struct *idle)
129 + return qcom_boot_secondary(cpu, kpssv1_release_secondary);
132 static void __init qcom_smp_prepare_cpus(unsigned int max_cpus)
135 @@ -117,6 +211,8 @@ static void __init qcom_smp_prepare_cpus
136 static const int cold_boot_flags[] = {
138 SCM_FLAG_COLDBOOT_CPU1,
139 + SCM_FLAG_COLDBOOT_CPU2,
140 + SCM_FLAG_COLDBOOT_CPU3,
143 for_each_present_cpu(cpu) {
144 @@ -147,3 +243,13 @@ static struct smp_operations smp_msm8660
147 CPU_METHOD_OF_DECLARE(qcom_smp, "qcom,gcc-msm8660", &smp_msm8660_ops);
149 +static struct smp_operations qcom_smp_kpssv1_ops __initdata = {
150 + .smp_prepare_cpus = qcom_smp_prepare_cpus,
151 + .smp_secondary_init = qcom_secondary_init,
152 + .smp_boot_secondary = kpssv1_boot_secondary,
153 +#ifdef CONFIG_HOTPLUG_CPU
154 + .cpu_die = qcom_cpu_die,
157 +CPU_METHOD_OF_DECLARE(qcom_smp_kpssv1, "qcom,kpss-acc-v1", &qcom_smp_kpssv1_ops);
158 --- a/arch/arm/mach-qcom/scm-boot.h
159 +++ b/arch/arm/mach-qcom/scm-boot.h
161 #define __MACH_SCM_BOOT_H
163 #define SCM_BOOT_ADDR 0x1
164 -#define SCM_FLAG_COLDBOOT_CPU1 0x1
165 -#define SCM_FLAG_WARMBOOT_CPU1 0x2
166 -#define SCM_FLAG_WARMBOOT_CPU0 0x4
167 +#define SCM_FLAG_COLDBOOT_CPU1 0x01
168 +#define SCM_FLAG_COLDBOOT_CPU2 0x08
169 +#define SCM_FLAG_COLDBOOT_CPU3 0x20
170 +#define SCM_FLAG_WARMBOOT_CPU0 0x04
171 +#define SCM_FLAG_WARMBOOT_CPU1 0x02
173 int scm_set_boot_addr(phys_addr_t addr, int flags);