All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: highbank: Add smc calls to enable/disable the L2
@ 2012-06-05  3:11 Rob Herring
  2012-06-05  9:49 ` Russell King - ARM Linux
  2012-06-06 22:20 ` [PATCH v2] " Rob Herring
  0 siblings, 2 replies; 5+ messages in thread
From: Rob Herring @ 2012-06-05  3:11 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

Linux runs in non-secure mode on highbank, so we need secure monitor calls
to enable and disable the PL310. Rather than invent new smc calls, the same
calling convention used by OMAP is used here.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 arch/arm/mach-highbank/Makefile   |    6 +++++-
 arch/arm/mach-highbank/core.h     |    1 +
 arch/arm/mach-highbank/highbank.c |   14 ++++++++++++++
 arch/arm/mach-highbank/smc.S      |   29 +++++++++++++++++++++++++++++
 4 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-highbank/smc.S

diff --git a/arch/arm/mach-highbank/Makefile b/arch/arm/mach-highbank/Makefile
index f8437dd..ded4652 100644
--- a/arch/arm/mach-highbank/Makefile
+++ b/arch/arm/mach-highbank/Makefile
@@ -1,4 +1,8 @@
-obj-y					:= clock.o highbank.o system.o
+obj-y					:= clock.o highbank.o system.o smc.o
+
+plus_sec := $(call as-instr,.arch_extension sec,+sec)
+AFLAGS_smc.o				:=-Wa,-march=armv7-a$(plus_sec)
+
 obj-$(CONFIG_DEBUG_HIGHBANK_UART)	+= lluart.o
 obj-$(CONFIG_SMP)			+= platsmp.o
 obj-$(CONFIG_HOTPLUG_CPU)		+= hotplug.o
diff --git a/arch/arm/mach-highbank/core.h b/arch/arm/mach-highbank/core.h
index d8e2d0b..141ed51 100644
--- a/arch/arm/mach-highbank/core.h
+++ b/arch/arm/mach-highbank/core.h
@@ -8,3 +8,4 @@ extern void highbank_lluart_map_io(void);
 static inline void highbank_lluart_map_io(void) {}
 #endif
 
+extern void highbank_smc1(int fn, int arg);
diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
index 410a112..8777612 100644
--- a/arch/arm/mach-highbank/highbank.c
+++ b/arch/arm/mach-highbank/highbank.c
@@ -85,10 +85,24 @@ const static struct of_device_id irq_match[] = {
 	{}
 };
 
+#ifdef CONFIG_CACHE_L2X0
+static void highbank_l2x0_disable(void)
+{
+	/* Disable PL310 L2 Cache controller */
+	highbank_smc1(0x102, 0x0);
+}
+#endif
+
 static void __init highbank_init_irq(void)
 {
 	of_irq_init(irq_match);
+
+#ifdef CONFIG_CACHE_L2X0
+	/* Enable PL310 L2 Cache controller */
+	highbank_smc1(0x102, 0x1);
 	l2x0_of_init(0, ~0UL);
+	outer_cache.disable = highbank_l2x0_disable;
+#endif
 }
 
 static void __init highbank_timer_init(void)
diff --git a/arch/arm/mach-highbank/smc.S b/arch/arm/mach-highbank/smc.S
new file mode 100644
index 0000000..bba369e
--- /dev/null
+++ b/arch/arm/mach-highbank/smc.S
@@ -0,0 +1,29 @@
+/*
+ * Copied from omap44xx-smc.S Copyright (C) 2010 Texas Instruments, Inc.
+ * Copyright 2012 Calxeda, 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>
+
+/*
+ * This is common routine to manage secure monitor API
+ * used to modify the PL310 secure registers.
+ * 'r0' contains the value to be modified and 'r12' contains
+ * the monitor API number. It uses few CPU registers
+ * internally and hence they need be backed up including
+ * link register "lr".
+ * Function signature : void highbank_smc1(u32 fn, u32 arg)
+ */
+
+ENTRY(highbank_smc1)
+	stmfd   sp!, {r2-r12, lr}
+	mov	r12, r0
+	mov 	r0, r1
+	dsb
+	smc	#0
+	ldmfd   sp!, {r2-r12, pc}
+ENDPROC(highbank_smc1)
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] ARM: highbank: Add smc calls to enable/disable the L2
  2012-06-05  3:11 [PATCH] ARM: highbank: Add smc calls to enable/disable the L2 Rob Herring
@ 2012-06-05  9:49 ` Russell King - ARM Linux
  2012-06-06 22:20 ` [PATCH v2] " Rob Herring
  1 sibling, 0 replies; 5+ messages in thread
From: Russell King - ARM Linux @ 2012-06-05  9:49 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jun 04, 2012 at 10:11:40PM -0500, Rob Herring wrote:
> +/*
> + * This is common routine to manage secure monitor API
> + * used to modify the PL310 secure registers.
> + * 'r0' contains the value to be modified and 'r12' contains
> + * the monitor API number. It uses few CPU registers
> + * internally and hence they need be backed up including
> + * link register "lr".
> + * Function signature : void highbank_smc1(u32 fn, u32 arg)
> + */
> +
> +ENTRY(highbank_smc1)
> +	stmfd   sp!, {r2-r12, lr}
> +	mov	r12, r0
> +	mov 	r0, r1
> +	dsb
> +	smc	#0
> +	ldmfd   sp!, {r2-r12, pc}
> +ENDPROC(highbank_smc1)

The ABI.  r0-r3 are used to pass arguments, and _may_ be corrupted by
the called function.  r12 is a temporary register which called functions
may corrupt.  lr is not expected to be preserved.  Everything else must
be preserved.  Return values in r0 and maybe r1.

So.  The registers you must preserve across a function call are r4-r11,
and r13(sp).

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] ARM: highbank: Add smc calls to enable/disable the L2
  2012-06-05  3:11 [PATCH] ARM: highbank: Add smc calls to enable/disable the L2 Rob Herring
  2012-06-05  9:49 ` Russell King - ARM Linux
@ 2012-06-06 22:20 ` Rob Herring
  2012-06-08  0:33   ` Rob Herring
  1 sibling, 1 reply; 5+ messages in thread
From: Rob Herring @ 2012-06-06 22:20 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

Linux runs in non-secure mode on highbank, so we need secure monitor calls
to enable and disable the PL310. Rather than invent new smc calls, the same
calling convention used by OMAP is used here.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
v2:
 - Only save registers required by ARM ABI

 arch/arm/mach-highbank/Makefile   |    6 +++++-
 arch/arm/mach-highbank/core.h     |    1 +
 arch/arm/mach-highbank/highbank.c |   14 ++++++++++++++
 arch/arm/mach-highbank/smc.S      |   27 +++++++++++++++++++++++++++
 4 files changed, 47 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-highbank/smc.S

diff --git a/arch/arm/mach-highbank/Makefile b/arch/arm/mach-highbank/Makefile
index f8437dd..ded4652 100644
--- a/arch/arm/mach-highbank/Makefile
+++ b/arch/arm/mach-highbank/Makefile
@@ -1,4 +1,8 @@
-obj-y					:= clock.o highbank.o system.o
+obj-y					:= clock.o highbank.o system.o smc.o
+
+plus_sec := $(call as-instr,.arch_extension sec,+sec)
+AFLAGS_smc.o				:=-Wa,-march=armv7-a$(plus_sec)
+
 obj-$(CONFIG_DEBUG_HIGHBANK_UART)	+= lluart.o
 obj-$(CONFIG_SMP)			+= platsmp.o
 obj-$(CONFIG_HOTPLUG_CPU)		+= hotplug.o
diff --git a/arch/arm/mach-highbank/core.h b/arch/arm/mach-highbank/core.h
index d8e2d0b..141ed51 100644
--- a/arch/arm/mach-highbank/core.h
+++ b/arch/arm/mach-highbank/core.h
@@ -8,3 +8,4 @@ extern void highbank_lluart_map_io(void);
 static inline void highbank_lluart_map_io(void) {}
 #endif
 
+extern void highbank_smc1(int fn, int arg);
diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
index 410a112..8777612 100644
--- a/arch/arm/mach-highbank/highbank.c
+++ b/arch/arm/mach-highbank/highbank.c
@@ -85,10 +85,24 @@ const static struct of_device_id irq_match[] = {
 	{}
 };
 
+#ifdef CONFIG_CACHE_L2X0
+static void highbank_l2x0_disable(void)
+{
+	/* Disable PL310 L2 Cache controller */
+	highbank_smc1(0x102, 0x0);
+}
+#endif
+
 static void __init highbank_init_irq(void)
 {
 	of_irq_init(irq_match);
+
+#ifdef CONFIG_CACHE_L2X0
+	/* Enable PL310 L2 Cache controller */
+	highbank_smc1(0x102, 0x1);
 	l2x0_of_init(0, ~0UL);
+	outer_cache.disable = highbank_l2x0_disable;
+#endif
 }
 
 static void __init highbank_timer_init(void)
diff --git a/arch/arm/mach-highbank/smc.S b/arch/arm/mach-highbank/smc.S
new file mode 100644
index 0000000..407d17b
--- /dev/null
+++ b/arch/arm/mach-highbank/smc.S
@@ -0,0 +1,27 @@
+/*
+ * Copied from omap44xx-smc.S Copyright (C) 2010 Texas Instruments, Inc.
+ * Copyright 2012 Calxeda, 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>
+
+/*
+ * This is common routine to manage secure monitor API
+ * used to modify the PL310 secure registers.
+ * 'r0' contains the value to be modified and 'r12' contains
+ * the monitor API number.
+ * Function signature : void highbank_smc1(u32 fn, u32 arg)
+ */
+
+ENTRY(highbank_smc1)
+	stmfd   sp!, {r4-r11, lr}
+	mov	r12, r0
+	mov 	r0, r1
+	dsb
+	smc	#0
+	ldmfd   sp!, {r4-r11, pc}
+ENDPROC(highbank_smc1)
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2] ARM: highbank: Add smc calls to enable/disable the L2
  2012-06-06 22:20 ` [PATCH v2] " Rob Herring
@ 2012-06-08  0:33   ` Rob Herring
  2012-06-08  8:21     ` Olof Johansson
  0 siblings, 1 reply; 5+ messages in thread
From: Rob Herring @ 2012-06-08  0:33 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/06/2012 05:20 PM, Rob Herring wrote:
> From: Rob Herring <rob.herring@calxeda.com>
> 
> Linux runs in non-secure mode on highbank, so we need secure monitor calls
> to enable and disable the PL310. Rather than invent new smc calls, the same
> calling convention used by OMAP is used here.
> 
> Signed-off-by: Rob Herring <rob.herring@calxeda.com>

Arnd, Olof,

Can you apply this fix for 3.5. It's needed to enable the L2 on highbank.

Rob

> ---
> v2:
>  - Only save registers required by ARM ABI
> 
>  arch/arm/mach-highbank/Makefile   |    6 +++++-
>  arch/arm/mach-highbank/core.h     |    1 +
>  arch/arm/mach-highbank/highbank.c |   14 ++++++++++++++
>  arch/arm/mach-highbank/smc.S      |   27 +++++++++++++++++++++++++++
>  4 files changed, 47 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arm/mach-highbank/smc.S
> 
> diff --git a/arch/arm/mach-highbank/Makefile b/arch/arm/mach-highbank/Makefile
> index f8437dd..ded4652 100644
> --- a/arch/arm/mach-highbank/Makefile
> +++ b/arch/arm/mach-highbank/Makefile
> @@ -1,4 +1,8 @@
> -obj-y					:= clock.o highbank.o system.o
> +obj-y					:= clock.o highbank.o system.o smc.o
> +
> +plus_sec := $(call as-instr,.arch_extension sec,+sec)
> +AFLAGS_smc.o				:=-Wa,-march=armv7-a$(plus_sec)
> +
>  obj-$(CONFIG_DEBUG_HIGHBANK_UART)	+= lluart.o
>  obj-$(CONFIG_SMP)			+= platsmp.o
>  obj-$(CONFIG_HOTPLUG_CPU)		+= hotplug.o
> diff --git a/arch/arm/mach-highbank/core.h b/arch/arm/mach-highbank/core.h
> index d8e2d0b..141ed51 100644
> --- a/arch/arm/mach-highbank/core.h
> +++ b/arch/arm/mach-highbank/core.h
> @@ -8,3 +8,4 @@ extern void highbank_lluart_map_io(void);
>  static inline void highbank_lluart_map_io(void) {}
>  #endif
>  
> +extern void highbank_smc1(int fn, int arg);
> diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
> index 410a112..8777612 100644
> --- a/arch/arm/mach-highbank/highbank.c
> +++ b/arch/arm/mach-highbank/highbank.c
> @@ -85,10 +85,24 @@ const static struct of_device_id irq_match[] = {
>  	{}
>  };
>  
> +#ifdef CONFIG_CACHE_L2X0
> +static void highbank_l2x0_disable(void)
> +{
> +	/* Disable PL310 L2 Cache controller */
> +	highbank_smc1(0x102, 0x0);
> +}
> +#endif
> +
>  static void __init highbank_init_irq(void)
>  {
>  	of_irq_init(irq_match);
> +
> +#ifdef CONFIG_CACHE_L2X0
> +	/* Enable PL310 L2 Cache controller */
> +	highbank_smc1(0x102, 0x1);
>  	l2x0_of_init(0, ~0UL);
> +	outer_cache.disable = highbank_l2x0_disable;
> +#endif
>  }
>  
>  static void __init highbank_timer_init(void)
> diff --git a/arch/arm/mach-highbank/smc.S b/arch/arm/mach-highbank/smc.S
> new file mode 100644
> index 0000000..407d17b
> --- /dev/null
> +++ b/arch/arm/mach-highbank/smc.S
> @@ -0,0 +1,27 @@
> +/*
> + * Copied from omap44xx-smc.S Copyright (C) 2010 Texas Instruments, Inc.
> + * Copyright 2012 Calxeda, 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>
> +
> +/*
> + * This is common routine to manage secure monitor API
> + * used to modify the PL310 secure registers.
> + * 'r0' contains the value to be modified and 'r12' contains
> + * the monitor API number.
> + * Function signature : void highbank_smc1(u32 fn, u32 arg)
> + */
> +
> +ENTRY(highbank_smc1)
> +	stmfd   sp!, {r4-r11, lr}
> +	mov	r12, r0
> +	mov 	r0, r1
> +	dsb
> +	smc	#0
> +	ldmfd   sp!, {r4-r11, pc}
> +ENDPROC(highbank_smc1)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] ARM: highbank: Add smc calls to enable/disable the L2
  2012-06-08  0:33   ` Rob Herring
@ 2012-06-08  8:21     ` Olof Johansson
  0 siblings, 0 replies; 5+ messages in thread
From: Olof Johansson @ 2012-06-08  8:21 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jun 7, 2012 at 5:33 PM, Rob Herring <robherring2@gmail.com> wrote:
> On 06/06/2012 05:20 PM, Rob Herring wrote:
>> From: Rob Herring <rob.herring@calxeda.com>
>>
>> Linux runs in non-secure mode on highbank, so we need secure monitor calls
>> to enable and disable the PL310. Rather than invent new smc calls, the same
>> calling convention used by OMAP is used here.
>>
>> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
>
> Arnd, Olof,
>
> Can you apply this fix for 3.5. It's needed to enable the L2 on highbank.

If we were to split hairs, this is a feature addition and not a
bugfix, so as such it belongs in the next merge window. But I applied
it anyway, it's well-contained in your platform and we're early in the
-rc cycle.


-Olof

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-06-08  8:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-05  3:11 [PATCH] ARM: highbank: Add smc calls to enable/disable the L2 Rob Herring
2012-06-05  9:49 ` Russell King - ARM Linux
2012-06-06 22:20 ` [PATCH v2] " Rob Herring
2012-06-08  0:33   ` Rob Herring
2012-06-08  8:21     ` Olof Johansson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.