diff mbox

[U-Boot,1/9] tegra2: Add arch_cpu_init() to fire up Cortex-A9

Message ID 1318539963-3329-2-git-send-email-sjg@chromium.org
State New, archived
Headers show

Commit Message

Simon Glass Oct. 13, 2011, 9:05 p.m. UTC
We want to move away from a special Tegra2 start-up, and just use
arch_cpu_init() instead. However, if we run board_init_f() from boot
we need to build it for ARMv4T, since the Tegra's AVP start-up CPU
does not support ARMv7.

The effect of this is to do the AVP init earlier, and in
arch_cpu_init(), rather that board_early_init_f().

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 arch/arm/cpu/armv7/tegra2/board.c |   15 +++++++++++++++
 arch/arm/lib/Makefile             |    6 ++++++
 board/nvidia/common/board.c       |    3 ---
 board/nvidia/common/board.h       |    1 -
 include/configs/tegra2-common.h   |    2 +-
 5 files changed, 22 insertions(+), 5 deletions(-)

Comments

Mike Frysinger Oct. 13, 2011, 10:52 p.m. UTC | #1
On Thursday 13 October 2011 17:05:55 Simon Glass wrote:
> --- a/arch/arm/lib/Makefile
> +++ b/arch/arm/lib/Makefile
> 
> +# Tegra has an ARMv4T CPU which runs board_init_f(), so we must build this
> +# file with compatible flags
> +ifdef CONFIG_TEGRA2
> +CFLAGS_arch/arm/lib/board.o += -march=armv4t
> +endif

all Tegra SoC's have an ARMv4T inside of the package ?  that's a bit crazy.  
isn't there a tegra-specific config.mk somewhere we could add this instead ?
-mike
Simon Glass Oct. 13, 2011, 11:18 p.m. UTC | #2
Hi Mike,

On Thu, Oct 13, 2011 at 3:52 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Thursday 13 October 2011 17:05:55 Simon Glass wrote:
>> --- a/arch/arm/lib/Makefile
>> +++ b/arch/arm/lib/Makefile
>>
>> +# Tegra has an ARMv4T CPU which runs board_init_f(), so we must build this
>> +# file with compatible flags
>> +ifdef CONFIG_TEGRA2
>> +CFLAGS_arch/arm/lib/board.o += -march=armv4t
>> +endif
>
> all Tegra SoC's have an ARMv4T inside of the package ?  that's a bit crazy.
> isn't there a tegra-specific config.mk somewhere we could add this instead ?
> -mike
>

Well that same line can't go into the tegra-specific config.mk as it
will not be seen when compiling arch/arm/lib.

The current code compiles the whole of U-Boot with ARMv4T which is bad
since only a few functions need it. This is one thing that the patch
series cleans up.

Regards,
Simon
Mike Frysinger Oct. 13, 2011, 11:34 p.m. UTC | #3
On Thursday 13 October 2011 19:18:22 Simon Glass wrote:
> On Thu, Oct 13, 2011 at 3:52 PM, Mike Frysinger wrote:
> > On Thursday 13 October 2011 17:05:55 Simon Glass wrote:
> >> --- a/arch/arm/lib/Makefile
> >> +++ b/arch/arm/lib/Makefile
> >> 
> >> +# Tegra has an ARMv4T CPU which runs board_init_f(), so we must build
> >> this +# file with compatible flags
> >> +ifdef CONFIG_TEGRA2
> >> +CFLAGS_arch/arm/lib/board.o += -march=armv4t
> >> +endif
> > 
> > all Tegra SoC's have an ARMv4T inside of the package ?  that's a bit
> > crazy. isn't there a tegra-specific config.mk somewhere we could add
> > this instead ?
> 
> Well that same line can't go into the tegra-specific config.mk as it
> will not be seen when compiling arch/arm/lib.

why not ?

arch/arm/lib/Makefile includes topdir/config.mk

topdir/config.mk includes topdir/$(CPUDIR)/$(SOC)/config.mk

isn't tegra your SOC here ?
-mike
Simon Glass Oct. 14, 2011, 12:47 a.m. UTC | #4
Hi Mike,

On Thu, Oct 13, 2011 at 4:34 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Thursday 13 October 2011 19:18:22 Simon Glass wrote:
>> On Thu, Oct 13, 2011 at 3:52 PM, Mike Frysinger wrote:
>> > On Thursday 13 October 2011 17:05:55 Simon Glass wrote:
>> >> --- a/arch/arm/lib/Makefile
>> >> +++ b/arch/arm/lib/Makefile
>> >>
>> >> +# Tegra has an ARMv4T CPU which runs board_init_f(), so we must build
>> >> this +# file with compatible flags
>> >> +ifdef CONFIG_TEGRA2
>> >> +CFLAGS_arch/arm/lib/board.o += -march=armv4t
>> >> +endif
>> >
>> > all Tegra SoC's have an ARMv4T inside of the package ?  that's a bit
>> > crazy. isn't there a tegra-specific config.mk somewhere we could add
>> > this instead ?
>>
>> Well that same line can't go into the tegra-specific config.mk as it
>> will not be seen when compiling arch/arm/lib.
>
> why not ?
>
> arch/arm/lib/Makefile includes topdir/config.mk
>
> topdir/config.mk includes topdir/$(CPUDIR)/$(SOC)/config.mk
>
> isn't tegra your SOC here ?

Oh I see. I missed that link - yes it should work. Thanks for pointing
it out - I will take another look.

Regards,
Simon

> -mike
>
diff mbox

Patch

diff --git a/arch/arm/cpu/armv7/tegra2/board.c b/arch/arm/cpu/armv7/tegra2/board.c
index 9061d18..e725134 100644
--- a/arch/arm/cpu/armv7/tegra2/board.c
+++ b/arch/arm/cpu/armv7/tegra2/board.c
@@ -23,6 +23,7 @@ 
 
 #include <common.h>
 #include <asm/io.h>
+#include "ap20.h"
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/tegra2.h>
 #include <asm/arch/pmc.h>
@@ -86,3 +87,17 @@  int checkboard(void)
 	return 0;
 }
 #endif	/* CONFIG_DISPLAY_BOARDINFO */
+
+#ifdef CONFIG_ARCH_CPU_INIT
+/*
+ * Note this function is executed by the ARM7TDMI AVP. It does not return
+ * in this case. It is also called once the A9 starts up, but does nothing in
+ * that case.
+ */
+int arch_cpu_init(void)
+{
+	/* Fire up the Cortex A9 */
+	tegra2_start();
+	return 0;
+}
+#endif
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index 300c8fa..3341d11 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -23,6 +23,12 @@ 
 
 include $(TOPDIR)/config.mk
 
+# Tegra has an ARMv4T CPU which runs board_init_f(), so we must build this
+# file with compatible flags
+ifdef CONFIG_TEGRA2
+CFLAGS_arch/arm/lib/board.o += -march=armv4t
+endif
+
 LIB	= $(obj)lib$(ARCH).o
 LIBGCC	= $(obj)libgcc.o
 
diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c
index d13537d..6af317b 100644
--- a/board/nvidia/common/board.c
+++ b/board/nvidia/common/board.c
@@ -188,9 +188,6 @@  int board_early_init_f(void)
 
 	/* Initialize periph GPIOs */
 	gpio_config_uart();
-
-	/* Init UART, scratch regs, and start CPU */
-	tegra2_start();
 	return 0;
 }
 #endif	/* EARLY_INIT */
diff --git a/board/nvidia/common/board.h b/board/nvidia/common/board.h
index 344e702..5a6b323 100644
--- a/board/nvidia/common/board.h
+++ b/board/nvidia/common/board.h
@@ -24,7 +24,6 @@ 
 #ifndef _BOARD_H_
 #define _BOARD_H_
 
-void tegra2_start(void);
 void gpio_config_uart(void);
 void gpio_config_mmc(void);
 int tegra2_mmc_init(int dev_index, int bus_width);
diff --git a/include/configs/tegra2-common.h b/include/configs/tegra2-common.h
index 73e0f05..3454689 100644
--- a/include/configs/tegra2-common.h
+++ b/include/configs/tegra2-common.h
@@ -32,7 +32,7 @@ 
 #define CONFIG_TEGRA2			/* in a NVidia Tegra2 core */
 #define CONFIG_MACH_TEGRA_GENERIC	/* which is a Tegra generic machine */
 #define CONFIG_SYS_L2CACHE_OFF		/* No L2 cache */
-
+#define CONFIG_ARCH_CPU_INIT		/* Fire up the A9 core */
 #define CONFIG_ENABLE_CORTEXA9		/* enable CPU (A9 complex) */
 
 #include <asm/arch/tegra2.h>		/* get chip and board defs */