[U-Boot] [PATCH 00/12] ARM: rpi_b: many minor enhancements

This is a slew of various small patches I've accumulated for the Raspberry Pi. They assume that the following have already been applied:
2230151 ARM: bcm2835: add Raspberry Pi model B board 3a43ab2 ARM: add basic support for the Broadcom BCM2835 SoC
Stephen Warren (12): ARM: arm1176: enable instruction cache in arch_cpu_init() ARM: rpi_b: enable CONFIG_ARCH_CPU_INIT for icache ARM: rpi_b: define CONFIG_MACH_TYPE ARM: rpi_b: include config_cmd_default.h ARM: rpi_b: enable CONFIG_OF_LIBFDT ARM: rpi_b: set bi_boot_params ARM: rpi_b: add ATAG support for bootm/bootz ARM: rpi_b: drop RAM size to 128M ARM: rpi_b: move stack to top of RAM ARM: rpi_b: re-order rpi_b.h to keep related defines adjacent ARM: bcm2835: implement reset using watchdog ARM: rpi_b: enabled bootz command
arch/arm/cpu/arm1176/bcm2835/reset.c | 18 +++++++++++---- arch/arm/cpu/arm1176/cpu.c | 7 ++++++ arch/arm/include/asm/arch-bcm2835/wdog.h | 37 ++++++++++++++++++++++++++++++ board/raspberrypi/rpi_b/rpi_b.c | 4 +++- include/configs/rpi_b.h | 34 +++++++++++++++++++++++---- 5 files changed, 89 insertions(+), 11 deletions(-) create mode 100644 arch/arm/include/asm/arch-bcm2835/wdog.h

Note that this affects all users of the ARM1176 CPU that enable CONFIG_ARCH_CPU_INIT, not just the BCM2835 SoC, potentially such as tnetv107x.
Cc: Cyril Chemparathy cyril@ti.com Signed-off-by: Stephen Warren swarren@wwwdotorg.org --- arch/arm/cpu/arm1176/cpu.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/arch/arm/cpu/arm1176/cpu.c b/arch/arm/cpu/arm1176/cpu.c index c0fd114..532a90b 100644 --- a/arch/arm/cpu/arm1176/cpu.c +++ b/arch/arm/cpu/arm1176/cpu.c @@ -65,3 +65,10 @@ static void cache_flush (void) /* mem barrier to sync things */ asm ("mcr p15, 0, %0, c7, c10, 4": :"r" (0)); } + +int arch_cpu_init(void) +{ + icache_enable(); + + return 0; +}

This causes arch_cpu_init() to be called, which enables the icache.
Extracted from work by Oleksandr Tymoshenko gonzo@bluezbox.com.
Signed-off-by: Stephen Warren swarren@wwwdotorg.org --- include/configs/rpi_b.h | 1 + 1 file changed, 1 insertion(+)
diff --git a/include/configs/rpi_b.h b/include/configs/rpi_b.h index f547027..8bdd014 100644 --- a/include/configs/rpi_b.h +++ b/include/configs/rpi_b.h @@ -22,6 +22,7 @@ /* Architecture, CPU, etc.*/ #define CONFIG_ARM1176 #define CONFIG_BCM2835 +#define CONFIG_ARCH_CPU_INIT
/* Timer */ #define CONFIG_SYS_HZ 1000000

Use MACH_TYPE_BCM2708 as the Linux machine type for the Raspberry Pi.
The Raspberry Pi actually uses a BCM2835. However, the 2835 this is apparently a SKU in a series for which the BCM2708 is the first or perhaps primary version, such that the 2708 name has historically been used for this purpose.
Extracted from work by Oleksandr Tymoshenko gonzo@bluezbox.com.
Signed-off-by: Stephen Warren swarren@wwwdotorg.org --- include/configs/rpi_b.h | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/include/configs/rpi_b.h b/include/configs/rpi_b.h index 8bdd014..a8883d3 100644 --- a/include/configs/rpi_b.h +++ b/include/configs/rpi_b.h @@ -23,6 +23,11 @@ #define CONFIG_ARM1176 #define CONFIG_BCM2835 #define CONFIG_ARCH_CPU_INIT +/* + * 2835 is a SKU in a series for which the 2708 is the first or primary SoC, + * so 2708 has historically been used rather than a dedicated 2835 ID. + */ +#define CONFIG_MACH_TYPE MACH_TYPE_BCM2708
/* Timer */ #define CONFIG_SYS_HZ 1000000

This enables a more typical default set of commands. Remove explicit enables for commands already in the default list.
Signed-off-by: Stephen Warren swarren@wwwdotorg.org --- include/configs/rpi_b.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/configs/rpi_b.h b/include/configs/rpi_b.h index a8883d3..9268efb 100644 --- a/include/configs/rpi_b.h +++ b/include/configs/rpi_b.h @@ -80,7 +80,11 @@ #define CONFIG_AUTO_COMPLETE
/* Commands */ -#define CONFIG_CMD_MEMORY -#define CONFIG_CMD_MISC +#include "config_cmd_default.h" +/* Some things don't make sense on this HW or yet */ +#undef CONFIG_CMD_FPGA +#undef CONFIG_CMD_NET +#undef CONFIG_CMD_NFS +#undef CONFIG_CMD_SAVEENV
#endif

On Tue, Jul 03, 2012 at 08:02:47PM -0600, Stephen Warren wrote:
This enables a more typical default set of commands. Remove explicit enables for commands already in the default list.
Signed-off-by: Stephen Warren swarren@wwwdotorg.org
include/configs/rpi_b.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/configs/rpi_b.h b/include/configs/rpi_b.h index a8883d3..9268efb 100644 --- a/include/configs/rpi_b.h +++ b/include/configs/rpi_b.h @@ -80,7 +80,11 @@ #define CONFIG_AUTO_COMPLETE
/* Commands */ -#define CONFIG_CMD_MEMORY -#define CONFIG_CMD_MISC +#include "config_cmd_default.h"
OK, the README says "config_cmd_default.h" but every other user does <config_cmd_default.h>.

This allows bootm/bootz to pass a device tree to the kernel.
Signed-off-by: Stephen Warren swarren@wwwdotorg.org --- include/configs/rpi_b.h | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/include/configs/rpi_b.h b/include/configs/rpi_b.h index 9268efb..52379b9 100644 --- a/include/configs/rpi_b.h +++ b/include/configs/rpi_b.h @@ -87,4 +87,7 @@ #undef CONFIG_CMD_NFS #undef CONFIG_CMD_SAVEENV
+/* Device tree support for bootm/bootz */ +#define CONFIG_OF_LIBFDT + #endif

On Tue, Jul 03, 2012 at 08:02:48PM -0600, Stephen Warren wrote:
This allows bootm/bootz to pass a device tree to the kernel.
Signed-off-by: Stephen Warren swarren@wwwdotorg.org
FWIW, I would combine this, 6 and 7 into a single commit and say "Enable booting the Linux Kernel" and in the body mention that today we use ATAGS and as the code moves into mainline device trees will be used and required, so enable both for now. This is roughly what I'm saying in my to-post series enhancing the am335x_evm support.

This defines where ATAGs will be written to when booting a Linux kernel.
Extracted from work by Oleksandr Tymoshenko gonzo@bluezbox.com.
Signed-off-by: Stephen Warren swarren@wwwdotorg.org --- board/raspberrypi/rpi_b/rpi_b.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/board/raspberrypi/rpi_b/rpi_b.c b/board/raspberrypi/rpi_b/rpi_b.c index f39440f..26df74b 100644 --- a/board/raspberrypi/rpi_b/rpi_b.c +++ b/board/raspberrypi/rpi_b/rpi_b.c @@ -28,5 +28,7 @@ int dram_init(void)
int board_init(void) { + gd->bd->bi_boot_params = 0x100; + return 0; }

Newer kernels use device tree, so this isn't that useful. However, old kernels all use board files, so this might still see some use.
Signed-off-by: Stephen Warren swarren@wwwdotorg.org --- include/configs/rpi_b.h | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/include/configs/rpi_b.h b/include/configs/rpi_b.h index 52379b9..b9595f9 100644 --- a/include/configs/rpi_b.h +++ b/include/configs/rpi_b.h @@ -89,5 +89,9 @@
/* Device tree support for bootm/bootz */ #define CONFIG_OF_LIBFDT +/* ATAGs support for bootm/bootz */ +#define CONFIG_SETUP_MEMORY_TAGS +#define CONFIG_CMDLINE_TAG +#define CONFIG_INITRD_TAG
#endif

The board really has 256M. However, the VC (VideoCore co-processor) shares the RAM, and uses a configurable portion at the top. We tell U-Boot that a smaller amount of RAM is present in order to avoid stomping on the area the VC uses.
Extracted from work by Oleksandr Tymoshenko gonzo@bluezbox.com.
Signed-off-by: Stephen Warren swarren@wwwdotorg.org --- board/raspberrypi/rpi_b/rpi_b.c | 2 +- include/configs/rpi_b.h | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/board/raspberrypi/rpi_b/rpi_b.c b/board/raspberrypi/rpi_b/rpi_b.c index 26df74b..688b0aa 100644 --- a/board/raspberrypi/rpi_b/rpi_b.c +++ b/board/raspberrypi/rpi_b/rpi_b.c @@ -21,7 +21,7 @@ DECLARE_GLOBAL_DATA_PTR;
int dram_init(void) { - gd->ram_size = SZ_256M; + gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
return 0; } diff --git a/include/configs/rpi_b.h b/include/configs/rpi_b.h index b9595f9..9f74731 100644 --- a/include/configs/rpi_b.h +++ b/include/configs/rpi_b.h @@ -36,6 +36,13 @@ #define CONFIG_NR_DRAM_BANKS 1 #define CONFIG_SYS_TEXT_BASE 0x00008000 #define CONFIG_SYS_SDRAM_BASE 0x00000000 +/* + * The board really has 256M. However, the VC (VideoCore co-processor) shares + * the RAM, and uses a configurable portion at the top. We tell U-Boot that a + * smaller amount of RAM is present in order to avoid stomping on the area + * the VC uses. + */ +#define CONFIG_SYS_SDRAM_SIZE SZ_128M #define CONFIG_SYS_UBOOT_BASE CONFIG_SYS_TEXT_BASE #define CONFIG_SYS_INIT_RAM_SIZE SZ_4K #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + \

Move the top-of-stack from 32k to near the top of RAM. This leaves the bottom of RAM free for ATAGs, or U-Boot scripts to use as they see fit.
Extracted from work by Oleksandr Tymoshenko gonzo@bluezbox.com.
Signed-off-by: Stephen Warren swarren@wwwdotorg.org --- include/configs/rpi_b.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/include/configs/rpi_b.h b/include/configs/rpi_b.h index 9f74731..93dd701 100644 --- a/include/configs/rpi_b.h +++ b/include/configs/rpi_b.h @@ -44,9 +44,8 @@ */ #define CONFIG_SYS_SDRAM_SIZE SZ_128M #define CONFIG_SYS_UBOOT_BASE CONFIG_SYS_TEXT_BASE -#define CONFIG_SYS_INIT_RAM_SIZE SZ_4K #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + \ - CONFIG_SYS_INIT_RAM_SIZE - \ + CONFIG_SYS_SDRAM_SIZE - \ GENERATED_GBL_DATA_SIZE) #define CONFIG_SYS_MALLOC_LEN SZ_4M #define CONFIG_SYS_MEMTEST_START 0x00100000

Signed-off-by: Stephen Warren swarren@wwwdotorg.org --- include/configs/rpi_b.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/configs/rpi_b.h b/include/configs/rpi_b.h index 93dd701..edffda2 100644 --- a/include/configs/rpi_b.h +++ b/include/configs/rpi_b.h @@ -35,6 +35,7 @@ /* Memory layout */ #define CONFIG_NR_DRAM_BANKS 1 #define CONFIG_SYS_TEXT_BASE 0x00008000 +#define CONFIG_SYS_UBOOT_BASE CONFIG_SYS_TEXT_BASE #define CONFIG_SYS_SDRAM_BASE 0x00000000 /* * The board really has 256M. However, the VC (VideoCore co-processor) shares @@ -43,7 +44,6 @@ * the VC uses. */ #define CONFIG_SYS_SDRAM_SIZE SZ_128M -#define CONFIG_SYS_UBOOT_BASE CONFIG_SYS_TEXT_BASE #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + \ CONFIG_SYS_SDRAM_SIZE - \ GENERATED_GBL_DATA_SIZE)

Signed-off-by: Stephen Warren swarren@wwwdotorg.org --- arch/arm/cpu/arm1176/bcm2835/reset.c | 18 +++++++++++---- arch/arm/include/asm/arch-bcm2835/wdog.h | 37 ++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 arch/arm/include/asm/arch-bcm2835/wdog.h
diff --git a/arch/arm/cpu/arm1176/bcm2835/reset.c b/arch/arm/cpu/arm1176/bcm2835/reset.c index 69c9577..8c37ad9 100644 --- a/arch/arm/cpu/arm1176/bcm2835/reset.c +++ b/arch/arm/cpu/arm1176/bcm2835/reset.c @@ -16,12 +16,20 @@
#include <common.h> #include <asm/io.h> +#include <asm/arch/wdog.h> + +#define RESET_TIMEOUT 10
void reset_cpu(ulong addr) { - /* - * We should probably use the WDT module here, but an unaligned - * access will do the trick for now. - */ - readl(1); + struct bcm2835_wdog_regs *regs = + (struct bcm2835_wdog_regs *)BCM2835_WDOG_PHYSADDR; + uint32_t rstc; + + rstc = readl(®s->rstc); + rstc &= ~BCM2835_WDOG_RSTC_WRCFG_MASK; + rstc |= BCM2835_WDOG_RSTC_WRCFG_FULL_RESET; + + writel(BCM2835_WDOG_PASSWORD | RESET_TIMEOUT, ®s->wdog); + writel(BCM2835_WDOG_PASSWORD | rstc, ®s->rstc); } diff --git a/arch/arm/include/asm/arch-bcm2835/wdog.h b/arch/arm/include/asm/arch-bcm2835/wdog.h new file mode 100644 index 0000000..d750a62 --- /dev/null +++ b/arch/arm/include/asm/arch-bcm2835/wdog.h @@ -0,0 +1,37 @@ +/* + * (C) Copyright 2012 Stephen Warren + * + * 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 + * version 2 as published by the Free Software Foundation. + * + * 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. + */ + +#ifndef _BCM2835_TIMER_H +#define _BCM2835_TIMER_H + +#define BCM2835_WDOG_PHYSADDR 0x20100000 + +struct bcm2835_wdog_regs { + u32 unknown0[7]; + u32 rstc; + u32 unknown1; + u32 wdog; +}; + +#define BCM2835_WDOG_PASSWORD 0x5a000000 + +#define BCM2835_WDOG_RSTC_WRCFG_MASK 0x00000030 +#define BCM2835_WDOG_RSTC_WRCFG_FULL_RESET 0x00000020 + +#define BCM2835_WDOG_WDOG_TIMEOUT_MASK 0x0000ffff + +#endif +

Signed-off-by: Stephen Warren swarren@wwwdotorg.org --- include/configs/rpi_b.h | 1 + 1 file changed, 1 insertion(+)
diff --git a/include/configs/rpi_b.h b/include/configs/rpi_b.h index edffda2..ee4887f 100644 --- a/include/configs/rpi_b.h +++ b/include/configs/rpi_b.h @@ -87,6 +87,7 @@
/* Commands */ #include "config_cmd_default.h" +#define CONFIG_CMD_BOOTZ /* Some things don't make sense on this HW or yet */ #undef CONFIG_CMD_FPGA #undef CONFIG_CMD_NET
participants (2)
-
Stephen Warren
-
Tom Rini