Skip to contentSkip to conversation

dm: Introduce device tree support in SPL (for Rockchip)

PATCH New Simon Glass 3 participants 36 messages Feb 28, 2015 – Apr 28, 2015

Subsystems (13)
lore
Share & tools
lore
#0 lore raw

cover dm: Introduce device tree support in SPL (for Rockchip)

With driver model SPL support in place the remaining driver difference between U-Boot proper and SPL is that SPL does not support device tree. This series adds this support, using a Rockchip board as an example.

One problem with device tree is that U-Boot has no way of dropping features it does not need or use. For SPL this problem needs to be solved and this series uses the preprocessor for this. The 45KB Firefly device tree reduces to 693 bytes when unused material is removed. A better solution might involve the 'fdtgrep' tool but this has not made it into the device tree compiler as yet.

This series includes some changes aimed at reduce code size in SPL, including:
- dropping alias sequence support (the aliases node) since many boards just use a single UART in SPL
- adding a smaller panic() function that does not support printf()-format strings
- removing device unbind code which will never be used in SPL

Overall the resulting SPL binary is 8829 bytes with my Linaro 4.8.2 compiler, including the device tree, using Thumb-2. Of this:

1768 bytes is driver model core code
1556 bytes is device tree code
693 bytes is the device tree itself
4756 is other code, including serial drivers, rodata and data

The last figure includes rodata incorrectly added by the tool chain [1]. With a bug-fixed gcc 4.9.2 the total size is 6893 bytes including device tree.

Approximately 750 bytes is used for strings and driver data (root device and serial) associated with driver model and device tree. This adds up an overhead of around 4750 bytes for driver model and device tree, including the code, rodata and device tree itself.

It should therefore be possible to use driver model and device tree in SPL for board that have enough SRAM. Clearly 4KB is impossible without further work (perhaps removing some error strings). I suspect 8KB would be tricky, allowing only 3KB for stack and other code. But 16KB should work OK.

SRAM sizes for recent SoCs I am aware of are:

Rockchip RK3288:     96KB
Tegra 124:           128KB
Samsung Exynos 5420: 384KB

The Rockchip Firefly was chosen for this work since it is a fairly recent board and is readily available. Rockchip engineers have been actively upstreaming code to Linux in the past year and there is a very full-featured U-Boot available. But it is invisible to most U-Boot people - mainline Rockchip support seems well overdue. This series does not make a serious start on that, since it only prints a message in SPL and then hangs, but additional work should get it booting to a prompt.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54303

Simon Glass (29):
serial: ns16550: Add an option to specify the debug UART register
shift
dm: ns16550: Support non-byte register spacing with driver model
dm: ns16550: Support CONFIG_SYS_NS16550_MEM32 with driver model
serial: ns16550: Remove unnecessary init on UART setup
fdt: arm: Drop device tree padding
dm: core: Allow sequence alias support to be removed for SPL
dm: core: Remove unbind operations when not required
dm: Add a panic_str() function to reduce code size
dm: core: Drop device removal error path when not supported
fdt: sandbox: Move setup code from board_f to fdtdec
fdt: Rename setup_fdt() and make it prepare also
Move initf_malloc() to a common place
Correct malloc_limit value for pre-relocation malloc()
fdt: Add an option to disable device tree in SPL
dts: Disable device tree for SPL on all boards
fdt: Allow FDT functions to be built for SPL
dm: core: Select device tree control correctly for SPL
dm: Init device tree as well as driver model in SPL
dm: serial: Don't support CONFIG_CONS_INDEX with device tree Remove SPL undefine of CONFIG_OF_CONTROL
fdt: arm: Build device tree in SPL
dm: rockchip: Add serial support
rockchip: Bring in RK3288 device tree file includes and bindings
rockchip: dts: Adjust device tree files for U-Boot SPL
rockchip: Add base SoC files
rockchip: Add basic support for firefly-rk3288
mkimage: Display a better list of available image types
rockchip: Add the beginnings of an image tool
rockchip: Add a simple README

 arch/arm/Kconfig                                   |   11 +
 arch/arm/Makefile                                  |    1 +
 arch/arm/cpu/armv7/exynos/Kconfig                  |    8 +
 arch/arm/cpu/armv7/s5pc1xx/Kconfig                 |    2 +
 arch/arm/cpu/u-boot-spl.lds                        |    2 +-
 arch/arm/dts/Makefile                              |    6 +-
 arch/arm/dts/rk3288-firefly.dts                    |   82 ++
 arch/arm/dts/rk3288-firefly.dtsi                   |  496 +++++++
 arch/arm/dts/rk3288-thermal.dtsi                   |   90 ++
 arch/arm/dts/rk3288.dtsi                           | 1480 ++++++++++++++++++++
 arch/arm/include/asm/arch-rockchip/clock.h         |   12 +
 arch/arm/include/asm/arch-rockchip/gpio.h          |    5 +
 arch/arm/include/asm/arch-rockchip/grf.h           |  181 +++
 arch/arm/mach-rockchip/Kconfig                     |   44 +
 arch/arm/mach-rockchip/Makefile                    |   12 +
 arch/arm/mach-rockchip/board-spl.c                 |   54 +
 arch/arm/mach-rockchip/board.c                     |   17 +
 arch/arm/mach-rockchip/common.c                    |   11 +
 arch/arm/mach-rockchip/rk3288/Kconfig              |   16 +
 arch/arm/mach-tegra/Kconfig                        |    3 +
 arch/sandbox/cpu/cpu.c                             |   41 +
 arch/sandbox/include/asm/u-boot-sandbox.h          |    8 +
 board/firefly/firefly-rk3288/Kconfig               |   15 +
 board/firefly/firefly-rk3288/MAINTAINERS           |    6 +
 board/firefly/firefly-rk3288/Makefile              |    7 +
 board/firefly/firefly-rk3288/firefly-rk3288.c      |    7 +
 common/board_f.c                                   |   84 +-
 common/dlmalloc.c                                  |   11 +
 common/image.c                                     |   55 +-
 common/spl/spl.c                                   |   22 +-
 configs/Linksprite_pcDuino3_fdt_defconfig          |    1 +
 configs/am335x_boneblack_vboot_defconfig           |    1 +
 configs/arches_defconfig                           |    1 +
 configs/canyonlands_defconfig                      |    1 +
 configs/firefly-rk3288_defconfig                   |   11 +
 configs/galileo_defconfig                          |    1 +
 configs/microblaze-generic_defconfig               |    1 +
 configs/odroid_defconfig                           |    1 +
 configs/origen_defconfig                           |    1 +
 configs/s5pc210_universal_defconfig                |    1 +
 configs/socfpga_socrates_defconfig                 |    1 +
 configs/trats2_defconfig                           |    1 +
 configs/trats_defconfig                            |    1 +
 configs/zynq_microzed_defconfig                    |    1 +
 configs/zynq_zc70x_defconfig                       |    1 +
 configs/zynq_zc770_xm010_defconfig                 |    1 +
 configs/zynq_zc770_xm012_defconfig                 |    1 +
 configs/zynq_zc770_xm013_defconfig                 |    1 +
 configs/zynq_zed_defconfig                         |    1 +
 configs/zynq_zybo_defconfig                        |    1 +
 doc/README.rockchip                                |   83 ++
 .../clock/rockchip,rk3288-cru.txt                  |   61 +
 doc/device-tree-bindings/clock/rockchip.txt        |   77 +
 .../pinctrl/rockchip,pinctrl.txt                   |  157 +++
 .../thermal/rockchip-thermal.txt                   |   68 +
 drivers/core/Kconfig                               |    9 +
 drivers/core/Makefile                              |    2 +
 drivers/core/device.c                              |   54 +-
 drivers/core/root.c                                |   14 +-
 drivers/core/uclass.c                              |    4 +
 drivers/serial/Kconfig                             |   19 +
 drivers/serial/Makefile                            |    1 +
 drivers/serial/ns16550.c                           |   44 +-
 drivers/serial/serial-uclass.c                     |   69 +-
 drivers/serial/serial_rockchip.c                   |   41 +
 dts/Kconfig                                        |   11 +-
 dts/Makefile                                       |    9 +-
 include/config_uncmd_spl.h                         |    3 +
 include/configs/firefly-rk3288.h                   |   50 +
 include/dm/uclass-internal.h                       |    8 +
 include/dt-bindings/clock/rk3288-cru.h             |  378 +++++
 include/dt-bindings/clock/rockchip,rk808.h         |   11 +
 include/dt-bindings/pinctrl/rockchip.h             |   34 +
 include/dt-bindings/power-domain/rk3288.h          |   11 +
 include/dt-bindings/thermal/thermal.h              |   17 +
 include/fdtdec.h                                   |   16 +
 include/image.h                                    |   12 +
 include/malloc.h                                   |    3 +
 include/vsprintf.h                                 |   23 +
 lib/Makefile                                       |    6 +
 lib/fdtdec.c                                       |   39 +-
 lib/vsprintf.c                                     |   23 +-
 scripts/Makefile.lib                               |   12 +-
 scripts/Makefile.spl                               |   35 +
 scripts/Makefile.uncmd_spl                         |    2 +
 tools/Makefile                                     |    1 +
 tools/mkimage.c                                    |   59 +-
 tools/rkimage.c                                    |   63 +
 88 files changed, 4136 insertions(+), 212 deletions(-)
 create mode 100644 arch/arm/dts/rk3288-firefly.dts
 create mode 100644 arch/arm/dts/rk3288-firefly.dtsi
 create mode 100644 arch/arm/dts/rk3288-thermal.dtsi
 create mode 100644 arch/arm/dts/rk3288.dtsi
 create mode 100644 arch/arm/include/asm/arch-rockchip/clock.h
 create mode 100644 arch/arm/include/asm/arch-rockchip/gpio.h
 create mode 100644 arch/arm/include/asm/arch-rockchip/grf.h
 create mode 100644 arch/arm/mach-rockchip/Kconfig
 create mode 100644 arch/arm/mach-rockchip/Makefile
 create mode 100644 arch/arm/mach-rockchip/board-spl.c
 create mode 100644 arch/arm/mach-rockchip/board.c
 create mode 100644 arch/arm/mach-rockchip/common.c
 create mode 100644 arch/arm/mach-rockchip/rk3288/Kconfig
 create mode 100644 board/firefly/firefly-rk3288/Kconfig
 create mode 100644 board/firefly/firefly-rk3288/MAINTAINERS
 create mode 100644 board/firefly/firefly-rk3288/Makefile
 create mode 100644 board/firefly/firefly-rk3288/firefly-rk3288.c
 create mode 100644 configs/firefly-rk3288_defconfig
 create mode 100644 doc/README.rockchip
 create mode 100644 doc/device-tree-bindings/clock/rockchip,rk3288-cru.txt
 create mode 100644 doc/device-tree-bindings/clock/rockchip.txt
 create mode 100644 doc/device-tree-bindings/pinctrl/rockchip,pinctrl.txt
 create mode 100644 doc/device-tree-bindings/thermal/rockchip-thermal.txt
 create mode 100644 drivers/serial/serial_rockchip.c
 create mode 100644 include/configs/firefly-rk3288.h
 create mode 100644 include/dt-bindings/clock/rk3288-cru.h
 create mode 100644 include/dt-bindings/clock/rockchip,rk808.h
 create mode 100644 include/dt-bindings/pinctrl/rockchip.h
 create mode 100644 include/dt-bindings/power-domain/rk3288.h
 create mode 100644 include/dt-bindings/thermal/thermal.h
 create mode 100644 tools/rkimage.c
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#1 lore raw

PATCH 1/29 serial: ns16550: Add an option to specify the debug UART register shift

This UART permits different register spacing. To support the debug UART on devices which have a spacing other than 1 byte, allow the shift value to be specified.

---

 drivers/serial/Kconfig   | 10 ++++++++++
 drivers/serial/ns16550.c | 25 +++++++++++++++----------
 2 files changed, 25 insertions(+), 10 deletions(-)
drivers/serial/Kconfig +10 -0
index 1686a1f..54e6f26 100644
@@ -66,6 +66,16 @@ config DEBUG_UART_CLOCK
 	  A default should be provided by your board, but if not you will need
 	  to use the correct value here.
 
+config DEBUG_UART_SHIFT
+	int "UART register shift"
+	depends on DEBUG_UART
+	default 0 if DEBUG_UART
+	help
+	  Some UARTs (notably ns16550) support different register layouts
+	  where the registers are spaced either as bytes, words or some other
+	  value. Use this value to specify the shift to use, where 0=byte
+	  registers, 2=32-bit word registers, etc.
+
 config UNIPHIER_SERIAL
 	bool "UniPhier on-chip UART support"
 	depends on ARCH_UNIPHIER && DM_SERIAL
drivers/serial/ns16550.c +15 -10
index eb00f1c..54f432f 100644
@@ -253,15 +253,20 @@ void debug_uart_init(void)
 	 */
 	baud_divisor = calc_divisor(com_port, CONFIG_DEBUG_UART_CLOCK,
 				    CONFIG_BAUDRATE);
-
-	serial_out_shift(&com_port->ier, 0, CONFIG_SYS_NS16550_IER);
-	serial_out_shift(&com_port->mcr, 0, UART_MCRVAL);
-	serial_out_shift(&com_port->fcr, 0, UART_FCRVAL);
-
-	serial_out_shift(&com_port->lcr, 0, UART_LCR_BKSE | UART_LCRVAL);
-	serial_out_shift(&com_port->dll, 0, baud_divisor & 0xff);
-	serial_out_shift(&com_port->dlm, 0, (baud_divisor >> 8) & 0xff);
-	serial_out_shift(&com_port->lcr, 0, UART_LCRVAL);
+	baud_divisor = 13;
+	serial_out_shift(&com_port->ier, CONFIG_DEBUG_UART_SHIFT,
+			 CONFIG_SYS_NS16550_IER);
+	serial_out_shift(&com_port->mcr, CONFIG_DEBUG_UART_SHIFT, UART_MCRVAL);
+	serial_out_shift(&com_port->fcr, CONFIG_DEBUG_UART_SHIFT, UART_FCRVAL);
+
+	serial_out_shift(&com_port->lcr, CONFIG_DEBUG_UART_SHIFT,
+			 UART_LCR_BKSE | UART_LCRVAL);
+	serial_out_shift(&com_port->dll, CONFIG_DEBUG_UART_SHIFT,
+			 baud_divisor & 0xff);
+	serial_out_shift(&com_port->dlm, CONFIG_DEBUG_UART_SHIFT,
+			 (baud_divisor >> 8) & 0xff);
+	serial_out_shift(&com_port->lcr, CONFIG_DEBUG_UART_SHIFT,
+			 UART_LCRVAL);
 }
 
 static inline void _debug_uart_putc(int ch)
@@ -270,7 +275,7 @@ static inline void _debug_uart_putc(int ch)
 
 	while (!(serial_in_shift(&com_port->lsr, 0) & UART_LSR_THRE))
 		;
-	serial_out_shift(&com_port->thr, 0, ch);
+	serial_out_shift(&com_port->thr, CONFIG_DEBUG_UART_SHIFT, ch);
 }
 
 DEBUG_UART_FUNCS
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#2 lore raw

PATCH 2/29 dm: ns16550: Support non-byte register spacing with driver model

In reply to Simon Glass

Allow this driver to support boards where the register shift is not 0. This fixes some compiler warnings which appear in that case.

---

 drivers/serial/ns16550.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/serial/ns16550.c +6 -4
index 54f432f..cfa91e2 100644
@@ -56,7 +56,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef CONFIG_DM_SERIAL
 
-static inline void serial_out_shift(unsigned char *addr, int shift, int value)
+static inline void serial_out_shift(void *addr, int shift, int value)
 {
 #ifdef CONFIG_SYS_NS16550_PORT_MAPPED
 	outb(value, (ulong)addr);
@@ -71,7 +71,7 @@ static inline void serial_out_shift(unsigned char *addr, int shift, int value)
 #endif
 }
 
-static inline int serial_in_shift(unsigned char *addr, int shift)
+static inline int serial_in_shift(void *addr, int shift)
 {
 #ifdef CONFIG_SYS_NS16550_PORT_MAPPED
 	return inb((ulong)addr);
@@ -113,9 +113,11 @@ static int ns16550_readb(NS16550_t port, int offset)
 
 /* We can clean these up once everything is moved to driver model */
 #define serial_out(value, addr)	\
-	ns16550_writeb(com_port, addr - (unsigned char *)com_port, value)
+	ns16550_writeb(com_port, \
+		(unsigned char *)addr - (unsigned char *)com_port, value)
 #define serial_in(addr) \
-	ns16550_readb(com_port, addr - (unsigned char *)com_port)
+	ns16550_readb(com_port, \
+		(unsigned char *)addr - (unsigned char *)com_port)
 #endif
 
 static inline int calc_divisor(NS16550_t port, int clock, int baudrate)
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#3 lore raw

PATCH 3/29 dm: ns16550: Support CONFIG_SYS_NS16550_MEM32 with driver model

In reply to Simon Glass

This option is used by some boards, so support it with driver model. This is really ugly - we should rewrite this driver once all users are moved to driver model.

---

 drivers/serial/ns16550.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/serial/ns16550.c +8 -0
index cfa91e2..eddd075 100644
@@ -64,6 +64,8 @@ static inline void serial_out_shift(void *addr, int shift, int value)
 	out_le32(addr, value);
 #elif defined(CONFIG_SYS_NS16550_MEM32) && defined(CONFIG_SYS_BIG_ENDIAN)
 	out_be32(addr, value);
+#elif defined(CONFIG_SYS_NS16550_MEM32)
+	writel(value, addr);
 #elif defined(CONFIG_SYS_BIG_ENDIAN)
 	writeb(value, addr + (1 << shift) - 1);
 #else
@@ -79,6 +81,8 @@ static inline int serial_in_shift(void *addr, int shift)
 	return in_le32(addr);
 #elif defined(CONFIG_SYS_NS16550_MEM32) && defined(CONFIG_SYS_BIG_ENDIAN)
 	return in_be32(addr);
+#elif defined(CONFIG_SYS_NS16550_MEM32)
+	return readl(addr);
 #elif defined(CONFIG_SYS_BIG_ENDIAN)
 	return readb(addr + (1 << reg_shift) - 1);
 #else
@@ -91,7 +95,9 @@ static void ns16550_writeb(NS16550_t port, int offset, int value)
 	struct ns16550_platdata *plat = port->plat;
 	unsigned char *addr;
 
+#ifndef CONFIG_SYS_NS16550_MEM32
 	offset *= 1 << plat->reg_shift;
+#endif
 	addr = map_sysmem(plat->base, 0) + offset;
 	/*
 	 * As far as we know it doesn't make sense to support selection of
@@ -105,7 +111,9 @@ static int ns16550_readb(NS16550_t port, int offset)
 	struct ns16550_platdata *plat = port->plat;
 	unsigned char *addr;
 
+#ifndef CONFIG_SYS_NS16550_MEM32
 	offset *= 1 << plat->reg_shift;
+#endif
 	addr = map_sysmem(plat->base, 0) + offset;
 
 	return serial_in_shift(addr, plat->reg_shift);
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#4 lore raw

PATCH 4/29 serial: ns16550: Remove unnecessary init on UART setup

In reply to Simon Glass

It is not necessary to write a zero baud rate to the device, and for some chips this will cause problems. Drop this code.

---

 drivers/serial/ns16550.c | 1 -
 1 file changed, 1 deletion(-)
drivers/serial/ns16550.c +0 -1
index eddd075..6a3a989 100644
@@ -182,7 +182,6 @@ void NS16550_init(NS16550_t com_port, int baud_divisor)
 			defined(CONFIG_TI81XX) || defined(CONFIG_AM43XX)
 	serial_out(0x7, &com_port->mdr1);	/* mode select reset TL16C750*/
 #endif
-	NS16550_setbrg(com_port, 0);
 	serial_out(UART_MCRVAL, &com_port->mcr);
 	serial_out(UART_FCRVAL, &com_port->fcr);
 	if (baud_divisor != -1)
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#5 lore raw

PATCH 5/29 fdt: arm: Drop device tree padding

In reply to Simon Glass

The 4KB padding doesn't seem necessary since we don't normally adjust the control device tree file within U-Boot.

---

 arch/arm/dts/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/dts/Makefile +1 -1
index fac16cc..121725e 100644
@@ -53,7 +53,7 @@ dtb-$(CONFIG_SOCFPGA) += socfpga_cyclone5_socrates.dtb
 
 targets += $(dtb-y)
 
-DTC_FLAGS += -R 4 -p 0x1000
+DTC_FLAGS += -R 4
 
 PHONY += dtbs
 dtbs: $(addprefix $(obj)/, $(dtb-y))
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#6 lore raw

PATCH 5/29 fdt: arm: Drop device tree padding

Hi Simon,

2015-02-28 14:06 GMT+09:00 Simon Glass <[email protected]>:

Quoted 14 lines

The 4KB padding doesn't seem necessary since we don't normally adjust the control device tree file within U-Boot.

---

 arch/arm/dts/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/dts/Makefile +0 -0
index fac16cc..121725e 100644

arch/arm/dts/Makefile dtb-$(CONFIG_SOCFPGA) += socfpga_cyclone5_socrates.dtb · line 59

Quoted 8 lines
arch/arm/dts/Makefile +1 -1
@@ -53,7 +53,7 @@ dtb-$(CONFIG_SOCFPGA) += socfpga_cyclone5_socrates.dtb
 
 targets += $(dtb-y)
 
-DTC_FLAGS += -R 4 -p 0x1000
+DTC_FLAGS += -R 4
 
 PHONY += dtbs
 dtbs: $(addprefix $(obj)/, $(dtb-y))

I think "-R 4" is not necessary, either.
We do not use the reserve map for OF_CONROL.
This option was also introduced by commit bbb0b128c,
but its git-description does not explain the reason for its necessity.

I vote for dropping "DTC_FLAGS += -R 4 -p 0x1000" line from

./arch/arm/dts/Makefile
./arch/powerpc/dts/Makefile
./arch/microblaze/dts/Makefile
./arch/sandbox/dts/Makefile
./arch/x86/dts/Makefile
./arch/arc/dts/Makefile

Signature · 2 lines
Best Regards
Masahiro Yamada
#7 lore raw

PATCH 5/29 fdt: arm: Drop device tree padding

Hi Masahiro,

Quoted 33 lines · Masahiro Yamada

Hi Simon,

2015-02-28 14:06 GMT+09:00 Simon Glass <[email protected]>:

Quoted 14 lines

The 4KB padding doesn't seem necessary since we don't normally adjust the control device tree file within U-Boot.

---

 arch/arm/dts/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/dts/Makefile +0 -0
index fac16cc..121725e 100644

arch/arm/dts/Makefile dtb-$(CONFIG_SOCFPGA) += socfpga_cyclone5_socrates.dtb · line 59

Quoted 8 lines
arch/arm/dts/Makefile +1 -1
@@ -53,7 +53,7 @@ dtb-$(CONFIG_SOCFPGA) += socfpga_cyclone5_socrates.dtb
 
 targets += $(dtb-y)
 
-DTC_FLAGS += -R 4 -p 0x1000
+DTC_FLAGS += -R 4
 
 PHONY += dtbs
 dtbs: $(addprefix $(obj)/, $(dtb-y))

I think "-R 4" is not necessary, either.
We do not use the reserve map for OF_CONROL.
This option was also introduced by commit bbb0b128c,
but its git-description does not explain the reason for its necessity.

Quoted 8 lines

I vote for dropping "DTC_FLAGS += -R 4 -p 0x1000" line from

./arch/arm/dts/Makefile
./arch/powerpc/dts/Makefile
./arch/microblaze/dts/Makefile
./arch/sandbox/dts/Makefile
./arch/x86/dts/Makefile
./arch/arc/dts/Makefile

Agreed, thanks for spotting this. I'll work up a patch.

Regards,
Simon

#8 lore raw

PATCH 6/29 dm: core: Allow sequence alias support to be removed for SPL

In reply to Simon Glass

In many cases SPL only uses a single serial port and there is no need for alias sequence support. We will just use the serial port pointed to by stdout-path in the /chosen node.

---

 drivers/core/Kconfig       |  9 +++++++++
 drivers/core/device.c      | 28 +++++++++++++++-------------
 include/config_uncmd_spl.h |  1 +
 3 files changed, 25 insertions(+), 13 deletions(-)
drivers/core/Kconfig +9 -0
index 75d182d..2861b43 100644
@@ -46,3 +46,12 @@ config DM_STDIO
 	  Normally serial drivers register with stdio so that they can be used
 	  as normal output devices. In SPL we don't normally use stdio, so
 	  we can omit this feature.
+
+config DM_SEQ_ALIAS
+	bool "Support numbered aliases in device tree"
+	depends on DM
+	default y
+	help
+	  Most boards will have a '/aliases' node containing the path to
+	  numbered devices (e.g. serial0 = &serial0). This feature can be
+	  disabled if it is not required, to save code space in SPL.
drivers/core/device.c +15 -13
index 73c3e07..78c9525 100644
@@ -55,21 +55,23 @@ int device_bind(struct udevice *parent, struct driver *drv, const char *name,
 
 	dev->seq = -1;
 	dev->req_seq = -1;
-#ifdef CONFIG_OF_CONTROL
-	/*
-	 * Some devices, such as a SPI bus, I2C bus and serial ports are
-	 * numbered using aliases.
-	 *
-	 * This is just a 'requested' sequence, and will be
-	 * resolved (and ->seq updated) when the device is probed.
-	 */
-	if (uc->uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS) {
-		if (uc->uc_drv->name && of_offset != -1) {
-			fdtdec_get_alias_seq(gd->fdt_blob, uc->uc_drv->name,
-					     of_offset, &dev->req_seq);
+	if (IS_ENABLED(CONFIG_OF_CONTROL) && IS_ENABLED(CONFIG_DM_SEQ_ALIAS)) {
+		/*
+		* Some devices, such as a SPI bus, I2C bus and serial ports
+		* are numbered using aliases.
+		*
+		* This is just a 'requested' sequence, and will be
+		* resolved (and ->seq updated) when the device is probed.
+		*/
+		if (uc->uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS) {
+			if (uc->uc_drv->name && of_offset != -1) {
+				fdtdec_get_alias_seq(gd->fdt_blob,
+						uc->uc_drv->name, of_offset,
+						&dev->req_seq);
+			}
 		}
 	}
-#endif
+
 	if (!dev->platdata && drv->platdata_auto_alloc_size) {
 		dev->flags |= DM_FLAG_ALLOC_PDATA;
 		dev->platdata = calloc(1, drv->platdata_auto_alloc_size);
include/config_uncmd_spl.h +1 -0
index a9106f4..38cb0e8 100644
@@ -31,6 +31,7 @@
 
 #undef CONFIG_DM_WARN
 #undef CONFIG_DM_DEVICE_REMOVE
+#undef CONFIG_DM_SEQ_ALIAS
 #undef CONFIG_DM_STDIO
 
 #endif /* CONFIG_SPL_BUILD */
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#9 lore raw

PATCH 7/29 dm: core: Remove unbind operations when not required

In reply to Simon Glass

The CONFIG_DM_DEVICE_REMOVE option takes out code related to removing devices. It should also remove the 'unbind' code since if we cannot remove we probably don't need to unbind.

---

 drivers/core/uclass.c        | 4 ++++
 include/dm/uclass-internal.h | 8 ++++++++
 2 files changed, 12 insertions(+)
drivers/core/uclass.c +4 -0
index 289a5d2..e8282d2 100644
@@ -344,6 +344,7 @@ err:
 	return ret;
 }
 
+#ifdef CONFIG_DM_DEVICE_REMOVE
 int uclass_unbind_device(struct udevice *dev)
 {
 	struct uclass *uc;
@@ -359,6 +360,7 @@ int uclass_unbind_device(struct udevice *dev)
 	list_del(&dev->uclass_node);
 	return 0;
 }
+#endif
 
 int uclass_resolve_seq(struct udevice *dev)
 {
@@ -414,6 +416,7 @@ int uclass_post_probe_device(struct udevice *dev)
 	return 0;
 }
 
+#ifdef CONFIG_DM_DEVICE_REMOVE
 int uclass_pre_remove_device(struct udevice *dev)
 {
 	struct uclass_driver *uc_drv;
@@ -435,3 +438,4 @@ int uclass_pre_remove_device(struct udevice *dev)
 
 	return 0;
 }
+#endif
include/dm/uclass-internal.h +8 -0
index f2f254a..4a492d6 100644
@@ -41,7 +41,11 @@ int uclass_bind_device(struct udevice *dev);
  * @dev:	Pointer to the device
  * #return 0 on success, -ve on error
  */
+#ifdef CONFIG_DM_DEVICE_REMOVE
 int uclass_unbind_device(struct udevice *dev);
+#else
+static inline int uclass_unbind_device(struct udevice *dev) { return 0; }
+#endif
 
 /**
  * uclass_pre_probe_child() - Deal with a child that is about to be probed
@@ -73,7 +77,11 @@ int uclass_post_probe_device(struct udevice *dev);
  * @dev:	Pointer to the device
  * #return 0 on success, -ve on error
  */
+#ifdef CONFIG_DM_DEVICE_REMOVE
 int uclass_pre_remove_device(struct udevice *dev);
+#else
+static inline int uclass_pre_remove_device(struct udevice *dev) { return 0; }
+#endif
 
 /**
  * uclass_find() - Find uclass by its id
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#10 lore raw

PATCH 8/29 dm: Add a panic_str() function to reduce code size

In reply to Simon Glass

The printf() in panic() adds about 1.5KB of code size to SPL when compiled with Thumb-2. Provide a smaller version that does not support printf()-style arguments and use it in two commonly compiled places.

---

 drivers/serial/serial-uclass.c |  2 +-
 include/vsprintf.h             | 23 +++++++++++++++++++++++
 lib/fdtdec.c                   |  8 +++++---
 lib/vsprintf.c                 | 23 ++++++++++++++++++-----
 4 files changed, 47 insertions(+), 9 deletions(-)
drivers/serial/serial-uclass.c +1 -1
index 3fc7104..13ba606 100644
@@ -72,7 +72,7 @@ static void serial_find_console_or_panic(void)
 	if (uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &dev) &&
 	    uclass_get_device(UCLASS_SERIAL, INDEX, &dev) &&
 	    (uclass_first_device(UCLASS_SERIAL, &dev) || !dev))
-		panic("No serial driver found");
+		panic_str("No serial driver found");
 #undef INDEX
 	gd->cur_serial_dev = dev;
 }
include/vsprintf.h +23 -0
index 5624482..09c8abd 100644
@@ -39,10 +39,33 @@ int strict_strtoul(const char *cp, unsigned int base, unsigned long *res);
 unsigned long long simple_strtoull(const char *cp, char **endp,
 					unsigned int base);
 long simple_strtol(const char *cp, char **endp, unsigned int base);
+
+/**
+ * panic() - Print a message and reset/hang
+ *
+ * Prints a message on the console(s) and then resets. If CONFIG_PANIC_HANG is
+ * defined, then it will hang instead of reseting.
+ *
+ * @param fmt:	printf() format string for message, which should not include
+ *		\n, followed by arguments
+ */
 void panic(const char *fmt, ...)
 		__attribute__ ((format (__printf__, 1, 2), noreturn));
 
 /**
+ * panic_str() - Print a message and reset/hang
+ *
+ * Prints a message on the console(s) and then resets. If CONFIG_PANIC_HANG is
+ * defined, then it will hang instead of reseting.
+ *
+ * This function can be used instead of panic() when your board does not
+ * already use printf(), * to keep code size small.
+ *
+ * @param fmt:	string to display, which should not include \n
+ */
+void panic_str(const char *str) __attribute__ ((noreturn));
+
+/**
  * Format a string and place it in a buffer
  *
  * @param buf	The buffer to place the result into
lib/fdtdec.c +5 -3
index dd58bbb..cc5ba20 100644
@@ -564,9 +564,11 @@ int fdtdec_prepare_fdt(void)
 {
 	if (!gd->fdt_blob || ((uintptr_t)gd->fdt_blob & 3) ||
 	    fdt_check_header(gd->fdt_blob)) {
-		printf("No valid FDT found - please append one to U-Boot "
-			"binary, use u-boot-dtb.bin or define "
-			"CONFIG_OF_EMBED. For sandbox, use -d <file.dtb>\n");
+#ifdef CONFIG_SPL_BUILD
+		puts("Missing DTB\n");
+#else
+		puts("No valid device tree binary found - please append one to U-Boot binary, use u-boot-dtb.bin or define CONFIG_OF_EMBED. For sandbox, use -d <file.dtb>\n");
+#endif
 		return -1;
 	}
 	return 0;
lib/vsprintf.c +18 -5
index e0f2648..bedc865 100644
@@ -842,13 +842,11 @@ int sprintf(char *buf, const char *fmt, ...)
 	return i;
 }
 
-void panic(const char *fmt, ...)
+static void panic_finish(void) __attribute__ ((noreturn));
+
+static void panic_finish(void)
 {
-	va_list args;
-	va_start(args, fmt);
-	vprintf(fmt, args);
 	putc('\n');
-	va_end(args);
 #if defined(CONFIG_PANIC_HANG)
 	hang();
 #else
@@ -859,6 +857,21 @@ void panic(const char *fmt, ...)
 		;
 }
 
+void panic_str(const char *str)
+{
+	puts(str);
+	panic_finish();
+}
+
+void panic(const char *fmt, ...)
+{
+	va_list args;
+	va_start(args, fmt);
+	vprintf(fmt, args);
+	va_end(args);
+	panic_finish();
+}
+
 void __assert_fail(const char *assertion, const char *file, unsigned line,
 		   const char *function)
 {
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#11 lore raw

PATCH 9/29 dm: core: Drop device removal error path when not supported

In reply to Simon Glass

When CONFIG_DM_DEVICE_REMOVE is not enabled, such as in SPL, we cannot remove or unbind devices and do not expect to get errors when binding and probing devices. So drop the error path to reduce code size.

---

 drivers/core/device.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)
drivers/core/device.c +16 -10
index 78c9525..37dc882 100644
@@ -124,21 +124,27 @@ int device_bind(struct udevice *parent, struct driver *drv, const char *name,
 	return 0;
 
 fail_child_post_bind:
-	if (drv->unbind && drv->unbind(dev)) {
-		dm_warn("unbind() method failed on dev '%s' on error path\n",
-			dev->name);
+	if (IS_ENABLED(DM_DEVICE_REMOVE)) {
+		if (drv->unbind && drv->unbind(dev)) {
+			dm_warn("unbind() method failed on dev '%s' on error path\n",
+				dev->name);
+		}
 	}
 
 fail_bind:
-	if (uclass_unbind_device(dev)) {
-		dm_warn("Failed to unbind dev '%s' on error path\n",
-			dev->name);
+	if (IS_ENABLED(DM_DEVICE_REMOVE)) {
+		if (uclass_unbind_device(dev)) {
+			dm_warn("Failed to unbind dev '%s' on error path\n",
+				dev->name);
+		}
 	}
 fail_uclass_bind:
-	list_del(&dev->sibling_node);
-	if (dev->flags & DM_FLAG_ALLOC_PARENT_PDATA) {
-		free(dev->parent_platdata);
-		dev->parent_platdata = NULL;
+	if (IS_ENABLED(DM_DEVICE_REMOVE)) {
+		list_del(&dev->sibling_node);
+		if (dev->flags & DM_FLAG_ALLOC_PARENT_PDATA) {
+			free(dev->parent_platdata);
+			dev->parent_platdata = NULL;
+		}
 	}
 fail_alloc2:
 	if (dev->flags & DM_FLAG_ALLOC_PDATA) {
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#12 lore raw

PATCH 10/29 fdt: sandbox: Move setup code from board_f to fdtdec

In reply to Simon Glass

We want to be able to set up the device tree in SPL, so move this code to a common place.

---

 arch/sandbox/cpu/cpu.c                    | 41 +++++++++++++++++++
 arch/sandbox/include/asm/u-boot-sandbox.h |  8 ++++
 common/board_f.c                          | 67 +------------------------------
 include/fdtdec.h                          |  6 +++
 lib/fdtdec.c                              | 31 ++++++++++++++
 5 files changed, 88 insertions(+), 65 deletions(-)
arch/sandbox/cpu/cpu.c +41 -0
index 1aa397c..1e10452 100644
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <dm/root.h>
 #include <os.h>
+#include <asm/io.h>
 #include <asm/state.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -70,3 +71,43 @@ phys_addr_t map_to_sysmem(const void *ptr)
 void flush_dcache_range(unsigned long start, unsigned long stop)
 {
 }
+
+int sandbox_read_fdt_from_file(void)
+{
+	struct sandbox_state *state = state_get_current();
+	const char *fname = state->fdt_fname;
+	void *blob;
+	loff_t size;
+	int err;
+	int fd;
+
+	blob = map_sysmem(CONFIG_SYS_FDT_LOAD_ADDR, 0);
+	if (!state->fdt_fname) {
+		err = fdt_create_empty_tree(blob, 256);
+		if (!err)
+			goto done;
+		printf("Unable to create empty FDT: %s\n", fdt_strerror(err));
+		return -EINVAL;
+	}
+
+	err = os_get_filesize(fname, &size);
+	if (err < 0) {
+		printf("Failed to file FDT file '%s'\n", fname);
+		return err;
+	}
+	fd = os_open(fname, OS_O_RDONLY);
+	if (fd < 0) {
+		printf("Failed to open FDT file '%s'\n", fname);
+		return -EACCES;
+	}
+	if (os_read(fd, blob, size) != size) {
+		os_close(fd);
+		return -EIO;
+	}
+	os_close(fd);
+
+done:
+	gd->fdt_blob = blob;
+
+	return 0;
+}
arch/sandbox/include/asm/u-boot-sandbox.h +8 -0
index 770ab5c..6802618 100644
@@ -27,4 +27,12 @@ int cleanup_before_linux(void);
 /* drivers/video/sandbox_sdl.c */
 int sandbox_lcd_sdl_early_init(void);
 
+/**
+ * sandbox_read_fdt_from_file() - Read a device tree from a file
+ *
+ * Read a device tree file from a host file and set it up for use as the
+ * control FDT.
+ */
+int sandbox_read_fdt_from_file(void);
+
 #endif	/* _U_BOOT_SANDBOX_H_ */
common/board_f.c +2 -65

86 lines not on this page · raw message

include/fdtdec.h +6 -0
index 1bc70db..ea92c2b 100644
@@ -778,4 +778,10 @@ int fdt_get_named_resource(const void *fdt, int node, const char *property,
 int fdtdec_decode_memory_region(const void *blob, int node,
 				const char *mem_type, const char *suffix,
 				fdt_addr_t *basep, fdt_size_t *sizep);
+
+/**
+ * Set up the device tree ready for use
+ */
+int setup_fdt(void);
+
 #endif
lib/fdtdec.c +31 -0
index cc5ba20..4668217 100644
@@ -9,6 +9,7 @@
 #include <serial.h>
 #include <libfdt.h>
 #include <fdtdec.h>
+#include <asm/sections.h>
 #include <linux/ctype.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -1036,4 +1037,34 @@ int fdtdec_decode_memory_region(const void *blob, int config_node,
 
 	return 0;
 }
+
+int setup_fdt(void)
+{
+#ifdef CONFIG_OF_CONTROL
+# ifdef CONFIG_OF_EMBED
+	/* Get a pointer to the FDT */
+	gd->fdt_blob = __dtb_dt_begin;
+# elif defined CONFIG_OF_SEPARATE
+#  ifdef CONFIG_SPL_BUILD
+	/* FDT is at end of BSS */
+	gd->fdt_blob = (ulong *)&__bss_end;
+#  else
+	/* FDT is at end of image */
+	gd->fdt_blob = (ulong *)&_end;
+#endif
+# elif defined(CONFIG_OF_HOSTFILE)
+	if (sandbox_read_fdt_from_file()) {
+		puts("Failed to read control FDT\n");
+		return -1;
+	}
+# endif
+# ifndef CONFIG_SPL_BUILD
+	/* Allow the early environment to override the fdt address */
+	gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16,
+						(uintptr_t)gd->fdt_blob);
+# endif
 #endif
+	return 0;
+}
+
+#endif /* !USE_HOSTCC */
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#13 lore raw

PATCH 11/29 fdt: Rename setup_fdt() and make it prepare also

In reply to Simon Glass

There is little reason to split these two functions. Bring them together which simplifies the init sequence.

---

 common/board_f.c | 5 +----
 include/fdtdec.h | 2 +-
 lib/fdtdec.c     | 4 ++--
 3 files changed, 4 insertions(+), 7 deletions(-)
common/board_f.c +1 -4
index 2499664..eab0050 100644
@@ -728,7 +728,7 @@ static init_fnc_t init_sequence_f[] = {
 #endif
 	setup_mon_len,
 #ifdef CONFIG_OF_CONTROL
-	setup_fdt,
+	fdtdec_setup,
 #endif
 #ifdef CONFIG_TRACE
 	trace_early_init,
@@ -740,9 +740,6 @@ static init_fnc_t init_sequence_f[] = {
 #endif
 	arch_cpu_init,		/* basic arch cpu dependent setup */
 	mark_bootstage,
-#ifdef CONFIG_OF_CONTROL
-	fdtdec_check_fdt,
-#endif
 	initf_dm,
 #if defined(CONFIG_BOARD_EARLY_INIT_F)
 	board_early_init_f,
include/fdtdec.h +1 -1
index ea92c2b..a49a184 100644
@@ -782,6 +782,6 @@ int fdtdec_decode_memory_region(const void *blob, int node,
 /**
  * Set up the device tree ready for use
  */
-int setup_fdt(void);
+int fdtdec_setup(void);
 
 #endif
lib/fdtdec.c +2 -2
index 4668217..67b2f34 100644
@@ -1038,7 +1038,7 @@ int fdtdec_decode_memory_region(const void *blob, int config_node,
 	return 0;
 }
 
-int setup_fdt(void)
+int fdtdec_setup(void)
 {
 #ifdef CONFIG_OF_CONTROL
 # ifdef CONFIG_OF_EMBED
@@ -1064,7 +1064,7 @@ int setup_fdt(void)
 						(uintptr_t)gd->fdt_blob);
 # endif
 #endif
-	return 0;
+	return fdtdec_prepare_fdt();
 }
 
 #endif /* !USE_HOSTCC */
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#14 lore raw

PATCH 12/29 Move initf_malloc() to a common place

In reply to Simon Glass

To allow this function to be used from SPL, move it to the malloc() code.

---

 common/board_f.c  | 12 +-----------
 common/dlmalloc.c | 11 +++++++++++
 include/malloc.h  |  3 +++
 3 files changed, 15 insertions(+), 11 deletions(-)
common/board_f.c +1 -11
index eab0050..82b8a66 100644
@@ -23,6 +23,7 @@
 #include <i2c.h>
 #include <initcall.h>
 #include <logbuff.h>
+#include <malloc.h>
 
 /* TODO: Can we move these into arch/ headers? */
 #ifdef CONFIG_8xx
@@ -692,17 +693,6 @@ static int mark_bootstage(void)
 	return 0;
 }
 
-static int initf_malloc(void)
-{
-#ifdef CONFIG_SYS_MALLOC_F_LEN
-	assert(gd->malloc_base);	/* Set up by crt0.S */
-	gd->malloc_limit = gd->malloc_base + CONFIG_SYS_MALLOC_F_LEN;
-	gd->malloc_ptr = 0;
-#endif
-
-	return 0;
-}
-
 static int initf_dm(void)
 {
 #if defined(CONFIG_DM) && defined(CONFIG_SYS_MALLOC_F_LEN)
common/dlmalloc.c +11 -0
index 6453ee9..741215b 100644
@@ -3257,6 +3257,17 @@ int mALLOPt(param_number, value) int param_number; int value;
   }
 }
 
+int initf_malloc(void)
+{
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+	assert(gd->malloc_base);	/* Set up by crt0.S */
+	gd->malloc_limit = CONFIG_SYS_MALLOC_F_LEN;
+	gd->malloc_ptr = 0;
+#endif
+
+	return 0;
+}
+
 /*
 
 History:
include/malloc.h +3 -0
index 5df6348..f4da9e6 100644
@@ -906,6 +906,9 @@ void *realloc_simple(void *ptr, size_t size);
 
 #endif
 
+/* Set up pre-relocation malloc() ready for use */
+int initf_malloc(void);
+
 /* Public routines */
 
 /* Simple versions which can be used when space is tight */
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#15 lore raw

PATCH 13/29 Correct malloc_limit value for pre-relocation malloc()

In reply to Simon Glass

The limit is measured from the start of the malloc() area and is not an absolute address. Correct this.

---
This bug has been there for a while but was not causing problems. I have been meaning to send a patch for a while.

 common/spl/spl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/spl/spl.c +1 -1
index cd75bbc..c655332 100644
@@ -146,7 +146,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 			CONFIG_SYS_SPL_MALLOC_SIZE);
 	gd->flags |= GD_FLG_FULL_MALLOC_INIT;
 #elif defined(CONFIG_SYS_MALLOC_F_LEN)
-	gd->malloc_limit = gd->malloc_base + CONFIG_SYS_MALLOC_F_LEN;
+	gd->malloc_limit = CONFIG_SYS_MALLOC_F_LEN;
 	gd->malloc_ptr = 0;
 #endif
 #ifdef CONFIG_SPL_DM
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#16 lore raw

PATCH 14/29 fdt: Add an option to disable device tree in SPL

In reply to Simon Glass

Some boards cannot support device tree due to lack of memory. Add an option to allow these boards to continue to work (and even use driver model). This is a 'negative' option since most boards are expected to support device tree in SPL.

---

 dts/Kconfig | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
dts/Kconfig +8 -3
index ca5bd6f..957f5c7 100644
@@ -1,9 +1,6 @@
 #
 # Device Tree Control
 #
-# TODO:
-#   This feature is not currently supported for SPL,
-#    but this restriction should be removed in the future.
 
 config SUPPORT_OF_CONTROL
 	bool
@@ -17,6 +14,14 @@ config OF_CONTROL
 	  This feature provides for run-time configuration of U-Boot
 	  via a flattened device tree.
 
+config SPL_DISABLE_OF_CONTROL
+	bool "Disable run-time configuration via Device Tree in SPL"
+	depends on OF_CONTROL
+	help
+	  Some boards use device tree in U-Boot but only have 4KB of SRAM
+	  which is not enough to support device tree. Enable this option to
+	  allow such boards to be supported by U-Boot SPL.
+
 choice
 	prompt "Provider of DTB for DT control"
 	depends on OF_CONTROL
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#17 lore raw

PATCH 15/29 dts: Disable device tree for SPL on all boards

In reply to Simon Glass

We plan to enable device tree in SPL by default. Before doing this, explicitly disable it for all boards.

---

 arch/arm/Kconfig                          | 2 ++
 arch/arm/cpu/armv7/exynos/Kconfig         | 8 ++++++++
 arch/arm/cpu/armv7/s5pc1xx/Kconfig        | 2 ++
 arch/arm/mach-tegra/Kconfig               | 3 +++
 configs/Linksprite_pcDuino3_fdt_defconfig | 1 +
 configs/am335x_boneblack_vboot_defconfig  | 1 +
 configs/arches_defconfig                  | 1 +
 configs/canyonlands_defconfig             | 1 +
 configs/galileo_defconfig                 | 1 +
 configs/microblaze-generic_defconfig      | 1 +
 configs/odroid_defconfig                  | 1 +
 configs/origen_defconfig                  | 1 +
 configs/s5pc210_universal_defconfig       | 1 +
 configs/socfpga_socrates_defconfig        | 1 +
 configs/trats2_defconfig                  | 1 +
 configs/trats_defconfig                   | 1 +
 configs/zynq_microzed_defconfig           | 1 +
 configs/zynq_zc70x_defconfig              | 1 +
 configs/zynq_zc770_xm010_defconfig        | 1 +
 configs/zynq_zc770_xm012_defconfig        | 1 +
 configs/zynq_zc770_xm013_defconfig        | 1 +
 configs/zynq_zed_defconfig                | 1 +
 configs/zynq_zybo_defconfig               | 1 +
 23 files changed, 34 insertions(+)
arch/arm/Kconfig +2 -0
index 7a2f91c..f0e6dec 100644
@@ -597,6 +597,7 @@ config TEGRA
 	select SUPPORT_SPL
 	select SPL
 	select OF_CONTROL
+	select SPL_DISABLE_OF_CONTROL
 	select CPU_V7
 
 config TARGET_VEXPRESS64_AEMV8A
@@ -690,6 +691,7 @@ config ARCH_UNIPHIER
 	select SUPPORT_SPL
 	select SPL
 	select OF_CONTROL
+	select SPL_DISABLE_OF_CONTROL
 
 endchoice
 
arch/arm/cpu/armv7/exynos/Kconfig +8 -0
index eb86a7f..46be502 100644
@@ -7,6 +7,7 @@ config TARGET_SMDKV310
 	select SUPPORT_SPL
 	bool "Exynos4210 SMDKV310 board"
 	select OF_CONTROL
+	select SPL_DISABLE_OF_CONTROL
 
 config TARGET_TRATS
 	bool "Exynos4210 Trats board"
@@ -27,6 +28,7 @@ config TARGET_ODROID
 config TARGET_ODROID_XU3
 	bool "Exynos5422 Odroid board"
 	select OF_CONTROL
+	select SPL_DISABLE_OF_CONTROL
 
 config TARGET_ARNDALE
 	bool "Exynos5250 Arndale board"
@@ -34,31 +36,37 @@ config TARGET_ARNDALE
 	select CPU_V7_HAS_VIRT
 	select SUPPORT_SPL
 	select OF_CONTROL
+	select SPL_DISABLE_OF_CONTROL
 
 config TARGET_SMDK5250
 	bool "SMDK5250 board"
 	select SUPPORT_SPL
 	select OF_CONTROL
+	select SPL_DISABLE_OF_CONTROL
 
 config TARGET_SNOW
 	bool "Snow board"
 	select SUPPORT_SPL
 	select OF_CONTROL
+	select SPL_DISABLE_OF_CONTROL
 
 config TARGET_SMDK5420
 	bool "SMDK5420 board"
 	select SUPPORT_SPL
 	select OF_CONTROL
+	select SPL_DISABLE_OF_CONTROL
 
 config TARGET_PEACH_PI
 	bool "Peach Pi board"
 	select SUPPORT_SPL
 	select OF_CONTROL
+	select SPL_DISABLE_OF_CONTROL
 
 config TARGET_PEACH_PIT
 	bool "Peach Pit board"
 	select SUPPORT_SPL
 	select OF_CONTROL
+	select SPL_DISABLE_OF_CONTROL
 
 endchoice
 
arch/arm/cpu/armv7/s5pc1xx/Kconfig +2 -0
index bc73813..65cc9eb 100644
@@ -6,10 +6,12 @@ choice
 config TARGET_S5P_GONI
 	bool "S5P Goni board"
 	select OF_CONTROL
+	select SPL_DISABLE_OF_CONTROL
 
 config TARGET_SMDKC100
 	bool "Support smdkc100 board"
 	select OF_CONTROL
+	select SPL_DISABLE_OF_CONTROL
 
 endchoice
 
arch/arm/mach-tegra/Kconfig +3 -0
index fccfd79..45b3148 100644
@@ -47,6 +47,9 @@ config DM_I2C
 config DM_GPIO
 	default y
 
+config SPL_DISABLE_OF_CONTROL
+	default y
+
 source "arch/arm/mach-tegra/tegra20/Kconfig"
 source "arch/arm/mach-tegra/tegra30/Kconfig"
 source "arch/arm/mach-tegra/tegra114/Kconfig"
configs/Linksprite_pcDuino3_fdt_defconfig +1 -0
index 1e749cd..cf9e090 100644
@@ -6,6 +6,7 @@ CONFIG_DM_GPIO=y
 CONFIG_DM_SERIAL=y
 CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-pcduino3"
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_DISABLE_OF_CONTROL=y
 CONFIG_OF_SEPARATE=y
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
configs/am335x_boneblack_vboot_defconfig +1 -0
index 51bf370..c241f47 100644
@@ -3,6 +3,7 @@ CONFIG_SYS_EXTRA_OPTIONS="EMMC_BOOT,ENABLE_VBOOT"
 +S:CONFIG_ARM=y
 +S:CONFIG_TARGET_AM335X_EVM=y
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_DISABLE_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="am335x-boneblack"
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
configs/arches_defconfig +1 -0
index 30c6932..2af8446 100644
@@ -4,4 +4,5 @@ CONFIG_TARGET_CANYONLANDS=y
 CONFIG_ARCHES=y
 CONFIG_DEFAULT_DEVICE_TREE="arches"
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_DISABLE_OF_CONTROL=y
 CONFIG_OF_SEPARATE=y
configs/canyonlands_defconfig +1 -0
index 44d4fbd..09172b1 100644
@@ -4,4 +4,5 @@ CONFIG_TARGET_CANYONLANDS=y
 CONFIG_CANYONLANDS=y
 CONFIG_DEFAULT_DEVICE_TREE="canyonlands"
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_DISABLE_OF_CONTROL=y
 CONFIG_OF_EMBED=y
configs/galileo_defconfig +1 -0
index f208651..60704d6 100644
@@ -2,5 +2,6 @@ CONFIG_SYS_EXTRA_OPTIONS="SYS_TEXT_BASE=0xfff10000"
 CONFIG_X86=y
 CONFIG_TARGET_GALILEO=y
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_DISABLE_OF_CONTROL=y
 CONFIG_OF_SEPARATE=y
 CONFIG_DEFAULT_DEVICE_TREE="galileo"
configs/microblaze-generic_defconfig +1 -0
index 5cfd596..074d4bf 100644
@@ -2,5 +2,6 @@ CONFIG_SPL=y
 +S:CONFIG_MICROBLAZE=y
 +S:CONFIG_TARGET_MICROBLAZE_GENERIC=y
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_DISABLE_OF_CONTROL=y
 CONFIG_OF_EMBED=y
 CONFIG_DEFAULT_DEVICE_TREE="microblaze-generic"
configs/odroid_defconfig +1 -0
index 816a3fa..4ae891c 100644
@@ -2,6 +2,7 @@ CONFIG_ARM=y
 CONFIG_ARCH_EXYNOS=y
 CONFIG_TARGET_ODROID=y
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_DISABLE_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="exynos4412-odroid"
 CONFIG_DM_I2C=y
 CONFIG_DM_I2C_COMPAT=y
configs/origen_defconfig +1 -0
index 2a7f83b..e831817 100644
@@ -3,4 +3,5 @@ CONFIG_SPL=y
 +S:CONFIG_ARCH_EXYNOS=y
 +S:CONFIG_TARGET_ORIGEN=y
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_DISABLE_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="exynos4210-origen"
configs/s5pc210_universal_defconfig +1 -0
index cdce39f..3419704 100644
@@ -2,4 +2,5 @@ CONFIG_ARM=y
 CONFIG_ARCH_EXYNOS=y
 CONFIG_TARGET_S5PC210_UNIVERSAL=y
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_DISABLE_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="exynos4210-universal_c210"
configs/socfpga_socrates_defconfig +1 -0
index 888bbb6..f2ddc31 100644
@@ -2,6 +2,7 @@ CONFIG_SPL=y
 +S:CONFIG_ARM=y
 +S:CONFIG_TARGET_SOCFPGA_CYCLONE5=y
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_DISABLE_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_cyclone5_socrates"
 CONFIG_DM=y
 CONFIG_DM_SPI=y
configs/trats2_defconfig +1 -0
index 1b98b73..c285a68 100644
@@ -2,4 +2,5 @@ CONFIG_ARM=y
 CONFIG_ARCH_EXYNOS=y
 CONFIG_TARGET_TRATS2=y
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_DISABLE_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="exynos4412-trats2"
configs/trats_defconfig +1 -0
index 901a014..db71c9b 100644
@@ -2,4 +2,5 @@ CONFIG_ARM=y
 CONFIG_ARCH_EXYNOS=y
 CONFIG_TARGET_TRATS=y
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_DISABLE_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="exynos4210-trats"
configs/zynq_microzed_defconfig +1 -0
index 8b985fe..1fa47ab 100644
@@ -3,6 +3,7 @@ CONFIG_SPL=y
 +S:CONFIG_ZYNQ=y
 +S:CONFIG_TARGET_ZYNQ_MICROZED=y
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_DISABLE_OF_CONTROL=y
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_FIT_SIGNATURE=y
configs/zynq_zc70x_defconfig +1 -0
index cceb321..849a162 100644
@@ -3,6 +3,7 @@ CONFIG_SPL=y
 +S:CONFIG_ZYNQ=y
 +S:CONFIG_TARGET_ZYNQ_ZC70X=y
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_DISABLE_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="zynq-zc702"
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
configs/zynq_zc770_xm010_defconfig +1 -0
index 2935c0d..5fe8e50 100644
@@ -4,6 +4,7 @@ CONFIG_SYS_EXTRA_OPTIONS="ZC770_XM010"
 +S:CONFIG_ZYNQ=y
 +S:CONFIG_TARGET_ZYNQ_ZC770=y
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_DISABLE_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="zynq-zc770-xm010"
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
configs/zynq_zc770_xm012_defconfig +1 -0
index 0401739..f15eb1b 100644
@@ -4,6 +4,7 @@ CONFIG_SYS_EXTRA_OPTIONS="ZC770_XM012"
 +S:CONFIG_ZYNQ=y
 +S:CONFIG_TARGET_ZYNQ_ZC770=y
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_DISABLE_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="zynq-zc770-xm012"
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
configs/zynq_zc770_xm013_defconfig +1 -0
index a95970a..ae33688 100644
@@ -4,6 +4,7 @@ CONFIG_SYS_EXTRA_OPTIONS="ZC770_XM013"
 +S:CONFIG_ZYNQ=y
 +S:CONFIG_TARGET_ZYNQ_ZC770=y
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_DISABLE_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="zynq-zc770-xm013"
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
configs/zynq_zed_defconfig +1 -0
index 0fbc41a..bc86bde 100644
@@ -3,6 +3,7 @@ CONFIG_SPL=y
 +S:CONFIG_ZYNQ=y
 +S:CONFIG_TARGET_ZYNQ_ZED=y
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_DISABLE_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="zynq-zed"
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
configs/zynq_zybo_defconfig +1 -0
index 4e66760..7467d42 100644
@@ -3,6 +3,7 @@ CONFIG_SPL=y
 +S:CONFIG_ZYNQ=y
 +S:CONFIG_TARGET_ZYNQ_ZYBO=y
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_DISABLE_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="zynq-zybo"
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#18 lore raw

PATCH 16/29 fdt: Allow FDT functions to be built for SPL

In reply to Simon Glass

Remove the implicit assumption that SPL does not support device tree.

---

 lib/Makefile | 6 ++++++
 1 file changed, 6 insertions(+)
lib/Makefile +6 -0
index 07d175f..97ed398 100644
@@ -44,6 +44,12 @@ obj-$(CONFIG_BITREVERSE) += bitrev.o
 obj-y += list_sort.o
 endif
 
+ifndef CONFIG_SPL_DISABLE_OF_CONTROL
+obj-$(CONFIG_OF_LIBFDT) += libfdt/
+obj-$(CONFIG_OF_CONTROL) += fdtdec_common.o
+obj-$(CONFIG_OF_CONTROL) += fdtdec.o
+endif
+
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_YMODEM_SUPPORT) += crc16.o
 obj-$(CONFIG_SPL_NET_SUPPORT) += net_utils.o
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#19 lore raw

PATCH 17/29 dm: core: Select device tree control correctly for SPL

In reply to Simon Glass

Some boards will not use device tree for SPL even with driver model. Add the logic to support this.

---

 drivers/core/root.c | 14 ++++++++------
 include/fdtdec.h    | 10 ++++++++++
 2 files changed, 18 insertions(+), 6 deletions(-)
drivers/core/root.c +8 -6
index 9b5c6bb..12d0460 100644
@@ -197,13 +197,15 @@ int dm_init_and_scan(bool pre_reloc_only)
 		debug("dm_scan_platdata() failed: %d\n", ret);
 		return ret;
 	}
-#ifdef CONFIG_OF_CONTROL
-	ret = dm_scan_fdt(gd->fdt_blob, pre_reloc_only);
-	if (ret) {
-		debug("dm_scan_fdt() failed: %d\n", ret);
-		return ret;
+
+	if (OF_CONTROL) {
+		ret = dm_scan_fdt(gd->fdt_blob, pre_reloc_only);
+		if (ret) {
+			debug("dm_scan_fdt() failed: %d\n", ret);
+			return ret;
+		}
 	}
-#endif
+
 	ret = dm_scan_other(pre_reloc_only);
 	if (ret)
 		return ret;
include/fdtdec.h +10 -0
index a49a184..489e8a6 100644
@@ -41,6 +41,16 @@ struct fdt_memory {
 	fdt_addr_t end;
 };
 
+#ifdef CONFIG_OF_CONTROL
+# if defined(CONFIG_SPL_BUILD) && defined(SPL_DISABLE_OF_CONTROL)
+#  define OF_CONTROL 0
+# else
+#  define OF_CONTROL 1
+# endif
+#else
+# define OF_CONTROL 0
+#endif
+
 /*
  * Information about a resource. start is the first address of the resource
  * and end is the last address (inclusive). The length of the resource will
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#20 lore raw

PATCH 18/29 dm: Init device tree as well as driver model in SPL

In reply to Simon Glass

If enabled, make sure that the device tree is available in SPL before setting up driver model.

---

 common/spl/spl.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
common/spl/spl.c +17 -3
index c655332..1e263b3 100644
@@ -139,6 +139,8 @@ static void spl_ram_load_image(void)
 void board_init_r(gd_t *dummy1, ulong dummy2)
 {
 	u32 boot_device;
+	int ret;
+
 	debug(">>spl:board_init_r()\n");
 
 #if defined(CONFIG_SYS_SPL_MALLOC_START)
@@ -149,9 +151,21 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	gd->malloc_limit = CONFIG_SYS_MALLOC_F_LEN;
 	gd->malloc_ptr = 0;
 #endif
-#ifdef CONFIG_SPL_DM
-	dm_init_and_scan(true);
-#endif
+	if (IS_ENABLED(CONFIG_OF_CONTROL) &&
+			!IS_ENABLED(CONFIG_SPL_DISABLE_OF_CONTROL)) {
+		ret = fdtdec_setup();
+		if (ret) {
+			debug("fdtdec_setup() returned error %d\n", ret);
+			hang();
+		}
+	}
+	if (IS_ENABLED(CONFIG_SPL_DM)) {
+		ret = dm_init_and_scan(true);
+		if (ret) {
+			debug("dm_init_and_scan() returned error %d\n", ret);
+			hang();
+		}
+	}
 
 #ifndef CONFIG_PPC
 	/*
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#21 lore raw

PATCH 19/29 dm: serial: Don't support CONFIG_CONS_INDEX with device tree

In reply to Simon Glass

This feature should be deprecated for new boards, and significantly adds to SPL code size. Drop it. Instead, we can use stdout-path in the /chosen node.

---

 drivers/serial/serial-uclass.c | 69 ++++++++++++++++++++++--------------------
 1 file changed, 37 insertions(+), 32 deletions(-)
drivers/serial/serial-uclass.c +37 -32
index 13ba606..6531841 100644
@@ -32,49 +32,54 @@ static const unsigned long baudrate_table[] = CONFIG_SYS_BAUDRATE_TABLE;
 static void serial_find_console_or_panic(void)
 {
 	struct udevice *dev;
-
-#ifdef CONFIG_OF_CONTROL
 	int node;
 
-	/* Check for a chosen console */
-	node = fdtdec_get_chosen_node(gd->fdt_blob, "stdout-path");
-	if (node < 0)
-		node = fdt_path_offset(gd->fdt_blob, "console");
-	if (!uclass_get_device_by_of_offset(UCLASS_SERIAL, node, &dev)) {
-		gd->cur_serial_dev = dev;
-		return;
-	}
-
-	/*
-	 * If the console is not marked to be bound before relocation, bind
-	 * it anyway.
-	 */
-	if (node > 0 &&
-	    !lists_bind_fdt(gd->dm_root, gd->fdt_blob, node, &dev)) {
-		if (!device_probe(dev)) {
+	if (OF_CONTROL) {
+		/* Check for a chosen console */
+		node = fdtdec_get_chosen_node(gd->fdt_blob, "stdout-path");
+		if (node < 0)
+			node = fdt_path_offset(gd->fdt_blob, "console");
+		if (!uclass_get_device_by_of_offset(UCLASS_SERIAL, node,
+						    &dev)) {
 			gd->cur_serial_dev = dev;
 			return;
 		}
-	}
-#endif
-	/*
-	 * Try to use CONFIG_CONS_INDEX if available (it is numbered from 1!).
-	 *
-	 * Failing that, get the device with sequence number 0, or in extremis
-	 * just the first serial device we can find. But we insist on having
-	 * a console (even if it is silent).
-	 */
+
+		/*
+		* If the console is not marked to be bound before relocation,
+		* bind it anyway.
+		*/
+		if (node > 0 &&
+		    !lists_bind_fdt(gd->dm_root, gd->fdt_blob, node, &dev)) {
+			if (!device_probe(dev)) {
+				gd->cur_serial_dev = dev;
+				return;
+			}
+		}
+	} else {
+		/*
+		* Try to use CONFIG_CONS_INDEX if available (it is numbered
+		* from 1!).
+		*
+		* Failing that, get the device with sequence number 0, or in
+		* extremis just the first serial device we can find. But we
+		* insist on having a console (even if it is silent).
+		*/
 #ifdef CONFIG_CONS_INDEX
 #define INDEX (CONFIG_CONS_INDEX - 1)
 #else
 #define INDEX 0
 #endif
-	if (uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &dev) &&
-	    uclass_get_device(UCLASS_SERIAL, INDEX, &dev) &&
-	    (uclass_first_device(UCLASS_SERIAL, &dev) || !dev))
-		panic_str("No serial driver found");
+		if (!uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &dev) ||
+		    !uclass_get_device(UCLASS_SERIAL, INDEX, &dev) ||
+		    (!uclass_first_device(UCLASS_SERIAL, &dev) || dev)) {
+			gd->cur_serial_dev = dev;
+			return;
+		}
 #undef INDEX
-	gd->cur_serial_dev = dev;
+	}
+
+	panic_str("No serial driver found");
 }
 
 /* Called prior to relocation */
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#22 lore raw

PATCH 20/29 Remove SPL undefine of CONFIG_OF_CONTROL

In reply to Simon Glass

Allow SPL to be built with this option so that we can support device tree control. Disable the simple bus for now in SPL. It may be needed later.

---

 drivers/core/Makefile      | 2 ++
 include/config_uncmd_spl.h | 2 ++
 scripts/Makefile.uncmd_spl | 2 ++
 3 files changed, 6 insertions(+)
drivers/core/Makefile +2 -0
index f14695b..a3fec38 100644
@@ -5,5 +5,7 @@
 #
 
 obj-$(CONFIG_DM)	+= device.o lists.o root.o uclass.o util.o
+ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_OF_CONTROL) += simple-bus.o
+endif
 obj-$(CONFIG_DM_DEVICE_REMOVE)	+= device-remove.o
include/config_uncmd_spl.h +2 -0
index 38cb0e8..c191f56 100644
@@ -20,7 +20,9 @@
 #undef CONFIG_CMD_SNTP
 #undef CONFIG_CMD_TFTPPUT
 #undef CONFIG_CMD_TFTPSRV
+#ifdef CONFIG_SPL_DISABLE_OF_CONTROL
 #undef CONFIG_OF_CONTROL
+#endif
 
 #ifndef CONFIG_SPL_DM
 #undef CONFIG_DM_SERIAL
scripts/Makefile.uncmd_spl +2 -0
index 343c3fc..4f05652 100644
@@ -3,7 +3,9 @@
 # TODO: Invent a better way
 
 ifdef CONFIG_SPL_BUILD
+ifdef CONFIG_SPL_DISABLE_OF_CONTROL
 CONFIG_OF_CONTROL=
+endif
 
 ifndef CONFIG_SPL_DM
 CONFIG_DM_SERIAL=
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#23 lore raw

PATCH 21/29 fdt: arm: Build device tree in SPL

In reply to Simon Glass

For SPL we want to support building device tree files. Due to limited memory some boards will include only a subset of the full device tree file. So build these files separately for SPL.

SPL does not relocate itself so we cannot use the BSS space for the device tree. Instead we place it at the end of BSS and provide a 'pad' file to overlay on the BSS space.

So far, CONFIG_OF_EMBED is not supported for SPL. There does not seem to be any reason for it other than debugging.

---

 arch/arm/cpu/u-boot-spl.lds |  2 +-
 arch/arm/dts/Makefile       |  2 +-
 dts/Makefile                |  9 ++++++---
 scripts/Makefile.lib        | 12 ++++++++----
 scripts/Makefile.spl        | 35 +++++++++++++++++++++++++++++++++++
 5 files changed, 51 insertions(+), 9 deletions(-)
arch/arm/cpu/u-boot-spl.lds +1 -1
index a8be204..4b6e0f6 100644
@@ -66,7 +66,7 @@ SECTIONS
 		 . = ALIGN(4);
 		__bss_end = .;
 	}
-
+	__bss_size = __bss_end - __bss_start;
 	.dynsym _image_binary_end : { *(.dynsym) }
 	.dynbss : { *(.dynbss) }
 	.dynstr : { *(.dynstr*) }
arch/arm/dts/Makefile +1 -1
index 121725e..6b9d8ea 100644
@@ -56,7 +56,7 @@ targets += $(dtb-y)
 DTC_FLAGS += -R 4
 
 PHONY += dtbs
-dtbs: $(addprefix $(obj)/, $(dtb-y))
+dtbs: $(addprefix $(DTB_PATH)$(obj)/, $(dtb-y))
 	@:
 
 clean-files := *.dtb
dts/Makefile +6 -3
index d3122aa..f8f06f0 100644
@@ -6,6 +6,7 @@
 
 # This Makefile builds the internal U-Boot fdt if CONFIG_OF_CONTROL is
 # enabled. See doc/README.fdt-control for more details.
+# DTB_PATH is empty for U-Boot proper, and "spl/" for SPL
 
 DEVICE_TREE ?= $(CONFIG_DEFAULT_DEVICE_TREE:"%"=%)
 ifeq ($(DEVICE_TREE),)
@@ -13,11 +14,13 @@ DEVICE_TREE := unset
 endif
 
 ifneq ($(EXT_DTB),)
-DTB := $(EXT_DTB)
+BASE_DTB := $(EXT_DTB)
 else
-DTB := arch/$(ARCH)/dts/$(DEVICE_TREE).dtb
+BASE_DTB := arch/$(ARCH)/dts/$(DEVICE_TREE).dtb
 endif
 
+DTB	:= $(DTB_PATH)$(BASE_DTB)
+
 $(obj)/dt.dtb: $(DTB) FORCE
 	$(call if_changed,shipped)
 
@@ -33,7 +36,7 @@ $(DTB): arch-dtbs
 	/bin/false)
 
 arch-dtbs:
-	$(Q)$(MAKE) $(build)=arch/$(ARCH)/dts dtbs
+	$(Q)$(MAKE) $(build)=arch/$(ARCH)/dts DTB_PATH=$(DTB_PATH) dtbs
 
 .SECONDARY: $(obj)/dt.dtb.S
 
scripts/Makefile.lib +8 -4
index 13af604..04d9b50 100644
@@ -150,11 +150,11 @@ cpp_flags      = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE)     \
 
 ld_flags       = $(LDFLAGS) $(ldflags-y)
 
-# Modified for U-Boot
+# Modified for U-Boot, include KBUILD_CPPFLAGS for CONFIG_SPL/TPL_BUILD
 dtc_cpp_flags  = -Wp,-MD,$(depfile).pre.tmp -nostdinc                    \
 		 -I$(srctree)/arch/$(ARCH)/dts                           \
 		 -I$(srctree)/arch/$(ARCH)/dts/include                   \
-		 -undef -D__DTS__
+		 -undef -D__DTS__ $(KBUILD_CPPFLAGS)
 
 # Finds the multi-part object the current object will be linked into
 modname-multi = $(sort $(foreach m,$(multi-used),\
@@ -272,15 +272,19 @@ cmd_dt_S_dtb=						\
 $(obj)/%.dtb.S: $(obj)/%.dtb
 	$(call cmd,dt_S_dtb)
 
+# Can we remove the duplication here?
+quiet_cmd_dtcspl = DTC SPL $@
+# Modified for U-Boot
 quiet_cmd_dtc = DTC     $@
 # Modified for U-Boot
-cmd_dtc = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
+cmd_dtc = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp  -o $(dtc-tmp) $< ; \
 	dtc -O dtb -o $@ -b 0 \
 		-i $(dir $<) $(DTC_FLAGS) \
 		-d $(depfile).dtc.tmp $(dtc-tmp) ; \
 	cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
 
-$(obj)/%.dtb: $(src)/%.dts FORCE
+$(obj)/%.dtb spl/$(obj)/%.dtb tpl/$(obj)/%.dtb: $(src)/%.dts FORCE
+	$(Q)mkdir -p $(dir $@)
 	$(call if_changed_dep,dtc)
 
 dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
scripts/Makefile.spl +35 -0
index ea67137..def962c 100644
@@ -31,10 +31,14 @@ endif
 
 ifeq ($(CONFIG_TPL_BUILD),y)
 SPL_BIN := u-boot-tpl
+DTB_PATH := tpl/
 else
 SPL_BIN := u-boot-spl
+DTB_PATH := spl/
 endif
 
+export DTB_PATH
+
 include $(srctree)/config.mk
 include $(srctree)/arch/$(ARCH)/Makefile
 
@@ -50,6 +54,7 @@ HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makef
 
 libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/)
 libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
+libs-$(CONFIG_OF_EMBED) += dts/
 
 libs-$(CONFIG_SPL_FRAMEWORK) += common/spl/
 libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/
@@ -151,6 +156,8 @@ boot.bin: $(obj)/u-boot-spl.bin
 
 ALL-y	+= $(obj)/$(SPL_BIN).bin $(obj)/$(SPL_BIN).cfg
 
+ALL-$(CONFIG_OF_SEPARATE) += $(obj)/$(SPL_BIN)-pad.bin $(obj)/$(SPL_BIN)-dtb.bin
+
 ifdef CONFIG_SAMSUNG
 ALL-y	+= $(obj)/$(BOARD)-spl.bin
 endif
@@ -163,8 +170,36 @@ ifeq ($(CONFIG_SYS_SOC),"at91")
 ALL-y	+= boot.bin
 endif
 
+checkdtc:
+	@if test $(call dtc-version) -lt 0104; then \
+		echo '*** Your dtc is too old, please upgrade to dtc 1.4 or newer'; \
+		false; \
+	fi
+
 all:	$(ALL-y)
 
+quiet_cmd_cat = CAT     $@
+cmd_cat = cat $(filter-out $(PHONY), $^) > $@
+
+$(obj)/$(SPL_BIN)-dtb.bin: $(obj)/$(SPL_BIN).bin $(obj)/$(SPL_BIN)-pad.bin \
+		$(obj)/$(SPL_BIN).dtb FORCE
+	$(call if_changed,cat)
+
+# Create a file that provings pads from the end of u-boot-spl.bin to bss_end
+$(obj)/$(SPL_BIN)-pad.bin: $(obj)/$(SPL_BIN)
+	@bss_size_str=$(shell $(NM) $< | awk 'BEGIN {size = 0} /__bss_size/ {size = $$1} END {print "ibase=16; " size}' | bc); \
+	dd if=/dev/zero of=$@ bs=1 count=$${bss_size_str} 2>/dev/null;
+
+quiet_cmd_copy = COPY    $@
+      cmd_copy = cp $< $@
+
+$(obj)/$(SPL_BIN).dtb: $(obj)/dts/dt.dtb
+	$(call cmd,copy)
+
+PHONY += dtbs
+dtbs $(obj)/dts/dt.dtb: checkdtc $(obj)/$(SPL_BIN)
+	$(Q)$(MAKE) $(build)=$(obj)/dts DTB_PATH=$(DTB_PATH) dtbs
+
 quiet_cmd_cpp_cfg = CFG     $@
 cmd_cpp_cfg = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \
 		-D__ASSEMBLY__ -x assembler-with-cpp -P -dM -E -o $@ $<
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#24 lore raw

PATCH 22/29 dm: rockchip: Add serial support

In reply to Simon Glass

Add support for the Rockchip serial device using the ns16550 driver. This uses driver model and device tree for both SPL and U-Boot proper.

---

 drivers/serial/Kconfig           |  9 +++++++++
 drivers/serial/Makefile          |  1 +
 drivers/serial/serial_rockchip.c | 41 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+)
 create mode 100644 drivers/serial/serial_rockchip.c
drivers/serial/Kconfig +9 -0
index 54e6f26..2e87199 100644
@@ -76,6 +76,15 @@ config DEBUG_UART_SHIFT
 	  value. Use this value to specify the shift to use, where 0=byte
 	  registers, 2=32-bit word registers, etc.
 
+config ROCKCHIP_SERIAL
+	bool "Rockchip on-chip UART support"
+	depends on ARCH_UNIPHIER && DM_SERIAL
+	help
+	  Select this to enable a debug UART for Rockchip devices. This uses
+	  the ns16550 driver. You will need to #define CONFIG_SYS_NS16550 in
+	  your board config header. The clock input is automatically set to
+	  use the oscillator (24MHz).
+
 config UNIPHIER_SERIAL
 	bool "UniPhier on-chip UART support"
 	depends on ARCH_UNIPHIER && DM_SERIAL
drivers/serial/Makefile +1 -0
index b385852..434d7fc 100644
@@ -39,6 +39,7 @@ obj-$(CONFIG_ZYNQ_SERIAL) += serial_zynq.o
 obj-$(CONFIG_BFIN_SERIAL) += serial_bfin.o
 obj-$(CONFIG_FSL_LPUART) += serial_lpuart.o
 obj-$(CONFIG_MXS_AUART) += mxs_auart.o
+obj-$(CONFIG_ROCKCHIP_SERIAL) += serial_rockchip.o
 obj-$(CONFIG_ARC_SERIAL) += serial_arc.o
 obj-$(CONFIG_TEGRA_SERIAL) += serial_tegra.o
 obj-$(CONFIG_UNIPHIER_SERIAL) += serial_uniphier.o
drivers/serial/serial_rockchip.c new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
2.2.0.rc0.207.ga3a616c
#25 lore raw

PATCH 23/29 rockchip: Bring in RK3288 device tree file includes and bindings

In reply to Simon Glass

Bring in required device tree files from Linux. Since mainline Linux is somewhat behind, use the files from the Chromium tree. We can re-sync once further code is acccepted upstream.

---

 arch/arm/dts/rk3288-thermal.dtsi                   |   90 ++
 arch/arm/dts/rk3288.dtsi                           | 1466 ++++++++++++++++++++
 .../clock/rockchip,rk3288-cru.txt                  |   61 +
 doc/device-tree-bindings/clock/rockchip.txt        |   77 +
 .../pinctrl/rockchip,pinctrl.txt                   |  157 +++
 .../thermal/rockchip-thermal.txt                   |   68 +
 include/dt-bindings/clock/rk3288-cru.h             |  378 +++++
 include/dt-bindings/clock/rockchip,rk808.h         |   11 +
 include/dt-bindings/pinctrl/rockchip.h             |   34 +
 include/dt-bindings/power-domain/rk3288.h          |   11 +
 include/dt-bindings/thermal/thermal.h              |   17 +
 11 files changed, 2370 insertions(+)
 create mode 100644 arch/arm/dts/rk3288-thermal.dtsi
 create mode 100644 arch/arm/dts/rk3288.dtsi
 create mode 100644 doc/device-tree-bindings/clock/rockchip,rk3288-cru.txt
 create mode 100644 doc/device-tree-bindings/clock/rockchip.txt
 create mode 100644 doc/device-tree-bindings/pinctrl/rockchip,pinctrl.txt
 create mode 100644 doc/device-tree-bindings/thermal/rockchip-thermal.txt
 create mode 100644 include/dt-bindings/clock/rk3288-cru.h
 create mode 100644 include/dt-bindings/clock/rockchip,rk808.h
 create mode 100644 include/dt-bindings/pinctrl/rockchip.h
 create mode 100644 include/dt-bindings/power-domain/rk3288.h
 create mode 100644 include/dt-bindings/thermal/thermal.h
arch/arm/dts/rk3288-thermal.dtsi new file +90 -0
new file mode 100644
index 0000000..1fde97c
@@ -0,0 +1,90 @@
+/*
+ * Device Tree Source for RK3288 SoC thermal
+ *
+ * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2.  This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include <dt-bindings/thermal/thermal.h>
+
+reserve_thermal: reserve_thermal {
+	polling-delay-passive = <1000>; /* milliseconds */
+	polling-delay = <5000>; /* milliseconds */
+
+			/* sensor	ID */
+	thermal-sensors = <&tsadc	0>;
+
+};
+
+cpu_thermal: cpu_thermal {
+	polling-delay-passive = <100>; /* milliseconds */
+	polling-delay = <5000>; /* milliseconds */
+
+			/* sensor	ID */
+	thermal-sensors = <&tsadc	1>;
+	linux,hwmon;
+
+	trips {
+		cpu_alert0: cpu_alert0 {
+			temperature = <70000>; /* millicelsius */
+			hysteresis = <2000>; /* millicelsius */
+			type = "passive";
+		};
+		cpu_alert1: cpu_alert1 {
+			temperature = <75000>; /* millicelsius */
+			hysteresis = <2000>; /* millicelsius */
+			type = "passive";
+		};
+		cpu_crit: cpu_crit {
+			temperature = <100000>; /* millicelsius */
+			hysteresis = <2000>; /* millicelsius */
+			type = "critical";
+		};
+	};
+
+	cooling-maps {
+		map0 {
+			trip = <&cpu_alert0>;
+			cooling-device =
+				<&cpu0 THERMAL_NO_LIMIT 6>;
+		};
+		map1 {
+			trip = <&cpu_alert1>;
+			cooling-device =
+				<&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+		};
+	};
+};
+
+gpu_thermal: gpu_thermal {
+	polling-delay-passive = <100>; /* milliseconds */
+	polling-delay = <5000>; /* milliseconds */
+
+			/* sensor	ID */
+	thermal-sensors = <&tsadc	2>;
+	linux,hwmon;
+
+	trips {
+		gpu_alert0: gpu_alert0 {
+			temperature = <80000>; /* millicelsius */
+			hysteresis = <2000>; /* millicelsius */
+			type = "passive";
+		};
+		gpu_crit: gpu_crit {
+			temperature = <100000>; /* millicelsius */
+			hysteresis = <2000>; /* millicelsius */
+			type = "critical";
+		};
+	};
+
+	cooling-maps {
+		map0 {
+			trip = <&gpu_alert0>;
+			cooling-device =
+				<&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+		};
+	};
+};
arch/arm/dts/rk3288.dtsi new file +1466 -0

1,466 lines not on this page · raw message

doc/device-tree-bindings/clock/rockchip,rk3288-cru.txt new file +61 -0

61 lines not on this page · raw message

doc/device-tree-bindings/clock/rockchip.txt new file +77 -0

77 lines not on this page · raw message

doc/device-tree-bindings/pinctrl/rockchip,pinctrl.txt new file +157 -0

157 lines not on this page · raw message

doc/device-tree-bindings/thermal/rockchip-thermal.txt new file +68 -0

68 lines not on this page · raw message

include/dt-bindings/clock/rk3288-cru.h new file +378 -0

378 lines not on this page · raw message

include/dt-bindings/clock/rockchip,rk808.h new file +11 -0
new file mode 100644
index 0000000..1a87343
@@ -0,0 +1,11 @@
+/*
+ * This header provides constants clk index RK808 pmic clkout
+ */
+#ifndef _CLK_ROCKCHIP_RK808
+#define _CLK_ROCKCHIP_RK808
+
+/* CLOCKOUT index */
+#define RK808_CLKOUT0		0
+#define RK808_CLKOUT1		1
+
+#endif
include/dt-bindings/pinctrl/rockchip.h new file +34 -0
new file mode 100644
index 0000000..743e66a
@@ -0,0 +1,34 @@
+/*
+ * Header providing constants for Rockchip pinctrl bindings.
+ *
+ * Copyright (c) 2013 MundoReader S.L.
+ * Author: Heiko Stuebner <[email protected]>
+ *
+ * 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.
+ */
+
+#ifndef __DT_BINDINGS_ROCKCHIP_PINCTRL_H__
+#define __DT_BINDINGS_ROCKCHIP_PINCTRL_H__
+
+#define RK_GPIO0	0
+#define RK_GPIO1	1
+#define RK_GPIO2	2
+#define RK_GPIO3	3
+#define RK_GPIO4	4
+#define RK_GPIO6	6
+
+#define RK_FUNC_GPIO	0
+#define RK_FUNC_1	1
+#define RK_FUNC_2	2
+#define RK_FUNC_3	3
+#define RK_FUNC_4	4
+
+#endif
include/dt-bindings/power-domain/rk3288.h new file +11 -0
new file mode 100644
index 0000000..ca68c11
@@ -0,0 +1,11 @@
+#ifndef __DT_BINDINGS_POWER_DOMAIN_RK3288_H__
+#define __DT_BINDINGS_POWER_DOMAIN_RK3288_H__
+
+/* RK3288 power domain index */
+#define RK3288_PD_GPU          0
+#define RK3288_PD_VIO          1
+#define RK3288_PD_VIDEO        2
+#define RK3288_PD_HEVC         3
+#define RK3288_PD_PERI         4
+
+#endif
include/dt-bindings/thermal/thermal.h new file +17 -0
new file mode 100644
index 0000000..59822a9
@@ -0,0 +1,17 @@
+/*
+ * This header provides constants for most thermal bindings.
+ *
+ * Copyright (C) 2013 Texas Instruments
+ *	Eduardo Valentin <[email protected]>
+ *
+ * GPLv2 only
+ */
+
+#ifndef _DT_BINDINGS_THERMAL_THERMAL_H
+#define _DT_BINDINGS_THERMAL_THERMAL_H
+
+/* On cooling devices upper and lower limits */
+#define THERMAL_NO_LIMIT		(-1UL)
+
+#endif
+
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#26 lore raw

PATCH 24/29 rockchip: dts: Adjust device tree files for U-Boot SPL

In reply to Simon Glass

The 'fdtgrep' tool would probably provide a better solution here, but for now we can use the C preprocessor to remove the parts of the device tree which are not needed in SPL.

---

 arch/arm/dts/rk3288.dtsi | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
arch/arm/dts/rk3288.dtsi +14 -0
index 8251441..8386bb2 100644
@@ -22,8 +22,11 @@
 / {
 	compatible = "rockchip,rk3288";
 
+#ifndef CONFIG_SPL_BUILD
 	interrupt-parent = <&gic>;
+#endif
 	aliases {
+#ifndef CONFIG_SPL_BUILD
 		i2c0 = &i2c0;
 		i2c1 = &i2c1;
 		i2c2 = &i2c2;
@@ -38,16 +41,22 @@
 		mshc1 = &sdmmc;
 		mshc2 = &sdio0;
 		mshc3 = &sdio1;
+#endif
+#ifndef CONFIG_SPL_BUILD
 		serial0 = &uart0;
 		serial1 = &uart1;
+#endif
 		serial2 = &uart2;
+#ifndef CONFIG_SPL_BUILD
 		serial3 = &uart3;
 		serial4 = &uart4;
 		spi0 = &spi0;
 		spi1 = &spi1;
 		spi2 = &spi2;
+#endif
 	};
 
+#ifndef CONFIG_SPL_BUILD
 	cpus {
 		#address-cells = <1>;
 		#size-cells = <0>;
@@ -342,6 +351,7 @@
 		pinctrl-0 = <&uart1_xfer>;
 		status = "disabled";
 	};
+#endif
 
 	uart2: serial at ff690000 {
 		compatible = "rockchip,rk3288-uart", "snps,dw-apb-uart";
@@ -349,12 +359,15 @@
 		interrupts = <GIC_SPI 57 IRQ_TYPE_LEVEL_HIGH>;
 		reg-shift = <2>;
 		reg-io-width = <4>;
+#ifndef CONFIG_SPL_BUILD
 		clocks = <&cru SCLK_UART2>, <&cru PCLK_UART2>;
 		clock-names = "baudclk", "apb_pclk";
 		pinctrl-names = "default";
 		pinctrl-0 = <&uart2_xfer>;
+#endif
 		status = "disabled";
 	};
+#ifndef CONFIG_SPL_BUILD
 	uart3: serial at ff1b0000 {
 		compatible = "rockchip,rk3288-uart", "snps,dw-apb-uart";
 		reg = <0xff1b0000 0x100>;
@@ -1463,4 +1476,5 @@
 				 <&cru HCLK_VCODEC>;
 		};
 	};
+#endif
 };
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#27 lore raw

PATCH 25/29 rockchip: Add base SoC files

In reply to Simon Glass

Add some basic files required to allow the SoC to start up. This is a minimal set, enough only to display a serial message in SPL and hang.

---

 arch/arm/Kconfig                           |   9 ++
 arch/arm/Makefile                          |   1 +
 arch/arm/include/asm/arch-rockchip/clock.h |  12 ++
 arch/arm/include/asm/arch-rockchip/gpio.h  |   5 +
 arch/arm/include/asm/arch-rockchip/grf.h   | 181 +++++++++++++++++++++++++++++
 arch/arm/mach-rockchip/Kconfig             |  44 +++++++
 arch/arm/mach-rockchip/Makefile            |  12 ++
 arch/arm/mach-rockchip/board-spl.c         |  54 +++++++++
 arch/arm/mach-rockchip/board.c             |  17 +++
 arch/arm/mach-rockchip/common.c            |  11 ++
 arch/arm/mach-rockchip/rk3288/Kconfig      |   6 +
 11 files changed, 352 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-rockchip/clock.h
 create mode 100644 arch/arm/include/asm/arch-rockchip/gpio.h
 create mode 100644 arch/arm/include/asm/arch-rockchip/grf.h
 create mode 100644 arch/arm/mach-rockchip/Kconfig
 create mode 100644 arch/arm/mach-rockchip/Makefile
 create mode 100644 arch/arm/mach-rockchip/board-spl.c
 create mode 100644 arch/arm/mach-rockchip/board.c
 create mode 100644 arch/arm/mach-rockchip/common.c
 create mode 100644 arch/arm/mach-rockchip/rk3288/Kconfig
arch/arm/Kconfig +9 -0
index f0e6dec..1eee2d8 100644
@@ -693,6 +693,13 @@ config ARCH_UNIPHIER
 	select OF_CONTROL
 	select SPL_DISABLE_OF_CONTROL
 
+config ARCH_ROCKCHIP
+	bool "Support Rockchip SoCs"
+	select SUPPORT_SPL
+	select SPL
+	select OF_CONTROL
+	select CPU_V7
+
 endchoice
 
 source "arch/arm/mach-at91/Kconfig"
@@ -721,6 +728,8 @@ source "arch/arm/mach-orion5x/Kconfig"
 
 source "arch/arm/cpu/armv7/rmobile/Kconfig"
 
+source "arch/arm/mach-rockchip/Kconfig"
+
 source "arch/arm/cpu/armv7/s5pc1xx/Kconfig"
 
 source "arch/arm/mach-tegra/Kconfig"
arch/arm/Makefile +1 -0
index 878ae26..29945c4 100644
@@ -14,6 +14,7 @@ machine-$(CONFIG_KIRKWOOD)		+= kirkwood
 machine-$(CONFIG_ARCH_NOMADIK)		+= nomadik
 # TODO: rename CONFIG_ORION5X -> CONFIG_ARCH_ORION5X
 machine-$(CONFIG_ORION5X)		+= orion5x
+machine-$(CONFIG_ARCH_ROCKCHIP)		+= rockchip
 machine-$(CONFIG_TEGRA)			+= tegra
 machine-$(CONFIG_ARCH_VERSATILE)	+= versatile
 
arch/arm/include/asm/arch-rockchip/clock.h new file +12 -0
new file mode 100644
index 0000000..9314585
@@ -0,0 +1,12 @@
+/*
+ * (C) Copyright 2015 Google, Inc
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#ifndef _ASM_ARCH_CLOCK_H
+#define _ASM_ARCH_CLOCK_H
+
+#define OSC_HZ		(24 * 1000 * 1000)
+
+#endif
arch/arm/include/asm/arch-rockchip/gpio.h new file +5 -0
new file mode 100644
index 0000000..607949c
@@ -0,0 +1,5 @@
+/*
+ * (C) Copyright 2015 Google, Inc
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
arch/arm/include/asm/arch-rockchip/grf.h new file +181 -0

181 lines not on this page · raw message

arch/arm/mach-rockchip/Kconfig new file +44 -0

44 lines not on this page · raw message

arch/arm/mach-rockchip/Makefile new file +12 -0
new file mode 100644
index 0000000..0cef0a2
@@ -0,0 +1,12 @@
+#
+# Copyright (c) 2014 Google, Inc
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+ifdef CONFIG_SPL_BUILD
+obj-y += board-spl.o
+else
+obj-y += board.o
+endif
+obj-y += common.o
arch/arm/mach-rockchip/board-spl.c new file +54 -0

54 lines not on this page · raw message

arch/arm/mach-rockchip/board.c new file +17 -0
new file mode 100644
index 0000000..38d2b40
@@ -0,0 +1,17 @@
+/*
+ * (C) Copyright 2015 Google, Inc
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#include <common.h>
+
+int board_init(void)
+{
+	return 0;
+}
+
+int dram_init(void)
+{
+	return 0;
+}
arch/arm/mach-rockchip/common.c new file +11 -0
new file mode 100644
index 0000000..51ea34d
@@ -0,0 +1,11 @@
+/*
+ * (C) Copyright 2015 Google, Inc
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#include <common.h>
+
+void reset_cpu(ulong addr)
+{
+}
arch/arm/mach-rockchip/rk3288/Kconfig new file +6 -0
new file mode 100644
index 0000000..26d5951
@@ -0,0 +1,6 @@
+if ROCKCHIP_RK3288
+
+config SYS_SOC
+	default "rockchip"
+
+endif
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#28 lore raw

PATCH 26/29 rockchip: Add basic support for firefly-rk3288

In reply to Simon Glass

The Firefly RK3288 is a suitable target board for initial mainline Rockchip support. It includes a good set of peripherals, a recent SoC and it is readily available.

This adds only some basic files required to allow the baord to display a serial message in SPL and hang.

---

 arch/arm/dts/Makefile                         |   2 +
 arch/arm/dts/rk3288-firefly.dts               |  82 +++++
 arch/arm/dts/rk3288-firefly.dtsi              | 496 ++++++++++++++++++++++++++
 arch/arm/mach-rockchip/rk3288/Kconfig         |  10 +
 board/firefly/firefly-rk3288/Kconfig          |  15 +
 board/firefly/firefly-rk3288/MAINTAINERS      |   6 +
 board/firefly/firefly-rk3288/Makefile         |   7 +
 board/firefly/firefly-rk3288/firefly-rk3288.c |   7 +
 configs/firefly-rk3288_defconfig              |  11 +
 include/configs/firefly-rk3288.h              |  50 +++
 10 files changed, 686 insertions(+)
 create mode 100644 arch/arm/dts/rk3288-firefly.dts
 create mode 100644 arch/arm/dts/rk3288-firefly.dtsi
 create mode 100644 board/firefly/firefly-rk3288/Kconfig
 create mode 100644 board/firefly/firefly-rk3288/MAINTAINERS
 create mode 100644 board/firefly/firefly-rk3288/Makefile
 create mode 100644 board/firefly/firefly-rk3288/firefly-rk3288.c
 create mode 100644 configs/firefly-rk3288_defconfig
 create mode 100644 include/configs/firefly-rk3288.h
arch/arm/dts/Makefile +2 -0
index 6b9d8ea..234254f 100644
@@ -15,6 +15,8 @@ dtb-$(CONFIG_EXYNOS5) += exynos5250-arndale.dtb \
 	exynos5420-peach-pit.dtb \
 	exynos5800-peach-pi.dtb \
 	exynos5422-odroidxu3.dtb
+dtb-$(CONFIG_ARCH_ROCKCHIP) += \
+	rk3288-firefly.dtb
 dtb-$(CONFIG_TEGRA) += tegra20-harmony.dtb \
 	tegra20-medcom-wide.dtb \
 	tegra20-paz00.dtb \
arch/arm/dts/rk3288-firefly.dts new file +82 -0

82 lines not on this page · raw message

arch/arm/dts/rk3288-firefly.dtsi new file +496 -0

496 lines not on this page · raw message

arch/arm/mach-rockchip/rk3288/Kconfig +10 -0
index 26d5951..7a77615 100644
@@ -1,6 +1,16 @@
 if ROCKCHIP_RK3288
 
+config TARGET_FIREFLY_RK3288
+	bool "Firefly-RK3288"
+	help
+	  Firefly is a RK3288-based development board with 2 USB ports,
+	  HDMI, VGA, micro-SD card, audio, WiFi  and Gigabit Ethernet, It
+	  also includes on-board eMMC and 1GB of SDRAM. Expansion connectors
+	  provide access to display pins, I2C, SPI, UART and GPIOs.
+
 config SYS_SOC
 	default "rockchip"
 
+source "board/firefly/firefly-rk3288/Kconfig"
+
 endif
board/firefly/firefly-rk3288/Kconfig new file +15 -0
new file mode 100644
index 0000000..1c2bca8
@@ -0,0 +1,15 @@
+if TARGET_FIREFLY_RK3288
+
+config SYS_BOARD
+	default "firefly-rk3288"
+
+config SYS_VENDOR
+	default "firefly"
+
+config SYS_CONFIG_NAME
+	default "firefly-rk3288"
+
+config BOARD_SPECIFIC_OPTIONS # dummy
+	def_bool y
+
+endif
board/firefly/firefly-rk3288/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000..42db0bd
@@ -0,0 +1,6 @@
+FIREFLY
+M:	Simon Glass <[email protected]>
+S:	Maintained
+F:	board/firefly/firefly-rk3288
+F:	include/configs/firefly-rk3288.h
+F:	configs/firefly-rk3288_defconfig
board/firefly/firefly-rk3288/Makefile new file +7 -0
new file mode 100644
index 0000000..6716845
@@ -0,0 +1,7 @@
+#
+# (C) Copyright 2015 Google, Inc
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-y	+= firefly-rk3288.o
board/firefly/firefly-rk3288/firefly-rk3288.c new file +7 -0
new file mode 100644
index 0000000..5119e95
@@ -0,0 +1,7 @@
+/*
+ * (C) Copyright 2015 Google, Inc
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#include <common.h>
configs/firefly-rk3288_defconfig new file +11 -0
new file mode 100644
index 0000000..a6db3d9
@@ -0,0 +1,11 @@
++S:CONFIG_ARM=y
++S:CONFIG_ARCH_ROCKCHIP=y
++S:CONFIG_ROCKCHIP_RK3288=y
++S:CONFIG_TARGET_FIREFLY_RK3288=y
++S:CONFIG_DEFAULT_DEVICE_TREE="rk3288-firefly"
++S:CONFIG_DEBUG_UART=y
++S:CONFIG_DEBUG_UART_NS16550=y
++S:CONFIG_DEBUG_UART_BASE=0xff690000
++S:CONFIG_DEBUG_UART_CLOCK=24000000
++S:CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_USE_PRIVATE_LIBGCC=y
include/configs/firefly-rk3288.h new file +50 -0

50 lines not on this page · raw message

Signature · 1 line
2.2.0.rc0.207.ga3a616c
#29 lore raw

PATCH 27/29 mkimage: Display a better list of available image types

In reply to Simon Glass

Offer to display the available image types in help. Also, rather than hacking the genimg_get_type_id() function to display a list of types, do this in the tool. Also, sort the list.

The list of image types is quite long, and hard to discover. Print it out when we show help information.

---

 common/image.c  | 54 +++++++++++++++++++++++++++++-----------------------
 include/image.h | 11 +++++++++++
 tools/mkimage.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
 3 files changed, 93 insertions(+), 31 deletions(-)
common/image.c +30 -24
index a911aa9..7faa91a 100644
@@ -541,6 +541,15 @@ void genimg_print_time(time_t timestamp)
 }
 #endif
 
+const table_entry_t *get_table_entry(const table_entry_t *table, int id)
+{
+	for (; table->id >= 0; ++table) {
+		if (table->id == id)
+			return table;
+	}
+	return NULL;
+}
+
 /**
  * get_table_entry_name - translate entry id to long name
  * @table: pointer to a translation table for entries of a specific type
@@ -557,15 +566,14 @@ void genimg_print_time(time_t timestamp)
  */
 char *get_table_entry_name(const table_entry_t *table, char *msg, int id)
 {
-	for (; table->id >= 0; ++table) {
-		if (table->id == id)
+	table = get_table_entry(table, id);
+	if (!table)
+		return msg;
 #if defined(USE_HOSTCC) || !defined(CONFIG_NEEDS_MANUAL_RELOC)
-			return table->lname;
+	return table->lname;
 #else
-			return table->lname + gd->reloc_off;
+	return table->lname + gd->reloc_off;
 #endif
-	}
-	return (msg);
 }
 
 const char *genimg_get_os_name(uint8_t os)
@@ -584,6 +592,20 @@ const char *genimg_get_type_name(uint8_t type)
 	return (get_table_entry_name(uimage_type, "Unknown Image", type));
 }
 
+const char *genimg_get_type_short_name(uint8_t type)
+{
+	const table_entry_t *table;
+
+	table = get_table_entry(uimage_type, type);
+	if (!table)
+		return "unknown";
+#if defined(USE_HOSTCC) || !defined(CONFIG_NEEDS_MANUAL_RELOC)
+	return table->sname;
+#else
+	return table->sname + gd->reloc_off;
+#endif
+}
+
 const char *genimg_get_comp_name(uint8_t comp)
 {
 	return (get_table_entry_name(uimage_comp, "Unknown Compression",
@@ -608,23 +630,7 @@ int get_table_entry_id(const table_entry_t *table,
 		const char *table_name, const char *name)
 {
 	const table_entry_t *t;
-#ifdef USE_HOSTCC
-	int first = 1;
-
-	for (t = table; t->id >= 0; ++t) {
-		if (t->sname && strcasecmp(t->sname, name) == 0)
-			return(t->id);
-	}
 
-	fprintf(stderr, "\nInvalid %s Type - valid names are", table_name);
-	for (t = table; t->id >= 0; ++t) {
-		if (t->sname == NULL)
-			continue;
-		fprintf(stderr, "%c %s", (first) ? ':' : ',', t->sname);
-		first = 0;
-	}
-	fprintf(stderr, "\n");
-#else
 	for (t = table; t->id >= 0; ++t) {
 #ifdef CONFIG_NEEDS_MANUAL_RELOC
 		if (t->sname && strcmp(t->sname + gd->reloc_off, name) == 0)
@@ -634,8 +640,8 @@ int get_table_entry_id(const table_entry_t *table,
 			return (t->id);
 	}
 	debug("Invalid %s Type: %s\n", table_name, name);
-#endif /* USE_HOSTCC */
-	return (-1);
+
+	return -1;
 }
 
 int genimg_get_os_id(const char *name)
include/image.h +11 -0
index 0e6af00..da17a6b 100644
@@ -243,6 +243,8 @@ struct lmb;
 #define IH_TYPE_SOCFPGAIMAGE	19	/* Altera SOCFPGA Preloader	*/
 #define IH_TYPE_X86_SETUP	20	/* x86 setup.bin Image		*/
 
+#define IH_TYPE_COUNT		21	/* Number of image types */
+
 /*
  * Compression Types
  */
@@ -408,6 +410,15 @@ char *get_table_entry_name(const table_entry_t *table, char *msg, int id);
 const char *genimg_get_os_name(uint8_t os);
 const char *genimg_get_arch_name(uint8_t arch);
 const char *genimg_get_type_name(uint8_t type);
+
+/**
+ * genimg_get_type_short_name() - get the short name for an image type
+ *
+ * @param type	Image type (IH_TYPE_...)
+ * @return image short name, or "unknown" if unknown
+ */
+const char *genimg_get_type_short_name(uint8_t type);
+
 const char *genimg_get_comp_name(uint8_t comp);
 int genimg_get_os_id(const char *name);
 int genimg_get_arch_id(const char *name);
tools/mkimage.c +52 -7

78 lines not on this page · raw message

Signature · 1 line
2.2.0.rc0.207.ga3a616c
#30 lore raw

PATCH 28/29 rockchip: Add the beginnings of an image tool

In reply to Simon Glass

Rockchip SoCs require certain formats for code that they execute, The simplest format is a 4-byte header at the start of a binary file. Add support for this intiially.

---

 common/image.c  |  1 +
 include/image.h |  3 ++-
 tools/Makefile  |  1 +
 tools/rkimage.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 67 insertions(+), 1 deletion(-)
 create mode 100644 tools/rkimage.c
common/image.c +1 -0
index 7faa91a..940ad6d 100644
@@ -149,6 +149,7 @@ static const table_entry_t uimage_type[] = {
 	{	IH_TYPE_MXSIMAGE,   "mxsimage",   "Freescale MXS Boot Image",},
 	{	IH_TYPE_ATMELIMAGE, "atmelimage", "ATMEL ROM-Boot Image",},
 	{	IH_TYPE_X86_SETUP,  "x86_setup",  "x86 setup.bin",    },
+	{	IH_TYPE_ROCKCHIP,   "rockchip",   "Rockchip Boot Image" },
 	{	-1,		    "",		  "",			},
 };
 
include/image.h +2 -1
index da17a6b..100acbb 100644
@@ -242,8 +242,9 @@ struct lmb;
 #define IH_TYPE_ATMELIMAGE	18	/* ATMEL ROM bootable Image	*/
 #define IH_TYPE_SOCFPGAIMAGE	19	/* Altera SOCFPGA Preloader	*/
 #define IH_TYPE_X86_SETUP	20	/* x86 setup.bin Image		*/
+#define IH_TYPE_ROCKCHIP	21	/* Rockchip Boot Image		*/
 
-#define IH_TYPE_COUNT		21	/* Number of image types */
+#define IH_TYPE_COUNT		22	/* Number of image types */
 
 /*
  * Compression Types
tools/Makefile +1 -0
index 88770b0..a3ab7a3 100644
@@ -88,6 +88,7 @@ dumpimage-mkimage-objs := aisimage.o \
 			os_support.o \
 			pblimage.o \
 			pbl_crc32.o \
+			rkimage.o \
 			socfpgaimage.o \
 			lib/sha1.o \
 			lib/sha256.o \
tools/rkimage.c new file +63 -0

63 lines not on this page · raw message

Signature · 1 line
2.2.0.rc0.207.ga3a616c
#31 lore raw

PATCH 29/29 rockchip: Add a simple README

In reply to Simon Glass

Add a few notes on how to try out the Rockchip support so far.

---

 doc/README.rockchip | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 83 insertions(+)
 create mode 100644 doc/README.rockchip
doc/README.rockchip new file +83 -0
new file mode 100644
index 0000000..2f26814
@@ -0,0 +1,83 @@
+#
+# Copyright (C) 2015 Google. Inc
+# Written by Simon Glass <[email protected]>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+U-Boot on Rockchip
+==================
+
+There are several repositories available with versions of U-Boot that support
+many Rockchip devices [1] [2].
+
+The current mainline support is experimental only and is not useful for
+anything. It should provide a base on which to build.
+
+
+Prerequisites
+=============
+
+You will need:
+
+   - Firefly RK3288 baord
+   - Power connection to 5V using the supplied micro-USB power cable
+   - Separate USB serial cable attached to your computer and the Firefly
+        (connect to the micro-USB connector below the logo)
+   - rkflashtool [3]
+   - openssl (sudo apt-get install openssl)
+   - Serial UART connection [4]
+   - Suitable ARM cross compiler, e.g.:
+        sudo apt-get install gcc-4.7-arm-linux-gnueabi
+
+
+Building
+========
+
+At present, only Firefly RK3288 is supported. You can use the firefly-rk3288
+configuration for this.
+
+   CROSS_COMPILE=arm-linux-gnueabi- make O=firefly firefly-rk3288_defconfig all
+
+(or you can use another cross compiler if you prefer)
+
+
+Writing to the board
+====================
+
+Only USB is supported. For this to work you must get your board into ROM
+boot mode, either by erasing your MMC or (perhaps) holding the recovery
+button when you boot the board. To erase your MMC, you can boot into Linux
+and type (as root) 'dd if=/dev/zero of=/dev/mmcblk0 bs=1M'.
+
+To create a suitable image and write it to the board:
+
+   ./firefly/tools/mkimage -T rockchip -d firefly/spl/u-boot-spl-dtb.bin out
+   cat out | openssl rc4 -K 7c4e0304550509072d2c7b38170d1711 |  rkflashtool l
+
+If all goes well you should something like:
+
+   U-Boot SPL 2015.04-rc2-00123-gc5b539a-dirty (Feb 27 2015 - 09:35:31)
+   SPL: Unsupported Boot Device!
+   ### ERROR ### Please RESET the board ###
+
+You will need to reset the board before each time you try. Yes, that's all
+it does so far.
+
+
+Future work
+===========
+
+Immediate priorities are:
+
+- Support SPL clock init
+- Support loading U-Boot from MMC
+- Boot U-Boot to a prompt
+
+There are plenty of patches in the links below to help with this work.
+
+
+[1] https://github.com/rkchrome/uboot.git
+[2] https://github.com/linux-rockchip/u-boot-rockchip.git branch u-boot-rk3288
+[3] https://github.com/linux-rockchip/rkflashtool.git
+[4] http://wiki.t-firefly.com/index.php/Firefly-RK3288/Serial_debug/en
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#32 lore raw

cover dm: Introduce device tree support in SPL (for Rockchip)

In reply to Simon Glass

Hi,

Quoted 56 lines · Simon Glass

With driver model SPL support in place the remaining driver difference between U-Boot proper and SPL is that SPL does not support device tree. This series adds this support, using a Rockchip board as an example.

One problem with device tree is that U-Boot has no way of dropping features it does not need or use. For SPL this problem needs to be solved and this series uses the preprocessor for this. The 45KB Firefly device tree reduces to 693 bytes when unused material is removed. A better solution might involve the 'fdtgrep' tool but this has not made it into the device tree compiler as yet.

This series includes some changes aimed at reduce code size in SPL, including:
- dropping alias sequence support (the aliases node) since many boards just use a single UART in SPL
- adding a smaller panic() function that does not support printf()-format strings
- removing device unbind code which will never be used in SPL

Overall the resulting SPL binary is 8829 bytes with my Linaro 4.8.2 compiler, including the device tree, using Thumb-2. Of this:

1768 bytes is driver model core code
1556 bytes is device tree code
693 bytes is the device tree itself
4756 is other code, including serial drivers, rodata and data

The last figure includes rodata incorrectly added by the tool chain [1]. With a bug-fixed gcc 4.9.2 the total size is 6893 bytes including device tree.

Approximately 750 bytes is used for strings and driver data (root device and serial) associated with driver model and device tree. This adds up an overhead of around 4750 bytes for driver model and device tree, including the code, rodata and device tree itself.

It should therefore be possible to use driver model and device tree in SPL for board that have enough SRAM. Clearly 4KB is impossible without further work (perhaps removing some error strings). I suspect 8KB would be tricky, allowing only 3KB for stack and other code. But 16KB should work OK.

SRAM sizes for recent SoCs I am aware of are:

Rockchip RK3288:     96KB
Tegra 124:           128KB
Samsung Exynos 5420: 384KB

The Rockchip Firefly was chosen for this work since it is a fairly recent board and is readily available. Rockchip engineers have been actively upstreaming code to Linux in the past year and there is a very full-featured U-Boot available. But it is invisible to most U-Boot people - mainline Rockchip support seems well overdue. This series does not make a serious start on that, since it only prints a message in SPL and then hangs, but additional work should get it booting to a prompt.

Quoted 1 line

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54303

I've held off pushing this into u-boot-dm/next since it is RFC and the device tree part needs work. But I'm thinking of respinning it to apply it within the upcoming merge window, or at least the core patches.

Does anyone have comments at this stage?

Regards,
Simon

#33 lore raw

cover dm: Introduce device tree support in SPL (for Rockchip)

Hi

Quoted 8 lines · Simon Glass

Hi,

Quoted 4 lines · Simon Glass

With driver model SPL support in place the remaining driver difference between U-Boot proper and SPL is that SPL does not support device tree. This series adds this support, using a Rockchip board as an example.

Glad to test on my firefly. Can you please give some basic test to flash on eMmc e/o on SDcard?

Michael

Quoted 1 line
Quoted 1 line

One problem with device tree is that U-Boot has no way of dropping

features

Quoted 1 line
Quoted 1 line

it does not need or use. For SPL this problem needs to be solved and

this

Quoted 1 line
Quoted 1 line

series uses the preprocessor for this. The 45KB Firefly device tree

reduces

Quoted 7 lines
Quoted 7 lines

to 693 bytes when unused material is removed. A better solution might involve the 'fdtgrep' tool but this has not made it into the device tree compiler as yet.

This series includes some changes aimed at reduce code size in SPL, including:
- dropping alias sequence support (the aliases node) since many boards

just

Quoted 2 lines
Quoted 2 lines

use a single UART in SPL
- adding a smaller panic() function that does not support

printf()-format

Quoted 4 lines
Quoted 4 lines

strings
- removing device unbind code which will never be used in SPL

Overall the resulting SPL binary is 8829 bytes with my Linaro 4.8.2

compiler,

Quoted 7 lines
Quoted 7 lines

including the device tree, using Thumb-2. Of this:

1768 bytes is driver model core code
1556 bytes is device tree code
693 bytes is the device tree itself
4756 is other code, including serial drivers, rodata and data

Quoted 6 lines
Quoted 6 lines

The last figure includes rodata incorrectly added by the tool chain [1]. With a bug-fixed gcc 4.9.2 the total size is 6893 bytes including device tree.

Approximately 750 bytes is used for strings and driver data (root device and serial) associated with driver model and device tree. This adds up

an

Quoted 1 line
Quoted 1 line

overhead of around 4750 bytes for driver model and device tree,

including

Quoted 8 lines
Quoted 8 lines

the code, rodata and device tree itself.

It should therefore be possible to use driver model and device tree in SPL for board that have enough SRAM. Clearly 4KB is impossible without further work (perhaps removing some error strings). I suspect 8KB would be tricky, allowing only 3KB for stack and other code. But 16KB should work OK.

Quoted 7 lines
Quoted 7 lines

SRAM sizes for recent SoCs I am aware of are:

Rockchip RK3288:     96KB
Tegra 124:           128KB
Samsung Exynos 5420: 384KB

The Rockchip Firefly was chosen for this work since it is a fairly

recent

Quoted 22 lines
Quoted 8 lines

board and is readily available. Rockchip engineers have been actively upstreaming code to Linux in the past year and there is a very full-featured U-Boot available. But it is invisible to most U-Boot people - mainline Rockchip support seems well overdue. This series does not make a serious start on that, since it only prints a message in SPL and then hangs, but additional work should get it booting to a prompt.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54303

I've held off pushing this into u-boot-dm/next since it is RFC and the device tree part needs work. But I'm thinking of respinning it to apply it within the upcoming merge window, or at least the core patches.

Does anyone have comments at this stage?

Regards,
Simon
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#34 lore raw

cover dm: Introduce device tree support in SPL (for Rockchip)

Hi Michael,

Quoted 6 lines · Michael Trimarchi

Hi

Quoted 3 lines · Simon Glass

Hi,

Quoted 8 lines
Quoted 5 lines · Simon Glass
Quoted 4 lines

With driver model SPL support in place the remaining driver difference between U-Boot proper and SPL is that SPL does not support device tree. This series adds this support, using a Rockchip board as an example.

Glad to test on my firefly. Can you please give some basic test to flash on eMmc e/o on SDcard?

Thanks. There is a README here:

http://patchwork.ozlabs.org/patch/444783/

Warning: it only prints a message on serial and hangs, so don't expect much!

[snip]

Regards,
Simon

#35 lore raw

cover dm: Introduce device tree support in SPL (for Rockchip)

Hi

Quoted 13 lines · Simon Glass

Hi Michael,

Quoted 8 lines · Michael Trimarchi

Hi

Quoted 5 lines · Simon Glass

Hi,

Quoted 1 line · Simon Glass

With driver model SPL support in place the remaining driver

difference

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

between U-Boot proper and SPL is that SPL does not support device

tree.

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

This series adds this support, using a Rockchip board as an example.

Glad to test on my firefly. Can you please give some basic test to

flash on

Quoted 7 lines
Quoted 1 line

eMmc e/o on SDcard?

Thanks. There is a README here:

http://patchwork.ozlabs.org/patch/444783/

Warning: it only prints a message on serial and hangs, so don't expect

much!

Quoted 1 line

It's already good to have this. Memory and serial is fine. I have read it and it's pretty simple.

Michael

Quoted 4 lines

[snip]

Regards,
Simon