aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2013-09-18 15:43:56 -0400
committerTony Lindgren <tony@atomide.com>2013-10-08 14:57:04 -0400
commit4748a7240284b0f68bd47a66365c2cd561939830 (patch)
treeafcfc03b29c7aa47fd48acfac02a770bc676d871 /arch/arm/mach-omap2
parenta33f1788192d13165594f8ec6975dbae34502ec9 (diff)
ARM: OMAP3: RX-51: ARM errata 430973 workaround
Closed and signed Nokia X-Loader bootloader stored in RX-51 nand does not set IBE bit in ACTLR and starting kernel in non-secure mode. So direct write to ACTLR by our kernel does not working and the code for ARM errata 430973 in commit 7ce236fcd6fd45b0441a2d49acb2ceb2de2e8a47 that sets IBE bit is a noop. In order to have workaround for ARM errata 430973 from non-secure world on RX-51 we needs Secure Monitor Call to set IBE BIT in ACTLR. This patch adds RX-51 specific secure support code and sets IBE bit in ACTLR during board init code for ARM errata 430973 workaround. Note that new function rx51_secure_dispatcher() differs from existing omap_secure_dispatcher(). It calling omap_smc3() and param[0] is nargs+1. ARM errata 430973 workaround is needed for thumb-2 ISA compiled userspace binaries. Without this workaround thumb-2 binaries crashing. So with this patch it is possible to recompile and run applications/binaries with thumb-2 ISA on RX-51. Signed-off-by: Ivaylo Dimitrov <freemangordon@abv.bg> Signed-off-by: Pali Rohár <pali.rohar@gmail.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2')
-rw-r--r--arch/arm/mach-omap2/board-rx51.c12
-rw-r--r--arch/arm/mach-omap2/omap-secure.c65
-rw-r--r--arch/arm/mach-omap2/omap-secure.h11
3 files changed, 88 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/board-rx51.c b/arch/arm/mach-omap2/board-rx51.c
index 7735105561d8..db168c9627a1 100644
--- a/arch/arm/mach-omap2/board-rx51.c
+++ b/arch/arm/mach-omap2/board-rx51.c
@@ -2,6 +2,8 @@
2 * Board support file for Nokia N900 (aka RX-51). 2 * Board support file for Nokia N900 (aka RX-51).
3 * 3 *
4 * Copyright (C) 2007, 2008 Nokia 4 * Copyright (C) 2007, 2008 Nokia
5 * Copyright (C) 2012 Ivaylo Dimitrov <freemangordon@abv.bg>
6 * Copyright (C) 2013 Pali Rohár <pali.rohar@gmail.com>
5 * 7 *
6 * This program is free software; you can redistribute it and/or modify 8 * 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 9 * it under the terms of the GNU General Public License version 2 as
@@ -31,7 +33,9 @@
31#include "mux.h" 33#include "mux.h"
32#include "gpmc.h" 34#include "gpmc.h"
33#include "pm.h" 35#include "pm.h"
36#include "soc.h"
34#include "sdram-nokia.h" 37#include "sdram-nokia.h"
38#include "omap-secure.h"
35 39
36#define RX51_GPIO_SLEEP_IND 162 40#define RX51_GPIO_SLEEP_IND 162
37 41
@@ -103,6 +107,14 @@ static void __init rx51_init(void)
103 usb_musb_init(&musb_board_data); 107 usb_musb_init(&musb_board_data);
104 rx51_peripherals_init(); 108 rx51_peripherals_init();
105 109
110 if (omap_type() == OMAP2_DEVICE_TYPE_SEC) {
111#ifdef CONFIG_ARM_ERRATA_430973
112 pr_info("RX-51: Enabling ARM errata 430973 workaround\n");
113 /* set IBE to 1 */
114 rx51_secure_update_aux_cr(BIT(6), 0);
115#endif
116 }
117
106 /* Ensure SDRC pins are mux'd for self-refresh */ 118 /* Ensure SDRC pins are mux'd for self-refresh */
107 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT); 119 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
108 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT); 120 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
diff --git a/arch/arm/mach-omap2/omap-secure.c b/arch/arm/mach-omap2/omap-secure.c
index b970440cffca..146a7c4e2a13 100644
--- a/arch/arm/mach-omap2/omap-secure.c
+++ b/arch/arm/mach-omap2/omap-secure.c
@@ -3,6 +3,8 @@
3 * 3 *
4 * Copyright (C) 2011 Texas Instruments, Inc. 4 * Copyright (C) 2011 Texas Instruments, Inc.
5 * Santosh Shilimkar <santosh.shilimkar@ti.com> 5 * Santosh Shilimkar <santosh.shilimkar@ti.com>
6 * Copyright (C) 2012 Ivaylo Dimitrov <freemangordon@abv.bg>
7 * Copyright (C) 2013 Pali Rohár <pali.rohar@gmail.com>
6 * 8 *
7 * 9 *
8 * This program is free software,you can redistribute it and/or modify 10 * This program is free software,you can redistribute it and/or modify
@@ -70,3 +72,66 @@ phys_addr_t omap_secure_ram_mempool_base(void)
70{ 72{
71 return omap_secure_memblock_base; 73 return omap_secure_memblock_base;
72} 74}
75
76/**
77 * rx51_secure_dispatcher: Routine to dispatch secure PPA API calls
78 * @idx: The PPA API index
79 * @process: Process ID
80 * @flag: The flag indicating criticality of operation
81 * @nargs: Number of valid arguments out of four.
82 * @arg1, arg2, arg3 args4: Parameters passed to secure API
83 *
84 * Return the non-zero error value on failure.
85 *
86 * NOTE: rx51_secure_dispatcher differs from omap_secure_dispatcher because
87 * it calling omap_smc3() instead omap_smc2() and param[0] is nargs+1
88 */
89u32 rx51_secure_dispatcher(u32 idx, u32 process, u32 flag, u32 nargs,
90 u32 arg1, u32 arg2, u32 arg3, u32 arg4)
91{
92 u32 ret;
93 u32 param[5];
94
95 param[0] = nargs+1; /* RX-51 needs number of arguments + 1 */
96 param[1] = arg1;
97 param[2] = arg2;
98 param[3] = arg3;
99 param[4] = arg4;
100
101 /*
102 * Secure API needs physical address
103 * pointer for the parameters
104 */
105 local_irq_disable();
106 local_fiq_disable();
107 flush_cache_all();
108 outer_clean_range(__pa(param), __pa(param + 5));
109 ret = omap_smc3(idx, process, flag, __pa(param));
110 flush_cache_all();
111 local_fiq_enable();
112 local_irq_enable();
113
114 return ret;
115}
116
117/**
118 * rx51_secure_update_aux_cr: Routine to modify the contents of Auxiliary Control Register
119 * @set_bits: bits to set in ACR
120 * @clr_bits: bits to clear in ACR
121 *
122 * Return the non-zero error value on failure.
123*/
124u32 rx51_secure_update_aux_cr(u32 set_bits, u32 clear_bits)
125{
126 u32 acr;
127
128 /* Read ACR */
129 asm volatile ("mrc p15, 0, %0, c1, c0, 1" : "=r" (acr));
130 acr &= ~clear_bits;
131 acr |= set_bits;
132
133 return rx51_secure_dispatcher(RX51_PPA_WRITE_ACR,
134 0,
135 FLAG_START_CRITICAL,
136 1, acr, 0, 0, 0);
137}
diff --git a/arch/arm/mach-omap2/omap-secure.h b/arch/arm/mach-omap2/omap-secure.h
index c4586f42ea98..51b59c686a53 100644
--- a/arch/arm/mach-omap2/omap-secure.h
+++ b/arch/arm/mach-omap2/omap-secure.h
@@ -3,6 +3,8 @@
3 * 3 *
4 * Copyright (C) 2011 Texas Instruments, Inc. 4 * Copyright (C) 2011 Texas Instruments, Inc.
5 * Santosh Shilimkar <santosh.shilimkar@ti.com> 5 * Santosh Shilimkar <santosh.shilimkar@ti.com>
6 * Copyright (C) 2012 Ivaylo Dimitrov <freemangordon@abv.bg>
7 * Copyright (C) 2013 Pali Rohár <pali.rohar@gmail.com>
6 * 8 *
7 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
@@ -46,6 +48,11 @@
46#define OMAP4_PPA_L2_POR_INDEX 0x23 48#define OMAP4_PPA_L2_POR_INDEX 0x23
47#define OMAP4_PPA_CPU_ACTRL_SMP_INDEX 0x25 49#define OMAP4_PPA_CPU_ACTRL_SMP_INDEX 0x25
48 50
51/* Secure RX-51 PPA (Primary Protected Application) APIs */
52#define RX51_PPA_HWRNG 29
53#define RX51_PPA_L2_INVAL 40
54#define RX51_PPA_WRITE_ACR 42
55
49#ifndef __ASSEMBLER__ 56#ifndef __ASSEMBLER__
50 57
51extern u32 omap_secure_dispatcher(u32 idx, u32 flag, u32 nargs, 58extern u32 omap_secure_dispatcher(u32 idx, u32 flag, u32 nargs,
@@ -55,6 +62,10 @@ extern u32 omap_smc3(u32 id, u32 process, u32 flag, u32 pargs);
55extern phys_addr_t omap_secure_ram_mempool_base(void); 62extern phys_addr_t omap_secure_ram_mempool_base(void);
56extern int omap_secure_ram_reserve_memblock(void); 63extern int omap_secure_ram_reserve_memblock(void);
57 64
65extern u32 rx51_secure_dispatcher(u32 idx, u32 process, u32 flag, u32 nargs,
66 u32 arg1, u32 arg2, u32 arg3, u32 arg4);
67extern u32 rx51_secure_update_aux_cr(u32 set_bits, u32 clear_bits);
68
58#ifdef CONFIG_OMAP4_ERRATA_I688 69#ifdef CONFIG_OMAP4_ERRATA_I688
59extern int omap_barrier_reserve_memblock(void); 70extern int omap_barrier_reserve_memblock(void);
60#else 71#else