diff mbox

[v4,8/8] ARM: VExpress: enable ARMv7 virt support for VExpress A15

Message ID 1376060592-10824-9-git-send-email-andre.przywara@linaro.org
State New
Headers show

Commit Message

Andre Przywara Aug. 9, 2013, 3:03 p.m. UTC
To enable hypervisors utilizing the ARMv7 virtualization extension
on the Versatile Express board with the A15 core tile, we add the
required configuration variable.
Also we define the board specific functions to do the SMP bringup:
smp_set_cpu_boot_addr() to set the start address for secondary cores
and smp_waitloop() to wait for IPIs and jump to the start address.

This also serves as an example for what to do when adding support for
new boards.

Signed-off-by: Andre Przywara <andre.przywara@linaro.org>
---
 board/armltd/vexpress/Makefile          |  7 +++++--
 board/armltd/vexpress/vexpress_common.c | 13 ++++++++++++
 board/armltd/vexpress/vexpress_smp.S    | 36 +++++++++++++++++++++++++++++++++
 include/configs/vexpress_ca15_tc2.h     |  4 ++++
 4 files changed, 58 insertions(+), 2 deletions(-)
 create mode 100644 board/armltd/vexpress/vexpress_smp.S

Comments

Albert ARIBAUD Sept. 14, 2013, 5 p.m. UTC | #1
Hi Andre,

On Fri,  9 Aug 2013 17:03:12 +0200, Andre Przywara
<andre.przywara@linaro.org> wrote:

> To enable hypervisors utilizing the ARMv7 virtualization extension
> on the Versatile Express board with the A15 core tile, we add the
> required configuration variable.
> Also we define the board specific functions to do the SMP bringup:
> smp_set_cpu_boot_addr() to set the start address for secondary cores
> and smp_waitloop() to wait for IPIs and jump to the start address.
> 
> This also serves as an example for what to do when adding support for
> new boards.
> 
> Signed-off-by: Andre Przywara <andre.przywara@linaro.org>
> ---
>  board/armltd/vexpress/Makefile          |  7 +++++--
>  board/armltd/vexpress/vexpress_common.c | 13 ++++++++++++
>  board/armltd/vexpress/vexpress_smp.S    | 36 +++++++++++++++++++++++++++++++++
>  include/configs/vexpress_ca15_tc2.h     |  4 ++++
>  4 files changed, 58 insertions(+), 2 deletions(-)
>  create mode 100644 board/armltd/vexpress/vexpress_smp.S
> 
> diff --git a/board/armltd/vexpress/Makefile b/board/armltd/vexpress/Makefile
> index 6719f3d..282ef6d 100644
> --- a/board/armltd/vexpress/Makefile
> +++ b/board/armltd/vexpress/Makefile
> @@ -26,9 +26,12 @@ include $(TOPDIR)/config.mk
>  LIB	= $(obj)lib$(BOARD).o
>  
>  COBJS	:= vexpress_common.o
> +ifneq ($(CONFIG_ARMV7_NONSEC)$(CONFIG_ARMV7_VIRT),)
> +SOBJS	:= vexpress_smp.o
> +endif
>  
> -SRCS	:= $(COBJS:.o=.c)
> -OBJS	:= $(addprefix $(obj),$(COBJS))
> +SRCS	:= $(COBJS:.o=.c) $(SOBJS:.o=.S)
> +OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
>  
>  $(LIB):	$(obj).depend $(OBJS)
>  	$(call cmd_link_o_target, $(OBJS))
> diff --git a/board/armltd/vexpress/vexpress_common.c b/board/armltd/vexpress/vexpress_common.c
> index 2c54869..66b810d 100644
> --- a/board/armltd/vexpress/vexpress_common.c
> +++ b/board/armltd/vexpress/vexpress_common.c
> @@ -272,3 +272,16 @@ ulong get_tbclk(void)
>  {
>  	return (ulong)CONFIG_SYS_HZ;
>  }
> +
> +/* Setting the address at which secondary cores start from.
> + * Versatile Express uses one address for all cores, so ignore corenr
> + */
> +void smp_set_core_boot_addr(unsigned long addr, int corenr)
> +{
> +	/* The SYSFLAGS register on VExpress needs to be cleared first
> +	 * by writing to the next address, since any writes to the address
> +	 * at offset 0 will only be ORed in
> +	 */
> +	writel(~0, CONFIG_SYSFLAGS_ADDR + 4);
> +	writel(addr, CONFIG_SYSFLAGS_ADDR);
> +}
> diff --git a/board/armltd/vexpress/vexpress_smp.S b/board/armltd/vexpress/vexpress_smp.S
> new file mode 100644
> index 0000000..41be2e7
> --- /dev/null
> +++ b/board/armltd/vexpress/vexpress_smp.S
> @@ -0,0 +1,36 @@
> +/*
> + * code for redirecting secondary cores to their start address
> + *
> + * Copyright (c) 2013	Andre Przywara <andre.przywara@linaro.org>
> + *
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> + * MA 02111-1307 USA
> + */
> +
> +#include <config.h>
> +#include <linux/linkage.h>
> +
> +/* void _smp_waitloop(unsigned previous_address); */
> +ENTRY(smp_waitloop)
> +	wfi
> +	ldr	r1, =CONFIG_SYSFLAGS_ADDR	@ load start address
> +	ldr	r1, [r1]
> +	cmp	r0, r1			@ make sure we dont execute this code
> +	beq	smp_waitloop		@ again (due to a spurious wakeup)
> +	mov	pc, r1
> +ENDPROC(smp_waitloop)
> diff --git a/include/configs/vexpress_ca15_tc2.h b/include/configs/vexpress_ca15_tc2.h
> index 4f425ac..14aa78e 100644
> --- a/include/configs/vexpress_ca15_tc2.h
> +++ b/include/configs/vexpress_ca15_tc2.h
> @@ -31,4 +31,8 @@
>  #include "vexpress_common.h"
>  #define CONFIG_BOOTP_VCI_STRING     "U-boot.armv7.vexpress_ca15x2_tc2"
>  
> +#define CONFIG_SYSFLAGS_ADDR 0x1c010030
> +
> +#define CONFIG_ARMV7_VIRT
> +
>  #endif

This patch breaks vexpress_ca9x4 and vexpress_ca5x2:

vexpress_common.c: In function 'smp_set_core_boot_addr':
vexpress_common.c:269:2: error: 'CONFIG_SYSFLAGS_ADDR' undeclared
(first use in this function) vexpress_common.c:269:2: note: each
undeclared identifier is reported only once for each function it
appears in.

Please provide V5 series addressing this as well as Christoffer's and
Nikolay's comments.

Amicalement,
diff mbox

Patch

diff --git a/board/armltd/vexpress/Makefile b/board/armltd/vexpress/Makefile
index 6719f3d..282ef6d 100644
--- a/board/armltd/vexpress/Makefile
+++ b/board/armltd/vexpress/Makefile
@@ -26,9 +26,12 @@  include $(TOPDIR)/config.mk
 LIB	= $(obj)lib$(BOARD).o
 
 COBJS	:= vexpress_common.o
+ifneq ($(CONFIG_ARMV7_NONSEC)$(CONFIG_ARMV7_VIRT),)
+SOBJS	:= vexpress_smp.o
+endif
 
-SRCS	:= $(COBJS:.o=.c)
-OBJS	:= $(addprefix $(obj),$(COBJS))
+SRCS	:= $(COBJS:.o=.c) $(SOBJS:.o=.S)
+OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
 
 $(LIB):	$(obj).depend $(OBJS)
 	$(call cmd_link_o_target, $(OBJS))
diff --git a/board/armltd/vexpress/vexpress_common.c b/board/armltd/vexpress/vexpress_common.c
index 2c54869..66b810d 100644
--- a/board/armltd/vexpress/vexpress_common.c
+++ b/board/armltd/vexpress/vexpress_common.c
@@ -272,3 +272,16 @@  ulong get_tbclk(void)
 {
 	return (ulong)CONFIG_SYS_HZ;
 }
+
+/* Setting the address at which secondary cores start from.
+ * Versatile Express uses one address for all cores, so ignore corenr
+ */
+void smp_set_core_boot_addr(unsigned long addr, int corenr)
+{
+	/* The SYSFLAGS register on VExpress needs to be cleared first
+	 * by writing to the next address, since any writes to the address
+	 * at offset 0 will only be ORed in
+	 */
+	writel(~0, CONFIG_SYSFLAGS_ADDR + 4);
+	writel(addr, CONFIG_SYSFLAGS_ADDR);
+}
diff --git a/board/armltd/vexpress/vexpress_smp.S b/board/armltd/vexpress/vexpress_smp.S
new file mode 100644
index 0000000..41be2e7
--- /dev/null
+++ b/board/armltd/vexpress/vexpress_smp.S
@@ -0,0 +1,36 @@ 
+/*
+ * code for redirecting secondary cores to their start address
+ *
+ * Copyright (c) 2013	Andre Przywara <andre.przywara@linaro.org>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <config.h>
+#include <linux/linkage.h>
+
+/* void _smp_waitloop(unsigned previous_address); */
+ENTRY(smp_waitloop)
+	wfi
+	ldr	r1, =CONFIG_SYSFLAGS_ADDR	@ load start address
+	ldr	r1, [r1]
+	cmp	r0, r1			@ make sure we dont execute this code
+	beq	smp_waitloop		@ again (due to a spurious wakeup)
+	mov	pc, r1
+ENDPROC(smp_waitloop)
diff --git a/include/configs/vexpress_ca15_tc2.h b/include/configs/vexpress_ca15_tc2.h
index 4f425ac..14aa78e 100644
--- a/include/configs/vexpress_ca15_tc2.h
+++ b/include/configs/vexpress_ca15_tc2.h
@@ -31,4 +31,8 @@ 
 #include "vexpress_common.h"
 #define CONFIG_BOOTP_VCI_STRING     "U-boot.armv7.vexpress_ca15x2_tc2"
 
+#define CONFIG_SYSFLAGS_ADDR 0x1c010030
+
+#define CONFIG_ARMV7_VIRT
+
 #endif