All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/5] nios2: add device tree control of U-Boot
@ 2015-09-04  3:15 Thomas Chou
  2015-09-04  3:15 ` [U-Boot] [PATCH 1/5] nios2: permit " Thomas Chou
                   ` (6 more replies)
  0 siblings, 7 replies; 79+ messages in thread
From: Thomas Chou @ 2015-09-04  3:15 UTC (permalink / raw)
  To: u-boot

These patches add device tree control of U-Boot to nios2 boards.

In case of separated device tree blob, the blob is relocated
from the end of u-boot-dtb.bin image.

Thomas Chou (5):
  nios2: permit device tree control of U-Boot
  nios2: enable device tree control of U-Boot
  nios2: revert _end symbol in link script
  nios2: initialize stack earlier in startup
  nios2: relocate dtb for separated device tree

 arch/Kconfig                       |   1 +
 arch/nios2/cpu/fdt.c               |  20 ++++-
 arch/nios2/cpu/start.S             |  55 +++++++------
 arch/nios2/cpu/u-boot.lds          |  16 +++-
 arch/nios2/dts/.gitignore          |   1 +
 arch/nios2/dts/3c120_devboard.dts  | 164 +++++++++++++++++++++++++++++++++++++
 arch/nios2/dts/Makefile            |  11 +++
 arch/nios2/dts/include/dt-bindings |   1 +
 configs/nios2-generic_defconfig    |   2 +
 9 files changed, 244 insertions(+), 27 deletions(-)
 create mode 100644 arch/nios2/dts/.gitignore
 create mode 100644 arch/nios2/dts/3c120_devboard.dts
 create mode 100644 arch/nios2/dts/Makefile
 create mode 120000 arch/nios2/dts/include/dt-bindings

-- 
2.1.4

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH 1/5] nios2: permit device tree control of U-Boot
  2015-09-04  3:15 [U-Boot] [PATCH 0/5] nios2: add device tree control of U-Boot Thomas Chou
@ 2015-09-04  3:15 ` Thomas Chou
  2015-09-04  4:08   ` Simon Glass
  2015-09-04  3:15 ` [U-Boot] [PATCH 2/5] nios2: enable " Thomas Chou
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-04  3:15 UTC (permalink / raw)
  To: u-boot

Enable this in the Kconfig so that nios2 boards can use device
tree to configure U-Boot.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 arch/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/Kconfig b/arch/Kconfig
index 4f73819..207c778 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -63,6 +63,7 @@ config NIOS2
 	bool "Nios II architecture"
 	select HAVE_GENERIC_BOARD
 	select SYS_GENERIC_BOARD
+	select SUPPORT_OF_CONTROL
 
 config OPENRISC
 	bool "OpenRISC architecture"
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH 2/5] nios2: enable device tree control of U-Boot
  2015-09-04  3:15 [U-Boot] [PATCH 0/5] nios2: add device tree control of U-Boot Thomas Chou
  2015-09-04  3:15 ` [U-Boot] [PATCH 1/5] nios2: permit " Thomas Chou
@ 2015-09-04  3:15 ` Thomas Chou
  2015-09-04  4:09   ` Simon Glass
  2015-09-04  3:15 ` [U-Boot] [PATCH 3/5] nios2: revert _end symbol in link script Thomas Chou
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-04  3:15 UTC (permalink / raw)
  To: u-boot

This patch adds device tree control of U-Boot to nios2 boards.
The example dts is taken from Linux kernel.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 arch/nios2/dts/.gitignore          |   1 +
 arch/nios2/dts/3c120_devboard.dts  | 164 +++++++++++++++++++++++++++++++++++++
 arch/nios2/dts/Makefile            |  11 +++
 arch/nios2/dts/include/dt-bindings |   1 +
 configs/nios2-generic_defconfig    |   2 +
 5 files changed, 179 insertions(+)
 create mode 100644 arch/nios2/dts/.gitignore
 create mode 100644 arch/nios2/dts/3c120_devboard.dts
 create mode 100644 arch/nios2/dts/Makefile
 create mode 120000 arch/nios2/dts/include/dt-bindings

diff --git a/arch/nios2/dts/.gitignore b/arch/nios2/dts/.gitignore
new file mode 100644
index 0000000..b60ed20
--- /dev/null
+++ b/arch/nios2/dts/.gitignore
@@ -0,0 +1 @@
+*.dtb
diff --git a/arch/nios2/dts/3c120_devboard.dts b/arch/nios2/dts/3c120_devboard.dts
new file mode 100644
index 0000000..31c51f9
--- /dev/null
+++ b/arch/nios2/dts/3c120_devboard.dts
@@ -0,0 +1,164 @@
+/*
+ *  Copyright (C) 2013 Altera Corporation
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * This file is generated by sopc2dts.
+ */
+
+/dts-v1/;
+
+/ {
+	model = "altr,qsys_ghrd_3c120";
+	compatible = "altr,qsys_ghrd_3c120";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu: cpu at 0x0 {
+			device_type = "cpu";
+			compatible = "altr,nios2-1.0";
+			reg = <0x00000000>;
+			interrupt-controller;
+			#interrupt-cells = <1>;
+			clock-frequency = <125000000>;
+			dcache-line-size = <32>;
+			icache-line-size = <32>;
+			dcache-size = <32768>;
+			icache-size = <32768>;
+			altr,implementation = "fast";
+			altr,pid-num-bits = <8>;
+			altr,tlb-num-ways = <16>;
+			altr,tlb-num-entries = <128>;
+			altr,tlb-ptr-sz = <7>;
+			altr,has-div = <1>;
+			altr,has-mul = <1>;
+			altr,reset-addr = <0xc2800000>;
+			altr,fast-tlb-miss-addr = <0xc7fff400>;
+			altr,exception-addr = <0xd0000020>;
+			altr,has-initda = <1>;
+			altr,has-mmu = <1>;
+		};
+	};
+
+	memory at 0 {
+		device_type = "memory";
+		reg = <0x10000000 0x08000000>,
+			<0x07fff400 0x00000400>;
+	};
+
+	sopc at 0 {
+		device_type = "soc";
+		ranges;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "altr,avalon", "simple-bus";
+		bus-frequency = <125000000>;
+
+		pb_cpu_to_io: bridge at 0x8000000 {
+			compatible = "simple-bus";
+			reg = <0x08000000 0x00800000>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges = <0x00002000 0x08002000 0x00002000>,
+				<0x00004000 0x08004000 0x00000400>,
+				<0x00004400 0x08004400 0x00000040>,
+				<0x00004800 0x08004800 0x00000040>,
+				<0x00004c80 0x08004c80 0x00000020>,
+				<0x00004d50 0x08004d50 0x00000008>,
+				<0x00008000 0x08008000 0x00000020>,
+				<0x00400000 0x08400000 0x00000020>;
+
+			timer_1ms: timer at 0x400000 {
+				compatible = "altr,timer-1.0";
+				reg = <0x00400000 0x00000020>;
+				interrupt-parent = <&cpu>;
+				interrupts = <11>;
+				clock-frequency = <125000000>;
+			};
+
+			timer_0: timer at 0x8000 {
+				compatible = "altr,timer-1.0";
+				reg = < 0x00008000 0x00000020 >;
+				interrupt-parent = < &cpu >;
+				interrupts = < 5 >;
+				clock-frequency = < 125000000 >;
+			};
+
+			jtag_uart: serial at 0x4d50 {
+				compatible = "altr,juart-1.0";
+				reg = <0x00004d50 0x00000008>;
+				interrupt-parent = <&cpu>;
+				interrupts = <1>;
+			};
+
+			tse_mac: ethernet at 0x4000 {
+				compatible = "altr,tse-1.0";
+				reg = <0x00004000 0x00000400>,
+					<0x00004400 0x00000040>,
+					<0x00004800 0x00000040>,
+					<0x00002000 0x00002000>;
+				reg-names = "control_port", "rx_csr", "tx_csr", "s1";
+				interrupt-parent = <&cpu>;
+				interrupts = <2 3>;
+				interrupt-names = "rx_irq", "tx_irq";
+				rx-fifo-depth = <8192>;
+				tx-fifo-depth = <8192>;
+				max-frame-size = <1518>;
+				local-mac-address = [ 00 00 00 00 00 00 ];
+				phy-mode = "rgmii-id";
+				phy-handle = <&phy0>;
+				tse_mac_mdio: mdio {
+					compatible = "altr,tse-mdio";
+					#address-cells = <1>;
+					#size-cells = <0>;
+					phy0: ethernet-phy at 18 {
+						reg = <18>;
+						device_type = "ethernet-phy";
+					};
+				};
+			};
+
+			uart: serial at 0x4c80 {
+				compatible = "altr,uart-1.0";
+				reg = <0x00004c80 0x00000020>;
+				interrupt-parent = <&cpu>;
+				interrupts = <10>;
+				current-speed = <115200>;
+				clock-frequency = <62500000>;
+			};
+		};
+
+		cfi_flash_64m: flash at 0x0 {
+			compatible = "cfi-flash";
+			reg = <0x00000000 0x04000000>;
+			bank-width = <2>;
+			device-width = <1>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 800000 {
+				reg = <0x00800000 0x01e00000>;
+				label = "JFFS2 Filesystem";
+			};
+		};
+	};
+
+	chosen {
+		bootargs = "debug console=ttyJ0,115200";
+	};
+};
diff --git a/arch/nios2/dts/Makefile b/arch/nios2/dts/Makefile
new file mode 100644
index 0000000..b2175a1
--- /dev/null
+++ b/arch/nios2/dts/Makefile
@@ -0,0 +1,11 @@
+dtb-y += 3c120_devboard.dtb
+
+targets += $(dtb-y)
+
+DTC_FLAGS += -R 4 -p 0x1000
+
+PHONY += dtbs
+dtbs: $(addprefix $(obj)/, $(dtb-y))
+	@:
+
+clean-files := *.dtb
diff --git a/arch/nios2/dts/include/dt-bindings b/arch/nios2/dts/include/dt-bindings
new file mode 120000
index 0000000..0cecb3d
--- /dev/null
+++ b/arch/nios2/dts/include/dt-bindings
@@ -0,0 +1 @@
+../../../../include/dt-bindings
\ No newline at end of file
diff --git a/configs/nios2-generic_defconfig b/configs/nios2-generic_defconfig
index f8d2821..09cc51e 100644
--- a/configs/nios2-generic_defconfig
+++ b/configs/nios2-generic_defconfig
@@ -1,5 +1,6 @@
 CONFIG_NIOS2=y
 CONFIG_TARGET_NIOS2_GENERIC=y
+CONFIG_DEFAULT_DEVICE_TREE="3c120_devboard"
 CONFIG_HUSH_PARSER=y
 # CONFIG_CMD_BOOTD is not set
 # CONFIG_CMD_IMLS is not set
@@ -10,4 +11,5 @@ CONFIG_HUSH_PARSER=y
 CONFIG_CMD_DHCP=y
 # CONFIG_CMD_NFS is not set
 CONFIG_CMD_PING=y
+CONFIG_OF_CONTROL=y
 CONFIG_NET_RANDOM_ETHADDR=y
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH 3/5] nios2: revert _end symbol in link script
  2015-09-04  3:15 [U-Boot] [PATCH 0/5] nios2: add device tree control of U-Boot Thomas Chou
  2015-09-04  3:15 ` [U-Boot] [PATCH 1/5] nios2: permit " Thomas Chou
  2015-09-04  3:15 ` [U-Boot] [PATCH 2/5] nios2: enable " Thomas Chou
@ 2015-09-04  3:15 ` Thomas Chou
  2015-09-04  4:09   ` Simon Glass
  2015-09-04  3:15 ` [U-Boot] [PATCH 4/5] nios2: initialize stack earlier in startup Thomas Chou
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-04  3:15 UTC (permalink / raw)
  To: u-boot

Since commit 44c6e6591cb451ae606f8bde71dd5fb7b4002544
"rename _end to __bss_end__" , the _end was removed.
But we need it now for separated device tree control,
ie, CONFIG_OF_SEPARATE .

Though _end used to be the end of u-boot.bin image,
we mark it up and relocate the dtb part of u-boot-dtb.bin
here to be used by fdtdec_setup().

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 arch/nios2/cpu/u-boot.lds | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/arch/nios2/cpu/u-boot.lds b/arch/nios2/cpu/u-boot.lds
index 6e174be..2d43602 100644
--- a/arch/nios2/cpu/u-boot.lds
+++ b/arch/nios2/cpu/u-boot.lds
@@ -50,9 +50,10 @@ SECTIONS
 	  *(.gnu.linkonce.d*)
 	}
 
-	. = ALIGN(16);
-	_gp = .;			/* Global pointer addr */
-	PROVIDE (gp = .);
+	/* gp - Since we don't use gp for small data with option "-G0",
+	 * we will use gp as global data pointer. The _gp location is
+	 * not needed.
+	 */
 
 	.sdata :
 	{
@@ -62,6 +63,9 @@ SECTIONS
 	}
 	. = ALIGN(4);
 
+	/* _edata - This is end of u-boot.bin image.
+	 * dtb will be appended here to make u-boot-dtb.bin
+         */
 	_edata = .;
 	PROVIDE (edata = .);
 
@@ -88,6 +92,12 @@ SECTIONS
 	}
 	. = ALIGN(4);
 	__bss_end = .;
+
+	/* _end - Though _end used to be the end of u-boot.bin image,
+	 * we mark it up and relocate the dtb part of u-boot-dtb.bin here
+	 * to be used by fdtdec_setup().
+	 */
+	_end = .;
 	PROVIDE (end = .);
 
 	/* DEBUG -- symbol table, string table, etc. etc.
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH 4/5] nios2: initialize stack earlier in startup
  2015-09-04  3:15 [U-Boot] [PATCH 0/5] nios2: add device tree control of U-Boot Thomas Chou
                   ` (2 preceding siblings ...)
  2015-09-04  3:15 ` [U-Boot] [PATCH 3/5] nios2: revert _end symbol in link script Thomas Chou
@ 2015-09-04  3:15 ` Thomas Chou
  2015-09-04  4:09   ` Simon Glass
  2015-09-04  3:15 ` [U-Boot] [PATCH 5/5] nios2: relocate dtb for separated device tree Thomas Chou
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-04  3:15 UTC (permalink / raw)
  To: u-boot

This patch reorders the startup sequence, and initializes stack
earlier. So that we can call external functions after stack
initialized.

We will add OF control and use separated dtb. As dtb is located at
the end of u-boot-dtb.bin image, we will need to relocate it before
zeroing the bss. It will be easier to handle fdt in C than ASM.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 arch/nios2/cpu/start.S | 45 ++++++++++++++++++++++-----------------------
 1 file changed, 22 insertions(+), 23 deletions(-)

diff --git a/arch/nios2/cpu/start.S b/arch/nios2/cpu/start.S
index 6af9b4e..dde80f7 100644
--- a/arch/nios2/cpu/start.S
+++ b/arch/nios2/cpu/start.S
@@ -68,7 +68,7 @@ _except_end:
 _cur:	movhi	r5, %hi(_cur - _start)
 	ori	r5, r5, %lo(_cur - _start)
 	sub	r4, r4, r5		/* r4 <- cur _start */
-	mov	r8, r4
+	mov	r8, r4			/* r8 <- cur _start */
 	movhi	r5, %hi(_start)
 	ori	r5, r5, %lo(_start)	/* r5 <- linked _start */
 	beq	r4, r5, 3f
@@ -82,26 +82,34 @@ _cur:	movhi	r5, %hi(_cur - _start)
 	bne	r5, r6, 2b
 3:
 
+	/* JUMP TO RELOC ADDR */
+	movhi	r4, %hi(_reloc)
+	ori	r4, r4, %lo(_reloc)
+	jmp	r4
+_reloc:
+
+	/* STACK INIT -- zero top two words for call back chain. */
+	movhi	sp, %hi(CONFIG_SYS_INIT_SP)
+	ori	sp, sp, %lo(CONFIG_SYS_INIT_SP)
+	addi	sp, sp, -8
+	stw	r0, 0(sp)
+	stw	r0, 4(sp)
+	mov	fp, sp
+
 	/* ZERO BSS/SBSS -- bss and sbss are assumed to be adjacent
 	 * and between __bss_start and __bss_end.
 	 */
-	 movhi	r5, %hi(__bss_start)
-	 ori	r5, r5, %lo(__bss_start)
-	 movhi	r6, %hi(__bss_end)
-	 ori	r6, r6, %lo(__bss_end)
-	 beq	r5, r6, 5f
+	movhi	r5, %hi(__bss_start)
+	ori	r5, r5, %lo(__bss_start)
+	movhi	r6, %hi(__bss_end)
+	ori	r6, r6, %lo(__bss_end)
+	beq	r5, r6, 5f
 
 4:	stwio	r0, 0(r5)
-	 addi	r5, r5, 4
-	 bne	r5, r6, 4b
+	addi	r5, r5, 4
+	bne	r5, r6, 4b
 5:
 
-	/* JUMP TO RELOC ADDR */
-	movhi	r4, %hi(_reloc)
-	ori	r4, r4, %lo(_reloc)
-	jmp	r4
-_reloc:
-
 	/* COPY EXCEPTION TRAMPOLINE -- copy the tramp to the
 	 * exception address. Define CONFIG_ROM_STUBS to prevent
 	 * the copy (e.g. exception in flash or in other
@@ -124,15 +132,6 @@ _reloc:
 7:
 #endif
 
-	/* STACK INIT -- zero top two words for call back chain.
-	 */
-	movhi	sp, %hi(CONFIG_SYS_INIT_SP)
-	ori	sp, sp, %lo(CONFIG_SYS_INIT_SP)
-	addi	sp, sp, -8
-	stw	r0, 0(sp)
-	stw	r0, 4(sp)
-	mov	fp, sp
-
 	/*
 	 * Call board_init_f -- never returns
 	 */
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH 5/5] nios2: relocate dtb for separated device tree
  2015-09-04  3:15 [U-Boot] [PATCH 0/5] nios2: add device tree control of U-Boot Thomas Chou
                   ` (3 preceding siblings ...)
  2015-09-04  3:15 ` [U-Boot] [PATCH 4/5] nios2: initialize stack earlier in startup Thomas Chou
@ 2015-09-04  3:15 ` Thomas Chou
  2015-09-04  4:09   ` Simon Glass
  2015-09-04 12:22 ` [U-Boot] [PATCH v2 0/8] nios2: add device tree control of U-Boot Thomas Chou
  2015-09-07  1:03 ` [U-Boot] [PATCH v4 0/7] " Thomas Chou
  6 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-04  3:15 UTC (permalink / raw)
  To: u-boot

The relocation of nios2 is different. We will need to move
dtb at the end of u-boot-dtb.bin image away from BSS sections.
Otherwise it will be zeroed during startup.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 arch/nios2/cpu/fdt.c   | 20 +++++++++++++++++++-
 arch/nios2/cpu/start.S | 10 ++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/arch/nios2/cpu/fdt.c b/arch/nios2/cpu/fdt.c
index 79f72aa..83d95ba 100644
--- a/arch/nios2/cpu/fdt.c
+++ b/arch/nios2/cpu/fdt.c
@@ -11,9 +11,11 @@
  */
 
 #include <common.h>
+#include <libfdt.h>
+#include <asm/sections.h>
+#include <linux/ctype.h>
 
 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
-#include <libfdt.h>
 #include <fdt_support.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -36,3 +38,19 @@ void ft_cpu_setup(void *blob, bd_t *bd)
 	fdt_fixup_ethernet(blob);
 }
 #endif /* CONFIG_OF_LIBFDT && CONFIG_OF_BOARD_SETUP */
+
+#ifdef CONFIG_OF_SEPARATE
+void relocate_dtb(ulong cur_start)
+{
+	/* This will be called from start.S .
+	 * As dtb is located at the end of u-boot-dtb.bin image,
+	 * we will need to relocate it before zeroing the bss.
+	 * The dtb is moved from _edata to _end, which is markuped
+	 * to __bss_end. Here _end will be used by fdtdec_setup().
+	 */
+	void *blob = (void *)(cur_start + (ulong)_edata - (ulong)_start);
+
+	if (fdt_magic(blob) == FDT_MAGIC)
+		memmove(_end, blob, fdt_totalsize(blob));
+}
+#endif /* CONFIG_OF_SEPARATE */
diff --git a/arch/nios2/cpu/start.S b/arch/nios2/cpu/start.S
index dde80f7..58e6826 100644
--- a/arch/nios2/cpu/start.S
+++ b/arch/nios2/cpu/start.S
@@ -96,6 +96,16 @@ _reloc:
 	stw	r0, 4(sp)
 	mov	fp, sp
 
+#ifdef CONFIG_OF_SEPARATE
+	/* RELOCATE DTB -- relocate dtb in u-boot-dtb.bin image
+	 * to be used by fdtdec_setup().
+	 */
+	mov	r4, r8			/* r8 <- cur _start */
+	movhi	r2, %hi(relocate_dtb at h)
+	ori	r2, r2, %lo(relocate_dtb@h)
+	callr	r2
+#endif
+
 	/* ZERO BSS/SBSS -- bss and sbss are assumed to be adjacent
 	 * and between __bss_start and __bss_end.
 	 */
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH 1/5] nios2: permit device tree control of U-Boot
  2015-09-04  3:15 ` [U-Boot] [PATCH 1/5] nios2: permit " Thomas Chou
@ 2015-09-04  4:08   ` Simon Glass
  0 siblings, 0 replies; 79+ messages in thread
From: Simon Glass @ 2015-09-04  4:08 UTC (permalink / raw)
  To: u-boot

On 3 September 2015 at 21:15, Thomas Chou <thomas@wytron.com.tw> wrote:
> Enable this in the Kconfig so that nios2 boards can use device
> tree to configure U-Boot.
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> ---
>  arch/Kconfig | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH 2/5] nios2: enable device tree control of U-Boot
  2015-09-04  3:15 ` [U-Boot] [PATCH 2/5] nios2: enable " Thomas Chou
@ 2015-09-04  4:09   ` Simon Glass
  0 siblings, 0 replies; 79+ messages in thread
From: Simon Glass @ 2015-09-04  4:09 UTC (permalink / raw)
  To: u-boot

Hi Thomas,

On 3 September 2015 at 21:15, Thomas Chou <thomas@wytron.com.tw> wrote:
> This patch adds device tree control of U-Boot to nios2 boards.
> The example dts is taken from Linux kernel.
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> ---
>  arch/nios2/dts/.gitignore          |   1 +
>  arch/nios2/dts/3c120_devboard.dts  | 164 +++++++++++++++++++++++++++++++++++++
>  arch/nios2/dts/Makefile            |  11 +++
>  arch/nios2/dts/include/dt-bindings |   1 +
>  configs/nios2-generic_defconfig    |   2 +
>  5 files changed, 179 insertions(+)
>  create mode 100644 arch/nios2/dts/.gitignore
>  create mode 100644 arch/nios2/dts/3c120_devboard.dts
>  create mode 100644 arch/nios2/dts/Makefile
>  create mode 120000 arch/nios2/dts/include/dt-bindings
>

Reviewed-by: Simon Glass <sjg@chromium.org>

But I think the license header should use SPDX.

> diff --git a/arch/nios2/dts/.gitignore b/arch/nios2/dts/.gitignore
> new file mode 100644
> index 0000000..b60ed20
> --- /dev/null
> +++ b/arch/nios2/dts/.gitignore
> @@ -0,0 +1 @@
> +*.dtb
> diff --git a/arch/nios2/dts/3c120_devboard.dts b/arch/nios2/dts/3c120_devboard.dts
> new file mode 100644
> index 0000000..31c51f9
> --- /dev/null
> +++ b/arch/nios2/dts/3c120_devboard.dts
> @@ -0,0 +1,164 @@
> +/*
> + *  Copyright (C) 2013 Altera Corporation
> + *
> + * 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.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + *
> + * This file is generated by sopc2dts.
> + */
> +
> +/dts-v1/;
> +
> +/ {
> +       model = "altr,qsys_ghrd_3c120";
> +       compatible = "altr,qsys_ghrd_3c120";
> +       #address-cells = <1>;
> +       #size-cells = <1>;
> +
[snip]

> diff --git a/arch/nios2/dts/Makefile b/arch/nios2/dts/Makefile
> new file mode 100644
> index 0000000..b2175a1
> --- /dev/null
> +++ b/arch/nios2/dts/Makefile
> @@ -0,0 +1,11 @@
> +dtb-y += 3c120_devboard.dtb
> +
> +targets += $(dtb-y)
> +
> +DTC_FLAGS += -R 4 -p 0x1000

You can drop the -p 0x1000 part. It isn't needed.

> +
> +PHONY += dtbs
> +dtbs: $(addprefix $(obj)/, $(dtb-y))
> +       @:
> +
> +clean-files := *.dtb
> diff --git a/arch/nios2/dts/include/dt-bindings b/arch/nios2/dts/include/dt-bindings
> new file mode 120000
> index 0000000..0cecb3d
> --- /dev/null
> +++ b/arch/nios2/dts/include/dt-bindings
> @@ -0,0 +1 @@
> +../../../../include/dt-bindings
> \ No newline at end of file
> diff --git a/configs/nios2-generic_defconfig b/configs/nios2-generic_defconfig
> index f8d2821..09cc51e 100644
> --- a/configs/nios2-generic_defconfig
> +++ b/configs/nios2-generic_defconfig
> @@ -1,5 +1,6 @@
>  CONFIG_NIOS2=y
>  CONFIG_TARGET_NIOS2_GENERIC=y
> +CONFIG_DEFAULT_DEVICE_TREE="3c120_devboard"
>  CONFIG_HUSH_PARSER=y
>  # CONFIG_CMD_BOOTD is not set
>  # CONFIG_CMD_IMLS is not set
> @@ -10,4 +11,5 @@ CONFIG_HUSH_PARSER=y
>  CONFIG_CMD_DHCP=y
>  # CONFIG_CMD_NFS is not set
>  CONFIG_CMD_PING=y
> +CONFIG_OF_CONTROL=y
>  CONFIG_NET_RANDOM_ETHADDR=y
> --
> 2.1.4
>

Regards,
Simon

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH 3/5] nios2: revert _end symbol in link script
  2015-09-04  3:15 ` [U-Boot] [PATCH 3/5] nios2: revert _end symbol in link script Thomas Chou
@ 2015-09-04  4:09   ` Simon Glass
  0 siblings, 0 replies; 79+ messages in thread
From: Simon Glass @ 2015-09-04  4:09 UTC (permalink / raw)
  To: u-boot

On 3 September 2015 at 21:15, Thomas Chou <thomas@wytron.com.tw> wrote:
> Since commit 44c6e6591cb451ae606f8bde71dd5fb7b4002544
> "rename _end to __bss_end__" , the _end was removed.
> But we need it now for separated device tree control,
> ie, CONFIG_OF_SEPARATE .
>
> Though _end used to be the end of u-boot.bin image,
> we mark it up and relocate the dtb part of u-boot-dtb.bin
> here to be used by fdtdec_setup().
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> ---
>  arch/nios2/cpu/u-boot.lds | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH 4/5] nios2: initialize stack earlier in startup
  2015-09-04  3:15 ` [U-Boot] [PATCH 4/5] nios2: initialize stack earlier in startup Thomas Chou
@ 2015-09-04  4:09   ` Simon Glass
  0 siblings, 0 replies; 79+ messages in thread
From: Simon Glass @ 2015-09-04  4:09 UTC (permalink / raw)
  To: u-boot

Hi Thomas,

On 3 September 2015 at 21:15, Thomas Chou <thomas@wytron.com.tw> wrote:
> This patch reorders the startup sequence, and initializes stack
> earlier. So that we can call external functions after stack
> initialized.
>
> We will add OF control and use separated dtb. As dtb is located at
> the end of u-boot-dtb.bin image, we will need to relocate it before
> zeroing the bss. It will be easier to handle fdt in C than ASM.
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> ---
>  arch/nios2/cpu/start.S | 45 ++++++++++++++++++++++-----------------------
>  1 file changed, 22 insertions(+), 23 deletions(-)

Instead, is it possible to move to calling board_init_f_mem()?

Regards,
Simon

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH 5/5] nios2: relocate dtb for separated device tree
  2015-09-04  3:15 ` [U-Boot] [PATCH 5/5] nios2: relocate dtb for separated device tree Thomas Chou
@ 2015-09-04  4:09   ` Simon Glass
  2015-09-04  4:47     ` Thomas Chou
  0 siblings, 1 reply; 79+ messages in thread
From: Simon Glass @ 2015-09-04  4:09 UTC (permalink / raw)
  To: u-boot

+Marek

Hi Thomas,

On 3 September 2015 at 21:15, Thomas Chou <thomas@wytron.com.tw> wrote:
> The relocation of nios2 is different. We will need to move
> dtb at the end of u-boot-dtb.bin image away from BSS sections.
> Otherwise it will be zeroed during startup.
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> ---
>  arch/nios2/cpu/fdt.c   | 20 +++++++++++++++++++-
>  arch/nios2/cpu/start.S | 10 ++++++++++
>  2 files changed, 29 insertions(+), 1 deletion(-)

Can you help me understand the relocation a bit? There is already code
in board_init_f() to relocate the device tree, and until
board_init_r(), BSS should not be used. What is different about NIOS?

>
> diff --git a/arch/nios2/cpu/fdt.c b/arch/nios2/cpu/fdt.c
> index 79f72aa..83d95ba 100644
> --- a/arch/nios2/cpu/fdt.c
> +++ b/arch/nios2/cpu/fdt.c
> @@ -11,9 +11,11 @@
>   */
>
>  #include <common.h>
> +#include <libfdt.h>
> +#include <asm/sections.h>
> +#include <linux/ctype.h>
>
>  #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
> -#include <libfdt.h>
>  #include <fdt_support.h>
>
>  DECLARE_GLOBAL_DATA_PTR;
> @@ -36,3 +38,19 @@ void ft_cpu_setup(void *blob, bd_t *bd)
>         fdt_fixup_ethernet(blob);
>  }
>  #endif /* CONFIG_OF_LIBFDT && CONFIG_OF_BOARD_SETUP */
> +
> +#ifdef CONFIG_OF_SEPARATE
> +void relocate_dtb(ulong cur_start)
> +{
> +       /* This will be called from start.S .
> +        * As dtb is located at the end of u-boot-dtb.bin image,
> +        * we will need to relocate it before zeroing the bss.
> +        * The dtb is moved from _edata to _end, which is markuped
> +        * to __bss_end. Here _end will be used by fdtdec_setup().
> +        */
> +       void *blob = (void *)(cur_start + (ulong)_edata - (ulong)_start);
> +
> +       if (fdt_magic(blob) == FDT_MAGIC)
> +               memmove(_end, blob, fdt_totalsize(blob));
> +}
> +#endif /* CONFIG_OF_SEPARATE */
> diff --git a/arch/nios2/cpu/start.S b/arch/nios2/cpu/start.S
> index dde80f7..58e6826 100644
> --- a/arch/nios2/cpu/start.S
> +++ b/arch/nios2/cpu/start.S
> @@ -96,6 +96,16 @@ _reloc:
>         stw     r0, 4(sp)
>         mov     fp, sp
>
> +#ifdef CONFIG_OF_SEPARATE
> +       /* RELOCATE DTB -- relocate dtb in u-boot-dtb.bin image
> +        * to be used by fdtdec_setup().
> +        */
> +       mov     r4, r8                  /* r8 <- cur _start */
> +       movhi   r2, %hi(relocate_dtb at h)
> +       ori     r2, r2, %lo(relocate_dtb at h)
> +       callr   r2
> +#endif
> +
>         /* ZERO BSS/SBSS -- bss and sbss are assumed to be adjacent
>          * and between __bss_start and __bss_end.
>          */
> --
> 2.1.4
>

Regards,
Simon

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH 5/5] nios2: relocate dtb for separated device tree
  2015-09-04  4:09   ` Simon Glass
@ 2015-09-04  4:47     ` Thomas Chou
  0 siblings, 0 replies; 79+ messages in thread
From: Thomas Chou @ 2015-09-04  4:47 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On 09/04/2015 12:09 PM, Simon Glass wrote:
> Can you help me understand the relocation a bit? There is already code
> in board_init_f() to relocate the device tree, and until
> board_init_r(), BSS should not be used. What is different about NIOS?

Thank you for the comment. I think the problem is in the current nios2 
startup code start.S. The BSS is cleared before board_init_f(). I will 
rework the startup code to make use of the board_init code.

Best regards,
Thomas Chou

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 0/8] nios2: add device tree control of U-Boot
  2015-09-04  3:15 [U-Boot] [PATCH 0/5] nios2: add device tree control of U-Boot Thomas Chou
                   ` (4 preceding siblings ...)
  2015-09-04  3:15 ` [U-Boot] [PATCH 5/5] nios2: relocate dtb for separated device tree Thomas Chou
@ 2015-09-04 12:22 ` Thomas Chou
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 1/8] nios2: permit " Thomas Chou
                     ` (8 more replies)
  2015-09-07  1:03 ` [U-Boot] [PATCH v4 0/7] " Thomas Chou
  6 siblings, 9 replies; 79+ messages in thread
From: Thomas Chou @ 2015-09-04 12:22 UTC (permalink / raw)
  To: u-boot

These patches add device tree control of U-Boot to nios2 boards.

v2
  use SPDX license header.
  use fdt relocation in board_init_f.

Thomas Chou (8):
  nios2: permit device tree control of U-Boot
  nios2: move altera_pio_init to board_early_init_r
  nios2: BSS should be cleared only after board_init_f
  nios2: enlarge the code relocation range
  nios2: remove gp assignments in link script
  nios2: define _end in link script
  nios2: show fdt blob address in board info command
  nios2: enable device tree control of U-Boot

 arch/Kconfig                               |   1 +
 arch/nios2/cpu/start.S                     |  34 ++++---
 arch/nios2/cpu/u-boot.lds                  |  12 ++-
 arch/nios2/dts/.gitignore                  |   1 +
 arch/nios2/dts/3c120_devboard.dts          | 153 +++++++++++++++++++++++++++++
 arch/nios2/dts/Makefile                    |  11 +++
 arch/nios2/dts/include/dt-bindings         |   1 +
 board/altera/nios2-generic/nios2-generic.c |  13 ++-
 common/cmd_bdinfo.c                        |   3 +
 configs/nios2-generic_defconfig            |   2 +
 include/configs/nios2-generic.h            |   1 +
 11 files changed, 209 insertions(+), 23 deletions(-)
 create mode 100644 arch/nios2/dts/.gitignore
 create mode 100644 arch/nios2/dts/3c120_devboard.dts
 create mode 100644 arch/nios2/dts/Makefile
 create mode 120000 arch/nios2/dts/include/dt-bindings

-- 
2.1.4

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 1/8] nios2: permit device tree control of U-Boot
  2015-09-04 12:22 ` [U-Boot] [PATCH v2 0/8] nios2: add device tree control of U-Boot Thomas Chou
@ 2015-09-04 12:22   ` Thomas Chou
  2015-09-04 13:54     ` Marek Vasut
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 2/8] nios2: move altera_pio_init to board_early_init_r Thomas Chou
                     ` (7 subsequent siblings)
  8 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-04 12:22 UTC (permalink / raw)
  To: u-boot

Enable this in the Kconfig so that nios2 boards can use device
tree to configure U-Boot.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 arch/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/Kconfig b/arch/Kconfig
index 4f73819..207c778 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -63,6 +63,7 @@ config NIOS2
 	bool "Nios II architecture"
 	select HAVE_GENERIC_BOARD
 	select SYS_GENERIC_BOARD
+	select SUPPORT_OF_CONTROL
 
 config OPENRISC
 	bool "OpenRISC architecture"
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 2/8] nios2: move altera_pio_init to board_early_init_r
  2015-09-04 12:22 ` [U-Boot] [PATCH v2 0/8] nios2: add device tree control of U-Boot Thomas Chou
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 1/8] nios2: permit " Thomas Chou
@ 2015-09-04 12:22   ` Thomas Chou
  2015-09-04 13:55     ` Marek Vasut
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 3/8] nios2: BSS should be cleared only after board_init_f Thomas Chou
                     ` (6 subsequent siblings)
  8 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-04 12:22 UTC (permalink / raw)
  To: u-boot

As altera_pio_init() uses BSS, it should be moved to
board_early_init_r().

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 board/altera/nios2-generic/nios2-generic.c | 13 +++++++++----
 include/configs/nios2-generic.h            |  1 +
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/board/altera/nios2-generic/nios2-generic.c b/board/altera/nios2-generic/nios2-generic.c
index 834cbeb..384fee9 100644
--- a/board/altera/nios2-generic/nios2-generic.c
+++ b/board/altera/nios2-generic/nios2-generic.c
@@ -28,6 +28,15 @@ void early_flash_cmd_reset(void)
 
 int board_early_init_f(void)
 {
+#if defined(CONFIG_ENV_IS_IN_FLASH) && defined(CONFIG_ENV_ADDR) && \
+    defined(CONFIG_CFI_FLASH_MTD)
+	early_flash_cmd_reset();
+#endif
+	return 0;
+}
+
+int board_early_init_r(void)
+{
 #ifdef CONFIG_ALTERA_PIO
 #ifdef LED_PIO_BASE
 	altera_pio_init(LED_PIO_BASE, LED_PIO_WIDTH, 'o',
@@ -35,10 +44,6 @@ int board_early_init_f(void)
 			"led");
 #endif
 #endif
-#if defined(CONFIG_ENV_IS_IN_FLASH) && defined(CONFIG_ENV_ADDR) && \
-    defined(CONFIG_CFI_FLASH_MTD)
-	early_flash_cmd_reset();
-#endif
 	return 0;
 }
 
diff --git a/include/configs/nios2-generic.h b/include/configs/nios2-generic.h
index 5bb7768..293acae 100644
--- a/include/configs/nios2-generic.h
+++ b/include/configs/nios2-generic.h
@@ -15,6 +15,7 @@
 #include "../board/altera/nios2-generic/custom_fpga.h" /* fpga parameters */
 #define CONFIG_BOARD_NAME "nios2-generic" /* custom board name */
 #define CONFIG_BOARD_EARLY_INIT_F	/* enable early board-spec. init */
+#define CONFIG_BOARD_EARLY_INIT_R
 #define CONFIG_DISPLAY_CPUINFO
 #define CONFIG_DISPLAY_BOARDINFO
 #define CONFIG_SYS_NIOS_SYSID_BASE	CONFIG_SYS_SYSID_BASE
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 3/8] nios2: BSS should be cleared only after board_init_f
  2015-09-04 12:22 ` [U-Boot] [PATCH v2 0/8] nios2: add device tree control of U-Boot Thomas Chou
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 1/8] nios2: permit " Thomas Chou
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 2/8] nios2: move altera_pio_init to board_early_init_r Thomas Chou
@ 2015-09-04 12:22   ` Thomas Chou
  2015-09-04 13:56     ` Marek Vasut
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 4/8] nios2: enlarge the code relocation range Thomas Chou
                     ` (5 subsequent siblings)
  8 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-04 12:22 UTC (permalink / raw)
  To: u-boot

As dtb in u-boot-dtb.bin overlapped the BSS section,
we should delay the clearing of BSS until dtb is relocated
in board_init_f().

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 arch/nios2/cpu/start.S | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/arch/nios2/cpu/start.S b/arch/nios2/cpu/start.S
index 6af9b4e..971bde8 100644
--- a/arch/nios2/cpu/start.S
+++ b/arch/nios2/cpu/start.S
@@ -82,20 +82,6 @@ _cur:	movhi	r5, %hi(_cur - _start)
 	bne	r5, r6, 2b
 3:
 
-	/* ZERO BSS/SBSS -- bss and sbss are assumed to be adjacent
-	 * and between __bss_start and __bss_end.
-	 */
-	 movhi	r5, %hi(__bss_start)
-	 ori	r5, r5, %lo(__bss_start)
-	 movhi	r6, %hi(__bss_end)
-	 ori	r6, r6, %lo(__bss_end)
-	 beq	r5, r6, 5f
-
-4:	stwio	r0, 0(r5)
-	 addi	r5, r5, 4
-	 bne	r5, r6, 4b
-5:
-
 	/* JUMP TO RELOC ADDR */
 	movhi	r4, %hi(_reloc)
 	ori	r4, r4, %lo(_reloc)
@@ -167,6 +153,21 @@ _reloc:
 relocate_code:
 	mov	sp, r4		/* Set the new sp */
 	mov	r4, r5
+
+	/* ZERO BSS/SBSS -- bss and sbss are assumed to be adjacent
+	 * and between __bss_start and __bss_end.
+	 */
+	movhi	r5, %hi(__bss_start)
+	ori	r5, r5, %lo(__bss_start)
+	movhi	r6, %hi(__bss_end)
+	ori	r6, r6, %lo(__bss_end)
+	beq	r5, r6, 5f
+
+4:	stwio	r0, 0(r5)
+	addi	r5, r5, 4
+	bne	r5, r6, 4b
+5:
+
 	movhi	r8, %hi(board_init_r at h)
 	ori	r8, r8, %lo(board_init_r at h)
 	callr	r8
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 4/8] nios2: enlarge the code relocation range
  2015-09-04 12:22 ` [U-Boot] [PATCH v2 0/8] nios2: add device tree control of U-Boot Thomas Chou
                     ` (2 preceding siblings ...)
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 3/8] nios2: BSS should be cleared only after board_init_f Thomas Chou
@ 2015-09-04 12:22   ` Thomas Chou
  2015-09-04 13:59     ` Marek Vasut
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 5/8] nios2: remove gp assignments in link script Thomas Chou
                     ` (4 subsequent siblings)
  8 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-04 12:22 UTC (permalink / raw)
  To: u-boot

As we will use u-boot-dtb.bin, the code relocation range
should be adjusted to accommodate the additional dtb.
It might be overkilled to look into dtb header to find the
dtb size, so we will simply use CONFIG_SYS_MONITOR_LEN.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 arch/nios2/cpu/start.S | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/nios2/cpu/start.S b/arch/nios2/cpu/start.S
index 971bde8..0b16633 100644
--- a/arch/nios2/cpu/start.S
+++ b/arch/nios2/cpu/start.S
@@ -73,8 +73,9 @@ _cur:	movhi	r5, %hi(_cur - _start)
 	ori	r5, r5, %lo(_start)	/* r5 <- linked _start */
 	beq	r4, r5, 3f
 
-	movhi	r6, %hi(_edata)
-	ori	r6, r6, %lo(_edata)
+	movhi	r6, %hi(CONFIG_SYS_MONITOR_LEN)
+	ori	r6, r6, %lo(CONFIG_SYS_MONITOR_LEN)
+	add	r6, r6, r5
 2:	ldwio	r7, 0(r4)
 	addi	r4, r4, 4
 	stwio	r7, 0(r5)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 5/8] nios2: remove gp assignments in link script
  2015-09-04 12:22 ` [U-Boot] [PATCH v2 0/8] nios2: add device tree control of U-Boot Thomas Chou
                     ` (3 preceding siblings ...)
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 4/8] nios2: enlarge the code relocation range Thomas Chou
@ 2015-09-04 12:22   ` Thomas Chou
  2015-09-04 14:00     ` Marek Vasut
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 6/8] nios2: define _end " Thomas Chou
                     ` (3 subsequent siblings)
  8 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-04 12:22 UTC (permalink / raw)
  To: u-boot

Since we don't use gp for small data with option "-G0",
we use gp as global data pointer. The _gp location is
not needed.

The ALIGN(16) was for gp only. It is removed, so that we
can get correct address of dtb in u-boot-dtb.bin image.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 arch/nios2/cpu/u-boot.lds | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/nios2/cpu/u-boot.lds b/arch/nios2/cpu/u-boot.lds
index 6e174be..951785c 100644
--- a/arch/nios2/cpu/u-boot.lds
+++ b/arch/nios2/cpu/u-boot.lds
@@ -50,9 +50,10 @@ SECTIONS
 	  *(.gnu.linkonce.d*)
 	}
 
-	. = ALIGN(16);
-	_gp = .;			/* Global pointer addr */
-	PROVIDE (gp = .);
+	/* gp - Since we don't use gp for small data with option "-G0",
+	 * we will use gp as global data pointer. The _gp location is
+	 * not needed.
+	 */
 
 	.sdata :
 	{
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 6/8] nios2: define _end in link script
  2015-09-04 12:22 ` [U-Boot] [PATCH v2 0/8] nios2: add device tree control of U-Boot Thomas Chou
                     ` (4 preceding siblings ...)
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 5/8] nios2: remove gp assignments in link script Thomas Chou
@ 2015-09-04 12:22   ` Thomas Chou
  2015-09-04 14:01     ` Marek Vasut
  2015-09-04 14:09     ` [U-Boot] [PATCH v2 " Simon Glass
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 7/8] nios2: show fdt blob address in board info command Thomas Chou
                     ` (2 subsequent siblings)
  8 siblings, 2 replies; 79+ messages in thread
From: Thomas Chou @ 2015-09-04 12:22 UTC (permalink / raw)
  To: u-boot

Since commit 44c6e6591cb451ae606f8bde71dd5fb7b4002544
"rename _end to __bss_end__" , the _end was removed.
But we need it now for separated device tree control,
ie, CONFIG_OF_SEPARATE .

The _end is used by fdtdec_setup() to find the blob.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 arch/nios2/cpu/u-boot.lds | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/nios2/cpu/u-boot.lds b/arch/nios2/cpu/u-boot.lds
index 951785c..535a974 100644
--- a/arch/nios2/cpu/u-boot.lds
+++ b/arch/nios2/cpu/u-boot.lds
@@ -66,6 +66,11 @@ SECTIONS
 	_edata = .;
 	PROVIDE (edata = .);
 
+	/* _end - This is end of u-boot.bin image.
+	 * dtb will be appended here to make u-boot-dtb.bin
+         */
+	_end = .;
+
 	/* UNINIT DATA - Small uninitialized data is first so it's
 	 * adjacent to sdata and can be referenced via gp. The normal
 	 * bss follows. We keep it adjacent to simplify init code.
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 7/8] nios2: show fdt blob address in board info command
  2015-09-04 12:22 ` [U-Boot] [PATCH v2 0/8] nios2: add device tree control of U-Boot Thomas Chou
                     ` (5 preceding siblings ...)
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 6/8] nios2: define _end " Thomas Chou
@ 2015-09-04 12:22   ` Thomas Chou
  2015-09-04 14:01     ` Marek Vasut
                       ` (2 more replies)
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 8/8] nios2: enable device tree control of U-Boot Thomas Chou
  2015-09-04 14:04   ` [U-Boot] [PATCH v2 0/8] nios2: add " Marek Vasut
  8 siblings, 3 replies; 79+ messages in thread
From: Thomas Chou @ 2015-09-04 12:22 UTC (permalink / raw)
  To: u-boot

Show fdt blob address in board info command.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 common/cmd_bdinfo.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c
index ed3b935..74ff229 100644
--- a/common/cmd_bdinfo.c
+++ b/common/cmd_bdinfo.c
@@ -176,6 +176,9 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 #endif
 
 	printf("baudrate    = %u bps\n", gd->baudrate);
+#if defined(CONFIG_OF_CONTROL)
+	print_num("fdt_blob", (ulong)gd->fdt_blob);
+#endif
 
 	return 0;
 }
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 8/8] nios2: enable device tree control of U-Boot
  2015-09-04 12:22 ` [U-Boot] [PATCH v2 0/8] nios2: add device tree control of U-Boot Thomas Chou
                     ` (6 preceding siblings ...)
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 7/8] nios2: show fdt blob address in board info command Thomas Chou
@ 2015-09-04 12:22   ` Thomas Chou
  2015-09-04 14:03     ` Marek Vasut
  2015-09-04 14:04   ` [U-Boot] [PATCH v2 0/8] nios2: add " Marek Vasut
  8 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-04 12:22 UTC (permalink / raw)
  To: u-boot

This patch adds device tree control of U-Boot to nios2 boards.
The example dts is taken from Linux kernel.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 arch/nios2/dts/.gitignore          |   1 +
 arch/nios2/dts/3c120_devboard.dts  | 153 +++++++++++++++++++++++++++++++++++++
 arch/nios2/dts/Makefile            |  11 +++
 arch/nios2/dts/include/dt-bindings |   1 +
 configs/nios2-generic_defconfig    |   2 +
 5 files changed, 168 insertions(+)
 create mode 100644 arch/nios2/dts/.gitignore
 create mode 100644 arch/nios2/dts/3c120_devboard.dts
 create mode 100644 arch/nios2/dts/Makefile
 create mode 120000 arch/nios2/dts/include/dt-bindings

diff --git a/arch/nios2/dts/.gitignore b/arch/nios2/dts/.gitignore
new file mode 100644
index 0000000..b60ed20
--- /dev/null
+++ b/arch/nios2/dts/.gitignore
@@ -0,0 +1 @@
+*.dtb
diff --git a/arch/nios2/dts/3c120_devboard.dts b/arch/nios2/dts/3c120_devboard.dts
new file mode 100644
index 0000000..02524ab
--- /dev/null
+++ b/arch/nios2/dts/3c120_devboard.dts
@@ -0,0 +1,153 @@
+/*
+ *  Copyright (C) 2013 Altera Corporation
+ *
+ * This file is generated by sopc2dts.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+/dts-v1/;
+
+/ {
+	model = "altr,qsys_ghrd_3c120";
+	compatible = "altr,qsys_ghrd_3c120";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu: cpu at 0x0 {
+			device_type = "cpu";
+			compatible = "altr,nios2-1.0";
+			reg = <0x00000000>;
+			interrupt-controller;
+			#interrupt-cells = <1>;
+			clock-frequency = <125000000>;
+			dcache-line-size = <32>;
+			icache-line-size = <32>;
+			dcache-size = <32768>;
+			icache-size = <32768>;
+			altr,implementation = "fast";
+			altr,pid-num-bits = <8>;
+			altr,tlb-num-ways = <16>;
+			altr,tlb-num-entries = <128>;
+			altr,tlb-ptr-sz = <7>;
+			altr,has-div = <1>;
+			altr,has-mul = <1>;
+			altr,reset-addr = <0xc2800000>;
+			altr,fast-tlb-miss-addr = <0xc7fff400>;
+			altr,exception-addr = <0xd0000020>;
+			altr,has-initda = <1>;
+			altr,has-mmu = <1>;
+		};
+	};
+
+	memory at 0 {
+		device_type = "memory";
+		reg = <0x10000000 0x08000000>,
+			<0x07fff400 0x00000400>;
+	};
+
+	sopc at 0 {
+		device_type = "soc";
+		ranges;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "altr,avalon", "simple-bus";
+		bus-frequency = <125000000>;
+
+		pb_cpu_to_io: bridge at 0x8000000 {
+			compatible = "simple-bus";
+			reg = <0x08000000 0x00800000>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges = <0x00002000 0x08002000 0x00002000>,
+				<0x00004000 0x08004000 0x00000400>,
+				<0x00004400 0x08004400 0x00000040>,
+				<0x00004800 0x08004800 0x00000040>,
+				<0x00004c80 0x08004c80 0x00000020>,
+				<0x00004d50 0x08004d50 0x00000008>,
+				<0x00008000 0x08008000 0x00000020>,
+				<0x00400000 0x08400000 0x00000020>;
+
+			timer_1ms: timer at 0x400000 {
+				compatible = "altr,timer-1.0";
+				reg = <0x00400000 0x00000020>;
+				interrupt-parent = <&cpu>;
+				interrupts = <11>;
+				clock-frequency = <125000000>;
+			};
+
+			timer_0: timer at 0x8000 {
+				compatible = "altr,timer-1.0";
+				reg = < 0x00008000 0x00000020 >;
+				interrupt-parent = < &cpu >;
+				interrupts = < 5 >;
+				clock-frequency = < 125000000 >;
+			};
+
+			jtag_uart: serial at 0x4d50 {
+				compatible = "altr,juart-1.0";
+				reg = <0x00004d50 0x00000008>;
+				interrupt-parent = <&cpu>;
+				interrupts = <1>;
+			};
+
+			tse_mac: ethernet at 0x4000 {
+				compatible = "altr,tse-1.0";
+				reg = <0x00004000 0x00000400>,
+					<0x00004400 0x00000040>,
+					<0x00004800 0x00000040>,
+					<0x00002000 0x00002000>;
+				reg-names = "control_port", "rx_csr", "tx_csr", "s1";
+				interrupt-parent = <&cpu>;
+				interrupts = <2 3>;
+				interrupt-names = "rx_irq", "tx_irq";
+				rx-fifo-depth = <8192>;
+				tx-fifo-depth = <8192>;
+				max-frame-size = <1518>;
+				local-mac-address = [ 00 00 00 00 00 00 ];
+				phy-mode = "rgmii-id";
+				phy-handle = <&phy0>;
+				tse_mac_mdio: mdio {
+					compatible = "altr,tse-mdio";
+					#address-cells = <1>;
+					#size-cells = <0>;
+					phy0: ethernet-phy at 18 {
+						reg = <18>;
+						device_type = "ethernet-phy";
+					};
+				};
+			};
+
+			uart: serial at 0x4c80 {
+				compatible = "altr,uart-1.0";
+				reg = <0x00004c80 0x00000020>;
+				interrupt-parent = <&cpu>;
+				interrupts = <10>;
+				current-speed = <115200>;
+				clock-frequency = <62500000>;
+			};
+		};
+
+		cfi_flash_64m: flash at 0x0 {
+			compatible = "cfi-flash";
+			reg = <0x00000000 0x04000000>;
+			bank-width = <2>;
+			device-width = <1>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 800000 {
+				reg = <0x00800000 0x01e00000>;
+				label = "JFFS2 Filesystem";
+			};
+		};
+	};
+
+	chosen {
+		bootargs = "debug console=ttyJ0,115200";
+	};
+};
diff --git a/arch/nios2/dts/Makefile b/arch/nios2/dts/Makefile
new file mode 100644
index 0000000..b2175a1
--- /dev/null
+++ b/arch/nios2/dts/Makefile
@@ -0,0 +1,11 @@
+dtb-y += 3c120_devboard.dtb
+
+targets += $(dtb-y)
+
+DTC_FLAGS += -R 4 -p 0x1000
+
+PHONY += dtbs
+dtbs: $(addprefix $(obj)/, $(dtb-y))
+	@:
+
+clean-files := *.dtb
diff --git a/arch/nios2/dts/include/dt-bindings b/arch/nios2/dts/include/dt-bindings
new file mode 120000
index 0000000..0cecb3d
--- /dev/null
+++ b/arch/nios2/dts/include/dt-bindings
@@ -0,0 +1 @@
+../../../../include/dt-bindings
\ No newline at end of file
diff --git a/configs/nios2-generic_defconfig b/configs/nios2-generic_defconfig
index f8d2821..09cc51e 100644
--- a/configs/nios2-generic_defconfig
+++ b/configs/nios2-generic_defconfig
@@ -1,5 +1,6 @@
 CONFIG_NIOS2=y
 CONFIG_TARGET_NIOS2_GENERIC=y
+CONFIG_DEFAULT_DEVICE_TREE="3c120_devboard"
 CONFIG_HUSH_PARSER=y
 # CONFIG_CMD_BOOTD is not set
 # CONFIG_CMD_IMLS is not set
@@ -10,4 +11,5 @@ CONFIG_HUSH_PARSER=y
 CONFIG_CMD_DHCP=y
 # CONFIG_CMD_NFS is not set
 CONFIG_CMD_PING=y
+CONFIG_OF_CONTROL=y
 CONFIG_NET_RANDOM_ETHADDR=y
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 1/8] nios2: permit device tree control of U-Boot
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 1/8] nios2: permit " Thomas Chou
@ 2015-09-04 13:54     ` Marek Vasut
  0 siblings, 0 replies; 79+ messages in thread
From: Marek Vasut @ 2015-09-04 13:54 UTC (permalink / raw)
  To: u-boot

On Friday, September 04, 2015 at 02:22:16 PM, Thomas Chou wrote:
> Enable this in the Kconfig so that nios2 boards can use device
> tree to configure U-Boot.
> 
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Acked-by: Marek Vasut <marex@denx.de>

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 2/8] nios2: move altera_pio_init to board_early_init_r
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 2/8] nios2: move altera_pio_init to board_early_init_r Thomas Chou
@ 2015-09-04 13:55     ` Marek Vasut
  2015-09-05  0:16       ` Thomas Chou
  0 siblings, 1 reply; 79+ messages in thread
From: Marek Vasut @ 2015-09-04 13:55 UTC (permalink / raw)
  To: u-boot

On Friday, September 04, 2015 at 02:22:17 PM, Thomas Chou wrote:
> As altera_pio_init() uses BSS, it should be moved to
> board_early_init_r().
> 
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>

Shouldn't this be part of arch_cpu_init() instead ?

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 3/8] nios2: BSS should be cleared only after board_init_f
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 3/8] nios2: BSS should be cleared only after board_init_f Thomas Chou
@ 2015-09-04 13:56     ` Marek Vasut
  0 siblings, 0 replies; 79+ messages in thread
From: Marek Vasut @ 2015-09-04 13:56 UTC (permalink / raw)
  To: u-boot

On Friday, September 04, 2015 at 02:22:18 PM, Thomas Chou wrote:
> As dtb in u-boot-dtb.bin overlapped the BSS section,
> we should delay the clearing of BSS until dtb is relocated
> in board_init_f().
> 
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>

Acked-by: Marek Vasut <marex@denx.de>

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 4/8] nios2: enlarge the code relocation range
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 4/8] nios2: enlarge the code relocation range Thomas Chou
@ 2015-09-04 13:59     ` Marek Vasut
  2015-09-05  2:17       ` Thomas Chou
  0 siblings, 1 reply; 79+ messages in thread
From: Marek Vasut @ 2015-09-04 13:59 UTC (permalink / raw)
  To: u-boot

On Friday, September 04, 2015 at 02:22:19 PM, Thomas Chou wrote:
> As we will use u-boot-dtb.bin, the code relocation range
> should be adjusted to accommodate the additional dtb.
> It might be overkilled to look into dtb header to find the
> dtb size, so we will simply use CONFIG_SYS_MONITOR_LEN.
> 
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> ---
>  arch/nios2/cpu/start.S | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/nios2/cpu/start.S b/arch/nios2/cpu/start.S
> index 971bde8..0b16633 100644
> --- a/arch/nios2/cpu/start.S
> +++ b/arch/nios2/cpu/start.S
> @@ -73,8 +73,9 @@ _cur:	movhi	r5, %hi(_cur - _start)
>  	ori	r5, r5, %lo(_start)	/* r5 <- linked _start */
>  	beq	r4, r5, 3f
> 
> -	movhi	r6, %hi(_edata)
> -	ori	r6, r6, %lo(_edata)
> +	movhi	r6, %hi(CONFIG_SYS_MONITOR_LEN)
> +	ori	r6, r6, %lo(CONFIG_SYS_MONITOR_LEN)
> +	add	r6, r6, r5
>  2:	ldwio	r7, 0(r4)
>  	addi	r4, r4, 4
>  	stwio	r7, 0(r5)

Can't you just call relocate_code the same way arm does it in
arch/arm/lib/crt0.S ?

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 5/8] nios2: remove gp assignments in link script
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 5/8] nios2: remove gp assignments in link script Thomas Chou
@ 2015-09-04 14:00     ` Marek Vasut
  2015-09-05  2:31       ` [U-Boot] [PATCH v3 " Thomas Chou
  0 siblings, 1 reply; 79+ messages in thread
From: Marek Vasut @ 2015-09-04 14:00 UTC (permalink / raw)
  To: u-boot

On Friday, September 04, 2015 at 02:22:20 PM, Thomas Chou wrote:
> Since we don't use gp for small data with option "-G0",
> we use gp as global data pointer. The _gp location is
> not needed.
> 
> The ALIGN(16) was for gp only. It is removed, so that we
> can get correct address of dtb in u-boot-dtb.bin image.
> 
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> ---
>  arch/nios2/cpu/u-boot.lds | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/nios2/cpu/u-boot.lds b/arch/nios2/cpu/u-boot.lds
> index 6e174be..951785c 100644
> --- a/arch/nios2/cpu/u-boot.lds
> +++ b/arch/nios2/cpu/u-boot.lds
> @@ -50,9 +50,10 @@ SECTIONS
>  	  *(.gnu.linkonce.d*)
>  	}
> 
> -	. = ALIGN(16);
> -	_gp = .;			/* Global pointer addr */
> -	PROVIDE (gp = .);
> +	/* gp - Since we don't use gp for small data with option "-G0",

Please make the multiline comment match the kernel coding style:

/*
 * foo
 * bar
 */

Otherwise
Acked-by: Marek Vasut <marex@denx.de>

> +	 * we will use gp as global data pointer. The _gp location is
> +	 * not needed.
> +	 */
> 
>  	.sdata :
>  	{

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 6/8] nios2: define _end in link script
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 6/8] nios2: define _end " Thomas Chou
@ 2015-09-04 14:01     ` Marek Vasut
  2015-09-05  2:41       ` [U-Boot] [PATCH v3 " Thomas Chou
  2015-09-04 14:09     ` [U-Boot] [PATCH v2 " Simon Glass
  1 sibling, 1 reply; 79+ messages in thread
From: Marek Vasut @ 2015-09-04 14:01 UTC (permalink / raw)
  To: u-boot

On Friday, September 04, 2015 at 02:22:21 PM, Thomas Chou wrote:
> Since commit 44c6e6591cb451ae606f8bde71dd5fb7b4002544
> "rename _end to __bss_end__" , the _end was removed.
> But we need it now for separated device tree control,
> ie, CONFIG_OF_SEPARATE .
> 
> The _end is used by fdtdec_setup() to find the blob.
> 
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> ---
>  arch/nios2/cpu/u-boot.lds | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/arch/nios2/cpu/u-boot.lds b/arch/nios2/cpu/u-boot.lds
> index 951785c..535a974 100644
> --- a/arch/nios2/cpu/u-boot.lds
> +++ b/arch/nios2/cpu/u-boot.lds
> @@ -66,6 +66,11 @@ SECTIONS
>  	_edata = .;
>  	PROVIDE (edata = .);
> 
> +	/* _end - This is end of u-boot.bin image.
> +	 * dtb will be appended here to make u-boot-dtb.bin
> +         */
> +	_end = .;

Same comment about the comment as in the previous patch, but otherwise:

Acked-by: Marek Vasut <marex@denx.de>

>  	/* UNINIT DATA - Small uninitialized data is first so it's
>  	 * adjacent to sdata and can be referenced via gp. The normal
>  	 * bss follows. We keep it adjacent to simplify init code.

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 7/8] nios2: show fdt blob address in board info command
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 7/8] nios2: show fdt blob address in board info command Thomas Chou
@ 2015-09-04 14:01     ` Marek Vasut
  2015-09-05  2:54       ` Thomas Chou
  2015-09-04 14:10     ` Simon Glass
  2015-09-09  4:26     ` Thomas Chou
  2 siblings, 1 reply; 79+ messages in thread
From: Marek Vasut @ 2015-09-04 14:01 UTC (permalink / raw)
  To: u-boot

On Friday, September 04, 2015 at 02:22:22 PM, Thomas Chou wrote:
> Show fdt blob address in board info command.
> 
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> ---
>  common/cmd_bdinfo.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c
> index ed3b935..74ff229 100644
> --- a/common/cmd_bdinfo.c
> +++ b/common/cmd_bdinfo.c
> @@ -176,6 +176,9 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc,
> char * const argv[]) #endif
> 
>  	printf("baudrate    = %u bps\n", gd->baudrate);
> +#if defined(CONFIG_OF_CONTROL)
> +	print_num("fdt_blob", (ulong)gd->fdt_blob);

I think this will not work on 64bit machines.

> +#endif
> 
>  	return 0;
>  }

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 8/8] nios2: enable device tree control of U-Boot
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 8/8] nios2: enable device tree control of U-Boot Thomas Chou
@ 2015-09-04 14:03     ` Marek Vasut
  2015-09-05  3:36       ` Thomas Chou
  0 siblings, 1 reply; 79+ messages in thread
From: Marek Vasut @ 2015-09-04 14:03 UTC (permalink / raw)
  To: u-boot

On Friday, September 04, 2015 at 02:22:23 PM, Thomas Chou wrote:
> This patch adds device tree control of U-Boot to nios2 boards.
> The example dts is taken from Linux kernel.
> 
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> ---
>  arch/nios2/dts/.gitignore          |   1 +
>  arch/nios2/dts/3c120_devboard.dts  | 153
> +++++++++++++++++++++++++++++++++++++ arch/nios2/dts/Makefile            |
>  11 +++
>  arch/nios2/dts/include/dt-bindings |   1 +
>  configs/nios2-generic_defconfig    |   2 +
>  5 files changed, 168 insertions(+)
>  create mode 100644 arch/nios2/dts/.gitignore
>  create mode 100644 arch/nios2/dts/3c120_devboard.dts
>  create mode 100644 arch/nios2/dts/Makefile
>  create mode 120000 arch/nios2/dts/include/dt-bindings

Acked-by: Marek Vasut <marex@denx.de>

You might also start working on dissolving the
board/altera/nios2-generic/custom_fpga.h horror file,
since with DT this is no longer needed :)

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 0/8] nios2: add device tree control of U-Boot
  2015-09-04 12:22 ` [U-Boot] [PATCH v2 0/8] nios2: add device tree control of U-Boot Thomas Chou
                     ` (7 preceding siblings ...)
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 8/8] nios2: enable device tree control of U-Boot Thomas Chou
@ 2015-09-04 14:04   ` Marek Vasut
  2015-09-05  3:20     ` Thomas Chou
  8 siblings, 1 reply; 79+ messages in thread
From: Marek Vasut @ 2015-09-04 14:04 UTC (permalink / raw)
  To: u-boot

On Friday, September 04, 2015 at 02:22:15 PM, Thomas Chou wrote:
> These patches add device tree control of U-Boot to nios2 boards.
> 
> v2
>   use SPDX license header.
>   use fdt relocation in board_init_f.

Excellent, thanks :)

I can start picking the NIOS2 stuff into U-Boot as well if you want.

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 6/8] nios2: define _end in link script
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 6/8] nios2: define _end " Thomas Chou
  2015-09-04 14:01     ` Marek Vasut
@ 2015-09-04 14:09     ` Simon Glass
  1 sibling, 0 replies; 79+ messages in thread
From: Simon Glass @ 2015-09-04 14:09 UTC (permalink / raw)
  To: u-boot

Hi Thomas,

On 4 September 2015 at 06:22, Thomas Chou <thomas@wytron.com.tw> wrote:
> Since commit 44c6e6591cb451ae606f8bde71dd5fb7b4002544
> "rename _end to __bss_end__" , the _end was removed.
> But we need it now for separated device tree control,
> ie, CONFIG_OF_SEPARATE .
>
> The _end is used by fdtdec_setup() to find the blob.
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> ---
>  arch/nios2/cpu/u-boot.lds | 5 +++++
>  1 file changed, 5 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

>
> diff --git a/arch/nios2/cpu/u-boot.lds b/arch/nios2/cpu/u-boot.lds
> index 951785c..535a974 100644
> --- a/arch/nios2/cpu/u-boot.lds
> +++ b/arch/nios2/cpu/u-boot.lds
> @@ -66,6 +66,11 @@ SECTIONS
>         _edata = .;
>         PROVIDE (edata = .);
>
> +       /* _end - This is end of u-boot.bin image.

comment style:

/*
 * _end -

> +        * dtb will be appended here to make u-boot-dtb.bin
> +         */
> +       _end = .;
> +
>         /* UNINIT DATA - Small uninitialized data is first so it's
>          * adjacent to sdata and can be referenced via gp. The normal
>          * bss follows. We keep it adjacent to simplify init code.
> --
> 2.1.4
>

Regards,
Simon

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 7/8] nios2: show fdt blob address in board info command
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 7/8] nios2: show fdt blob address in board info command Thomas Chou
  2015-09-04 14:01     ` Marek Vasut
@ 2015-09-04 14:10     ` Simon Glass
  2015-09-09  4:26     ` Thomas Chou
  2 siblings, 0 replies; 79+ messages in thread
From: Simon Glass @ 2015-09-04 14:10 UTC (permalink / raw)
  To: u-boot

On 4 September 2015 at 06:22, Thomas Chou <thomas@wytron.com.tw> wrote:
> Show fdt blob address in board info command.
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> ---
>  common/cmd_bdinfo.c | 3 +++
>  1 file changed, 3 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 2/8] nios2: move altera_pio_init to board_early_init_r
  2015-09-04 13:55     ` Marek Vasut
@ 2015-09-05  0:16       ` Thomas Chou
  2015-09-05  0:54         ` Marek Vasut
  0 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-05  0:16 UTC (permalink / raw)
  To: u-boot

Hi Marek,

On 09/04/2015 09:55 PM, Marek Vasut wrote:
> On Friday, September 04, 2015 at 02:22:17 PM, Thomas Chou wrote:
>> As altera_pio_init() uses BSS, it should be moved to
>> board_early_init_r().
>>
>> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
>
> Shouldn't this be part of arch_cpu_init() instead ?

This is per board setup. Each board might has a different PIO configuration.

Regards,
Thomas Chou

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 2/8] nios2: move altera_pio_init to board_early_init_r
  2015-09-05  0:16       ` Thomas Chou
@ 2015-09-05  0:54         ` Marek Vasut
  0 siblings, 0 replies; 79+ messages in thread
From: Marek Vasut @ 2015-09-05  0:54 UTC (permalink / raw)
  To: u-boot

On Saturday, September 05, 2015 at 02:16:20 AM, Thomas Chou wrote:
> Hi Marek,
> 
> On 09/04/2015 09:55 PM, Marek Vasut wrote:
> > On Friday, September 04, 2015 at 02:22:17 PM, Thomas Chou wrote:
> >> As altera_pio_init() uses BSS, it should be moved to
> >> board_early_init_r().
> >> 
> >> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> > 
> > Shouldn't this be part of arch_cpu_init() instead ?
> 
> This is per board setup. Each board might has a different PIO
> configuration.

OK, I see what you're doing here now. I agree.

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 4/8] nios2: enlarge the code relocation range
  2015-09-04 13:59     ` Marek Vasut
@ 2015-09-05  2:17       ` Thomas Chou
  2015-09-05 12:50         ` Marek Vasut
  0 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-05  2:17 UTC (permalink / raw)
  To: u-boot

Hi Marek,

On 09/04/2015 09:59 PM, Marek Vasut wrote:
> Can't you just call relocate_code the same way arm does it in
> arch/arm/lib/crt0.S ?

We didn't include relocation records in nios2 binary image, so there is 
no real relocation like that of ARM.

Altera provides small boot loaders for cfi/sf along with their nios2 
jtag flash programmer, which will load the image to the linked address 
in sdram. The relocating loop in start.S works only if such Altera boot 
loader is not used, ie, booting directly from cfi flash.

Best regards,
Thomas Chou

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v3 5/8] nios2: remove gp assignments in link script
  2015-09-04 14:00     ` Marek Vasut
@ 2015-09-05  2:31       ` Thomas Chou
  0 siblings, 0 replies; 79+ messages in thread
From: Thomas Chou @ 2015-09-05  2:31 UTC (permalink / raw)
  To: u-boot

Since we don't use gp for small data with option "-G0",
we use gp as global data pointer. The _gp location is
not needed.

The ALIGN(16) was for gp only. It is removed, so that we
can get correct address of dtb in u-boot-dtb.bin image.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Acked-by: Marek Vasut <marex@denx.de>
---

v3 comment coding style fix

 arch/nios2/cpu/u-boot.lds | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/nios2/cpu/u-boot.lds b/arch/nios2/cpu/u-boot.lds
index 6e174be..8b0fd1a 100644
--- a/arch/nios2/cpu/u-boot.lds
+++ b/arch/nios2/cpu/u-boot.lds
@@ -50,9 +50,11 @@ SECTIONS
 	  *(.gnu.linkonce.d*)
 	}
 
-	. = ALIGN(16);
-	_gp = .;			/* Global pointer addr */
-	PROVIDE (gp = .);
+	/*
+	 * gp - Since we don't use gp for small data with option "-G0",
+	 * we will use gp as global data pointer. The _gp location is
+	 * not needed.
+	 */
 
 	.sdata :
 	{
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v3 6/8] nios2: define _end in link script
  2015-09-04 14:01     ` Marek Vasut
@ 2015-09-05  2:41       ` Thomas Chou
  2015-09-05 12:49         ` Marek Vasut
  0 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-05  2:41 UTC (permalink / raw)
  To: u-boot

Since commit 44c6e6591cb451ae606f8bde71dd5fb7b4002544
"rename _end to __bss_end__" , the _end was removed.
But we need it now for separated device tree control,
ie, CONFIG_OF_SEPARATE .

The _end is used by fdtdec_setup() to find the blob.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Acked-by: Marek Vasut <marex@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

v3 comment coding style fix

 arch/nios2/cpu/u-boot.lds | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/nios2/cpu/u-boot.lds b/arch/nios2/cpu/u-boot.lds
index 8b0fd1a..9d13ecc 100644
--- a/arch/nios2/cpu/u-boot.lds
+++ b/arch/nios2/cpu/u-boot.lds
@@ -67,6 +67,12 @@ SECTIONS
 	_edata = .;
 	PROVIDE (edata = .);
 
+	/*
+	 * _end - This is end of u-boot.bin image.
+	 * dtb will be appended here to make u-boot-dtb.bin
+         */
+	_end = .;
+
 	/* UNINIT DATA - Small uninitialized data is first so it's
 	 * adjacent to sdata and can be referenced via gp. The normal
 	 * bss follows. We keep it adjacent to simplify init code.
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 7/8] nios2: show fdt blob address in board info command
  2015-09-04 14:01     ` Marek Vasut
@ 2015-09-05  2:54       ` Thomas Chou
  2015-09-05 12:51         ` Marek Vasut
  0 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-05  2:54 UTC (permalink / raw)
  To: u-boot

Hi Marek,

On 09/04/2015 10:01 PM, Marek Vasut wrote:
>> +	print_num("fdt_blob", (ulong)gd->fdt_blob);
>
> I think this will not work on 64bit machines.

I'd agree that it won't work on 64bits machines, but it is enough for a 
soft-core 32btis fpga processor. :)

Best regards,
Thomas Chou

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 0/8] nios2: add device tree control of U-Boot
  2015-09-04 14:04   ` [U-Boot] [PATCH v2 0/8] nios2: add " Marek Vasut
@ 2015-09-05  3:20     ` Thomas Chou
  2015-09-05 12:53       ` Marek Vasut
  2015-09-07  1:36       ` Ley Foon Tan
  0 siblings, 2 replies; 79+ messages in thread
From: Thomas Chou @ 2015-09-05  3:20 UTC (permalink / raw)
  To: u-boot

Hi Marek,

On 09/04/2015 10:04 PM, Marek Vasut wrote:
> I can start picking the NIOS2 stuff into U-Boot as well if you want.

That's great! You are very kind and responsive. Thanks a lot. You can 
take over the custodianship of nios2 arch. Then I will be retired. :)

BTW, please also look over the earlier patches,

[PATCH] nios2: move command line configuration to Kconfig, Aug,28
[PATCH] nios2: enable CONFIG_NET_RANDOM_ETHADDR, Aug,29
And perhaps,
[PATCH] mmc_spi: fix big-endian support error on be_to_cpu16, Aug,31

Cheers,
Thomas Chou

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 8/8] nios2: enable device tree control of U-Boot
  2015-09-04 14:03     ` Marek Vasut
@ 2015-09-05  3:36       ` Thomas Chou
  2015-09-05 12:52         ` Marek Vasut
  0 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-05  3:36 UTC (permalink / raw)
  To: u-boot

Hi Marek,

On 09/04/2015 10:03 PM, Marek Vasut wrote:
> You might also start working on dissolving the
> board/altera/nios2-generic/custom_fpga.h horror file,
> since with DT this is no longer needed :)

Sure thing. This is on my TODO list.

May I know that if there is any work in process on Driver Model for 
Altera jtaguart, uart, spi and ethernet?

Best regards,
Thomas Chou

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v3 6/8] nios2: define _end in link script
  2015-09-05  2:41       ` [U-Boot] [PATCH v3 " Thomas Chou
@ 2015-09-05 12:49         ` Marek Vasut
  0 siblings, 0 replies; 79+ messages in thread
From: Marek Vasut @ 2015-09-05 12:49 UTC (permalink / raw)
  To: u-boot

On Saturday, September 05, 2015 at 04:41:27 AM, Thomas Chou wrote:
> Since commit 44c6e6591cb451ae606f8bde71dd5fb7b4002544
> "rename _end to __bss_end__" , the _end was removed.
> But we need it now for separated device tree control,
> ie, CONFIG_OF_SEPARATE .
> 
> The _end is used by fdtdec_setup() to find the blob.
> 
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> Acked-by: Marek Vasut <marex@denx.de>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> ---
> 
> v3 comment coding style fix
> 
>  arch/nios2/cpu/u-boot.lds | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/arch/nios2/cpu/u-boot.lds b/arch/nios2/cpu/u-boot.lds
> index 8b0fd1a..9d13ecc 100644
> --- a/arch/nios2/cpu/u-boot.lds
> +++ b/arch/nios2/cpu/u-boot.lds
> @@ -67,6 +67,12 @@ SECTIONS
>  	_edata = .;
>  	PROVIDE (edata = .);
> 
> +	/*
> +	 * _end - This is end of u-boot.bin image.
> +	 * dtb will be appended here to make u-boot-dtb.bin
> +         */

Still broken ;-)

btw. please either repost the whole series or use git send-email --in-reply-to ,
so I dont have to hunt down patches all over the place.

> +	_end = .;
> +
>  	/* UNINIT DATA - Small uninitialized data is first so it's
>  	 * adjacent to sdata and can be referenced via gp. The normal
>  	 * bss follows. We keep it adjacent to simplify init code.

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 4/8] nios2: enlarge the code relocation range
  2015-09-05  2:17       ` Thomas Chou
@ 2015-09-05 12:50         ` Marek Vasut
  2015-09-06 11:28           ` Thomas Chou
  0 siblings, 1 reply; 79+ messages in thread
From: Marek Vasut @ 2015-09-05 12:50 UTC (permalink / raw)
  To: u-boot

On Saturday, September 05, 2015 at 04:17:05 AM, Thomas Chou wrote:
> Hi Marek,

Hi,

> On 09/04/2015 09:59 PM, Marek Vasut wrote:
> > Can't you just call relocate_code the same way arm does it in
> > arch/arm/lib/crt0.S ?
> 
> We didn't include relocation records in nios2 binary image, so there is
> no real relocation like that of ARM.

Can we add them instead ?

> Altera provides small boot loaders for cfi/sf along with their nios2
> jtag flash programmer, which will load the image to the linked address
> in sdram. The relocating loop in start.S works only if such Altera boot
> loader is not used, ie, booting directly from cfi flash.

Hm, Im not using the Altera loader :)

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 7/8] nios2: show fdt blob address in board info command
  2015-09-05  2:54       ` Thomas Chou
@ 2015-09-05 12:51         ` Marek Vasut
  2015-09-06 11:31           ` Thomas Chou
  2015-09-06 13:20           ` Thomas Chou
  0 siblings, 2 replies; 79+ messages in thread
From: Marek Vasut @ 2015-09-05 12:51 UTC (permalink / raw)
  To: u-boot

On Saturday, September 05, 2015 at 04:54:52 AM, Thomas Chou wrote:
> Hi Marek,

Hi,

> On 09/04/2015 10:01 PM, Marek Vasut wrote:
> >> +	print_num("fdt_blob", (ulong)gd->fdt_blob);
> > 
> > I think this will not work on 64bit machines.
> 
> I'd agree that it won't work on 64bits machines, but it is enough for a
> soft-core 32btis fpga processor. :)

That's a common code you're modifying, so it has to be done right, sorry,
this patch cannot be accepted in this form.

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 8/8] nios2: enable device tree control of U-Boot
  2015-09-05  3:36       ` Thomas Chou
@ 2015-09-05 12:52         ` Marek Vasut
  0 siblings, 0 replies; 79+ messages in thread
From: Marek Vasut @ 2015-09-05 12:52 UTC (permalink / raw)
  To: u-boot

On Saturday, September 05, 2015 at 05:36:02 AM, Thomas Chou wrote:
> Hi Marek,

Hi,

> On 09/04/2015 10:03 PM, Marek Vasut wrote:
> > You might also start working on dissolving the
> > board/altera/nios2-generic/custom_fpga.h horror file,
> > since with DT this is no longer needed :)
> 
> Sure thing. This is on my TODO list.
> 
> May I know that if there is any work in process on Driver Model for
> Altera jtaguart, uart, spi and ethernet?

There isn't any, feel free to start playing around :)

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 0/8] nios2: add device tree control of U-Boot
  2015-09-05  3:20     ` Thomas Chou
@ 2015-09-05 12:53       ` Marek Vasut
  2015-09-07  1:36       ` Ley Foon Tan
  1 sibling, 0 replies; 79+ messages in thread
From: Marek Vasut @ 2015-09-05 12:53 UTC (permalink / raw)
  To: u-boot

On Saturday, September 05, 2015 at 05:20:49 AM, Thomas Chou wrote:
> Hi Marek,

Hi,

> On 09/04/2015 10:04 PM, Marek Vasut wrote:
> > I can start picking the NIOS2 stuff into U-Boot as well if you want.
> 
> That's great! You are very kind and responsive. Thanks a lot. You can
> take over the custodianship of nios2 arch. Then I will be retired. :)
> 
> BTW, please also look over the earlier patches,

Did you do the custodianing before ? Wow, looks like there's a bit of a
chaos in this :)

I'll gladly leave it to you ;-)

> [PATCH] nios2: move command line configuration to Kconfig, Aug,28
> [PATCH] nios2: enable CONFIG_NET_RANDOM_ETHADDR, Aug,29
> And perhaps,
> [PATCH] mmc_spi: fix big-endian support error on be_to_cpu16, Aug,31

This one should be handled by Pantelis.

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 4/8] nios2: enlarge the code relocation range
  2015-09-05 12:50         ` Marek Vasut
@ 2015-09-06 11:28           ` Thomas Chou
  2015-09-06 12:29             ` Marek Vasut
  0 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-06 11:28 UTC (permalink / raw)
  To: u-boot

HI Marek,

On 09/05/2015 08:50 PM, Marek Vasut wrote:
>> We didn't include relocation records in nios2 binary image, so there is
>> no real relocation like that of ARM.
>
> Can we add them instead ?

I think it is possible. I recalled that we have an old flat image format 
with elf2flt to run nonmmu uclinux, which does a similar relocation. But 
I would suggest that we should keep thing simple and small in a boot 
loader like U-Boot.

>
>> Altera provides small boot loaders for cfi/sf along with their nios2
>> jtag flash programmer, which will load the image to the linked address
>> in sdram. The relocating loop in start.S works only if such Altera boot
>> loader is not used, ie, booting directly from cfi flash.
>
> Hm, Im not using the Altera loader :)
>

Neither am I. Look like we all use custom boot copiers, and we don't 
need the relocation in the patch above. It doesn't make sense to copy 
the code twice. Right? :)

Best regards
Thomas Chou

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 7/8] nios2: show fdt blob address in board info command
  2015-09-05 12:51         ` Marek Vasut
@ 2015-09-06 11:31           ` Thomas Chou
  2015-09-06 13:20           ` Thomas Chou
  1 sibling, 0 replies; 79+ messages in thread
From: Thomas Chou @ 2015-09-06 11:31 UTC (permalink / raw)
  To: u-boot

Hi Marek,

On 09/05/2015 08:51 PM, Marek Vasut wrote:
> That's a common code you're modifying, so it has to be done right, sorry,
> this patch cannot be accepted in this form.

I understand. I will use (u64) and print_lnum().

Best regards,
Thomas Chou

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 4/8] nios2: enlarge the code relocation range
  2015-09-06 11:28           ` Thomas Chou
@ 2015-09-06 12:29             ` Marek Vasut
  2015-09-06 13:12               ` Thomas Chou
  0 siblings, 1 reply; 79+ messages in thread
From: Marek Vasut @ 2015-09-06 12:29 UTC (permalink / raw)
  To: u-boot

On Sunday, September 06, 2015 at 01:28:08 PM, Thomas Chou wrote:
> HI Marek,

Hi!

> On 09/05/2015 08:50 PM, Marek Vasut wrote:
> >> We didn't include relocation records in nios2 binary image, so there is
> >> no real relocation like that of ARM.
> > 
> > Can we add them instead ?
> 
> I think it is possible. I recalled that we have an old flat image format
> with elf2flt to run nonmmu uclinux, which does a similar relocation. But
> I would suggest that we should keep thing simple and small in a boot
> loader like U-Boot.

We already do it on ARM though and the reason for this is to place U-Boot
at the end of the DRAM, so that most of the DRAM can be used by the user.

> >> Altera provides small boot loaders for cfi/sf along with their nios2
> >> jtag flash programmer, which will load the image to the linked address
> >> in sdram. The relocating loop in start.S works only if such Altera boot
> >> loader is not used, ie, booting directly from cfi flash.
> > 
> > Hm, Im not using the Altera loader :)
> 
> Neither am I. Look like we all use custom boot copiers, and we don't
> need the relocation in the patch above. It doesn't make sense to copy
> the code twice. Right? :)

In fact, I am loading U-Boot with GDB thus far, so I am only copying it
once ;-) Where is the second copying coming from ?

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 4/8] nios2: enlarge the code relocation range
  2015-09-06 12:29             ` Marek Vasut
@ 2015-09-06 13:12               ` Thomas Chou
  2015-09-06 13:18                 ` Marek Vasut
  0 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-06 13:12 UTC (permalink / raw)
  To: u-boot

Hi Marek,

On 09/06/2015 08:29 PM, Marek Vasut wrote:
> We already do it on ARM though and the reason for this is to place U-Boot
> at the end of the DRAM, so that most of the DRAM can be used by the user.

We place U-Boot at the end of the DRAM on nios2, too. :)

I will look into the relocation on nios2 next time. But for now, I would 
suggest that we skip this and move on to driver model.

> In fact, I am loading U-Boot with GDB thus far, so I am only copying it
> once ;-) Where is the second copying coming from ?

That was true for gdb. But when you need to try out u-boot-dtb.bin on 
EPCS/sf, it will be another story..

Best regards,
Thomas Chou

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 4/8] nios2: enlarge the code relocation range
  2015-09-06 13:12               ` Thomas Chou
@ 2015-09-06 13:18                 ` Marek Vasut
  2015-09-06 13:49                   ` Thomas Chou
  0 siblings, 1 reply; 79+ messages in thread
From: Marek Vasut @ 2015-09-06 13:18 UTC (permalink / raw)
  To: u-boot

On Sunday, September 06, 2015 at 03:12:44 PM, Thomas Chou wrote:
> Hi Marek,

Hi,

> On 09/06/2015 08:29 PM, Marek Vasut wrote:
> > We already do it on ARM though and the reason for this is to place U-Boot
> > at the end of the DRAM, so that most of the DRAM can be used by the user.
> 
> We place U-Boot at the end of the DRAM on nios2, too. :)
> 
> I will look into the relocation on nios2 next time. But for now, I would
> suggest that we skip this and move on to driver model.

These two things are orthogonal, so no problem :)

> > In fact, I am loading U-Boot with GDB thus far, so I am only copying it
> > once ;-) Where is the second copying coming from ?
> 
> That was true for gdb. But when you need to try out u-boot-dtb.bin on
> EPCS/sf, it will be another story..

Why so? The EPCS is memory mapped and U-Boot starts from it, right ? So
U-Boot can relocate itself to the end of DRAM , right ?

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 7/8] nios2: show fdt blob address in board info command
  2015-09-05 12:51         ` Marek Vasut
  2015-09-06 11:31           ` Thomas Chou
@ 2015-09-06 13:20           ` Thomas Chou
  2015-09-06 14:27             ` Marek Vasut
  1 sibling, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-06 13:20 UTC (permalink / raw)
  To: u-boot

Hi Marek,

>>> I think this will not work on 64bit machines.

I tried 64bits with

	print_lnum("fdt_blob", (u64)gd->fdt_blob);

But got this warning,

   CC      common/cmd_bdinfo.o
common/cmd_bdinfo.c: In function 'do_bdinfo':
common/cmd_bdinfo.c:180:25: warning: cast from pointer to integer of 
different size [-Wpointer-to-int-cast]
   print_lnum("fdt_blob", (u64)gd->fdt_blob);
                          ^
include/asm-generic/global_data.h
	const void *fdt_blob;	/* Our device tree, NULL if none */

Actually, the print is guarded with CONFIG_NIOS2, so it is safe to use 
32bits.

Or shall we invent a "print pointer address"?

Best regards,
Thomas Chou

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 4/8] nios2: enlarge the code relocation range
  2015-09-06 13:18                 ` Marek Vasut
@ 2015-09-06 13:49                   ` Thomas Chou
  2015-09-06 15:23                     ` Marek Vasut
  0 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-06 13:49 UTC (permalink / raw)
  To: u-boot

Hi Marek,

On 09/06/2015 09:18 PM, Marek Vasut wrote:
> Why so? The EPCS is memory mapped and U-Boot starts from it, right ? So
> U-Boot can relocate itself to the end of DRAM , right ?

No. EPCS contains a default boot copier which I said earlier.

Please take a look at this,

https://www.altera.com/support/support-resources/design-examples/intellectual-property/embedded/nios-ii/exm-alt-boot-methods.html

Though the default EPCS boot copier works, it is not easy to update 
u-boot(-dtb).bin image with u-boot sf command. So I used a modified 
version, which copies the u-boot image from a fixed location on EPCS/sf 
to the end of DRAM.

Best regards,
Thomas Chou

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 7/8] nios2: show fdt blob address in board info command
  2015-09-06 13:20           ` Thomas Chou
@ 2015-09-06 14:27             ` Marek Vasut
  2015-09-08  3:55               ` Simon Glass
  0 siblings, 1 reply; 79+ messages in thread
From: Marek Vasut @ 2015-09-06 14:27 UTC (permalink / raw)
  To: u-boot

On Sunday, September 06, 2015 at 03:20:21 PM, Thomas Chou wrote:
> Hi Marek,
> 
> >>> I think this will not work on 64bit machines.
> 
> I tried 64bits with
> 
> 	print_lnum("fdt_blob", (u64)gd->fdt_blob);
> 
> But got this warning,
> 
>    CC      common/cmd_bdinfo.o
> common/cmd_bdinfo.c: In function 'do_bdinfo':
> common/cmd_bdinfo.c:180:25: warning: cast from pointer to integer of
> different size [-Wpointer-to-int-cast]
>    print_lnum("fdt_blob", (u64)gd->fdt_blob);
>                           ^
> include/asm-generic/global_data.h
> 	const void *fdt_blob;	/* Our device tree, NULL if none */
> 
> Actually, the print is guarded with CONFIG_NIOS2, so it is safe to use
> 32bits.
> 
> Or shall we invent a "print pointer address"?

Simon, Tom, what's your take on this ?

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 4/8] nios2: enlarge the code relocation range
  2015-09-06 13:49                   ` Thomas Chou
@ 2015-09-06 15:23                     ` Marek Vasut
  2015-09-07  0:22                       ` Thomas Chou
  0 siblings, 1 reply; 79+ messages in thread
From: Marek Vasut @ 2015-09-06 15:23 UTC (permalink / raw)
  To: u-boot

On Sunday, September 06, 2015 at 03:49:20 PM, Thomas Chou wrote:
> Hi Marek,

Hi,

> On 09/06/2015 09:18 PM, Marek Vasut wrote:
> > Why so? The EPCS is memory mapped and U-Boot starts from it, right ? So
> > U-Boot can relocate itself to the end of DRAM , right ?
> 
> No. EPCS contains a default boot copier which I said earlier.
> 
> Please take a look at this,
> 
> https://www.altera.com/support/support-resources/design-examples/intellectu
> al-property/embedded/nios-ii/exm-alt-boot-methods.html
> 
> Though the default EPCS boot copier works, it is not easy to update
> u-boot(-dtb).bin image with u-boot sf command. So I used a modified
> version, which copies the u-boot image from a fixed location on EPCS/sf
> to the end of DRAM.

Uh oh, is this copying something the U-Boot SPL cannot do for us ?

Sorry, I might be a bit lost in the "official" ways because I'm too
used to mainline ;-)

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 4/8] nios2: enlarge the code relocation range
  2015-09-06 15:23                     ` Marek Vasut
@ 2015-09-07  0:22                       ` Thomas Chou
  2015-09-07  0:53                         ` Marek Vasut
  0 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-07  0:22 UTC (permalink / raw)
  To: u-boot

Hi Marek,

On 09/06/2015 11:23 PM, Marek Vasut wrote:
> Uh oh, is this copying something the U-Boot SPL cannot do for us ?

Though U-Boot SPL can do, it will need 64KB onchip memory. While the 
EPCS controller needs only 512B onchip memory. So we didn't ever 
consider SPL for nios2.

Best regards,
Thomas Chou

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 4/8] nios2: enlarge the code relocation range
  2015-09-07  0:22                       ` Thomas Chou
@ 2015-09-07  0:53                         ` Marek Vasut
  2015-09-07  1:47                           ` Thomas Chou
  0 siblings, 1 reply; 79+ messages in thread
From: Marek Vasut @ 2015-09-07  0:53 UTC (permalink / raw)
  To: u-boot

On Monday, September 07, 2015 at 02:22:52 AM, Thomas Chou wrote:
> Hi Marek,

Hi!

> On 09/06/2015 11:23 PM, Marek Vasut wrote:
> > Uh oh, is this copying something the U-Boot SPL cannot do for us ?
> 
> Though U-Boot SPL can do, it will need 64KB onchip memory. While the
> EPCS controller needs only 512B onchip memory. So we didn't ever
> consider SPL for nios2.

Where did that 64KB figure come from ? :O

I assume the simple loader is just a copy loop, huh ? And you synthesise
a small RAM or ROM into the FPGA and point NIOS to boot from that, right?
What about U-Boot TPL, can that cook the loader ? (yes, I'd like to be as
independent of the external code as possible).

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v4 0/7] nios2: add device tree control of U-Boot
  2015-09-04  3:15 [U-Boot] [PATCH 0/5] nios2: add device tree control of U-Boot Thomas Chou
                   ` (5 preceding siblings ...)
  2015-09-04 12:22 ` [U-Boot] [PATCH v2 0/8] nios2: add device tree control of U-Boot Thomas Chou
@ 2015-09-07  1:03 ` Thomas Chou
  2015-09-07  1:03   ` [U-Boot] [PATCH v4 1/7] nios2: permit " Thomas Chou
                     ` (7 more replies)
  6 siblings, 8 replies; 79+ messages in thread
From: Thomas Chou @ 2015-09-07  1:03 UTC (permalink / raw)
  To: u-boot

These patches add device tree control of U-Boot to nios2 boards.

v2
  use SPDX license header.
  use fdt relocation in board_init_f.
v3
  fix comment style.
v4
  drop fdt_blob print in board info, which needs more discussion.

Thomas Chou (7):
  nios2: permit device tree control of U-Boot
  nios2: move altera_pio_init to board_early_init_r
  nios2: BSS should be cleared only after board_init_f
  nios2: enlarge the code relocation range
  nios2: remove gp assignments in link script
  nios2: define _end in link script
  nios2: enable device tree control of U-Boot

 arch/Kconfig                               |   1 +
 arch/nios2/cpu/start.S                     |  35 ++++---
 arch/nios2/cpu/u-boot.lds                  |  14 ++-
 arch/nios2/dts/.gitignore                  |   1 +
 arch/nios2/dts/3c120_devboard.dts          | 153 +++++++++++++++++++++++++++++
 arch/nios2/dts/Makefile                    |  11 +++
 arch/nios2/dts/include/dt-bindings         |   1 +
 board/altera/nios2-generic/nios2-generic.c |  13 ++-
 configs/nios2-generic_defconfig            |   2 +
 include/configs/nios2-generic.h            |   1 +
 10 files changed, 209 insertions(+), 23 deletions(-)
 create mode 100644 arch/nios2/dts/.gitignore
 create mode 100644 arch/nios2/dts/3c120_devboard.dts
 create mode 100644 arch/nios2/dts/Makefile
 create mode 120000 arch/nios2/dts/include/dt-bindings

-- 
2.1.4

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v4 1/7] nios2: permit device tree control of U-Boot
  2015-09-07  1:03 ` [U-Boot] [PATCH v4 0/7] " Thomas Chou
@ 2015-09-07  1:03   ` Thomas Chou
  2015-09-07  2:24     ` Thomas Chou
  2015-09-07  1:03   ` [U-Boot] [PATCH v4 2/7] nios2: move altera_pio_init to board_early_init_r Thomas Chou
                     ` (6 subsequent siblings)
  7 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-07  1:03 UTC (permalink / raw)
  To: u-boot

Enable this in the Kconfig so that nios2 boards can use device
tree to configure U-Boot.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Marek Vasut <marex@denx.de>
---
 arch/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/Kconfig b/arch/Kconfig
index 4f73819..207c778 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -63,6 +63,7 @@ config NIOS2
 	bool "Nios II architecture"
 	select HAVE_GENERIC_BOARD
 	select SYS_GENERIC_BOARD
+	select SUPPORT_OF_CONTROL
 
 config OPENRISC
 	bool "OpenRISC architecture"
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v4 2/7] nios2: move altera_pio_init to board_early_init_r
  2015-09-07  1:03 ` [U-Boot] [PATCH v4 0/7] " Thomas Chou
  2015-09-07  1:03   ` [U-Boot] [PATCH v4 1/7] nios2: permit " Thomas Chou
@ 2015-09-07  1:03   ` Thomas Chou
  2015-09-07  2:24     ` Thomas Chou
  2015-09-07  1:03   ` [U-Boot] [PATCH v4 3/7] nios2: BSS should be cleared only after board_init_f Thomas Chou
                     ` (5 subsequent siblings)
  7 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-07  1:03 UTC (permalink / raw)
  To: u-boot

As altera_pio_init() uses BSS, it should be moved to
board_early_init_r().

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Acked-by: Marek Vasut <marex@denx.de>
---
 board/altera/nios2-generic/nios2-generic.c | 13 +++++++++----
 include/configs/nios2-generic.h            |  1 +
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/board/altera/nios2-generic/nios2-generic.c b/board/altera/nios2-generic/nios2-generic.c
index 834cbeb..384fee9 100644
--- a/board/altera/nios2-generic/nios2-generic.c
+++ b/board/altera/nios2-generic/nios2-generic.c
@@ -28,6 +28,15 @@ void early_flash_cmd_reset(void)
 
 int board_early_init_f(void)
 {
+#if defined(CONFIG_ENV_IS_IN_FLASH) && defined(CONFIG_ENV_ADDR) && \
+    defined(CONFIG_CFI_FLASH_MTD)
+	early_flash_cmd_reset();
+#endif
+	return 0;
+}
+
+int board_early_init_r(void)
+{
 #ifdef CONFIG_ALTERA_PIO
 #ifdef LED_PIO_BASE
 	altera_pio_init(LED_PIO_BASE, LED_PIO_WIDTH, 'o',
@@ -35,10 +44,6 @@ int board_early_init_f(void)
 			"led");
 #endif
 #endif
-#if defined(CONFIG_ENV_IS_IN_FLASH) && defined(CONFIG_ENV_ADDR) && \
-    defined(CONFIG_CFI_FLASH_MTD)
-	early_flash_cmd_reset();
-#endif
 	return 0;
 }
 
diff --git a/include/configs/nios2-generic.h b/include/configs/nios2-generic.h
index 5bb7768..293acae 100644
--- a/include/configs/nios2-generic.h
+++ b/include/configs/nios2-generic.h
@@ -15,6 +15,7 @@
 #include "../board/altera/nios2-generic/custom_fpga.h" /* fpga parameters */
 #define CONFIG_BOARD_NAME "nios2-generic" /* custom board name */
 #define CONFIG_BOARD_EARLY_INIT_F	/* enable early board-spec. init */
+#define CONFIG_BOARD_EARLY_INIT_R
 #define CONFIG_DISPLAY_CPUINFO
 #define CONFIG_DISPLAY_BOARDINFO
 #define CONFIG_SYS_NIOS_SYSID_BASE	CONFIG_SYS_SYSID_BASE
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v4 3/7] nios2: BSS should be cleared only after board_init_f
  2015-09-07  1:03 ` [U-Boot] [PATCH v4 0/7] " Thomas Chou
  2015-09-07  1:03   ` [U-Boot] [PATCH v4 1/7] nios2: permit " Thomas Chou
  2015-09-07  1:03   ` [U-Boot] [PATCH v4 2/7] nios2: move altera_pio_init to board_early_init_r Thomas Chou
@ 2015-09-07  1:03   ` Thomas Chou
  2015-09-07  2:25     ` Thomas Chou
  2015-09-07  1:03   ` [U-Boot] [PATCH v4 4/7] nios2: enlarge the code relocation range Thomas Chou
                     ` (4 subsequent siblings)
  7 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-07  1:03 UTC (permalink / raw)
  To: u-boot

As dtb in u-boot-dtb.bin overlapped the BSS section,
we should delay the clearing of BSS until dtb is relocated
in board_init_f().

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Acked-by: Marek Vasut <marex@denx.de>
---
 arch/nios2/cpu/start.S | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/arch/nios2/cpu/start.S b/arch/nios2/cpu/start.S
index 6af9b4e..9e440c2 100644
--- a/arch/nios2/cpu/start.S
+++ b/arch/nios2/cpu/start.S
@@ -82,20 +82,6 @@ _cur:	movhi	r5, %hi(_cur - _start)
 	bne	r5, r6, 2b
 3:
 
-	/* ZERO BSS/SBSS -- bss and sbss are assumed to be adjacent
-	 * and between __bss_start and __bss_end.
-	 */
-	 movhi	r5, %hi(__bss_start)
-	 ori	r5, r5, %lo(__bss_start)
-	 movhi	r6, %hi(__bss_end)
-	 ori	r6, r6, %lo(__bss_end)
-	 beq	r5, r6, 5f
-
-4:	stwio	r0, 0(r5)
-	 addi	r5, r5, 4
-	 bne	r5, r6, 4b
-5:
-
 	/* JUMP TO RELOC ADDR */
 	movhi	r4, %hi(_reloc)
 	ori	r4, r4, %lo(_reloc)
@@ -167,6 +153,22 @@ _reloc:
 relocate_code:
 	mov	sp, r4		/* Set the new sp */
 	mov	r4, r5
+
+	/*
+	 * ZERO BSS/SBSS -- bss and sbss are assumed to be adjacent
+	 * and between __bss_start and __bss_end.
+	 */
+	movhi	r5, %hi(__bss_start)
+	ori	r5, r5, %lo(__bss_start)
+	movhi	r6, %hi(__bss_end)
+	ori	r6, r6, %lo(__bss_end)
+	beq	r5, r6, 5f
+
+4:	stwio	r0, 0(r5)
+	addi	r5, r5, 4
+	bne	r5, r6, 4b
+5:
+
 	movhi	r8, %hi(board_init_r at h)
 	ori	r8, r8, %lo(board_init_r at h)
 	callr	r8
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v4 4/7] nios2: enlarge the code relocation range
  2015-09-07  1:03 ` [U-Boot] [PATCH v4 0/7] " Thomas Chou
                     ` (2 preceding siblings ...)
  2015-09-07  1:03   ` [U-Boot] [PATCH v4 3/7] nios2: BSS should be cleared only after board_init_f Thomas Chou
@ 2015-09-07  1:03   ` Thomas Chou
  2015-09-07  2:26     ` Thomas Chou
  2015-09-07  1:03   ` [U-Boot] [PATCH v4 5/7] nios2: remove gp assignments in link script Thomas Chou
                     ` (3 subsequent siblings)
  7 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-07  1:03 UTC (permalink / raw)
  To: u-boot

As we will use u-boot-dtb.bin, the code relocation range
should be adjusted to accommodate the additional dtb.
It might be overkilled to look into dtb header to find the
dtb size, so we will simply use CONFIG_SYS_MONITOR_LEN.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 arch/nios2/cpu/start.S | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/nios2/cpu/start.S b/arch/nios2/cpu/start.S
index 9e440c2..f80b4f3 100644
--- a/arch/nios2/cpu/start.S
+++ b/arch/nios2/cpu/start.S
@@ -73,8 +73,9 @@ _cur:	movhi	r5, %hi(_cur - _start)
 	ori	r5, r5, %lo(_start)	/* r5 <- linked _start */
 	beq	r4, r5, 3f
 
-	movhi	r6, %hi(_edata)
-	ori	r6, r6, %lo(_edata)
+	movhi	r6, %hi(CONFIG_SYS_MONITOR_LEN)
+	ori	r6, r6, %lo(CONFIG_SYS_MONITOR_LEN)
+	add	r6, r6, r5
 2:	ldwio	r7, 0(r4)
 	addi	r4, r4, 4
 	stwio	r7, 0(r5)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v4 5/7] nios2: remove gp assignments in link script
  2015-09-07  1:03 ` [U-Boot] [PATCH v4 0/7] " Thomas Chou
                     ` (3 preceding siblings ...)
  2015-09-07  1:03   ` [U-Boot] [PATCH v4 4/7] nios2: enlarge the code relocation range Thomas Chou
@ 2015-09-07  1:03   ` Thomas Chou
  2015-09-07  2:26     ` Thomas Chou
  2015-09-07  1:03   ` [U-Boot] [PATCH v4 6/7] nios2: define _end " Thomas Chou
                     ` (2 subsequent siblings)
  7 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-07  1:03 UTC (permalink / raw)
  To: u-boot

Since we don't use gp for small data with option "-G0",
we use gp as global data pointer. The _gp location is
not needed.

The ALIGN(16) was for gp only. It is removed, so that we
can get correct address of dtb in u-boot-dtb.bin image.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Marek Vasut <marex@denx.de>
---
 arch/nios2/cpu/u-boot.lds | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/nios2/cpu/u-boot.lds b/arch/nios2/cpu/u-boot.lds
index 6e174be..8b0fd1a 100644
--- a/arch/nios2/cpu/u-boot.lds
+++ b/arch/nios2/cpu/u-boot.lds
@@ -50,9 +50,11 @@ SECTIONS
 	  *(.gnu.linkonce.d*)
 	}
 
-	. = ALIGN(16);
-	_gp = .;			/* Global pointer addr */
-	PROVIDE (gp = .);
+	/*
+	 * gp - Since we don't use gp for small data with option "-G0",
+	 * we will use gp as global data pointer. The _gp location is
+	 * not needed.
+	 */
 
 	.sdata :
 	{
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v4 6/7] nios2: define _end in link script
  2015-09-07  1:03 ` [U-Boot] [PATCH v4 0/7] " Thomas Chou
                     ` (4 preceding siblings ...)
  2015-09-07  1:03   ` [U-Boot] [PATCH v4 5/7] nios2: remove gp assignments in link script Thomas Chou
@ 2015-09-07  1:03   ` Thomas Chou
  2015-09-07  2:27     ` Thomas Chou
  2015-09-07  1:03   ` [U-Boot] [PATCH v4 7/7] nios2: enable device tree control of U-Boot Thomas Chou
  2015-09-07  9:29   ` [U-Boot] [PATCH v4 0/7] nios2: add " Marek Vasut
  7 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-07  1:03 UTC (permalink / raw)
  To: u-boot

Since commit 44c6e6591cb451ae606f8bde71dd5fb7b4002544
"rename _end to __bss_end__" , the _end was removed.
But we need it now for separated device tree control,
ie, CONFIG_OF_SEPARATE .

The _end is used by fdtdec_setup() to find the blob.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Acked-by: Marek Vasut <marex@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 arch/nios2/cpu/u-boot.lds | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/nios2/cpu/u-boot.lds b/arch/nios2/cpu/u-boot.lds
index 8b0fd1a..3bd3f2c 100644
--- a/arch/nios2/cpu/u-boot.lds
+++ b/arch/nios2/cpu/u-boot.lds
@@ -67,6 +67,12 @@ SECTIONS
 	_edata = .;
 	PROVIDE (edata = .);
 
+	/*
+	 * _end - This is end of u-boot.bin image.
+	 * dtb will be appended here to make u-boot-dtb.bin
+	 */
+	_end = .;
+
 	/* UNINIT DATA - Small uninitialized data is first so it's
 	 * adjacent to sdata and can be referenced via gp. The normal
 	 * bss follows. We keep it adjacent to simplify init code.
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v4 7/7] nios2: enable device tree control of U-Boot
  2015-09-07  1:03 ` [U-Boot] [PATCH v4 0/7] " Thomas Chou
                     ` (5 preceding siblings ...)
  2015-09-07  1:03   ` [U-Boot] [PATCH v4 6/7] nios2: define _end " Thomas Chou
@ 2015-09-07  1:03   ` Thomas Chou
  2015-09-07  2:28     ` Thomas Chou
  2015-09-07  9:29   ` [U-Boot] [PATCH v4 0/7] nios2: add " Marek Vasut
  7 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-07  1:03 UTC (permalink / raw)
  To: u-boot

This patch adds device tree control of U-Boot to nios2 boards.
The example dts is taken from Linux kernel.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Marek Vasut <marex@denx.de>
---
 arch/nios2/dts/.gitignore          |   1 +
 arch/nios2/dts/3c120_devboard.dts  | 153 +++++++++++++++++++++++++++++++++++++
 arch/nios2/dts/Makefile            |  11 +++
 arch/nios2/dts/include/dt-bindings |   1 +
 configs/nios2-generic_defconfig    |   2 +
 5 files changed, 168 insertions(+)
 create mode 100644 arch/nios2/dts/.gitignore
 create mode 100644 arch/nios2/dts/3c120_devboard.dts
 create mode 100644 arch/nios2/dts/Makefile
 create mode 120000 arch/nios2/dts/include/dt-bindings

diff --git a/arch/nios2/dts/.gitignore b/arch/nios2/dts/.gitignore
new file mode 100644
index 0000000..b60ed20
--- /dev/null
+++ b/arch/nios2/dts/.gitignore
@@ -0,0 +1 @@
+*.dtb
diff --git a/arch/nios2/dts/3c120_devboard.dts b/arch/nios2/dts/3c120_devboard.dts
new file mode 100644
index 0000000..02524ab
--- /dev/null
+++ b/arch/nios2/dts/3c120_devboard.dts
@@ -0,0 +1,153 @@
+/*
+ *  Copyright (C) 2013 Altera Corporation
+ *
+ * This file is generated by sopc2dts.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+/dts-v1/;
+
+/ {
+	model = "altr,qsys_ghrd_3c120";
+	compatible = "altr,qsys_ghrd_3c120";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu: cpu at 0x0 {
+			device_type = "cpu";
+			compatible = "altr,nios2-1.0";
+			reg = <0x00000000>;
+			interrupt-controller;
+			#interrupt-cells = <1>;
+			clock-frequency = <125000000>;
+			dcache-line-size = <32>;
+			icache-line-size = <32>;
+			dcache-size = <32768>;
+			icache-size = <32768>;
+			altr,implementation = "fast";
+			altr,pid-num-bits = <8>;
+			altr,tlb-num-ways = <16>;
+			altr,tlb-num-entries = <128>;
+			altr,tlb-ptr-sz = <7>;
+			altr,has-div = <1>;
+			altr,has-mul = <1>;
+			altr,reset-addr = <0xc2800000>;
+			altr,fast-tlb-miss-addr = <0xc7fff400>;
+			altr,exception-addr = <0xd0000020>;
+			altr,has-initda = <1>;
+			altr,has-mmu = <1>;
+		};
+	};
+
+	memory at 0 {
+		device_type = "memory";
+		reg = <0x10000000 0x08000000>,
+			<0x07fff400 0x00000400>;
+	};
+
+	sopc at 0 {
+		device_type = "soc";
+		ranges;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "altr,avalon", "simple-bus";
+		bus-frequency = <125000000>;
+
+		pb_cpu_to_io: bridge at 0x8000000 {
+			compatible = "simple-bus";
+			reg = <0x08000000 0x00800000>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges = <0x00002000 0x08002000 0x00002000>,
+				<0x00004000 0x08004000 0x00000400>,
+				<0x00004400 0x08004400 0x00000040>,
+				<0x00004800 0x08004800 0x00000040>,
+				<0x00004c80 0x08004c80 0x00000020>,
+				<0x00004d50 0x08004d50 0x00000008>,
+				<0x00008000 0x08008000 0x00000020>,
+				<0x00400000 0x08400000 0x00000020>;
+
+			timer_1ms: timer at 0x400000 {
+				compatible = "altr,timer-1.0";
+				reg = <0x00400000 0x00000020>;
+				interrupt-parent = <&cpu>;
+				interrupts = <11>;
+				clock-frequency = <125000000>;
+			};
+
+			timer_0: timer at 0x8000 {
+				compatible = "altr,timer-1.0";
+				reg = < 0x00008000 0x00000020 >;
+				interrupt-parent = < &cpu >;
+				interrupts = < 5 >;
+				clock-frequency = < 125000000 >;
+			};
+
+			jtag_uart: serial at 0x4d50 {
+				compatible = "altr,juart-1.0";
+				reg = <0x00004d50 0x00000008>;
+				interrupt-parent = <&cpu>;
+				interrupts = <1>;
+			};
+
+			tse_mac: ethernet at 0x4000 {
+				compatible = "altr,tse-1.0";
+				reg = <0x00004000 0x00000400>,
+					<0x00004400 0x00000040>,
+					<0x00004800 0x00000040>,
+					<0x00002000 0x00002000>;
+				reg-names = "control_port", "rx_csr", "tx_csr", "s1";
+				interrupt-parent = <&cpu>;
+				interrupts = <2 3>;
+				interrupt-names = "rx_irq", "tx_irq";
+				rx-fifo-depth = <8192>;
+				tx-fifo-depth = <8192>;
+				max-frame-size = <1518>;
+				local-mac-address = [ 00 00 00 00 00 00 ];
+				phy-mode = "rgmii-id";
+				phy-handle = <&phy0>;
+				tse_mac_mdio: mdio {
+					compatible = "altr,tse-mdio";
+					#address-cells = <1>;
+					#size-cells = <0>;
+					phy0: ethernet-phy at 18 {
+						reg = <18>;
+						device_type = "ethernet-phy";
+					};
+				};
+			};
+
+			uart: serial at 0x4c80 {
+				compatible = "altr,uart-1.0";
+				reg = <0x00004c80 0x00000020>;
+				interrupt-parent = <&cpu>;
+				interrupts = <10>;
+				current-speed = <115200>;
+				clock-frequency = <62500000>;
+			};
+		};
+
+		cfi_flash_64m: flash at 0x0 {
+			compatible = "cfi-flash";
+			reg = <0x00000000 0x04000000>;
+			bank-width = <2>;
+			device-width = <1>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 800000 {
+				reg = <0x00800000 0x01e00000>;
+				label = "JFFS2 Filesystem";
+			};
+		};
+	};
+
+	chosen {
+		bootargs = "debug console=ttyJ0,115200";
+	};
+};
diff --git a/arch/nios2/dts/Makefile b/arch/nios2/dts/Makefile
new file mode 100644
index 0000000..b2175a1
--- /dev/null
+++ b/arch/nios2/dts/Makefile
@@ -0,0 +1,11 @@
+dtb-y += 3c120_devboard.dtb
+
+targets += $(dtb-y)
+
+DTC_FLAGS += -R 4 -p 0x1000
+
+PHONY += dtbs
+dtbs: $(addprefix $(obj)/, $(dtb-y))
+	@:
+
+clean-files := *.dtb
diff --git a/arch/nios2/dts/include/dt-bindings b/arch/nios2/dts/include/dt-bindings
new file mode 120000
index 0000000..0cecb3d
--- /dev/null
+++ b/arch/nios2/dts/include/dt-bindings
@@ -0,0 +1 @@
+../../../../include/dt-bindings
\ No newline at end of file
diff --git a/configs/nios2-generic_defconfig b/configs/nios2-generic_defconfig
index f8d2821..09cc51e 100644
--- a/configs/nios2-generic_defconfig
+++ b/configs/nios2-generic_defconfig
@@ -1,5 +1,6 @@
 CONFIG_NIOS2=y
 CONFIG_TARGET_NIOS2_GENERIC=y
+CONFIG_DEFAULT_DEVICE_TREE="3c120_devboard"
 CONFIG_HUSH_PARSER=y
 # CONFIG_CMD_BOOTD is not set
 # CONFIG_CMD_IMLS is not set
@@ -10,4 +11,5 @@ CONFIG_HUSH_PARSER=y
 CONFIG_CMD_DHCP=y
 # CONFIG_CMD_NFS is not set
 CONFIG_CMD_PING=y
+CONFIG_OF_CONTROL=y
 CONFIG_NET_RANDOM_ETHADDR=y
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 0/8] nios2: add device tree control of U-Boot
  2015-09-05  3:20     ` Thomas Chou
  2015-09-05 12:53       ` Marek Vasut
@ 2015-09-07  1:36       ` Ley Foon Tan
  1 sibling, 0 replies; 79+ messages in thread
From: Ley Foon Tan @ 2015-09-07  1:36 UTC (permalink / raw)
  To: u-boot

On Sab, 2015-09-05 at 11:20 +0800, Thomas Chou wrote:
> Hi Marek,
> 
> On 09/04/2015 10:04 PM, Marek Vasut wrote:
> > I can start picking the NIOS2 stuff into U-Boot as well if you want.
> 
> That's great! You are very kind and responsive. Thanks a lot. You can 
> take over the custodianship of nios2 arch. Then I will be retired. :)
Added Altera socfpga U-boot owner in CC list. 
> 
> BTW, please also look over the earlier patches,
> 
> [PATCH] nios2: move command line configuration to Kconfig, Aug,28
> [PATCH] nios2: enable CONFIG_NET_RANDOM_ETHADDR, Aug,29
> And perhaps,
> [PATCH] mmc_spi: fix big-endian support error on be_to_cpu16, Aug,31
> 
> Cheers,
> Thomas Chou

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 4/8] nios2: enlarge the code relocation range
  2015-09-07  0:53                         ` Marek Vasut
@ 2015-09-07  1:47                           ` Thomas Chou
  2015-09-07  9:31                             ` Marek Vasut
  0 siblings, 1 reply; 79+ messages in thread
From: Thomas Chou @ 2015-09-07  1:47 UTC (permalink / raw)
  To: u-boot

Hi Marek,

On 09/07/2015 08:53 AM, Marek Vasut wrote:
> Where did that 64KB figure come from ? :O

This is estimated from 41KB of the SPL of socfpga. The code density of 
nios2 is worse than ARM.

> I assume the simple loader is just a copy loop, huh ? And you synthesise
> a small RAM or ROM into the FPGA and point NIOS to boot from that, right?

Right. It is hidden from the user in qsys. You will need to dig into the 
code to find out. The EPCS boot copier is coded in nios2 ASM.

> What about U-Boot TPL, can that cook the loader ? (yes, I'd like to be as
> independent of the external code as possible).

I'd like to be independent of the external code, too. In the past, I 
have my own SPI core (now the oc_tiny_spi) to control EPCS, which is 
actually SPI flash, and my own boot copier with/out decompression.

It is possible to add an TPL support for nios2 EPCS. If someone want to 
work on it.. :)

Best regards,
Thomas Chou

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v4 1/7] nios2: permit device tree control of U-Boot
  2015-09-07  1:03   ` [U-Boot] [PATCH v4 1/7] nios2: permit " Thomas Chou
@ 2015-09-07  2:24     ` Thomas Chou
  0 siblings, 0 replies; 79+ messages in thread
From: Thomas Chou @ 2015-09-07  2:24 UTC (permalink / raw)
  To: u-boot



On 09/07/2015 09:03 AM, Thomas Chou wrote:
> Enable this in the Kconfig so that nios2 boards can use device
> tree to configure U-Boot.
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Acked-by: Marek Vasut <marex@denx.de>
> ---
>   arch/Kconfig | 1 +
>   1 file changed, 1 insertion(+)

Applied to u-boot-nios.

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v4 2/7] nios2: move altera_pio_init to board_early_init_r
  2015-09-07  1:03   ` [U-Boot] [PATCH v4 2/7] nios2: move altera_pio_init to board_early_init_r Thomas Chou
@ 2015-09-07  2:24     ` Thomas Chou
  0 siblings, 0 replies; 79+ messages in thread
From: Thomas Chou @ 2015-09-07  2:24 UTC (permalink / raw)
  To: u-boot



On 09/07/2015 09:03 AM, Thomas Chou wrote:
> As altera_pio_init() uses BSS, it should be moved to
> board_early_init_r().
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> Acked-by: Marek Vasut <marex@denx.de>
> ---
>   board/altera/nios2-generic/nios2-generic.c | 13 +++++++++----
>   include/configs/nios2-generic.h            |  1 +
>   2 files changed, 10 insertions(+), 4 deletions(-)

Applied to u-boot-nios.

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v4 3/7] nios2: BSS should be cleared only after board_init_f
  2015-09-07  1:03   ` [U-Boot] [PATCH v4 3/7] nios2: BSS should be cleared only after board_init_f Thomas Chou
@ 2015-09-07  2:25     ` Thomas Chou
  0 siblings, 0 replies; 79+ messages in thread
From: Thomas Chou @ 2015-09-07  2:25 UTC (permalink / raw)
  To: u-boot



On 09/07/2015 09:03 AM, Thomas Chou wrote:
> As dtb in u-boot-dtb.bin overlapped the BSS section,
> we should delay the clearing of BSS until dtb is relocated
> in board_init_f().
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> Acked-by: Marek Vasut <marex@denx.de>
> ---
>   arch/nios2/cpu/start.S | 30 ++++++++++++++++--------------
>   1 file changed, 16 insertions(+), 14 deletions(-)

Applied to u-boot-nios.

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v4 4/7] nios2: enlarge the code relocation range
  2015-09-07  1:03   ` [U-Boot] [PATCH v4 4/7] nios2: enlarge the code relocation range Thomas Chou
@ 2015-09-07  2:26     ` Thomas Chou
  0 siblings, 0 replies; 79+ messages in thread
From: Thomas Chou @ 2015-09-07  2:26 UTC (permalink / raw)
  To: u-boot



On 09/07/2015 09:03 AM, Thomas Chou wrote:
> As we will use u-boot-dtb.bin, the code relocation range
> should be adjusted to accommodate the additional dtb.
> It might be overkilled to look into dtb header to find the
> dtb size, so we will simply use CONFIG_SYS_MONITOR_LEN.
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> ---
>   arch/nios2/cpu/start.S | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>

Applied to u-boot-nios.

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v4 5/7] nios2: remove gp assignments in link script
  2015-09-07  1:03   ` [U-Boot] [PATCH v4 5/7] nios2: remove gp assignments in link script Thomas Chou
@ 2015-09-07  2:26     ` Thomas Chou
  0 siblings, 0 replies; 79+ messages in thread
From: Thomas Chou @ 2015-09-07  2:26 UTC (permalink / raw)
  To: u-boot



On 09/07/2015 09:03 AM, Thomas Chou wrote:
> Since we don't use gp for small data with option "-G0",
> we use gp as global data pointer. The _gp location is
> not needed.
>
> The ALIGN(16) was for gp only. It is removed, so that we
> can get correct address of dtb in u-boot-dtb.bin image.
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Acked-by: Marek Vasut <marex@denx.de>
> ---
>   arch/nios2/cpu/u-boot.lds | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
>

Applied to u-boot-nios.

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v4 6/7] nios2: define _end in link script
  2015-09-07  1:03   ` [U-Boot] [PATCH v4 6/7] nios2: define _end " Thomas Chou
@ 2015-09-07  2:27     ` Thomas Chou
  0 siblings, 0 replies; 79+ messages in thread
From: Thomas Chou @ 2015-09-07  2:27 UTC (permalink / raw)
  To: u-boot



On 09/07/2015 09:03 AM, Thomas Chou wrote:
> Since commit 44c6e6591cb451ae606f8bde71dd5fb7b4002544
> "rename _end to __bss_end__" , the _end was removed.
> But we need it now for separated device tree control,
> ie, CONFIG_OF_SEPARATE .
>
> The _end is used by fdtdec_setup() to find the blob.
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> Acked-by: Marek Vasut <marex@denx.de>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> ---
>   arch/nios2/cpu/u-boot.lds | 6 ++++++
>   1 file changed, 6 insertions(+)
>

Applied to u-boot-nios.

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v4 7/7] nios2: enable device tree control of U-Boot
  2015-09-07  1:03   ` [U-Boot] [PATCH v4 7/7] nios2: enable device tree control of U-Boot Thomas Chou
@ 2015-09-07  2:28     ` Thomas Chou
  0 siblings, 0 replies; 79+ messages in thread
From: Thomas Chou @ 2015-09-07  2:28 UTC (permalink / raw)
  To: u-boot



On 09/07/2015 09:03 AM, Thomas Chou wrote:
> This patch adds device tree control of U-Boot to nios2 boards.
> The example dts is taken from Linux kernel.
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Acked-by: Marek Vasut <marex@denx.de>
> ---
>   arch/nios2/dts/.gitignore          |   1 +
>   arch/nios2/dts/3c120_devboard.dts  | 153 +++++++++++++++++++++++++++++++++++++
>   arch/nios2/dts/Makefile            |  11 +++
>   arch/nios2/dts/include/dt-bindings |   1 +
>   configs/nios2-generic_defconfig    |   2 +
>   5 files changed, 168 insertions(+)
>   create mode 100644 arch/nios2/dts/.gitignore
>   create mode 100644 arch/nios2/dts/3c120_devboard.dts
>   create mode 100644 arch/nios2/dts/Makefile
>   create mode 120000 arch/nios2/dts/include/dt-bindings
>

Applied to u-boot-nios.

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v4 0/7] nios2: add device tree control of U-Boot
  2015-09-07  1:03 ` [U-Boot] [PATCH v4 0/7] " Thomas Chou
                     ` (6 preceding siblings ...)
  2015-09-07  1:03   ` [U-Boot] [PATCH v4 7/7] nios2: enable device tree control of U-Boot Thomas Chou
@ 2015-09-07  9:29   ` Marek Vasut
  2015-09-07 14:20     ` Thomas Chou
  7 siblings, 1 reply; 79+ messages in thread
From: Marek Vasut @ 2015-09-07  9:29 UTC (permalink / raw)
  To: u-boot

On Monday, September 07, 2015 at 03:03:19 AM, Thomas Chou wrote:
> These patches add device tree control of U-Boot to nios2 boards.
> 
> v2
>   use SPDX license header.
>   use fdt relocation in board_init_f.
> v3
>   fix comment style.
> v4
>   drop fdt_blob print in board info, which needs more discussion.
> 
> Thomas Chou (7):
>   nios2: permit device tree control of U-Boot
>   nios2: move altera_pio_init to board_early_init_r
>   nios2: BSS should be cleared only after board_init_f
>   nios2: enlarge the code relocation range
>   nios2: remove gp assignments in link script
>   nios2: define _end in link script
>   nios2: enable device tree control of U-Boot

Hi,

Nice, I like seeing how NIOS2 getting back to shape. btw you could have
waited a few days before applying patches that were just posted.

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 4/8] nios2: enlarge the code relocation range
  2015-09-07  1:47                           ` Thomas Chou
@ 2015-09-07  9:31                             ` Marek Vasut
  0 siblings, 0 replies; 79+ messages in thread
From: Marek Vasut @ 2015-09-07  9:31 UTC (permalink / raw)
  To: u-boot

On Monday, September 07, 2015 at 03:47:46 AM, Thomas Chou wrote:
> Hi Marek,

Hi!

> On 09/07/2015 08:53 AM, Marek Vasut wrote:
> > Where did that 64KB figure come from ? :O
> 
> This is estimated from 41KB of the SPL of socfpga. The code density of
> nios2 is worse than ARM.
> 
> > I assume the simple loader is just a copy loop, huh ? And you synthesise
> > a small RAM or ROM into the FPGA and point NIOS to boot from that, right?
> 
> Right. It is hidden from the user in qsys. You will need to dig into the
> code to find out. The EPCS boot copier is coded in nios2 ASM.

Oh, I see.

> > What about U-Boot TPL, can that cook the loader ? (yes, I'd like to be as
> > independent of the external code as possible).
> 
> I'd like to be independent of the external code, too. In the past, I
> have my own SPI core (now the oc_tiny_spi) to control EPCS, which is
> actually SPI flash, and my own boot copier with/out decompression.
> 
> It is possible to add an TPL support for nios2 EPCS. If someone want to
> work on it.. :)

I'll keep this in mind, thanks :)

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v4 0/7] nios2: add device tree control of U-Boot
  2015-09-07  9:29   ` [U-Boot] [PATCH v4 0/7] nios2: add " Marek Vasut
@ 2015-09-07 14:20     ` Thomas Chou
  0 siblings, 0 replies; 79+ messages in thread
From: Thomas Chou @ 2015-09-07 14:20 UTC (permalink / raw)
  To: u-boot

Hi Marek,

On 09/07/2015 05:29 PM, Marek Vasut wrote:
> Nice, I like seeing how NIOS2 getting back to shape. btw you could have
> waited a few days before applying patches that were just posted.

Thanks for reminding. I used to wait a week. But I hate too many things 
floating around, that would prevent me to focus. Something we might have 
enough discussion or too trivial..

Thank you again. And please continue your great work.

Cheers,
Thomas Chou

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 7/8] nios2: show fdt blob address in board info command
  2015-09-06 14:27             ` Marek Vasut
@ 2015-09-08  3:55               ` Simon Glass
  2015-09-08 10:10                 ` Marek Vasut
  0 siblings, 1 reply; 79+ messages in thread
From: Simon Glass @ 2015-09-08  3:55 UTC (permalink / raw)
  To: u-boot

Hi,

On 6 September 2015 at 08:27, Marek Vasut <marex@denx.de> wrote:
> On Sunday, September 06, 2015 at 03:20:21 PM, Thomas Chou wrote:
>> Hi Marek,
>>
>> >>> I think this will not work on 64bit machines.
>>
>> I tried 64bits with
>>
>>       print_lnum("fdt_blob", (u64)gd->fdt_blob);
>>
>> But got this warning,
>>
>>    CC      common/cmd_bdinfo.o
>> common/cmd_bdinfo.c: In function 'do_bdinfo':
>> common/cmd_bdinfo.c:180:25: warning: cast from pointer to integer of
>> different size [-Wpointer-to-int-cast]
>>    print_lnum("fdt_blob", (u64)gd->fdt_blob);
>>                           ^
>> include/asm-generic/global_data.h
>>       const void *fdt_blob;   /* Our device tree, NULL if none */
>>
>> Actually, the print is guarded with CONFIG_NIOS2, so it is safe to use
>> 32bits.
>>
>> Or shall we invent a "print pointer address"?
>
> Simon, Tom, what's your take on this ?

From what I can tell this code is not generic, and is built for NIOS
only. So IMO the patch is fine and we don't need to worry about
64-bit.

Regards,
Simon

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 7/8] nios2: show fdt blob address in board info command
  2015-09-08  3:55               ` Simon Glass
@ 2015-09-08 10:10                 ` Marek Vasut
  0 siblings, 0 replies; 79+ messages in thread
From: Marek Vasut @ 2015-09-08 10:10 UTC (permalink / raw)
  To: u-boot

On Tuesday, September 08, 2015 at 05:55:59 AM, Simon Glass wrote:
> Hi,
> 
> On 6 September 2015 at 08:27, Marek Vasut <marex@denx.de> wrote:
> > On Sunday, September 06, 2015 at 03:20:21 PM, Thomas Chou wrote:
> >> Hi Marek,
> >> 
> >> >>> I think this will not work on 64bit machines.
> >> 
> >> I tried 64bits with
> >> 
> >>       print_lnum("fdt_blob", (u64)gd->fdt_blob);
> >> 
> >> But got this warning,
> >> 
> >>    CC      common/cmd_bdinfo.o
> >> 
> >> common/cmd_bdinfo.c: In function 'do_bdinfo':
> >> common/cmd_bdinfo.c:180:25: warning: cast from pointer to integer of
> >> different size [-Wpointer-to-int-cast]
> >> 
> >>    print_lnum("fdt_blob", (u64)gd->fdt_blob);
> >>    
> >>                           ^
> >> 
> >> include/asm-generic/global_data.h
> >> 
> >>       const void *fdt_blob;   /* Our device tree, NULL if none */
> >> 
> >> Actually, the print is guarded with CONFIG_NIOS2, so it is safe to use
> >> 32bits.
> >> 
> >> Or shall we invent a "print pointer address"?
> > 
> > Simon, Tom, what's your take on this ?
> 
> From what I can tell this code is not generic, and is built for NIOS
> only. So IMO the patch is fine and we don't need to worry about
> 64-bit.

Oh my $DEITY, we have one bdinfo implementation per architecture, all in
one ugly file. In that case, you're right, but this is truly horrible.

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [U-Boot] [PATCH v2 7/8] nios2: show fdt blob address in board info command
  2015-09-04 12:22   ` [U-Boot] [PATCH v2 7/8] nios2: show fdt blob address in board info command Thomas Chou
  2015-09-04 14:01     ` Marek Vasut
  2015-09-04 14:10     ` Simon Glass
@ 2015-09-09  4:26     ` Thomas Chou
  2 siblings, 0 replies; 79+ messages in thread
From: Thomas Chou @ 2015-09-09  4:26 UTC (permalink / raw)
  To: u-boot



On 09/04/2015 08:22 PM, Thomas Chou wrote:
> Show fdt blob address in board info command.
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> ---
>   common/cmd_bdinfo.c | 3 +++
>   1 file changed, 3 insertions(+)

Applied to u-boot-nios2.

^ permalink raw reply	[flat|nested] 79+ messages in thread

end of thread, other threads:[~2015-09-09  4:26 UTC | newest]

Thread overview: 79+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-04  3:15 [U-Boot] [PATCH 0/5] nios2: add device tree control of U-Boot Thomas Chou
2015-09-04  3:15 ` [U-Boot] [PATCH 1/5] nios2: permit " Thomas Chou
2015-09-04  4:08   ` Simon Glass
2015-09-04  3:15 ` [U-Boot] [PATCH 2/5] nios2: enable " Thomas Chou
2015-09-04  4:09   ` Simon Glass
2015-09-04  3:15 ` [U-Boot] [PATCH 3/5] nios2: revert _end symbol in link script Thomas Chou
2015-09-04  4:09   ` Simon Glass
2015-09-04  3:15 ` [U-Boot] [PATCH 4/5] nios2: initialize stack earlier in startup Thomas Chou
2015-09-04  4:09   ` Simon Glass
2015-09-04  3:15 ` [U-Boot] [PATCH 5/5] nios2: relocate dtb for separated device tree Thomas Chou
2015-09-04  4:09   ` Simon Glass
2015-09-04  4:47     ` Thomas Chou
2015-09-04 12:22 ` [U-Boot] [PATCH v2 0/8] nios2: add device tree control of U-Boot Thomas Chou
2015-09-04 12:22   ` [U-Boot] [PATCH v2 1/8] nios2: permit " Thomas Chou
2015-09-04 13:54     ` Marek Vasut
2015-09-04 12:22   ` [U-Boot] [PATCH v2 2/8] nios2: move altera_pio_init to board_early_init_r Thomas Chou
2015-09-04 13:55     ` Marek Vasut
2015-09-05  0:16       ` Thomas Chou
2015-09-05  0:54         ` Marek Vasut
2015-09-04 12:22   ` [U-Boot] [PATCH v2 3/8] nios2: BSS should be cleared only after board_init_f Thomas Chou
2015-09-04 13:56     ` Marek Vasut
2015-09-04 12:22   ` [U-Boot] [PATCH v2 4/8] nios2: enlarge the code relocation range Thomas Chou
2015-09-04 13:59     ` Marek Vasut
2015-09-05  2:17       ` Thomas Chou
2015-09-05 12:50         ` Marek Vasut
2015-09-06 11:28           ` Thomas Chou
2015-09-06 12:29             ` Marek Vasut
2015-09-06 13:12               ` Thomas Chou
2015-09-06 13:18                 ` Marek Vasut
2015-09-06 13:49                   ` Thomas Chou
2015-09-06 15:23                     ` Marek Vasut
2015-09-07  0:22                       ` Thomas Chou
2015-09-07  0:53                         ` Marek Vasut
2015-09-07  1:47                           ` Thomas Chou
2015-09-07  9:31                             ` Marek Vasut
2015-09-04 12:22   ` [U-Boot] [PATCH v2 5/8] nios2: remove gp assignments in link script Thomas Chou
2015-09-04 14:00     ` Marek Vasut
2015-09-05  2:31       ` [U-Boot] [PATCH v3 " Thomas Chou
2015-09-04 12:22   ` [U-Boot] [PATCH v2 6/8] nios2: define _end " Thomas Chou
2015-09-04 14:01     ` Marek Vasut
2015-09-05  2:41       ` [U-Boot] [PATCH v3 " Thomas Chou
2015-09-05 12:49         ` Marek Vasut
2015-09-04 14:09     ` [U-Boot] [PATCH v2 " Simon Glass
2015-09-04 12:22   ` [U-Boot] [PATCH v2 7/8] nios2: show fdt blob address in board info command Thomas Chou
2015-09-04 14:01     ` Marek Vasut
2015-09-05  2:54       ` Thomas Chou
2015-09-05 12:51         ` Marek Vasut
2015-09-06 11:31           ` Thomas Chou
2015-09-06 13:20           ` Thomas Chou
2015-09-06 14:27             ` Marek Vasut
2015-09-08  3:55               ` Simon Glass
2015-09-08 10:10                 ` Marek Vasut
2015-09-04 14:10     ` Simon Glass
2015-09-09  4:26     ` Thomas Chou
2015-09-04 12:22   ` [U-Boot] [PATCH v2 8/8] nios2: enable device tree control of U-Boot Thomas Chou
2015-09-04 14:03     ` Marek Vasut
2015-09-05  3:36       ` Thomas Chou
2015-09-05 12:52         ` Marek Vasut
2015-09-04 14:04   ` [U-Boot] [PATCH v2 0/8] nios2: add " Marek Vasut
2015-09-05  3:20     ` Thomas Chou
2015-09-05 12:53       ` Marek Vasut
2015-09-07  1:36       ` Ley Foon Tan
2015-09-07  1:03 ` [U-Boot] [PATCH v4 0/7] " Thomas Chou
2015-09-07  1:03   ` [U-Boot] [PATCH v4 1/7] nios2: permit " Thomas Chou
2015-09-07  2:24     ` Thomas Chou
2015-09-07  1:03   ` [U-Boot] [PATCH v4 2/7] nios2: move altera_pio_init to board_early_init_r Thomas Chou
2015-09-07  2:24     ` Thomas Chou
2015-09-07  1:03   ` [U-Boot] [PATCH v4 3/7] nios2: BSS should be cleared only after board_init_f Thomas Chou
2015-09-07  2:25     ` Thomas Chou
2015-09-07  1:03   ` [U-Boot] [PATCH v4 4/7] nios2: enlarge the code relocation range Thomas Chou
2015-09-07  2:26     ` Thomas Chou
2015-09-07  1:03   ` [U-Boot] [PATCH v4 5/7] nios2: remove gp assignments in link script Thomas Chou
2015-09-07  2:26     ` Thomas Chou
2015-09-07  1:03   ` [U-Boot] [PATCH v4 6/7] nios2: define _end " Thomas Chou
2015-09-07  2:27     ` Thomas Chou
2015-09-07  1:03   ` [U-Boot] [PATCH v4 7/7] nios2: enable device tree control of U-Boot Thomas Chou
2015-09-07  2:28     ` Thomas Chou
2015-09-07  9:29   ` [U-Boot] [PATCH v4 0/7] nios2: add " Marek Vasut
2015-09-07 14:20     ` Thomas Chou

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.