diff options
author | Kumar Gala <galak@codeaurora.org> | 2014-01-21 18:14:10 -0500 |
---|---|---|
committer | Kumar Gala <galak@codeaurora.org> | 2014-02-06 17:20:26 -0500 |
commit | 8fc1b0f87d9fcc7f05873c70b3003328c3d7defa (patch) | |
tree | 7f5007bea484e69a9d9776336062933f9a61b964 /arch/arm/mach-msm | |
parent | 3f8e8cee2f4bd02367583cc2d143887d1f49fd6c (diff) |
ARM: qcom: Split Qualcomm support into legacy and multiplatform
Introduce a new mach-qcom that will support SoCs that intend to be
multiplatform compatible while keeping mach-msm to legacy SoC/board
support that will not transition over to multiplatform.
As part of this, we move support for MSM8X60, MSM8960 and MSM8974 over
to mach-qcom.
Signed-off-by: Kumar Gala <galak@codeaurora.org>
Diffstat (limited to 'arch/arm/mach-msm')
-rw-r--r-- | arch/arm/mach-msm/Kconfig | 45 | ||||
-rw-r--r-- | arch/arm/mach-msm/Makefile | 6 | ||||
-rw-r--r-- | arch/arm/mach-msm/board-dt.c | 41 | ||||
-rw-r--r-- | arch/arm/mach-msm/platsmp.c | 137 | ||||
-rw-r--r-- | arch/arm/mach-msm/scm-boot.c | 39 | ||||
-rw-r--r-- | arch/arm/mach-msm/scm-boot.h | 22 | ||||
-rw-r--r-- | arch/arm/mach-msm/scm.c | 299 | ||||
-rw-r--r-- | arch/arm/mach-msm/scm.h | 25 |
8 files changed, 2 insertions, 612 deletions
diff --git a/arch/arm/mach-msm/Kconfig b/arch/arm/mach-msm/Kconfig index 3c4eca71f976..a7f959e58c3d 100644 --- a/arch/arm/mach-msm/Kconfig +++ b/arch/arm/mach-msm/Kconfig | |||
@@ -1,50 +1,9 @@ | |||
1 | config ARCH_MSM | ||
2 | bool | ||
3 | |||
4 | config ARCH_MSM_DT | ||
5 | bool "Qualcomm MSM DT Support" if ARCH_MULTI_V7 | ||
6 | select ARCH_MSM | ||
7 | select ARCH_REQUIRE_GPIOLIB | ||
8 | select CLKSRC_OF | ||
9 | select GENERIC_CLOCKEVENTS | ||
10 | help | ||
11 | Support for Qualcomm's devicetree based MSM systems. | ||
12 | |||
13 | if ARCH_MSM | 1 | if ARCH_MSM |
14 | 2 | ||
15 | menu "Qualcomm MSM SoC Selection" | ||
16 | depends on ARCH_MSM_DT | ||
17 | |||
18 | config ARCH_MSM8X60 | ||
19 | bool "Enable support for MSM8X60" | ||
20 | select ARM_GIC | ||
21 | select CPU_V7 | ||
22 | select HAVE_SMP | ||
23 | select MSM_SCM if SMP | ||
24 | select CLKSRC_QCOM | ||
25 | |||
26 | config ARCH_MSM8960 | ||
27 | bool "Enable support for MSM8960" | ||
28 | select ARM_GIC | ||
29 | select CPU_V7 | ||
30 | select HAVE_SMP | ||
31 | select MSM_SCM if SMP | ||
32 | select CLKSRC_QCOM | ||
33 | |||
34 | config ARCH_MSM8974 | ||
35 | bool "Enable support for MSM8974" | ||
36 | select ARM_GIC | ||
37 | select CPU_V7 | ||
38 | select HAVE_ARM_ARCH_TIMER | ||
39 | select HAVE_SMP | ||
40 | select MSM_SCM if SMP | ||
41 | |||
42 | endmenu | ||
43 | |||
44 | choice | 3 | choice |
45 | prompt "Qualcomm MSM SoC Type" | 4 | prompt "Qualcomm MSM SoC Type" |
46 | default ARCH_MSM7X00A | 5 | default ARCH_MSM7X00A |
47 | depends on ARCH_MSM_NODT | 6 | depends on ARCH_MSM |
48 | 7 | ||
49 | config ARCH_MSM7X00A | 8 | config ARCH_MSM7X00A |
50 | bool "MSM7x00A / MSM7x01A" | 9 | bool "MSM7x00A / MSM7x01A" |
@@ -99,7 +58,7 @@ config MSM_VIC | |||
99 | bool | 58 | bool |
100 | 59 | ||
101 | menu "Qualcomm MSM Board Type" | 60 | menu "Qualcomm MSM Board Type" |
102 | depends on ARCH_MSM_NODT | 61 | depends on ARCH_MSM |
103 | 62 | ||
104 | config MACH_HALIBUT | 63 | config MACH_HALIBUT |
105 | depends on ARCH_MSM | 64 | depends on ARCH_MSM |
diff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefile index 04b1bee941f5..27c078a568df 100644 --- a/arch/arm/mach-msm/Makefile +++ b/arch/arm/mach-msm/Makefile | |||
@@ -13,17 +13,11 @@ obj-$(CONFIG_ARCH_QSD8X50) += dma.o io.o | |||
13 | 13 | ||
14 | obj-$(CONFIG_MSM_SMD) += smd.o smd_debug.o | 14 | obj-$(CONFIG_MSM_SMD) += smd.o smd_debug.o |
15 | obj-$(CONFIG_MSM_SMD) += last_radio_log.o | 15 | obj-$(CONFIG_MSM_SMD) += last_radio_log.o |
16 | obj-$(CONFIG_MSM_SCM) += scm.o scm-boot.o | ||
17 | |||
18 | CFLAGS_scm.o :=$(call as-instr,.arch_extension sec,-DREQUIRES_SEC=1) | ||
19 | |||
20 | obj-$(CONFIG_SMP) += platsmp.o | ||
21 | 16 | ||
22 | obj-$(CONFIG_MACH_TROUT) += board-trout.o board-trout-gpio.o board-trout-mmc.o devices-msm7x00.o | 17 | obj-$(CONFIG_MACH_TROUT) += board-trout.o board-trout-gpio.o board-trout-mmc.o devices-msm7x00.o |
23 | obj-$(CONFIG_MACH_TROUT) += board-trout.o board-trout-gpio.o board-trout-mmc.o board-trout-panel.o devices-msm7x00.o | 18 | obj-$(CONFIG_MACH_TROUT) += board-trout.o board-trout-gpio.o board-trout-mmc.o board-trout-panel.o devices-msm7x00.o |
24 | obj-$(CONFIG_MACH_HALIBUT) += board-halibut.o devices-msm7x00.o | 19 | obj-$(CONFIG_MACH_HALIBUT) += board-halibut.o devices-msm7x00.o |
25 | obj-$(CONFIG_ARCH_MSM7X30) += board-msm7x30.o devices-msm7x30.o | 20 | obj-$(CONFIG_ARCH_MSM7X30) += board-msm7x30.o devices-msm7x30.o |
26 | obj-$(CONFIG_ARCH_QSD8X50) += board-qsd8x50.o devices-qsd8x50.o | 21 | obj-$(CONFIG_ARCH_QSD8X50) += board-qsd8x50.o devices-qsd8x50.o |
27 | obj-$(CONFIG_ARCH_MSM_DT) += board-dt.o | ||
28 | obj-$(CONFIG_MSM_GPIOMUX) += gpiomux.o | 22 | obj-$(CONFIG_MSM_GPIOMUX) += gpiomux.o |
29 | obj-$(CONFIG_ARCH_QSD8X50) += gpiomux-8x50.o | 23 | obj-$(CONFIG_ARCH_QSD8X50) += gpiomux-8x50.o |
diff --git a/arch/arm/mach-msm/board-dt.c b/arch/arm/mach-msm/board-dt.c deleted file mode 100644 index 1f11d93e700e..000000000000 --- a/arch/arm/mach-msm/board-dt.c +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | /* Copyright (c) 2010-2012,2013 The Linux Foundation. All rights reserved. | ||
2 | * | ||
3 | * This program is free software; you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License version 2 and | ||
5 | * only version 2 as published by the Free Software Foundation. | ||
6 | * | ||
7 | * This program is distributed in the hope that it will be useful, | ||
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
10 | * GNU General Public License for more details. | ||
11 | */ | ||
12 | |||
13 | #include <linux/init.h> | ||
14 | #include <linux/of.h> | ||
15 | #include <linux/of_platform.h> | ||
16 | |||
17 | #include <asm/mach/arch.h> | ||
18 | #include <asm/mach/map.h> | ||
19 | |||
20 | #include "common.h" | ||
21 | |||
22 | static const char * const msm_dt_match[] __initconst = { | ||
23 | "qcom,msm8660-fluid", | ||
24 | "qcom,msm8660-surf", | ||
25 | "qcom,msm8960-cdp", | ||
26 | NULL | ||
27 | }; | ||
28 | |||
29 | static const char * const apq8074_dt_match[] __initconst = { | ||
30 | "qcom,apq8074-dragonboard", | ||
31 | NULL | ||
32 | }; | ||
33 | |||
34 | DT_MACHINE_START(MSM_DT, "Qualcomm MSM (Flattened Device Tree)") | ||
35 | .smp = smp_ops(msm_smp_ops), | ||
36 | .dt_compat = msm_dt_match, | ||
37 | MACHINE_END | ||
38 | |||
39 | DT_MACHINE_START(APQ_DT, "Qualcomm MSM (Flattened Device Tree)") | ||
40 | .dt_compat = apq8074_dt_match, | ||
41 | MACHINE_END | ||
diff --git a/arch/arm/mach-msm/platsmp.c b/arch/arm/mach-msm/platsmp.c deleted file mode 100644 index 251a91eb102a..000000000000 --- a/arch/arm/mach-msm/platsmp.c +++ /dev/null | |||
@@ -1,137 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 ARM Ltd. | ||
3 | * All Rights Reserved | ||
4 | * Copyright (c) 2010, Code Aurora Forum. All rights reserved. | ||
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 | |||
11 | #include <linux/init.h> | ||
12 | #include <linux/errno.h> | ||
13 | #include <linux/delay.h> | ||
14 | #include <linux/device.h> | ||
15 | #include <linux/smp.h> | ||
16 | #include <linux/io.h> | ||
17 | |||
18 | #include <asm/cputype.h> | ||
19 | #include <asm/smp_plat.h> | ||
20 | |||
21 | #include "scm-boot.h" | ||
22 | #include "common.h" | ||
23 | |||
24 | #define VDD_SC1_ARRAY_CLAMP_GFS_CTL 0x15A0 | ||
25 | #define SCSS_CPU1CORE_RESET 0xD80 | ||
26 | #define SCSS_DBG_STATUS_CORE_PWRDUP 0xE64 | ||
27 | |||
28 | extern void secondary_startup(void); | ||
29 | |||
30 | static DEFINE_SPINLOCK(boot_lock); | ||
31 | |||
32 | #ifdef CONFIG_HOTPLUG_CPU | ||
33 | static void __ref msm_cpu_die(unsigned int cpu) | ||
34 | { | ||
35 | wfi(); | ||
36 | } | ||
37 | #endif | ||
38 | |||
39 | static inline int get_core_count(void) | ||
40 | { | ||
41 | /* 1 + the PART[1:0] field of MIDR */ | ||
42 | return ((read_cpuid_id() >> 4) & 3) + 1; | ||
43 | } | ||
44 | |||
45 | static void msm_secondary_init(unsigned int cpu) | ||
46 | { | ||
47 | /* | ||
48 | * Synchronise with the boot thread. | ||
49 | */ | ||
50 | spin_lock(&boot_lock); | ||
51 | spin_unlock(&boot_lock); | ||
52 | } | ||
53 | |||
54 | static void prepare_cold_cpu(unsigned int cpu) | ||
55 | { | ||
56 | int ret; | ||
57 | ret = scm_set_boot_addr(virt_to_phys(secondary_startup), | ||
58 | SCM_FLAG_COLDBOOT_CPU1); | ||
59 | if (ret == 0) { | ||
60 | void __iomem *sc1_base_ptr; | ||
61 | sc1_base_ptr = ioremap_nocache(0x00902000, SZ_4K*2); | ||
62 | if (sc1_base_ptr) { | ||
63 | writel(0, sc1_base_ptr + VDD_SC1_ARRAY_CLAMP_GFS_CTL); | ||
64 | writel(0, sc1_base_ptr + SCSS_CPU1CORE_RESET); | ||
65 | writel(3, sc1_base_ptr + SCSS_DBG_STATUS_CORE_PWRDUP); | ||
66 | iounmap(sc1_base_ptr); | ||
67 | } | ||
68 | } else | ||
69 | printk(KERN_DEBUG "Failed to set secondary core boot " | ||
70 | "address\n"); | ||
71 | } | ||
72 | |||
73 | static int msm_boot_secondary(unsigned int cpu, struct task_struct *idle) | ||
74 | { | ||
75 | static int cold_boot_done; | ||
76 | |||
77 | /* Only need to bring cpu out of reset this way once */ | ||
78 | if (cold_boot_done == false) { | ||
79 | prepare_cold_cpu(cpu); | ||
80 | cold_boot_done = true; | ||
81 | } | ||
82 | |||
83 | /* | ||
84 | * set synchronisation state between this boot processor | ||
85 | * and the secondary one | ||
86 | */ | ||
87 | spin_lock(&boot_lock); | ||
88 | |||
89 | /* | ||
90 | * Send the secondary CPU a soft interrupt, thereby causing | ||
91 | * the boot monitor to read the system wide flags register, | ||
92 | * and branch to the address found there. | ||
93 | */ | ||
94 | arch_send_wakeup_ipi_mask(cpumask_of(cpu)); | ||
95 | |||
96 | /* | ||
97 | * now the secondary core is starting up let it run its | ||
98 | * calibrations, then wait for it to finish | ||
99 | */ | ||
100 | spin_unlock(&boot_lock); | ||
101 | |||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | /* | ||
106 | * Initialise the CPU possible map early - this describes the CPUs | ||
107 | * which may be present or become present in the system. The msm8x60 | ||
108 | * does not support the ARM SCU, so just set the possible cpu mask to | ||
109 | * NR_CPUS. | ||
110 | */ | ||
111 | static void __init msm_smp_init_cpus(void) | ||
112 | { | ||
113 | unsigned int i, ncores = get_core_count(); | ||
114 | |||
115 | if (ncores > nr_cpu_ids) { | ||
116 | pr_warn("SMP: %u cores greater than maximum (%u), clipping\n", | ||
117 | ncores, nr_cpu_ids); | ||
118 | ncores = nr_cpu_ids; | ||
119 | } | ||
120 | |||
121 | for (i = 0; i < ncores; i++) | ||
122 | set_cpu_possible(i, true); | ||
123 | } | ||
124 | |||
125 | static void __init msm_smp_prepare_cpus(unsigned int max_cpus) | ||
126 | { | ||
127 | } | ||
128 | |||
129 | struct smp_operations msm_smp_ops __initdata = { | ||
130 | .smp_init_cpus = msm_smp_init_cpus, | ||
131 | .smp_prepare_cpus = msm_smp_prepare_cpus, | ||
132 | .smp_secondary_init = msm_secondary_init, | ||
133 | .smp_boot_secondary = msm_boot_secondary, | ||
134 | #ifdef CONFIG_HOTPLUG_CPU | ||
135 | .cpu_die = msm_cpu_die, | ||
136 | #endif | ||
137 | }; | ||
diff --git a/arch/arm/mach-msm/scm-boot.c b/arch/arm/mach-msm/scm-boot.c deleted file mode 100644 index 45cee3e469a5..000000000000 --- a/arch/arm/mach-msm/scm-boot.c +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | /* Copyright (c) 2010, Code Aurora Forum. All rights reserved. | ||
2 | * | ||
3 | * This program is free software; you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License version 2 and | ||
5 | * only version 2 as published by the Free Software Foundation. | ||
6 | * | ||
7 | * This program is distributed in the hope that it will be useful, | ||
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
10 | * GNU General Public License for more details. | ||
11 | * | ||
12 | * You should have received a copy of the GNU General Public License | ||
13 | * along with this program; if not, write to the Free Software | ||
14 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
15 | * 02110-1301, USA. | ||
16 | */ | ||
17 | |||
18 | #include <linux/module.h> | ||
19 | #include <linux/slab.h> | ||
20 | |||
21 | #include "scm.h" | ||
22 | #include "scm-boot.h" | ||
23 | |||
24 | /* | ||
25 | * Set the cold/warm boot address for one of the CPU cores. | ||
26 | */ | ||
27 | int scm_set_boot_addr(phys_addr_t addr, int flags) | ||
28 | { | ||
29 | struct { | ||
30 | unsigned int flags; | ||
31 | phys_addr_t addr; | ||
32 | } cmd; | ||
33 | |||
34 | cmd.addr = addr; | ||
35 | cmd.flags = flags; | ||
36 | return scm_call(SCM_SVC_BOOT, SCM_BOOT_ADDR, | ||
37 | &cmd, sizeof(cmd), NULL, 0); | ||
38 | } | ||
39 | EXPORT_SYMBOL(scm_set_boot_addr); | ||
diff --git a/arch/arm/mach-msm/scm-boot.h b/arch/arm/mach-msm/scm-boot.h deleted file mode 100644 index 7be32ff5d687..000000000000 --- a/arch/arm/mach-msm/scm-boot.h +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | /* Copyright (c) 2010, Code Aurora Forum. All rights reserved. | ||
2 | * | ||
3 | * This program is free software; you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License version 2 and | ||
5 | * only version 2 as published by the Free Software Foundation. | ||
6 | * | ||
7 | * This program is distributed in the hope that it will be useful, | ||
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
10 | * GNU General Public License for more details. | ||
11 | */ | ||
12 | #ifndef __MACH_SCM_BOOT_H | ||
13 | #define __MACH_SCM_BOOT_H | ||
14 | |||
15 | #define SCM_BOOT_ADDR 0x1 | ||
16 | #define SCM_FLAG_COLDBOOT_CPU1 0x1 | ||
17 | #define SCM_FLAG_WARMBOOT_CPU1 0x2 | ||
18 | #define SCM_FLAG_WARMBOOT_CPU0 0x4 | ||
19 | |||
20 | int scm_set_boot_addr(phys_addr_t addr, int flags); | ||
21 | |||
22 | #endif | ||
diff --git a/arch/arm/mach-msm/scm.c b/arch/arm/mach-msm/scm.c deleted file mode 100644 index c536fd6bf827..000000000000 --- a/arch/arm/mach-msm/scm.c +++ /dev/null | |||
@@ -1,299 +0,0 @@ | |||
1 | /* Copyright (c) 2010, Code Aurora Forum. All rights reserved. | ||
2 | * | ||
3 | * This program is free software; you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License version 2 and | ||
5 | * only version 2 as published by the Free Software Foundation. | ||
6 | * | ||
7 | * This program is distributed in the hope that it will be useful, | ||
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
10 | * GNU General Public License for more details. | ||
11 | * | ||
12 | * You should have received a copy of the GNU General Public License | ||
13 | * along with this program; if not, write to the Free Software | ||
14 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
15 | * 02110-1301, USA. | ||
16 | */ | ||
17 | |||
18 | #include <linux/slab.h> | ||
19 | #include <linux/io.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/mutex.h> | ||
22 | #include <linux/errno.h> | ||
23 | #include <linux/err.h> | ||
24 | |||
25 | #include <asm/cacheflush.h> | ||
26 | |||
27 | #include "scm.h" | ||
28 | |||
29 | /* Cache line size for msm8x60 */ | ||
30 | #define CACHELINESIZE 32 | ||
31 | |||
32 | #define SCM_ENOMEM -5 | ||
33 | #define SCM_EOPNOTSUPP -4 | ||
34 | #define SCM_EINVAL_ADDR -3 | ||
35 | #define SCM_EINVAL_ARG -2 | ||
36 | #define SCM_ERROR -1 | ||
37 | #define SCM_INTERRUPTED 1 | ||
38 | |||
39 | static DEFINE_MUTEX(scm_lock); | ||
40 | |||
41 | /** | ||
42 | * struct scm_command - one SCM command buffer | ||
43 | * @len: total available memory for command and response | ||
44 | * @buf_offset: start of command buffer | ||
45 | * @resp_hdr_offset: start of response buffer | ||
46 | * @id: command to be executed | ||
47 | * @buf: buffer returned from scm_get_command_buffer() | ||
48 | * | ||
49 | * An SCM command is laid out in memory as follows: | ||
50 | * | ||
51 | * ------------------- <--- struct scm_command | ||
52 | * | command header | | ||
53 | * ------------------- <--- scm_get_command_buffer() | ||
54 | * | command buffer | | ||
55 | * ------------------- <--- struct scm_response and | ||
56 | * | response header | scm_command_to_response() | ||
57 | * ------------------- <--- scm_get_response_buffer() | ||
58 | * | response buffer | | ||
59 | * ------------------- | ||
60 | * | ||
61 | * There can be arbitrary padding between the headers and buffers so | ||
62 | * you should always use the appropriate scm_get_*_buffer() routines | ||
63 | * to access the buffers in a safe manner. | ||
64 | */ | ||
65 | struct scm_command { | ||
66 | u32 len; | ||
67 | u32 buf_offset; | ||
68 | u32 resp_hdr_offset; | ||
69 | u32 id; | ||
70 | u32 buf[0]; | ||
71 | }; | ||
72 | |||
73 | /** | ||
74 | * struct scm_response - one SCM response buffer | ||
75 | * @len: total available memory for response | ||
76 | * @buf_offset: start of response data relative to start of scm_response | ||
77 | * @is_complete: indicates if the command has finished processing | ||
78 | */ | ||
79 | struct scm_response { | ||
80 | u32 len; | ||
81 | u32 buf_offset; | ||
82 | u32 is_complete; | ||
83 | }; | ||
84 | |||
85 | /** | ||
86 | * alloc_scm_command() - Allocate an SCM command | ||
87 | * @cmd_size: size of the command buffer | ||
88 | * @resp_size: size of the response buffer | ||
89 | * | ||
90 | * Allocate an SCM command, including enough room for the command | ||
91 | * and response headers as well as the command and response buffers. | ||
92 | * | ||
93 | * Returns a valid &scm_command on success or %NULL if the allocation fails. | ||
94 | */ | ||
95 | static struct scm_command *alloc_scm_command(size_t cmd_size, size_t resp_size) | ||
96 | { | ||
97 | struct scm_command *cmd; | ||
98 | size_t len = sizeof(*cmd) + sizeof(struct scm_response) + cmd_size + | ||
99 | resp_size; | ||
100 | |||
101 | cmd = kzalloc(PAGE_ALIGN(len), GFP_KERNEL); | ||
102 | if (cmd) { | ||
103 | cmd->len = len; | ||
104 | cmd->buf_offset = offsetof(struct scm_command, buf); | ||
105 | cmd->resp_hdr_offset = cmd->buf_offset + cmd_size; | ||
106 | } | ||
107 | return cmd; | ||
108 | } | ||
109 | |||
110 | /** | ||
111 | * free_scm_command() - Free an SCM command | ||
112 | * @cmd: command to free | ||
113 | * | ||
114 | * Free an SCM command. | ||
115 | */ | ||
116 | static inline void free_scm_command(struct scm_command *cmd) | ||
117 | { | ||
118 | kfree(cmd); | ||
119 | } | ||
120 | |||
121 | /** | ||
122 | * scm_command_to_response() - Get a pointer to a scm_response | ||
123 | * @cmd: command | ||
124 | * | ||
125 | * Returns a pointer to a response for a command. | ||
126 | */ | ||
127 | static inline struct scm_response *scm_command_to_response( | ||
128 | const struct scm_command *cmd) | ||
129 | { | ||
130 | return (void *)cmd + cmd->resp_hdr_offset; | ||
131 | } | ||
132 | |||
133 | /** | ||
134 | * scm_get_command_buffer() - Get a pointer to a command buffer | ||
135 | * @cmd: command | ||
136 | * | ||
137 | * Returns a pointer to the command buffer of a command. | ||
138 | */ | ||
139 | static inline void *scm_get_command_buffer(const struct scm_command *cmd) | ||
140 | { | ||
141 | return (void *)cmd->buf; | ||
142 | } | ||
143 | |||
144 | /** | ||
145 | * scm_get_response_buffer() - Get a pointer to a response buffer | ||
146 | * @rsp: response | ||
147 | * | ||
148 | * Returns a pointer to a response buffer of a response. | ||
149 | */ | ||
150 | static inline void *scm_get_response_buffer(const struct scm_response *rsp) | ||
151 | { | ||
152 | return (void *)rsp + rsp->buf_offset; | ||
153 | } | ||
154 | |||
155 | static int scm_remap_error(int err) | ||
156 | { | ||
157 | switch (err) { | ||
158 | case SCM_ERROR: | ||
159 | return -EIO; | ||
160 | case SCM_EINVAL_ADDR: | ||
161 | case SCM_EINVAL_ARG: | ||
162 | return -EINVAL; | ||
163 | case SCM_EOPNOTSUPP: | ||
164 | return -EOPNOTSUPP; | ||
165 | case SCM_ENOMEM: | ||
166 | return -ENOMEM; | ||
167 | } | ||
168 | return -EINVAL; | ||
169 | } | ||
170 | |||
171 | static u32 smc(u32 cmd_addr) | ||
172 | { | ||
173 | int context_id; | ||
174 | register u32 r0 asm("r0") = 1; | ||
175 | register u32 r1 asm("r1") = (u32)&context_id; | ||
176 | register u32 r2 asm("r2") = cmd_addr; | ||
177 | do { | ||
178 | asm volatile( | ||
179 | __asmeq("%0", "r0") | ||
180 | __asmeq("%1", "r0") | ||
181 | __asmeq("%2", "r1") | ||
182 | __asmeq("%3", "r2") | ||
183 | #ifdef REQUIRES_SEC | ||
184 | ".arch_extension sec\n" | ||
185 | #endif | ||
186 | "smc #0 @ switch to secure world\n" | ||
187 | : "=r" (r0) | ||
188 | : "r" (r0), "r" (r1), "r" (r2) | ||
189 | : "r3"); | ||
190 | } while (r0 == SCM_INTERRUPTED); | ||
191 | |||
192 | return r0; | ||
193 | } | ||
194 | |||
195 | static int __scm_call(const struct scm_command *cmd) | ||
196 | { | ||
197 | int ret; | ||
198 | u32 cmd_addr = virt_to_phys(cmd); | ||
199 | |||
200 | /* | ||
201 | * Flush the entire cache here so callers don't have to remember | ||
202 | * to flush the cache when passing physical addresses to the secure | ||
203 | * side in the buffer. | ||
204 | */ | ||
205 | flush_cache_all(); | ||
206 | ret = smc(cmd_addr); | ||
207 | if (ret < 0) | ||
208 | ret = scm_remap_error(ret); | ||
209 | |||
210 | return ret; | ||
211 | } | ||
212 | |||
213 | /** | ||
214 | * scm_call() - Send an SCM command | ||
215 | * @svc_id: service identifier | ||
216 | * @cmd_id: command identifier | ||
217 | * @cmd_buf: command buffer | ||
218 | * @cmd_len: length of the command buffer | ||
219 | * @resp_buf: response buffer | ||
220 | * @resp_len: length of the response buffer | ||
221 | * | ||
222 | * Sends a command to the SCM and waits for the command to finish processing. | ||
223 | */ | ||
224 | int scm_call(u32 svc_id, u32 cmd_id, const void *cmd_buf, size_t cmd_len, | ||
225 | void *resp_buf, size_t resp_len) | ||
226 | { | ||
227 | int ret; | ||
228 | struct scm_command *cmd; | ||
229 | struct scm_response *rsp; | ||
230 | |||
231 | cmd = alloc_scm_command(cmd_len, resp_len); | ||
232 | if (!cmd) | ||
233 | return -ENOMEM; | ||
234 | |||
235 | cmd->id = (svc_id << 10) | cmd_id; | ||
236 | if (cmd_buf) | ||
237 | memcpy(scm_get_command_buffer(cmd), cmd_buf, cmd_len); | ||
238 | |||
239 | mutex_lock(&scm_lock); | ||
240 | ret = __scm_call(cmd); | ||
241 | mutex_unlock(&scm_lock); | ||
242 | if (ret) | ||
243 | goto out; | ||
244 | |||
245 | rsp = scm_command_to_response(cmd); | ||
246 | do { | ||
247 | u32 start = (u32)rsp; | ||
248 | u32 end = (u32)scm_get_response_buffer(rsp) + resp_len; | ||
249 | start &= ~(CACHELINESIZE - 1); | ||
250 | while (start < end) { | ||
251 | asm ("mcr p15, 0, %0, c7, c6, 1" : : "r" (start) | ||
252 | : "memory"); | ||
253 | start += CACHELINESIZE; | ||
254 | } | ||
255 | } while (!rsp->is_complete); | ||
256 | |||
257 | if (resp_buf) | ||
258 | memcpy(resp_buf, scm_get_response_buffer(rsp), resp_len); | ||
259 | out: | ||
260 | free_scm_command(cmd); | ||
261 | return ret; | ||
262 | } | ||
263 | EXPORT_SYMBOL(scm_call); | ||
264 | |||
265 | u32 scm_get_version(void) | ||
266 | { | ||
267 | int context_id; | ||
268 | static u32 version = -1; | ||
269 | register u32 r0 asm("r0"); | ||
270 | register u32 r1 asm("r1"); | ||
271 | |||
272 | if (version != -1) | ||
273 | return version; | ||
274 | |||
275 | mutex_lock(&scm_lock); | ||
276 | |||
277 | r0 = 0x1 << 8; | ||
278 | r1 = (u32)&context_id; | ||
279 | do { | ||
280 | asm volatile( | ||
281 | __asmeq("%0", "r0") | ||
282 | __asmeq("%1", "r1") | ||
283 | __asmeq("%2", "r0") | ||
284 | __asmeq("%3", "r1") | ||
285 | #ifdef REQUIRES_SEC | ||
286 | ".arch_extension sec\n" | ||
287 | #endif | ||
288 | "smc #0 @ switch to secure world\n" | ||
289 | : "=r" (r0), "=r" (r1) | ||
290 | : "r" (r0), "r" (r1) | ||
291 | : "r2", "r3"); | ||
292 | } while (r0 == SCM_INTERRUPTED); | ||
293 | |||
294 | version = r1; | ||
295 | mutex_unlock(&scm_lock); | ||
296 | |||
297 | return version; | ||
298 | } | ||
299 | EXPORT_SYMBOL(scm_get_version); | ||
diff --git a/arch/arm/mach-msm/scm.h b/arch/arm/mach-msm/scm.h deleted file mode 100644 index 00b31ea58f29..000000000000 --- a/arch/arm/mach-msm/scm.h +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | /* Copyright (c) 2010, Code Aurora Forum. All rights reserved. | ||
2 | * | ||
3 | * This program is free software; you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License version 2 and | ||
5 | * only version 2 as published by the Free Software Foundation. | ||
6 | * | ||
7 | * This program is distributed in the hope that it will be useful, | ||
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
10 | * GNU General Public License for more details. | ||
11 | */ | ||
12 | #ifndef __MACH_SCM_H | ||
13 | #define __MACH_SCM_H | ||
14 | |||
15 | #define SCM_SVC_BOOT 0x1 | ||
16 | #define SCM_SVC_PIL 0x2 | ||
17 | |||
18 | extern int scm_call(u32 svc_id, u32 cmd_id, const void *cmd_buf, size_t cmd_len, | ||
19 | void *resp_buf, size_t resp_len); | ||
20 | |||
21 | #define SCM_VERSION(major, minor) (((major) << 16) | ((minor) & 0xFF)) | ||
22 | |||
23 | extern u32 scm_get_version(void); | ||
24 | |||
25 | #endif | ||