Patchwork [U-Boot,6/7] Tegra30: Add generic Tegra30 build support

login
register
mail settings
Submitter Tom Warren
Date Oct. 2, 2012, 10:45 p.m.
Message ID <1349217955-8729-7-git-send-email-twarren@nvidia.com>
Download mbox | patch
Permalink /patch/188678/
State Superseded
Delegated to: Tom Warren
Headers show

Comments

Tom Warren - Oct. 2, 2012, 10:45 p.m.
This patch adds basic Tegra30 (T30) build support - no specific
board is targeted.

Signed-off-by: Tom Warren <twarren@nvidia.com>
---
 Makefile                    |    6 +++---
 arch/arm/cpu/armv7/Makefile |    2 +-
 arch/arm/cpu/armv7/start.S  |    4 ++--
 board/nvidia/common/board.c |   26 ++++++++++++++++++++++++--
 include/serial.h            |    2 +-
 spl/Makefile                |    2 +-
 6 files changed, 32 insertions(+), 10 deletions(-)
Stephen Warren - Oct. 3, 2012, 8:38 p.m.
On 10/02/2012 04:45 PM, Tom Warren wrote:
> This patch adds basic Tegra30 (T30) build support - no specific
> board is targeted.
> 

> diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c

> +#ifdef CONFIG_USB_EHCI_TEGRA
> +#include <asm/arch/usb.h>
> +#endif

That seems unrelated.

> +#ifdef CONFIG_TEGRA30
> +#include <asm/arch/pinmux-config-common.h>
> +#endif
...
>  /*
> + * Routine: pinmux_init
> + * Description: Do individual peripheral pinmux configs
> + */
> +static void pinmux_init(void)
> +{
> +#if defined(CONFIG_TEGRA30)
> +	pinmux_config_table(tegra3_pinmux_common,
> +		ARRAY_SIZE(tegra3_pinmux_common));
> +
> +	pinmux_config_table(unused_pins_lowpower,
> +		ARRAY_SIZE(unused_pins_lowpower));
> +#endif
> +}

I think that should be done by the Cardhu board file, since the data is
Cardhu-specific.
Tom Warren - Oct. 3, 2012, 9:56 p.m.
Stephen,

On Wed, Oct 3, 2012 at 1:38 PM, Stephen Warren <swarren@wwwdotorg.org> wrote:
> On 10/02/2012 04:45 PM, Tom Warren wrote:
>> This patch adds basic Tegra30 (T30) build support - no specific
>> board is targeted.
>>
>
>> diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c
>
>> +#ifdef CONFIG_USB_EHCI_TEGRA
>> +#include <asm/arch/usb.h>
>> +#endif
>
> That seems unrelated.

It's related because I don't have a usb.h file for Tegra30 yet (not
used/needed), and this is a common file, so I have to #ifdef the
inclusion or Cardhu won't build. I could put an empty usb.h file in
arch-tegra30, but I don't like that approach and there's a need for
this if someone turns off USB support in a Tegra20 build. The code
further down in the file uses the same #ifdef.

>
>> +#ifdef CONFIG_TEGRA30
>> +#include <asm/arch/pinmux-config-common.h>
>> +#endif
> ...
>>  /*
>> + * Routine: pinmux_init
>> + * Description: Do individual peripheral pinmux configs
>> + */
>> +static void pinmux_init(void)
>> +{
>> +#if defined(CONFIG_TEGRA30)
>> +     pinmux_config_table(tegra3_pinmux_common,
>> +             ARRAY_SIZE(tegra3_pinmux_common));
>> +
>> +     pinmux_config_table(unused_pins_lowpower,
>> +             ARRAY_SIZE(unused_pins_lowpower));
>> +#endif
>> +}
>
> I think that should be done by the Cardhu board file, since the data is
> Cardhu-specific.

If I move pinmux_init to cardhu.c, I'll need matching (empty) funcs in
all the other board files, since it's called in board_early_init_f
later in board.c. Or it could be made a weak function that's only
overridden in cardhu files. But all this is more that I wanted to
change in this first pass of T30/Cardhu support - I didn't want to
touch any of the Tegra20 builds that I didn't have to.

Tom
Stephen Warren - Oct. 3, 2012, 10:27 p.m.
On 10/03/2012 03:56 PM, Tom Warren wrote:
> Stephen,
> 
> On Wed, Oct 3, 2012 at 1:38 PM, Stephen Warren <swarren@wwwdotorg.org> wrote:
>> On 10/02/2012 04:45 PM, Tom Warren wrote:
>>> This patch adds basic Tegra30 (T30) build support - no specific
>>> board is targeted.
>>>
>>
>>> diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c
>>
>>> +#ifdef CONFIG_USB_EHCI_TEGRA
>>> +#include <asm/arch/usb.h>
>>> +#endif
>>
>> That seems unrelated.
> 
> It's related because I don't have a usb.h file for Tegra30 yet (not
> used/needed), and this is a common file, so I have to #ifdef the
> inclusion or Cardhu won't build. I could put an empty usb.h file in
> arch-tegra30, but I don't like that approach and there's a need for
> this if someone turns off USB support in a Tegra20 build. The code
> further down in the file uses the same #ifdef.

Ah right, that makes sense.

>>> +#ifdef CONFIG_TEGRA30
>>> +#include <asm/arch/pinmux-config-common.h>
>>> +#endif
>> ...
>>>  /*
>>> + * Routine: pinmux_init
>>> + * Description: Do individual peripheral pinmux configs
>>> + */
>>> +static void pinmux_init(void)
>>> +{
>>> +#if defined(CONFIG_TEGRA30)
>>> +     pinmux_config_table(tegra3_pinmux_common,
>>> +             ARRAY_SIZE(tegra3_pinmux_common));
>>> +
>>> +     pinmux_config_table(unused_pins_lowpower,
>>> +             ARRAY_SIZE(unused_pins_lowpower));
>>> +#endif
>>> +}
>>
>> I think that should be done by the Cardhu board file, since the data is
>> Cardhu-specific.
> 
> If I move pinmux_init to cardhu.c, I'll need matching (empty) funcs in
> all the other board files, since it's called in board_early_init_f
> later in board.c. Or it could be made a weak function that's only
> overridden in cardhu files. But all this is more that I wanted to
> change in this first pass of T30/Cardhu support - I didn't want to
> touch any of the Tegra20 builds that I didn't have to.

A weak function certainly seems the way to go; all (or at least most of)
the other per-device pinmux/GPIO setup functions are all implemented
this way now.

Patch

diff --git a/Makefile b/Makefile
index 614f6fe..d7e2c2f 100644
--- a/Makefile
+++ b/Makefile
@@ -323,7 +323,7 @@  endif
 ifeq ($(SOC),exynos)
 LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o
 endif
-ifeq ($(SOC),tegra20)
+ifneq ($(CONFIG_TEGRA),)
 LIBS-y += arch/$(ARCH)/cpu/$(SOC)-common/lib$(SOC)-common.o
 LIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o
 LIBS-y += $(CPUDIR)/tegra-common/libtegra-common.o
@@ -387,7 +387,7 @@  ALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin
 ALL-$(CONFIG_OF_SEPARATE) += $(obj)u-boot.dtb $(obj)u-boot-dtb.bin
 
 # enable combined SPL/u-boot/dtb rules for tegra
-ifeq ($(SOC),tegra20)
+ifneq ($(CONFIG_TEGRA),)
 ifeq ($(CONFIG_OF_SEPARATE),y)
 ALL-y += $(obj)u-boot-dtb-tegra.bin
 else
@@ -494,7 +494,7 @@  $(obj)u-boot.spr:	$(obj)u-boot.img $(obj)spl/u-boot-spl.bin
 			conv=notrunc 2>/dev/null
 		cat $(obj)spl/u-boot-spl-pad.img $(obj)u-boot.img > $@
 
-ifeq ($(SOC),tegra20)
+ifneq ($(CONFIG_TEGRA),)
 ifeq ($(CONFIG_OF_SEPARATE),y)
 $(obj)u-boot-dtb-tegra.bin:	$(obj)spl/u-boot-spl.bin $(obj)u-boot.bin $(obj)u-boot.dtb
 		$(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_SYS_TEXT_BASE) -O binary $(obj)spl/u-boot-spl $(obj)spl/u-boot-spl-pad.bin
diff --git a/arch/arm/cpu/armv7/Makefile b/arch/arm/cpu/armv7/Makefile
index 4fdbee4..ee8c2b3 100644
--- a/arch/arm/cpu/armv7/Makefile
+++ b/arch/arm/cpu/armv7/Makefile
@@ -32,7 +32,7 @@  COBJS	+= cache_v7.o
 COBJS	+= cpu.o
 COBJS	+= syslib.o
 
-ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TEGRA20),)
+ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TEGRA),)
 SOBJS	+= lowlevel_init.o
 endif
 
diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
index f26308d..11317b0 100644
--- a/arch/arm/cpu/armv7/start.S
+++ b/arch/arm/cpu/armv7/start.S
@@ -272,12 +272,12 @@  jump_2_ram:
 /*
  * Move vector table
  */
-#if !defined(CONFIG_TEGRA20)
+#if !defined(CONFIG_TEGRA)
 	/* Set vector address in CP15 VBAR register */
 	ldr     r0, =_start
 	add     r0, r0, r9
 	mcr     p15, 0, r0, c12, c0, 0  @Set VBAR
-#endif /* !Tegra20 */
+#endif /* !Tegra */
 
 	ldr	r0, _board_init_r_ofs
 	adr	r1, _start
diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c
index 2c7cd0d..151d972 100644
--- a/board/nvidia/common/board.c
+++ b/board/nvidia/common/board.c
@@ -31,15 +31,20 @@ 
 #include <asm/arch/pinmux.h>
 #include <asm/arch/pmu.h>
 #include <asm/arch/tegra.h>
-#include <asm/arch/usb.h>
 #include <asm/arch-tegra/board.h>
 #include <asm/arch-tegra/clk_rst.h>
 #include <asm/arch-tegra/pmc.h>
 #include <asm/arch-tegra/sys_proto.h>
 #include <asm/arch-tegra/uart.h>
 #include <asm/arch-tegra/warmboot.h>
-#include <spi.h>
+#ifdef CONFIG_USB_EHCI_TEGRA
+#include <asm/arch/usb.h>
+#endif
+#ifdef CONFIG_TEGRA30
+#include <asm/arch/pinmux-config-common.h>
+#endif
 #include <i2c.h>
+#include <spi.h>
 #include "emc.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -101,6 +106,21 @@  static void power_det_init(void)
 }
 
 /*
+ * Routine: pinmux_init
+ * Description: Do individual peripheral pinmux configs
+ */
+static void pinmux_init(void)
+{
+#if defined(CONFIG_TEGRA30)
+	pinmux_config_table(tegra3_pinmux_common,
+		ARRAY_SIZE(tegra3_pinmux_common));
+
+	pinmux_config_table(unused_pins_lowpower,
+		ARRAY_SIZE(unused_pins_lowpower));
+#endif
+}
+
+/*
  * Routine: board_init
  * Description: Early hardware init.
  */
@@ -169,6 +189,8 @@  void gpio_early_init(void) __attribute__((weak, alias("__gpio_early_init")));
 
 int board_early_init_f(void)
 {
+	pinmux_init();
+
 	board_init_uart_f();
 
 	/* Initialize periph GPIOs */
diff --git a/include/serial.h b/include/serial.h
index d76d6df..75d76e6 100644
--- a/include/serial.h
+++ b/include/serial.h
@@ -31,7 +31,7 @@  extern struct serial_device *default_serial_console(void);
 	defined(CONFIG_MB86R0x) || defined(CONFIG_MPC5xxx) || \
 	defined(CONFIG_MPC83xx) || defined(CONFIG_MPC85xx) || \
 	defined(CONFIG_MPC86xx) || defined(CONFIG_SYS_SC520) || \
-	defined(CONFIG_TEGRA20) || defined(CONFIG_SYS_COREBOOT) || \
+	defined(CONFIG_TEGRA) || defined(CONFIG_SYS_COREBOOT) || \
 	defined(CONFIG_MICROBLAZE)
 extern struct serial_device serial0_device;
 extern struct serial_device serial1_device;
diff --git a/spl/Makefile b/spl/Makefile
index 8c6dcbd..7d6df9d 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -62,7 +62,7 @@  ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),)
 LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
 endif
 
-ifeq ($(SOC),tegra20)
+ifneq ($(CONFIG_TEGRA),)
 LIBS-y += arch/$(ARCH)/cpu/$(SOC)-common/lib$(SOC)-common.o
 LIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o
 LIBS-y += $(CPUDIR)/tegra-common/libtegra-common.o