ARM: EXYNOS: Add secure firmware support
Subsystems (5)
v4 cover ARM: EXYNOS: Add secure firmware support
Some Exynos-based boards are running with secure firmware running in TrustZone secure world, which changes the way some things have to be initialized.
This series adds support for specifying firmware operations, implements some firmware operations for Exynos secure firmware and adds a method of enabling secure firmware operations on Exynos-based boards through board file and device tree.
Depends on:
- ARM: EXYNOS: Add support for secondary CPU bring-up on Exynos4412
Changes since v3
( http://thread.gmane.org/gmane.linux.kernel.samsung-soc/13442 )
- Replaced cpu_boot_reg call with cpu_set_boot_addr
- Added interface documentation
- Separated from Exynos4x12 secondary CPU bring-up patch
Changes since v2
( http://thread.gmane.org/gmane.linux.kernel.samsung-soc/12848 )
- Made Exynos firmware binding require address
- Minor style fixes
Changes since v1
( http://thread.gmane.org/gmane.linux.kernel.samsung-soc/12583/focus=12820 )
- Changed return types of all operations to int
- Defined all operations to return 0 on success, -ENOSYS when not implemented or appropriate error code on error
Tomasz Figa (5):
ARM: Add interface for registering and calling firmware-specific
operations
ARM: EXYNOS: Add support for secure monitor calls
ARM: EXYNOS: Add support for Exynos secure firmware
ARM: EXYNOS: Add IO mapping for non-secure SYSRAM.
ARM: EXYNOS: Add secure firmware support to secondary CPU bring-up
Documentation/arm/firmware.txt | 88 ++++++++++++++++++++++ .../devicetree/bindings/arm/samsung-boards.txt | 10 +++ arch/arm/common/Makefile | 2 + arch/arm/common/firmware.c | 18 +++++ arch/arm/include/asm/firmware.h | 66 ++++++++++++++++ arch/arm/mach-exynos/Makefile | 6 ++ arch/arm/mach-exynos/common.c | 35 +++++++++ arch/arm/mach-exynos/common.h | 2 + arch/arm/mach-exynos/exynos-smc.S | 22 ++++++ arch/arm/mach-exynos/firmware.c | 70 +++++++++++++++++ arch/arm/mach-exynos/include/mach/map.h | 3 + arch/arm/mach-exynos/mach-exynos4-dt.c | 1 + arch/arm/mach-exynos/platsmp.c | 32 ++++++-- arch/arm/mach-exynos/smc.h | 31 ++++++++ arch/arm/plat-samsung/include/plat/map-s5p.h | 1 + 15 files changed, 382 insertions(+), 5 deletions(-) create mode 100644 Documentation/arm/firmware.txt create mode 100644 arch/arm/common/firmware.c create mode 100644 arch/arm/include/asm/firmware.h create mode 100644 arch/arm/mach-exynos/exynos-smc.S create mode 100644 arch/arm/mach-exynos/firmware.c create mode 100644 arch/arm/mach-exynos/smc.h
Signature · 1 line
1.8.0
PATCH v4 1/5 ARM: Add interface for registering and calling firmware-specific operations
Some boards are running with secure firmware running in TrustZone secure world, which changes the way some things have to be initialized.
This patch adds an interface for platforms to specify available firmware operations and call them.
A wrapper macro, call_firmware_op(), checks if the operation is provided and calls it if so, otherwise returns -ENOSYS to allow fallback to legacy operation..
By default no operations are provided.
Example of use:
In code using firmware ops:
__raw_writel(virt_to_phys(exynos4_secondary_startup), CPU1_BOOT_REG); /* Call Exynos specific smc call */ if (call_firmware_op(cpu_boot, cpu) == -ENOSYS) cpu_boot_legacy(...); /* Try legacy way */ gic_raise_softirq(cpumask_of(cpu), 1);
In board-/platform-specific code:
static int platformX_do_idle(void)
{
/* tell platformX firmware to enter idle */
return 0;
}
static int platformX_cpu_boot(int i)
{
/* tell platformX firmware to boot CPU i */
return 0;
}
static const struct firmware_ops platformX_firmware_ops = {
.do_idle = exynos_do_idle,
.cpu_boot = exynos_cpu_boot,
/* other operations not available on platformX */
};
static void __init board_init_early(void)
{
????????register_firmware_ops(&platformX_firmware_ops);
}--- Documentation/arm/firmware.txt | 88 +++++++++++++++++++++++++++++++++++++++++ arch/arm/common/Makefile | 2 + arch/arm/common/firmware.c | 18 +++++++++ arch/arm/include/asm/firmware.h | 66 +++++++++++++++++++++++++++++++ 4 files changed, 174 insertions(+) create mode 100644 Documentation/arm/firmware.txt create mode 100644 arch/arm/common/firmware.c create mode 100644 arch/arm/include/asm/firmware.h
Documentation/arm/firmware.txt new file +88 -0
@@ -0,0 +1,88 @@ +Interface for registering and calling firmware-specific operations for ARM. +---- +Written by Tomasz Figa <[email protected]> + +Some boards are running with secure firmware running in TrustZone secure +world, which changes the way some things have to be initialized. This makes +a need to provide an interface for such platforms to specify available firmware +operations and call them when needed. + +Firmware operations can be specified using struct firmware_ops + + struct firmware_ops { + /* + * Enters CPU idle mode + */ + int (*do_idle)(void); + /* + * Sets boot address of specified physical CPU + */ + int (*set_cpu_boot_addr)(int cpu, unsigned long boot_addr); + /* + * Boots specified physical CPU + */ + int (*cpu_boot)(int cpu); + /* + * Initializes L2 cache + */ + int (*l2x0_init)(void); + }; + +and then registered with register_firmware_ops function + + void register_firmware_ops(const struct firmware_ops *ops) + +the ops pointer must be non-NULL. + +There is a default, empty set of operations provided, so there is no need to +set anything if platform does not require firmware operations. + +To call a firmware operation, a helper macro is provided + + #define call_firmware_op(op, ...) \ + ((firmware_ops->op) ? firmware_ops->op(__VA_ARGS__) : (-ENOSYS)) + +the macro checks if the operation is provided and calls it or otherwise returns +-ENOSYS to signal that given operation is not available (for example, to allow +fallback to legacy operation). + +Example of registering firmware operations: + + /* board file */ + + static int platformX_do_idle(void) + { + /* tell platformX firmware to enter idle */ + return 0; + } + + static int platformX_cpu_boot(int i) + { + /* tell platformX firmware to boot CPU i */ + return 0; + } + + static const struct firmware_ops platformX_firmware_ops = { + .do_idle = exynos_do_idle, + .cpu_boot = exynos_cpu_boot, + /* other operations not available on platformX */ + }; + + /* init_early callback of machine descriptor */ + static void __init board_init_early(void) + { + register_firmware_ops(&platformX_firmware_ops); + } + +Example of using a firmware operation: + + /* some platform code, e.g. SMP initialization */ + + __raw_writel(virt_to_phys(exynos4_secondary_startup), + CPU1_BOOT_REG); + + /* Call Exynos specific smc call */ + if (call_firmware_op(cpu_boot, cpu) == -ENOSYS) + cpu_boot_legacy(...); /* Try legacy way */ + + gic_raise_softirq(cpumask_of(cpu), 1);
arch/arm/common/Makefile +2 -0
@@ -2,6 +2,8 @@ # Makefile for the linux kernel. # +obj-y += firmware.o + obj-$(CONFIG_ARM_GIC) += gic.o obj-$(CONFIG_ARM_VIC) += vic.o obj-$(CONFIG_ICST) += icst.o
arch/arm/common/firmware.c new file +18 -0
@@ -0,0 +1,18 @@ +/* +* Copyright (C) 2012 Samsung Electronics. +* Kyungmin Park <[email protected]> +* Tomasz Figa <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#include <linux/kernel.h> +#include <linux/suspend.h> + +#include <asm/firmware.h> + +static const struct firmware_ops default_firmware_ops; + +const struct firmware_ops *firmware_ops = &default_firmware_ops;
arch/arm/include/asm/firmware.h new file +66 -0
66 lines not on this page · raw message
Signature · 1 line
1.8.0
PATCH v4 1/5 ARM: Add interface for registering and calling firmware-specific operations
2012/11/22, Tomasz Figa <[email protected]>:
Quoted 36 lines
Some boards are running with secure firmware running in TrustZone secure world, which changes the way some things have to be initialized.
This patch adds an interface for platforms to specify available firmware operations and call them.
A wrapper macro,
call_firmware_op(), checks if the operation is provided and calls it if so, otherwise returns-ENOSYSto allow fallback to legacy operation..By default no operations are provided.
Example of use:
In code using firmware ops:
__raw_writel(virt_to_phys(exynos4_secondary_startup), CPU1_BOOT_REG); /* Call Exynos specific smc call */ if (call_firmware_op(cpu_boot, cpu) == -ENOSYS) cpu_boot_legacy(...); /* Try legacy way */ gic_raise_softirq(cpumask_of(cpu), 1);In board-/platform-specific code:
static int platformX_do_idle(void) { /* tell platformX firmware to enter idle */ return 0; } static int platformX_cpu_boot(int i) { /* tell platformX firmware to boot CPU i */
Quoted 8 lines
return 0;
}
static const struct firmware_ops platformX_firmware_ops = {
.do_idle = exynos_do_idle,
.cpu_boot = exynos_cpu_boot,
/* other operations not available on platformX */
};i am thinking the firmware_ops should be namespaced, some hardware has firmware, firmware_ops should not be using a global namespace here.
Quoted 6 lines
static void __init board_init_early(void)
{
register_firmware_ops(&platformX_firmware_ops);
}-barry
PATCH v4 2/5 ARM: EXYNOS: Add support for secure monitor calls
In reply to Tomasz FigaSome boards use secure monitor calls to communicate with secure firmware.
This patch adds exynos_smc function which uses smc assembly instruction to do secure monitor calls.
--- arch/arm/mach-exynos/Makefile | 5 +++++ arch/arm/mach-exynos/exynos-smc.S | 22 ++++++++++++++++++++++ arch/arm/mach-exynos/smc.h | 31 +++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 arch/arm/mach-exynos/exynos-smc.S create mode 100644 arch/arm/mach-exynos/smc.h
arch/arm/mach-exynos/Makefile +5 -0
@@ -30,6 +30,11 @@ obj-$(CONFIG_EXYNOS4_MCT) += mct.o obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o +obj-$(CONFIG_ARCH_EXYNOS) += exynos-smc.o + +plus_sec := $(call as-instr,.arch_extension sec,+sec) +AFLAGS_exynos-smc.o :=-Wa,-march=armv7-a$(plus_sec) + # machine support obj-$(CONFIG_MACH_SMDKC210) += mach-smdkv310.o
arch/arm/mach-exynos/exynos-smc.S new file +22 -0
@@ -0,0 +1,22 @@ +/* + * Copyright (C) 2012 Samsung Electronics. + * + * Copied from omap-smc.S Copyright (C) 2010 Texas Instruments, Inc. + * + * This program is free software,you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include <linux/linkage.h> + +/* + * Function signature: void exynos_smc(u32 cmd, u32 arg1, u32 arg2, u32 arg3) + */ + +ENTRY(exynos_smc) + stmfd sp!, {r4-r11, lr} + dsb + smc #0 + ldmfd sp!, {r4-r11, pc} +ENDPROC(exynos_smc)
arch/arm/mach-exynos/smc.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* Copyright (c) 2012 Samsung Electronics. +* +* EXYNOS - SMC Call +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef __ASM_ARCH_EXYNOS_SMC_H +#define __ASM_ARCH_EXYNOS_SMC_H + +#define SMC_CMD_INIT (-1) +#define SMC_CMD_INFO (-2) +/* For Power Management */ +#define SMC_CMD_SLEEP (-3) +#define SMC_CMD_CPU1BOOT (-4) +#define SMC_CMD_CPU0AFTR (-5) +/* For CP15 Access */ +#define SMC_CMD_C15RESUME (-11) +/* For L2 Cache Access */ +#define SMC_CMD_L2X0CTRL (-21) +#define SMC_CMD_L2X0SETUP1 (-22) +#define SMC_CMD_L2X0SETUP2 (-23) +#define SMC_CMD_L2X0INVALL (-24) +#define SMC_CMD_L2X0DEBUG (-25) + +extern void exynos_smc (u32 cmd,u32 arg1,u32 arg2,u32 arg3); + +#endif
Signature · 1 line
1.8.0
PATCH v4 3/5 ARM: EXYNOS: Add support for Exynos secure firmware
In reply to Tomasz FigaSome Exynos-based boards contain secure firmware and must use firmware operations to set up some hardware.
This patch adds firmware operations for Exynos secure firmware and a way for board code and device tree to specify that they must be used.
Example of use:
In board code:
...MACHINE_START(...) /* ... */ .init_early = exynos_firmware_init, /* ... */ MACHINE_END
In device tree:
/ {
/* ... */
firmware at 0203F000 {
compatible = "samsung,secure-firmware";
reg = <0x0203F000 0x1000>;
};
/* ... */
};--- .../devicetree/bindings/arm/samsung-boards.txt | 10 ++++ arch/arm/mach-exynos/Makefile | 1 + arch/arm/mach-exynos/common.h | 2 + arch/arm/mach-exynos/firmware.c | 70 ++++++++++++++++++++++ arch/arm/mach-exynos/mach-exynos4-dt.c | 1 + 5 files changed, 84 insertions(+) create mode 100644 arch/arm/mach-exynos/firmware.c
Documentation/devicetree/bindings/arm/samsung-boards.txt +10 -0
@@ -6,3 +6,13 @@ Required root node properties: - compatible = should be one or more of the following. (a) "samsung,smdkv310" - for Samsung's SMDKV310 eval board. (b) "samsung,exynos4210" - for boards based on Exynos4210 SoC. + +Optional: + - firmware node, specifying presence and type of secure firmware: + - compatible: only "samsung,secure-firmware" is currently supported + - reg: address of non-secure SYSRAM used for communication with firmware + + firmware at 0203F000 { + compatible = "samsung,secure-firmware"; + reg = <0x0203F000 0x1000>; + };
arch/arm/mach-exynos/Makefile +1 -0
@@ -31,6 +31,7 @@ obj-$(CONFIG_EXYNOS4_MCT) += mct.o obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o obj-$(CONFIG_ARCH_EXYNOS) += exynos-smc.o +obj-$(CONFIG_ARCH_EXYNOS) += firmware.o plus_sec := $(call as-instr,.arch_extension sec,+sec) AFLAGS_exynos-smc.o :=-Wa,-march=armv7-a$(plus_sec)
arch/arm/mach-exynos/common.h +2 -0
@@ -22,6 +22,8 @@ void exynos4_restart(char mode, const char *cmd);void exynos5_restart (char mode,const char *cmd);void exynos_init_late (void ); +void exynos_firmware_init (void ); +#ifdef CONFIG_PM_GENERIC_DOMAINS int exynos_pm_late_initcall (void );#else
arch/arm/mach-exynos/firmware.c new file +70 -0
70 lines not on this page · raw message
arch/arm/mach-exynos/mach-exynos4-dt.c +1 -0
@@ -107,6 +107,7 @@ DT_MACHINE_START(EXYNOS4210_DT, "Samsung Exynos4 (Flattened Device Tree)") .init_irq = exynos4_init_irq, .map_io = exynos4_dt_map_io, .handle_irq = gic_handle_irq, + .init_early = exynos_firmware_init, .init_machine = exynos4_dt_machine_init, .init_late = exynos_init_late, .timer = &exynos4_timer,
Signature · 1 line
1.8.0
PATCH v4 3/5 ARM: EXYNOS: Add support for Exynos secure firmware
2012/11/22, Tomasz Figa <[email protected]>:
Quoted 18 lines
Some Exynos-based boards contain secure firmware and must use firmware operations to set up some hardware.
This patch adds firmware operations for Exynos secure firmware and a way for board code and device tree to specify that they must be used.
Example of use:
In board code:
...MACHINE_START(...) /* ... */ .init_early = exynos_firmware_init, /* ... */ MACHINE_ENDIn device tree:
Quoted 10 lines
/ {
/* ... */
firmware at 0203F000 {
compatible = "samsung,secure-firmware";
reg = <0x0203F000 0x1000>;
};
/* ... */
};well. amazing, dts is used to describle hardware details, here the firmware is just a software and reg is the memory the firmware will use. is this something againest the dt rule?
but it is really simple.
Quoted 126 lines
Signed-off-by Kyungmin Park <[email protected]>Signed-off-by Tomasz Figa <[email protected]>--- .../devicetree/bindings/arm/samsung-boards.txt | 10 ++++ arch/arm/mach-exynos/Makefile | 1 + arch/arm/mach-exynos/common.h | 2 + arch/arm/mach-exynos/firmware.c | 70 ++++++++++++++++++++++ arch/arm/mach-exynos/mach-exynos4-dt.c | 1 + 5 files changed, 84 insertions(+) create mode 100644 arch/arm/mach-exynos/firmware.cDocumentation/devicetree/bindings/arm/samsung-boards.txt +4
-0@@ -6,3 +6,13 @@ Required root node properties: - compatible = should be one or more of the following. (a) "samsung,smdkv310" - for Samsung's SMDKV310 eval board. (b) "samsung,exynos4210" - for boards based on Exynos4210 SoC. + +Optional: + - firmware node, specifying presence and type of secure firmware: + - compatible: only "samsung,secure-firmware" is currentlysupported
+ - reg: address of non-secure SYSRAM used for communication with
firmwareDocumentation/devicetree/bindings/arm/samsung-boards.txt +5
-0+ + firmware at 0203F000 { + compatible = "samsung,secure-firmware"; + reg = <0x0203F000 0x1000>; + };arch/arm/mach-exynos/Makefile +1
-0@@ -31,6 +31,7 @@ obj-$(CONFIG_EXYNOS4_MCT) += mct.o obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o obj-$(CONFIG_ARCH_EXYNOS) += exynos-smc.o +obj-$(CONFIG_ARCH_EXYNOS) += firmware.o plus_sec := $(call as-instr,.arch_extension sec,+sec) AFLAGS_exynos-smc.o :=-Wa,-march=armv7-a$(plus_sec)arch/arm/mach-exynos/common.h +2
-0@@ -22,6 +22,8 @@ void exynos4_restart(char mode, const char *cmd);void exynos5_restart (char mode,const char *cmd);void exynos_init_late (void ); +void exynos_firmware_init (void ); +#ifdef CONFIG_PM_GENERIC_DOMAINS int exynos_pm_late_initcall (void );#else arch/arm/mach-exynos/firmware.c new file +60
-0@@ -0,0 +1,70 @@ +/* +* Copyright (C) 2012 Samsung Electronics. +* Kyungmin Park <[email protected]> +* Tomasz Figa <[email protected]> +* +* This program is free software,you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#include <linux/kernel.h> +#include <linux/io.h> +#include <linux/init.h> +#include <linux/of.h> +#include <linux/of_address.h> + +#include <asm/firmware.h> + +#include <mach/map.h> + +#include "smc.h" + +static int exynos_do_idle (void ) +{ +exynos_smc (SMC_CMD_SLEEP ,0 ,0 ,0 ); +return 0 ; +} + +static int exynos_cpu_boot (int cpu) +{ +exynos_smc (SMC_CMD_CPU1BOOT , cpu,0 ,0 ); +return 0 ; +} + +static int exynos_set_cpu_boot_addr (int cpu,unsigned long boot_addr) +{ +void __iomem *boot_reg =S5P_VA_SYSRAM_NS +0x1c +4 *cpu; + +__raw_writel (boot_addr, boot_reg); +return 0 ; +} + +static const struct firmware_ops exynos_firmware_ops = { + .do_idle = exynos_do_idle, + .set_cpu_boot_addr = exynos_set_cpu_boot_addr, + .cpu_boot = exynos_cpu_boot, +}; + +void __init exynos_firmware_init (void ) +{ +if (of_have_populated_dt ()) { +struct device_node *nd; +const __be32 *addr; + + nd =of_find_compatible_node (NULL ,NULL , +"samsung,secure-firmware" ); +if (!nd) +return ; + + addr =of_get_address (nd,0 ,NULL ,NULL );
arch/arm/mach-exynos/firmware.c line 70
Quoted 10 lines
arch/arm/mach-exynos/firmware.c new file +10
-0+if (!addr) { +pr_err ("%s: No address specified.\n" , __func__); +return ; + } + } + +pr_info ("Running under secure firmware.\n" ); + +register_firmware_ops (&exynos_firmware_ops); +}
except these smc calls when system boots, there must be some smc calls in the runtime of linux. it seems the firmware_ops can cover those callbacks of the communication between linux and firmware as well?
Quoted 13 lines
arch/arm/mach-exynos/mach-exynos4-dt.c +1
-0@@ -107,6 +107,7 @@ DT_MACHINE_START(EXYNOS4210_DT, "Samsung Exynos4 (Flattened Device Tree)") .init_irq = exynos4_init_irq, .map_io = exynos4_dt_map_io, .handle_irq = gic_handle_irq, + .init_early = exynos_firmware_init, .init_machine = exynos4_dt_machine_init, .init_late = exynos_init_late,
Quoted 3 lines
.timer =
&exynos4_timer,
--
1.8.0
-barry
PATCH v4 3/5 ARM: EXYNOS: Add support for Exynos secure firmware
Quoted 8 lines · Barry Song
Quoted 8 lines
/ { /* ... */ firmware at 0203F000 { compatible = "samsung,secure-firmware"; reg = <0x0203F000 0x1000>; };
Quoted 7 lines
Quoted 2 lines
/* ... */ };well. amazing, dts is used to describle hardware details, here the firmware is just a software and reg is the memory the firmware will use. is this something againest the dt rule?
but it is really simple.
We have for a long time had DT bindings to describe firmware, e.g. on IBM Power systems, I think this is fine.
Arnd
PATCH v4 4/5 ARM: EXYNOS: Add IO mapping for non-secure SYSRAM.
In reply to Tomasz FigaOn TrustZone-enabled boards the non-secure SYSRAM is used for secondary CPU bring-up, so add a mapping for it.
--- arch/arm/mach-exynos/common.c | 35 ++++++++++++++++++++++++++++ arch/arm/mach-exynos/include/mach/map.h | 3 +++ arch/arm/plat-samsung/include/plat/map-s5p.h | 1 + 3 files changed, 39 insertions(+)
arch/arm/mach-exynos/common.c +35 -0
@@ -231,6 +231,33 @@ static struct map_desc exynos4_iodesc1[] __initdata = { }, }; +static struct map_desc exynos4210_iodesc[]__initdata = { + { + .virtual = (unsigned long )S5P_VA_SYSRAM_NS , + .pfn =__phys_to_pfn (EXYNOS4210_PA_SYSRAM_NS ), + .length =SZ_4K , + .type =MT_DEVICE , + }, +}; + +static struct map_desc exynos4x12_iodesc[]__initdata = { + { + .virtual = (unsigned long )S5P_VA_SYSRAM_NS , + .pfn =__phys_to_pfn (EXYNOS4x12_PA_SYSRAM_NS), + .length =SZ_4K , + .type =MT_DEVICE , + }, +}; + +static struct map_desc exynos5250_iodesc[]__initdata = { + { + .virtual = (unsigned long )S5P_VA_SYSRAM_NS , + .pfn =__phys_to_pfn (EXYNOS5250_PA_SYSRAM_NS ), + .length =SZ_4K , + .type =MT_DEVICE , + }, +}; +static struct map_desc exynos5_iodesc[]__initdata = { { .virtual = (unsigned long )S3C_VA_SYS ,
@@ -354,6 +381,11 @@ static void __init exynos4_map_io(void)else iotable_init (exynos4_iodesc1,ARRAY_SIZE (exynos4_iodesc1)); +if (soc_is_exynos4210 ()) +iotable_init (exynos4210_iodesc,ARRAY_SIZE (exynos4210_iodesc)); +if (soc_is_exynos4212 () ||soc_is_exynos4412 ()) +iotable_init (exynos4x12_iodesc,ARRAY_SIZE (exynos4x12_iodesc)); +/* initialize device information early */ exynos4_default_sdhci0 ();exynos4_default_sdhci1 ();
@@ -386,6 +418,9 @@ static void __init exynos4_map_io(void)static void __init exynos5_map_io (void ) {iotable_init (exynos5_iodesc,ARRAY_SIZE (exynos5_iodesc)); + +if (soc_is_exynos5250 ()) +iotable_init (exynos5250_iodesc,ARRAY_SIZE (exynos5250_iodesc)); }static void __init exynos4_init_clocks (int xtal)
arch/arm/mach-exynos/include/mach/map.h +3 -0
@@ -26,6 +26,9 @@#define EXYNOS4_PA_SYSRAM0 0x02025000#define EXYNOS4_PA_SYSRAM1 0x02020000#define EXYNOS5_PA_SYSRAM 0x02020000 +#define EXYNOS4210_PA_SYSRAM_NS 0x0203F000 +#define EXYNOS4x12_PA_SYSRAM_NS 0x0204F000 +#define EXYNOS5250_PA_SYSRAM_NS 0x0204F000#define EXYNOS4_PA_FIMC0 0x11800000#define EXYNOS4_PA_FIMC1 0x11810000
arch/arm/plat-samsung/include/plat/map-s5p.h +1 -0
@@ -22,6 +22,7 @@#define S5P_VA_GPIO3 S3C_ADDR(0x02280000)#define S5P_VA_SYSRAM S3C_ADDR(0x02400000) +#define S5P_VA_SYSRAM_NS S3C_ADDR(0x02410000)#define S5P_VA_DMC0 S3C_ADDR(0x02440000)#define S5P_VA_DMC1 S3C_ADDR(0x02480000)#define S5P_VA_SROMC S3C_ADDR(0x024C0000)
Signature · 1 line
1.8.0
PATCH v4 5/5 ARM: EXYNOS: Add secure firmware support to secondary CPU bring-up
In reply to Tomasz FigaBoards using secure firmware must use different CPU boot registers and call secure firmware to boot the CPU.
--- arch/arm/mach-exynos/platsmp.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-)
arch/arm/mach-exynos/platsmp.c +27 -5
@@ -25,6 +25,7 @@#include <asm/hardware/gic.h> #include <asm/smp_plat.h> #include <asm/smp_scu.h> +#include <asm/firmware.h> #include <mach/hardware.h> #include <mach/regs-clock.h>
@@ -145,10 +146,21 @@ static int __cpuinit exynos_boot_secondary(unsigned int cpu, struct task_struct timeout = jiffies + (1 *HZ );while (time_before (jiffies, timeout)) { +unsigned long boot_addr; +smp_rmb (); -__raw_writel (virt_to_phys (exynos4_secondary_startup), -cpu_boot_reg (phys_cpu)); + boot_addr =virt_to_phys (exynos4_secondary_startup); + +/* +* Try to set boot address using firmware first +* and fall back to boot register if it fails. +*/ +if (call_firmware_op (set_cpu_boot_addr, phys_cpu, boot_addr)) +__raw_writel (boot_addr,cpu_boot_reg (phys_cpu)); + +call_firmware_op (cpu_boot, phys_cpu); +gic_raise_softirq (cpumask_of (cpu),0 );if (pen_release ==-1 )
@@ -206,10 +218,20 @@ static void __init exynos_smp_prepare_cpus(unsigned int max_cpus)* system-wide flags register. The boot monitor waits * until it receives a soft interrupt, and then the * secondary CPU branches to this address. +* +* Try using firmware operation first and fall back to +* boot register if it fails. */ -for (i =1 ; i < max_cpus; ++i) -__raw_writel (virt_to_phys (exynos4_secondary_startup), -cpu_boot_reg (cpu_logical_map (i))); +for (i =1 ; i < max_cpus; ++i) { +unsigned long phys_cpu; +unsigned long boot_addr; + + phys_cpu =cpu_logical_map (i); + boot_addr =virt_to_phys (exynos4_secondary_startup); + +if (call_firmware_op (set_cpu_boot_addr, phys_cpu, boot_addr)) +__raw_writel (boot_addr,cpu_boot_reg (phys_cpu)); + } }struct smp_operations exynos_smp_ops__initdata = {
Signature · 1 line
1.8.0
v4 cover ARM: EXYNOS: Add secure firmware support
In reply to Tomasz FigaQuoted 62 lines · Tomasz Figa
Some Exynos-based boards are running with secure firmware running in TrustZone secure world, which changes the way some things have to be initialized.
This series adds support for specifying firmware operations, implements some firmware operations for Exynos secure firmware and adds a method of enabling secure firmware operations on Exynos-based boards through board file and device tree.
Depends on:
- ARM: EXYNOS: Add support for secondary CPU bring-up on Exynos4412Changes since v3
( http://thread.gmane.org/gmane.linux.kernel.samsung-soc/13442 )
- Replacedcpu_boot_regcall withcpu_set_boot_addr
- Added interface documentation
- Separated from Exynos4x12 secondary CPU bring-up patchChanges since v2
( http://thread.gmane.org/gmane.linux.kernel.samsung-soc/12848 )
- Made Exynos firmware binding require address
- Minor style fixesChanges since v1
( http://thread.gmane.org/gmane.linux.kernel.samsung-
soc/12583/focus=12820 )
- Changed return types of all operations to int
- Defined all operations to return 0 on success,-ENOSYSwhen not implemented or appropriate error code on errorTomasz Figa (5):
ARM: Add interface for registering and calling firmware-specific
operations
ARM: EXYNOS: Add support for secure monitor calls
ARM: EXYNOS: Add support for Exynos secure firmware
ARM: EXYNOS: Add IO mapping for non-secure SYSRAM.
ARM: EXYNOS: Add secure firmware support to secondary CPU bring-upDocumentation/arm/firmware.txt | 88 ++++++++++++++++++++++ .../devicetree/bindings/arm/samsung-boards.txt | 10 +++ arch/arm/common/Makefile | 2 + arch/arm/common/firmware.c | 18 +++++ arch/arm/include/asm/firmware.h | 66 ++++++++++++++++ arch/arm/mach-exynos/Makefile | 6 ++ arch/arm/mach-exynos/common.c | 35 +++++++++ arch/arm/mach-exynos/common.h | 2 + arch/arm/mach-exynos/exynos-smc.S | 22 ++++++ arch/arm/mach-exynos/firmware.c | 70 +++++++++++++++++ arch/arm/mach-exynos/include/mach/map.h | 3 + arch/arm/mach-exynos/mach-exynos4-dt.c | 1 + arch/arm/mach-exynos/platsmp.c | 32 ++++++-- arch/arm/mach-exynos/smc.h | 31 ++++++++ arch/arm/plat-samsung/include/plat/map-s5p.h | 1 + 15 files changed, 382 insertions(+), 5 deletions(-) create mode 100644 Documentation/arm/firmware.txt create mode 100644 arch/arm/common/firmware.c create mode 100644 arch/arm/include/asm/firmware.h create mode 100644 arch/arm/mach-exynos/exynos-smc.S create mode 100644 arch/arm/mach-exynos/firmware.c create mode 100644 arch/arm/mach-exynos/smc.h
Quoted 2 lines
--
1.8.0
Russell, I think, Tomasz addressed comments from you.
If you're ok on this, please ack so that I can pick this up in my tree for v3.8...
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.
v4 cover ARM: EXYNOS: Add secure firmware support
Hi,
Quoted 72 lines · On Saturday 24 of November 2012 11:21:03 Kukjin Kim wrote:
Quoted 71 lines · Tomasz Figa
Some Exynos-based boards are running with secure firmware running in TrustZone secure world, which changes the way some things have to be initialized.
This series adds support for specifying firmware operations, implements
some firmware operations for Exynos secure firmware and adds a method of enabling secure firmware operations on Exynos-based boards through board file and device tree.Depends on:
- ARM: EXYNOS: Add support for secondary CPU bring-up on Exynos4412Changes since v3
( http://thread.gmane.org/gmane.linux.kernel.samsung-soc/13442 )- Replaced
cpu_boot_regcall withcpu_set_boot_addr
- Added interface documentation
- Separated from Exynos4x12 secondary CPU bring-up patchChanges since v2
( http://thread.gmane.org/gmane.linux.kernel.samsung-soc/12848 )- Made Exynos firmware binding require address
- Minor style fixesChanges since v1
( http://thread.gmane.org/gmane.linux.kernel.samsung-
soc/12583/focus=12820 )- Changed return types of all operations to int
- Defined all operations to return 0 on success,-ENOSYSwhen notimplemented or appropriate error code on error
Tomasz Figa (5):
ARM: Add interface for registering and calling firmware-specificoperations
ARM: EXYNOS: Add support for secure monitor calls
ARM: EXYNOS: Add support for Exynos secure firmware
ARM: EXYNOS: Add IO mapping for non-secure SYSRAM.
ARM: EXYNOS: Add secure firmware support to secondary CPU bring-upDocumentation/arm/firmware.txt | 88 ++++++++++++++++++++++ .../devicetree/bindings/arm/samsung-boards.txt | 10 +++ arch/arm/common/Makefile | 2 + arch/arm/common/firmware.c | 18 +++++ arch/arm/include/asm/firmware.h | 66 ++++++++++++++++ arch/arm/mach-exynos/Makefile | 6 ++ arch/arm/mach-exynos/common.c | 35 +++++++++ arch/arm/mach-exynos/common.h | 2 + arch/arm/mach-exynos/exynos-smc.S | 22 ++++++ arch/arm/mach-exynos/firmware.c | 70 +++++++++++++++++ arch/arm/mach-exynos/include/mach/map.h | 3 + arch/arm/mach-exynos/mach-exynos4-dt.c | 1 + arch/arm/mach-exynos/platsmp.c | 32 ++++++-- arch/arm/mach-exynos/smc.h | 31 ++++++++ arch/arm/plat-samsung/include/plat/map-s5p.h | 1 + 15 files changed, 382 insertions(+), 5 deletions(-) create mode 100644 Documentation/arm/firmware.txt create mode 100644 arch/arm/common/firmware.c create mode 100644 arch/arm/include/asm/firmware.h create mode 100644 arch/arm/mach-exynos/exynos-smc.S create mode 100644 arch/arm/mach-exynos/firmware.c create mode 100644 arch/arm/mach-exynos/smc.h
Quoted 7 lines
Quoted 2 lines
--
1.8.0Russell, I think, Tomasz addressed comments from you.
If you're ok on this, please ack so that I can pick this up in my tree for v3.8...
Arnd, Olof, what do you think?
Best regards,
Signature · 3 lines
Tomasz Figa Samsung Poland R&D Center SW Solution Development, Linux Platform
v4 cover ARM: EXYNOS: Add secure firmware support
Quoted 2 lines · Tomasz Figa
Hi,
[...]
Quoted 4 lines
Quoted 4 lines
Russell, I think, Tomasz addressed comments from you.
If you're ok on this, please ack so that I can pick this up in my tree for v3.8...
I'm holding on this series...any opinions on this?
If there is no objection on this, let me try to send this out...
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.