Skip to contentSkip to conversation

Clean out SPL and enable driver model

PATCH Superseded Simon Glass 2 participants 12 messages Feb 26, 2015 – Mar 3, 2015

Subsystems (5)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover Clean out SPL and enable driver model

This series includes a few more patches aimed at getting rid of gdata, the parallel global_data structure introduced on some ARM boards.

It also collects together the other patches which have been sent previously, so that everything is in one place.

I would like get this agreed and applied to u-boot-dm this week if possible so that we will at last have driver model available in SPL.

This series is available at u-boot-dm/spl-working.

Changes in v5:
- Rebase to master

Changes in v4:
- Squash the gdata revert patch into this one
- Allow gdata to survive unless CONFIG_DM is defined, for now
- Rebase on top of dm/master
- Adjust README to mention that lowlevel_init() should have no stack
- Add new patch to make the export interface support CONFIG_SYS_MALLOC_SIMPLE

Changes in v3:
- Drop extra blank line

Changes in v2:
- Remove gdata definition from ARM spl header file also
- Rebase on top of the SPI series
- Move docs to top-level README file and expand them to cover U-Boot proper
- Add Kconfig settings

Simon Glass (5):
arm: Reduce the scope of lowlevel_init()
arm: spl: Avoid setting up a duplicate global data structure
dm: tegra: Enable driver model in SPL and adjust the GPIO driver
arm: spl: Allow board_init_r() to run with a larger stack Make export interface support CONFIG_SYS_MALLOC_SIMPLE

 Kconfig                            | 18 ++++++++++
 README                             | 69 ++++++++++++++++++++++++++++++++++++++
 arch/arm/cpu/armv7/lowlevel_init.S | 23 +++++++------
 arch/arm/include/asm/spl.h         |  2 ++
 arch/arm/lib/crt0.S                | 13 +++++--
 arch/arm/lib/spl.c                 |  4 +++
 arch/arm/mach-tegra/Kconfig        |  3 ++
 board/nvidia/seaboard/seaboard.c   |  4 +--
 common/spl/spl.c                   | 35 +++++++++++++++++++
 drivers/gpio/Makefile              |  4 +++
 drivers/gpio/tegra_gpio.c          | 27 ++++++---------
 include/_exports.h                 |  2 ++
 include/configs/tegra-common.h     |  6 ----
 include/exports.h                  |  2 ++
 14 files changed, 174 insertions(+), 38 deletions(-)
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#1 lore raw

PATCH v5 1/5 arm: Reduce the scope of lowlevel_init()

This function has grown into something of a monster. Some boards are setting up a console and DRAM here in SPL. This requires global_data which should be set up in one place (crt0.S).

There is no need for SPL to use s_init() for anything since board_init_f() is called immediately afterwards.

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/arm/cpu/armv7/lowlevel_init.S | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)
arch/arm/cpu/armv7/lowlevel_init.S +13 -10
index f1aea05..4803150 100644
@@ -17,24 +17,27 @@
 
 ENTRY(lowlevel_init)
 	/*
-	 * Setup a temporary stack
+	 * Setup a temporary stack. Global data is not available yet.
 	 */
 	ldr	sp, =CONFIG_SYS_INIT_SP_ADDR
-	bic	sp, sp, #7 /* 8-byte alignment for ABI compliance */
-#ifdef CONFIG_SPL_BUILD
-	ldr	r9, =gdata
-#else
-	sub	sp, sp, #GD_SIZE
-	bic	sp, sp, #7
-	mov	r9, sp
-#endif
+	mov	r9, #0
 	/*
 	 * Save the old lr(passed in ip) and the current lr to stack
 	 */
 	push	{ip, lr}
 
 	/*
-	 * go setup pll, mux, memory
+	 * Call the very early init function. This should do only the
+	 * absolute bare minimum to get started. It should not:
+	 *
+	 * - set up DRAM
+	 * - use global_data
+	 * - clear BSS
+	 * - try to start a console
+	 *
+	 * For boards with SPL this should be empty since SPL can do all of
+	 * this init in the SPL board_init_f() function which is called
+	 * immediately after this.
 	 */
 	bl	s_init
 	pop	{ip, pc}
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#2 lore raw

PATCH v5 2/5 arm: spl: Avoid setting up a duplicate global data structure

In reply to Simon Glass

This is already set up in crt0.S. We don't need a new structure and don't really want one in the 'data' section of the image, since it will be empty and crt0.S's changes will be ignored.

As an interim measure, remove it only if CONFIG_DM is not defined. This allows us to press ahead with driver model in SPL and allow the stragglers to catch up.

---

Changes in v5: None
Changes in v4:
- Squash the gdata revert patch into this one
- Allow gdata to survive unless CONFIG_DM is defined, for now

Changes in v3: None
Changes in v2:
- Remove gdata definition from ARM spl header file also

 arch/arm/include/asm/spl.h | 2 ++
 arch/arm/lib/spl.c         | 4 ++++
 2 files changed, 6 insertions(+)
arch/arm/include/asm/spl.h +2 -0
index 17b6f54..6db405d 100644
@@ -37,6 +37,8 @@ void spl_board_load_image(void);
 /* Linker symbols. */
 extern char __bss_start[], __bss_end[];
 
+#ifndef CONFIG_DM
 extern gd_t gdata;
+#endif
 
 #endif
arch/arm/lib/spl.c +4 -0
index c41850a..bd8c7d2 100644
@@ -13,6 +13,7 @@
 #include <image.h>
 #include <linux/compiler.h>
 
+#ifndef CONFIG_DM
 /* Pointer to as well as the global data structure for SPL */
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -21,6 +22,7 @@ DECLARE_GLOBAL_DATA_PTR;
  * pafches that rely on it. The global_data area is set up in crt0.S.
  */
 gd_t gdata __attribute__ ((section(".data")));
+#endif
 
 /*
  * In the context of SPL, board_init_f must ensure that any clocks/etc for
@@ -33,8 +35,10 @@ void __weak board_init_f(ulong dummy)
 	/* Clear the BSS. */
 	memset(__bss_start, 0, __bss_end - __bss_start);
 
+#ifndef CONFIG_DM
 	/* TODO: Remove settings of the global data pointer here */
 	gd = &gdata;
+#endif
 
 	board_init_r(NULL, 0);
 }
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#3 lore raw

PATCH v5 3/5 dm: tegra: Enable driver model in SPL and adjust the GPIO driver

In reply to Simon Glass

Use the full driver model GPIO and serial drivers in SPL now that these are supported. Since device tree is not available they will use platform data.

Remove the special SPL GPIO function as it is no longer needed.

This is all in one commit to maintain bisectability.

---

Changes in v5: None
Changes in v4:
- Rebase on top of dm/master

Changes in v3:
- Drop extra blank line

Changes in v2:
- Rebase on top of the SPI series

 arch/arm/mach-tegra/Kconfig      |  3 +++
 board/nvidia/seaboard/seaboard.c |  4 +---
 drivers/gpio/Makefile            |  4 ++++
 drivers/gpio/tegra_gpio.c        | 27 +++++++++++----------------
 include/configs/tegra-common.h   |  6 ------
 5 files changed, 19 insertions(+), 25 deletions(-)
arch/arm/mach-tegra/Kconfig +3 -0
index 8615248..fccfd79 100644
@@ -29,6 +29,9 @@ config USE_PRIVATE_LIBGCC
 config DM
 	default y
 
+config SPL_DM
+	default y
+
 config DM_SERIAL
 	default y
 
board/nvidia/seaboard/seaboard.c +1 -3
index 11472eb..25480e4 100644
@@ -20,10 +20,8 @@
 void gpio_early_init_uart(void)
 {
 	/* Enable UART via GPIO_PI3 (port 8, bit 3) so serial console works */
-#ifndef CONFIG_SPL_BUILD
 	gpio_request(GPIO_PI3, NULL);
-#endif
-	tegra_spl_gpio_direction_output(GPIO_PI3, 0);
+	gpio_direction_output(GPIO_PI3, 0);
 }
 #endif
 
drivers/gpio/Makefile +4 -0
index aa11f15..fe9a3b2 100644
@@ -8,6 +8,10 @@
 ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_DM_GPIO)		+= gpio-uclass.o
 endif
+/* TODO(sjg at chromium.org): Only tegra supports driver model in SPL */
+ifdef CONFIG_TEGRA_GPIO
+obj-$(CONFIG_DM_GPIO)		+= gpio-uclass.o
+endif
 
 obj-$(CONFIG_AT91_GPIO)	+= at91_gpio.o
 obj-$(CONFIG_INTEL_ICH6_GPIO)	+= intel_ich6_gpio.o
drivers/gpio/tegra_gpio.c +11 -16
index 43928b8..f870cdb 100644
@@ -132,21 +132,6 @@ static void set_level(unsigned gpio, int high)
 	writel(u, &bank->gpio_out[GPIO_PORT(gpio)]);
 }
 
-/* set GPIO pin 'gpio' as an output, with polarity 'value' */
-int tegra_spl_gpio_direction_output(int gpio, int value)
-{
-	/* Configure as a GPIO */
-	set_config(gpio, 1);
-
-	/* Configure GPIO output value. */
-	set_level(gpio, value);
-
-	/* Configure GPIO direction as output. */
-	set_direction(gpio, 1);
-
-	return 0;
-}
-
 /*
  * Generic_GPIO primitives.
  */
@@ -338,12 +323,19 @@ static int gpio_tegra_bind(struct udevice *parent)
 	int bank_count;
 	int bank;
 	int ret;
-	int len;
 
 	/* If this is a child device, there is nothing to do here */
 	if (plat)
 		return 0;
 
+	/* TODO(sjg at chromium.org): Remove once SPL supports device tree */
+#ifdef CONFIG_SPL_BUILD
+	ctlr = (struct gpio_ctlr *)NV_PA_GPIO_BASE;
+	bank_count = TEGRA_GPIO_BANKS;
+#else
+	{
+	int len;
+
 	/*
 	 * This driver does not make use of interrupts, other than to figure
 	 * out the number of GPIO banks
@@ -353,6 +345,8 @@ static int gpio_tegra_bind(struct udevice *parent)
 	bank_count = len / 3 / sizeof(u32);
 	ctlr = (struct gpio_ctlr *)fdtdec_get_addr(gd->fdt_blob,
 						   parent->of_offset, "reg");
+	}
+#endif
 	for (bank = 0; bank < bank_count; bank++) {
 		int port;
 
@@ -388,4 +382,5 @@ U_BOOT_DRIVER(gpio_tegra) = {
 	.probe = gpio_tegra_probe,
 	.priv_auto_alloc_size = sizeof(struct tegra_port_info),
 	.ops	= &gpio_tegra_ops,
+	.flags	= DM_FLAG_PRE_RELOC,
 };
include/configs/tegra-common.h +0 -6
index 005fc6a..fa6ccc1 100644
@@ -43,13 +43,7 @@
 /*
  * NS16550 Configuration
  */
-#ifdef CONFIG_SPL_BUILD
-#define CONFIG_SYS_NS16550_SERIAL
-#define CONFIG_SYS_NS16550_REG_SIZE	(-4)
-#define CONFIG_SYS_NS16550_CLK		V_NS16550_CLK
-#else
 #define CONFIG_TEGRA_SERIAL
-#endif
 #define CONFIG_SYS_NS16550
 
 /*
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#4 lore raw

PATCH v5 4/5 arm: spl: Allow board_init_r() to run with a larger stack

In reply to Simon Glass

At present SPL uses a single stack, either CONFIG_SPL_STACK or CONFIG_SYS_INIT_SP_ADDR. Since some SPL features (such as MMC and environment) require a lot of stack, some boards set CONFIG_SPL_STACK to point into SDRAM. They then set up SDRAM very early, before board_init_f(), so that the larger stack can be used.

This is an abuse of lowlevel_init(). That function should only be used for essential start-up code which cannot be delayed. An example of a valid use is when only part of the SPL code is visible/executable, and the SoC must be set up so that board_init_f() can be reached. It should not be used for SDRAM init, console init, etc.

Add a CONFIG_SPL_STACK_R option, which allows the stack to be moved to a new address before board_init_r() is called in SPL.

The expected SPL flow (for CONFIG_SPL_FRAMEWORK) is documented in the README.

For version 1:

---

Changes in v5:
- Rebase to master

Changes in v4:
- Adjust README to mention that lowlevel_init() should have no stack

Changes in v3: None
Changes in v2:
- Move docs to top-level README file and expand them to cover U-Boot proper
- Add Kconfig settings

 Kconfig             | 18 ++++++++++++++
 README              | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/lib/crt0.S | 13 +++++++---
 common/spl/spl.c    | 35 +++++++++++++++++++++++++++
 4 files changed, 132 insertions(+), 3 deletions(-)
Kconfig +18 -0
index 91a0618..8de731d 100644
@@ -96,6 +96,24 @@ config SPL
 	help
 	  If you want to build SPL as well as the normal image, say Y.
 
+config CONFIG_SPL_STACK_R
+	depends on SPL
+	bool "Enable SDRAM location for SPL stack"
+	help
+	  SPL starts off execution in SRAM and thus typically has only a small
+	  stack available. Since SPL sets up DRAM while in its board_init_f()
+	  function, it is possible for the stack to move there before
+	  board_init_r() is reached. This option enables a special SDRAM
+	  location for the SPL stack. U-Boot SPL switches to this after
+	  board_init_f() completes, and before board_init_r() starts.
+
+config CONFIG_SPL_STACK_R_ADDR
+	depends on CONFIG_SPL_STACK_R
+	hex "SDRAM location for SPL stack"
+	help
+	  Specify the address in SDRAM for the SPL stack. This will be set up
+	  before board_init_r() is called.
+
 config TPL
 	bool
 	depends on SPL && SUPPORT_TPL
README +69 -0

75 lines not on this page · raw message

arch/arm/lib/crt0.S +10 -3
index 22df3e5..7939ced 100644
@@ -113,7 +113,14 @@ here:
 /* Set up final (full) environment */
 
 	bl	c_runtime_cpu_setup	/* we still call old routine here */
-
+#endif
+#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_FRAMEWORK)
+# ifdef CONFIG_SPL_BUILD
+	/* Use a DRAM stack for the rest of SPL, if requested */
+	bl	spl_relocate_stack_gd
+	cmp	r0, #0
+	movne	sp, r0
+# endif
 	ldr	r0, =__bss_start	/* this is auto-relocated! */
 	ldr	r1, =__bss_end		/* this is auto-relocated! */
 
@@ -124,9 +131,10 @@ clbss_l:cmp	r0, r1			/* while not at end of BSS */
 	addlo	r0, r0, #4		/* move to next */
 	blo	clbss_l
 
+#if ! defined(CONFIG_SPL_BUILD)
 	bl coloured_LED_init
 	bl red_led_on
-
+#endif
 	/* call board_init_r(gd_t *id, ulong dest_addr) */
 	mov     r0, r9                  /* gd_t */
 	ldr	r1, [r9, #GD_RELOCADDR]	/* dest_addr */
@@ -134,7 +142,6 @@ clbss_l:cmp	r0, r1			/* while not at end of BSS */
 	ldr	pc, =board_init_r	/* this is auto-relocated! */
 
 	/* we should not return here. */
-
 #endif
 
 ENDPROC(_main)
common/spl/spl.c +35 -0
index ded0f30..cd75bbc 100644
@@ -281,3 +281,38 @@ void preloader_console_init(void)
 	spl_display_print();
 #endif
 }
+
+/**
+ * spl_relocate_stack_gd() - Relocate stack ready for board_init_r() execution
+ *
+ * Sometimes board_init_f() runs with a stack in SRAM but we want to use SDRAM
+ * for the main board_init_r() execution. This is typically because we need
+ * more stack space for things like the MMC sub-system.
+ *
+ * This function calculates the stack position, copies the global_data into
+ * place and returns the new stack position. The caller is responsible for
+ * setting up the sp register.
+ *
+ * @return new stack location, or 0 to use the same stack
+ */
+ulong spl_relocate_stack_gd(void)
+{
+#ifdef CONFIG_SPL_STACK_R
+	gd_t *new_gd;
+	ulong ptr;
+
+	/* Get stack position: use 8-byte alignment for ABI compliance */
+	ptr = CONFIG_SPL_STACK_R - sizeof(gd_t);
+	ptr &= ~7;
+	new_gd = (gd_t *)ptr;
+	memcpy(new_gd, (void *)gd, sizeof(gd_t));
+	gd = new_gd;
+
+	/* Clear the BSS. */
+	memset(__bss_start, 0, __bss_end - __bss_start);
+
+	return ptr;
+#else
+	return 0;
+#endif
+}
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#5 lore raw

PATCH v5 5/5 Make export interface support CONFIG_SYS_MALLOC_SIMPLE

In reply to Simon Glass

When CONFIG_SYS_MALLOC_SIMPLE is defined, free() is a static inline. Make sure that the export interface still builds in this case.

---

Changes in v5: None
Changes in v4:
- Add new patch to make the export interface support CONFIG_SYS_MALLOC_SIMPLE

Changes in v3: None
Changes in v2: None

 include/_exports.h | 2 ++
 include/exports.h  | 2 ++
 2 files changed, 4 insertions(+)
include/_exports.h +2 -0
index 5944703..279017e 100644
@@ -23,7 +23,9 @@
 	EXPORT_FUNC(dummy, void, free_hdlr, void)
 #endif
 	EXPORT_FUNC(malloc, void *, malloc, size_t)
+#ifndef CONFIG_SYS_MALLOC_SIMPLE
 	EXPORT_FUNC(free, void, free, void *)
+#endif
 	EXPORT_FUNC(udelay, void, udelay, unsigned long)
 	EXPORT_FUNC(get_timer, unsigned long, get_timer, unsigned long)
 	EXPORT_FUNC(vprintf, int, vprintf, const char *, va_list)
include/exports.h +2 -0
index 205affe..1a01e43 100644
@@ -15,7 +15,9 @@ int printf(const char* fmt, ...);
 void install_hdlr(int, interrupt_handler_t, void*);
 void free_hdlr(int);
 void *malloc(size_t);
+#ifndef CONFIG_SYS_MALLOC_SIMPLE
 void free(void*);
+#endif
 void __udelay(unsigned long);
 unsigned long get_timer(unsigned long);
 int vprintf(const char *, va_list);
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#6 lore raw

v5 cover Clean out SPL and enable driver model

In reply to Simon Glass

Hi,

Quoted 6 lines · Simon Glass

This series includes a few more patches aimed at getting rid of gdata, the parallel global_data structure introduced on some ARM boards.

It also collects together the other patches which have been sent previously, so that everything is in one place.

Quoted 7 lines

I would like get this agreed and applied to u-boot-dm this week if possible so that we will at last have driver model available in SPL.

This series is available at u-boot-dm/spl-working.

Changes in v5:
- Rebase to master

Are there any more comments on this? I know Albert was looking at applying it, but I am tempted to bring it through the u-boot-dm tree and get it in. RC3 is soon!

Regards,
Simon

#7 lore raw

v5 cover Clean out SPL and enable driver model

Quoted 12 lines · Simon Glass

Hi,

Quoted 9 lines · Simon Glass

This series includes a few more patches aimed at getting rid of gdata, the parallel global_data structure introduced on some ARM boards.

It also collects together the other patches which have been sent previously, so that everything is in one place.

I would like get this agreed and applied to u-boot-dm this week if possible so that we will at last have driver model available in SPL.

Quoted 8 lines
Quoted 4 lines

This series is available at u-boot-dm/spl-working.

Changes in v5:
- Rebase to master

Are there any more comments on this? I know Albert was looking at applying it, but I am tempted to bring it through the u-boot-dm tree and get it in. RC3 is soon!

Did you have something that switched beaglebone black over to this? Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150302/d21140a0/attachment.sig>
#8 lore raw

v5 cover Clean out SPL and enable driver model

Hi Tom,

Quoted 18 lines · Tom Rini
Quoted 17 lines · Simon Glass

Hi,

Quoted 13 lines · Simon Glass

This series includes a few more patches aimed at getting rid of gdata, the parallel global_data structure introduced on some ARM boards.

It also collects together the other patches which have been sent previously, so that everything is in one place.

I would like get this agreed and applied to u-boot-dm this week if possible so that we will at last have driver model available in SPL.

This series is available at u-boot-dm/spl-working.

Changes in v5:
- Rebase to master

Quoted 6 lines
Quoted 3 lines

Are there any more comments on this? I know Albert was looking at applying it, but I am tempted to bring it through the u-boot-dm tree and get it in. RC3 is soon!

Did you have something that switched beaglebone black over to this? Thanks!

I think I sent patches at the time but they were too radical. I'm even nervous about the current set which is why I want time for people to test this.

I'll dig this up and send a v6.

Regards,
Simon

#9 lore raw

v5 cover Clean out SPL and enable driver model

Quoted 25 lines · Simon Glass

Hi Tom,

Quoted 22 lines · Tom Rini
Quoted 20 lines · Simon Glass

Hi,

Quoted 6 lines · Simon Glass

This series includes a few more patches aimed at getting rid of gdata, the parallel global_data structure introduced on some ARM boards.

It also collects together the other patches which have been sent previously, so that everything is in one place.

Quoted 7 lines

I would like get this agreed and applied to u-boot-dm this week if possible so that we will at last have driver model available in SPL.

This series is available at u-boot-dm/spl-working.

Changes in v5:
- Rebase to master

Are there any more comments on this? I know Albert was looking at applying it, but I am tempted to bring it through the u-boot-dm tree and get it in. RC3 is soon!

Quoted 8 lines
Quoted 2 lines

Did you have something that switched beaglebone black over to this? Thanks!

I think I sent patches at the time but they were too radical. I'm even nervous about the current set which is why I want time for people to test this.

I'll dig this up and send a v6.

I recall you had something radical before but I solved those problems (I thought!) differently and that brought us back to the need to add CONFIG_SPL_STACK_R which shouldn't be a big deal. I'm kicking at the problem again differently this morning (aside, conmux + XMODEM is broken in conmux it seem which breaks my workflow on some boards pretty bad).

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150303/f8935743/attachment.sig>
#10 lore raw

v5 cover Clean out SPL and enable driver model

Quoted 33 lines · Tom Rini
Quoted 32 lines · Simon Glass

Hi Tom,

Quoted 18 lines · Tom Rini
Quoted 17 lines · Simon Glass

Hi,

Quoted 13 lines · Simon Glass

This series includes a few more patches aimed at getting rid of gdata, the parallel global_data structure introduced on some ARM boards.

It also collects together the other patches which have been sent previously, so that everything is in one place.

I would like get this agreed and applied to u-boot-dm this week if possible so that we will at last have driver model available in SPL.

This series is available at u-boot-dm/spl-working.

Changes in v5:
- Rebase to master

Quoted 6 lines
Quoted 3 lines

Are there any more comments on this? I know Albert was looking at applying it, but I am tempted to bring it through the u-boot-dm tree and get it in. RC3 is soon!

Did you have something that switched beaglebone black over to this? Thanks!

I think I sent patches at the time but they were too radical. I'm even nervous about the current set which is why I want time for people to test this.

Quoted 7 lines
Quoted 1 line

I'll dig this up and send a v6.

I recall you had something radical before but I solved those problems (I thought!) differently and that brought us back to the need to add CONFIG_SPL_STACK_R which shouldn't be a big deal. I'm kicking at the problem again differently this morning (aside, conmux + XMODEM is broken in conmux it seem which breaks my workflow on some boards pretty bad).

OK, yeah, it's not _that_ bad:

arch/arm/cpu/armv7/am33xx/board.c +4 -6
index 81477aa..4436413 100644
@@ -204,18 +204,20 @@ int arch_misc_init(void)
 }
 
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
+#ifdef CONFIG_SPL_BUILD
 /*
  * In the case of non-SPL based booting we'll want to call these
  * functions a tiny bit later as it will require gd to be set and cleared
  * and that's not true in s_init in this case so we cannot do it there.
  */
-int board_early_init_f(void)
+void board_init_f(ulong dummy)
 {
 	prcm_init();
 	set_mux_conf_regs();
 
-	return 0;
+	sdram_init();
 }
+#endif
 
 /*
  * This function is the place to do per-board things such as ramp up the
@@ -298,9 +300,5 @@ void s_init(void)
 	/* Enable RTC32K clock */
 	rtc32k_enable();
 #endif
-#ifdef CONFIG_SPL_BUILD
-	board_early_init_f();
-	sdram_init();
-#endif
 }
 #endif
configs/am335x_evm_defconfig +2 -0
index 2e5aeaa..deecf95 100644
@@ -1,4 +1,6 @@
 CONFIG_SPL=y
+CONFIG_CONFIG_SPL_STACK_R=y
+CONFIG_CONFIG_SPL_STACK_R_ADDR=0x82000000
 CONFIG_SYS_EXTRA_OPTIONS="NAND"
 CONFIG_CONS_INDEX=1
 +S:CONFIG_ARM=y
include/configs/ti_armv7_common.h +0 -1
index 2bd1164..1882073 100644
@@ -216,7 +216,6 @@
  * end of the BSS area.  We place our stack at 32MiB after the start of
  * DRAM to allow room for all of the above.
  */
-#define CONFIG_SPL_STACK		(CONFIG_SYS_SDRAM_BASE + (32 << 20))
 #ifndef CONFIG_SYS_TEXT_BASE
 #define CONFIG_SYS_TEXT_BASE		0x80800000
 #endif

I might even go so far as to say that's a clean-up. I do need to put this through it's paces tho on am335x and then work on converting the rest of the families.

But, Albert, shall we put this in right after -rc3?

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150303/9699afc1/attachment.sig>
#11 lore raw

v5 cover Clean out SPL and enable driver model

Hi Tom,

Quoted 105 lines · Tom Rini
Quoted 33 lines · Tom Rini
Quoted 32 lines · Simon Glass

Hi Tom,

Quoted 18 lines · Tom Rini
Quoted 17 lines · Simon Glass

Hi,

Quoted 13 lines · Simon Glass

This series includes a few more patches aimed at getting rid of gdata, the parallel global_data structure introduced on some ARM boards.

It also collects together the other patches which have been sent previously, so that everything is in one place.

I would like get this agreed and applied to u-boot-dm this week if possible so that we will at last have driver model available in SPL.

This series is available at u-boot-dm/spl-working.

Changes in v5:
- Rebase to master

Quoted 6 lines
Quoted 3 lines

Are there any more comments on this? I know Albert was looking at applying it, but I am tempted to bring it through the u-boot-dm tree and get it in. RC3 is soon!

Did you have something that switched beaglebone black over to this? Thanks!

I think I sent patches at the time but they were too radical. I'm even nervous about the current set which is why I want time for people to test this.

Quoted 7 lines
Quoted 1 line

I'll dig this up and send a v6.

I recall you had something radical before but I solved those problems (I thought!) differently and that brought us back to the need to add CONFIG_SPL_STACK_R which shouldn't be a big deal. I'm kicking at the problem again differently this morning (aside, conmux + XMODEM is broken in conmux it seem which breaks my workflow on some boards pretty bad).

OK, yeah, it's not _that_ bad:

arch/arm/cpu/armv7/am33xx/board.c +4 -6
index 81477aa..4436413 100644
@@ -204,18 +204,20 @@ int arch_misc_init(void)
 }
 
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
+#ifdef CONFIG_SPL_BUILD
 /*
  * In the case of non-SPL based booting we'll want to call these
  * functions a tiny bit later as it will require gd to be set and cleared
  * and that's not true in s_init in this case so we cannot do it there.
  */
-int board_early_init_f(void)
+void board_init_f(ulong dummy)
 {
        prcm_init();
        set_mux_conf_regs();
 
-       return 0;
+       sdram_init();
 }
+#endif
 
 /*
  * This function is the place to do per-board things such as ramp up the
@@ -298,9 +300,5 @@ void s_init(void)
        /* Enable RTC32K clock */
        rtc32k_enable();
 #endif
-#ifdef CONFIG_SPL_BUILD
-       board_early_init_f();
-       sdram_init();
-#endif
 }
 #endif
configs/am335x_evm_defconfig +2 -0
index 2e5aeaa..deecf95 100644
@@ -1,4 +1,6 @@
 CONFIG_SPL=y
+CONFIG_CONFIG_SPL_STACK_R=y
+CONFIG_CONFIG_SPL_STACK_R_ADDR=0x82000000
 CONFIG_SYS_EXTRA_OPTIONS="NAND"
 CONFIG_CONS_INDEX=1
 +S:CONFIG_ARM=y
include/configs/ti_armv7_common.h +0 -1
index 2bd1164..1882073 100644
@@ -216,7 +216,6 @@
  * end of the BSS area.  We place our stack at 32MiB after the start of
  * DRAM to allow room for all of the above.
  */
-#define CONFIG_SPL_STACK               (CONFIG_SYS_SDRAM_BASE + (32 << 20))
 #ifndef CONFIG_SYS_TEXT_BASE
 #define CONFIG_SYS_TEXT_BASE           0x80800000
 #endif
Quoted 3 lines

I might even go so far as to say that's a clean-up. I do need to put this through it's paces tho on am335x and then work on converting the rest of the families.

Yes this looks similar to what I was fiddling with this morning. It's at u-boot-dm/spl-working. It's just finished a run through buildman so I'll resend v6. I made a change to the first patch to keep gdata around for non-DM boards (seems prudent just in case).

Quoted 2 lines

But, Albert, shall we put this in right after -rc3?

Regards,
Simon