Skip to contentSkip to conversation

MIPS: add initial device tree support

RFC Superseded Antony Pavlov 2 participants 6 messages May 7, 2013 – May 8, 2013

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover MIPS: add initial device tree support

The patch 2/4 (of: add MIPS memory bank adding support) is debatable, please comment it.

[RFC 1/4] MIPS: add initial device tree support [RFC 2/4] of: add MIPS memory bank adding support [RFC 3/4] MIPS: qemu-malta: add device tree support [RFC 4/4] MIPS: qemu-malta_defconfig: enable OF support

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#1 lore raw

RFC 1/4 MIPS: add initial device tree support

---
 arch/mips/Kconfig           |    8 ++++++++
 arch/mips/Makefile          |   12 ++++++++++++
 arch/mips/boot/Makefile     |    2 ++
 arch/mips/boot/dtb.c        |   44 +++++++++++++++++++++++++++++++++++++++++++
 arch/mips/dts/Makefile      |   10 ++++++++++
 arch/mips/dts/skeleton.dtsi |   13 +++++++++++++
 arch/mips/lib/barebox.lds.S |    2 ++
 7 files changed, 91 insertions(+)
 create mode 100644 arch/mips/boot/dtb.c
 create mode 100644 arch/mips/dts/Makefile
 create mode 100644 arch/mips/dts/skeleton.dtsi
arch/mips/Kconfig +8 -0
index 947edcf..d58b804 100644
@@ -23,6 +23,14 @@ config GENERIC_LINKER_SCRIPT
 
 menu "Machine selection"
 
+config BUILTIN_DTB
+	bool "link a DTB into the barebox image"
+	depends on OFTREE
+
+config BUILTIN_DTB_NAME
+	string "DTB to build into the barebox image"
+	depends on BUILTIN_DTB
+
 choice
 	prompt "System type"
 	default MACH_MIPS_MALTA
arch/mips/Makefile +12 -0
index 3c565a4..c038933 100644
@@ -113,6 +113,8 @@ common-y += $(BOARD) $(MACH)
 common-y += arch/mips/lib/
 common-y += arch/mips/boot/
 
+common-$(CONFIG_BUILTIN_DTB) += arch/mips/dts/
+
 CPPFLAGS += $(cflags-y)
 CFLAGS += $(cflags-y)
 
@@ -127,4 +129,14 @@ zbarebox.S zbarebox.bin zbarebox: barebox.bin
 archclean:
 	$(MAKE) $(clean)=$(pbl)
 
+dts := arch/mips/dts
+
+%.dtb: scripts
+	$(Q)$(MAKE) $(build)=$(dts) $(dts)/$@
+
+dtbs: scripts
+	$(Q)$(MAKE) $(build)=$(dts) dtbs
+
+KBUILD_DTBS := dtbs
+
 KBUILD_IMAGE ?= $(KBUILD_BINARY)
arch/mips/boot/Makefile +2 -0
index 6b093f1..b865b10 100644
@@ -1,4 +1,6 @@
 obj-y += start.o
 obj-y += main_entry.o
 
+obj-$(CONFIG_BUILTIN_DTB) += dtb.o
+
 pbl-y += start-pbl.o main_entry-pbl.o
arch/mips/boot/dtb.c new file +44 -0

44 lines not on this page · raw message

arch/mips/dts/Makefile new file +10 -0
new file mode 100644
index 0000000..3ee8924
@@ -0,0 +1,10 @@
+
+BUILTIN_DTB := $(patsubst "%",%,$(CONFIG_BUILTIN_DTB_NAME)).dtb.o
+obj-$(CONFIG_BUILTIN_DTB) += $(BUILTIN_DTB)
+
+targets += dtbs
+targets += $(dtb-y)
+
+dtbs: $(addprefix $(obj)/, $(dtb-y))
+
+clean-files := *.dtb *.dtb.S
arch/mips/dts/skeleton.dtsi new file +13 -0
new file mode 100644
index 0000000..b41d241
@@ -0,0 +1,13 @@
+/*
+ * Skeleton device tree; the bare minimum needed to boot; just include and
+ * add a compatible value.  The bootloader will typically populate the memory
+ * node.
+ */
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+	chosen { };
+	aliases { };
+	memory { device_type = "memory"; reg = <0 0>; };
+};
arch/mips/lib/barebox.lds.S +2 -0
index 5b3d45d..bc78d2b 100644
@@ -69,6 +69,8 @@ SECTIONS
 	__usymtab : { BAREBOX_SYMS }
 	__usymtab_end = .;
 
+	.dtb : { BAREBOX_DTB() }
+
 	_edata = .;
 	. = ALIGN(4);
 	__bss_start = .;
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

RFC 2/4 of: add MIPS memory bank adding support

In reply to Antony Pavlov

The MIPS architecture has different view on memory resources than the ARM architecture.
This patch move memory segment registration to a arch-specific files.

---
 arch/arm/cpu/dtb.c   |   13 +++++++++++++
 arch/mips/boot/dtb.c |   17 +++++++++++++++++
 drivers/of/base.c    |    8 +-------
 include/of.h         |    2 ++
 4 files changed, 33 insertions(+), 7 deletions(-)
arch/arm/cpu/dtb.c +13 -0
index 10b73bd..66346cf 100644
@@ -17,6 +17,19 @@
 #include <common.h>
 #include <init.h>
 #include <of.h>
+#include <memory.h>
+
+void of_add_memory_bank(struct device_node *node, bool dump, int r,
+		u64 base, u64 size)
+{
+	static char str[6];
+
+	sprintf(str, "ram%d", r);
+	barebox_add_memory_bank(str, base, size);
+
+	if (dump)
+		pr_info("%s: %s: 0x%llx@0x%llx\n", node->name, str, size, base);
+}
 
 extern char __dtb_start[];
 
arch/mips/boot/dtb.c +17 -0
index d20fab3..c1962bf 100644
@@ -20,6 +20,23 @@
 #include <common.h>
 #include <init.h>
 #include <of.h>
+#include <memory.h>
+#include <asm/addrspace.h>
+
+void of_add_memory_bank(struct device_node *node, bool dump, int r,
+		u64 base, u64 size)
+{
+	static char str[12];
+
+	sprintf(str, "kseg0_ram%d", r);
+	barebox_add_memory_bank(str, KSEG0 | base, size);
+
+	sprintf(str, "kseg1_ram%d", r);
+	barebox_add_memory_bank(str, KSEG1 | base, size);
+
+	if (dump)
+		pr_info("%s: %s: 0x%llx@0x%llx\n", node->name, str, size, base);
+}
 
 extern char __dtb_start[];
 
drivers/of/base.c +1 -7
index 8383549..1158132 100644
@@ -873,7 +873,6 @@ int of_add_memory(struct device_node *node, bool dump)
 	int na, nc;
 	const __be32 *reg, *endp;
 	int len, r = 0, ret;
-	static char str[6];
 	const char *device_type;
 
 	ret = of_property_read_string(node, "device_type", &device_type);
@@ -900,12 +899,7 @@ int of_add_memory(struct device_node *node, bool dump)
 		if (size == 0)
 			continue;
 
-		sprintf(str, "ram%d", r);
-
-		barebox_add_memory_bank(str, base, size);
-
-		if (dump)
-			pr_info("%s: %s: 0x%llx@0x%llx\n", node->name, str, size, base);
+		of_add_memory_bank(node, dump, r, base, size);
 
 		r++;
 	}
include/of.h +2 -0
index 4dcf37e..e0fc768 100644
@@ -180,6 +180,8 @@ int of_device_is_stdout_path(struct device_d *dev);
 const char *of_get_model(void);
 void *of_flatten_dtb(struct device_node *node);
 int of_add_memory(struct device_node *node, bool dump);
+void of_add_memory_bank(struct device_node *node, bool dump, int r,
+		u64 base, u64 size);
 #else
 static inline int of_parse_partitions(struct cdev *cdev,
 					  struct device_node *node)
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

Re: [RFC 2/4] of: add MIPS memory bank adding support

Quoted 24 lines · Antony Pavlov

The MIPS architecture has different view on memory resources than the ARM architecture.
This patch move memory segment registration to a arch-specific files.

---
 arch/arm/cpu/dtb.c   |   13 +++++++++++++
 arch/mips/boot/dtb.c |   17 +++++++++++++++++
 drivers/of/base.c    |    8 +-------
 include/of.h         |    2 ++
 4 files changed, 33 insertions(+), 7 deletions(-)
arch/arm/cpu/dtb.c +3 -0
index 10b73bd..66346cf 100644
@@ -17,6 +17,19 @@
 #include <common.h>
 #include <init.h>
 #include <of.h>
+#include <memory.h>
+
+void of_add_memory_bank(struct device_node *node, bool dump, int r,

arch/arm/cpu/dtb.c line 32

Quoted 10 lines
arch/arm/cpu/dtb.c +10 -0
+		u64 base, u64 size)
+{
+	static char str[6];
+
+	sprintf(str, "ram%d", r);
+	barebox_add_memory_bank(str, base, size);
+
+	if (dump)
+		pr_info("%s: %s: 0x%llx@0x%llx\n", node->name, str, size, base);
+}

Would be good to have this as generic version and call it from arm specific code. What about powerpc? Does it compile with this patch?

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

RFC 3/4 MIPS: qemu-malta: add device tree support

In reply to Antony Pavlov
---
 arch/mips/boards/qemu-malta/init.c |   11 -----------
 arch/mips/dts/qemu-malta.dts       |   12 ++++++++++++
 2 files changed, 12 insertions(+), 11 deletions(-)
 create mode 100644 arch/mips/dts/qemu-malta.dts
arch/mips/boards/qemu-malta/init.c +0 -11
index fb4472f..db26b3b 100644
@@ -20,21 +20,10 @@
 #include <types.h>
 #include <driver.h>
 #include <init.h>
-#include <asm/memory.h>
 #include <ns16550.h>
 #include <mach/hardware.h>
-#include <io.h>
 #include <partition.h>
 #include <sizes.h>
-#include <asm/common.h>
-
-static int malta_mem_init(void)
-{
-	mips_add_ram0(SZ_256M);
-
-	return 0;
-}
-mem_initcall(malta_mem_init);
 
 static int malta_devices_init(void)
 {
arch/mips/dts/qemu-malta.dts new file +12 -0
new file mode 100644
index 0000000..c4dcf05
@@ -0,0 +1,12 @@
+/dts-v1/;
+
+/include/ "skeleton.dtsi"
+
+/ {
+	model = "qemu malta";
+	compatible = "qemu,malta";
+
+	memory {
+		reg = <0x00000000 0x10000000>;
+	};
+};
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

RFC 4/4 MIPS: qemu-malta_defconfig: enable OF support

In reply to Antony Pavlov

Also enable iomem.

---
 arch/mips/configs/qemu-malta_defconfig |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
arch/mips/configs/qemu-malta_defconfig +11 -6
index 7dab969..18c840d 100644
@@ -1,3 +1,5 @@
+CONFIG_BUILTIN_DTB=y
+CONFIG_BUILTIN_DTB_NAME="qemu-malta"
 CONFIG_PBL_IMAGE=y
 CONFIG_STACK_SIZE=0x7000
 CONFIG_BROKEN=y
@@ -23,22 +25,25 @@ CONFIG_CMD_MENU=y
 CONFIG_CMD_MENU_MANAGEMENT=y
 CONFIG_CMD_PASSWD=y
 CONFIG_CMD_TIME=y
+CONFIG_CMD_TFTP=y
 CONFIG_CMD_ECHO_E=y
 CONFIG_CMD_LOADB=y
 CONFIG_CMD_LOADY=y
 CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_IOMEM=y
 CONFIG_CMD_CRC=y
 CONFIG_CMD_CRC_CMP=y
 CONFIG_CMD_MD5SUM=y
 CONFIG_CMD_SHA1SUM=y
 CONFIG_CMD_SHA256SUM=y
-CONFIG_CMD_MTEST=y
 CONFIG_CMD_FLASH=y
-CONFIG_CMD_BOOTM_ZLIB=y
-CONFIG_CMD_BOOTM_BZLIB=y
 CONFIG_CMD_BOOTM_SHOW_TYPE=y
 CONFIG_CMD_RESET=y
 CONFIG_CMD_GO=y
+CONFIG_CMD_OFTREE=y
+CONFIG_CMD_OF_PROPERTY=y
+CONFIG_CMD_OF_NODE=y
+CONFIG_CMD_MTEST=y
 CONFIG_CMD_TIMEOUT=y
 CONFIG_CMD_PARTITION=y
 CONFIG_CMD_UNCOMPRESS=y
@@ -46,18 +51,18 @@ CONFIG_NET=y
 CONFIG_NET_DHCP=y
 CONFIG_NET_NFS=y
 CONFIG_NET_PING=y
-CONFIG_CMD_TFTP=y
-CONFIG_FS_TFTP=y
 CONFIG_NET_NETCONSOLE=y
 CONFIG_NET_RESOLV=y
+CONFIG_OFDEVICE=y
 # CONFIG_SPI is not set
+CONFIG_MTD=y
 CONFIG_DRIVER_CFI=y
 # CONFIG_DRIVER_CFI_AMD is not set
 # CONFIG_DRIVER_CFI_BANK_WIDTH_1 is not set
 # CONFIG_DRIVER_CFI_BANK_WIDTH_2 is not set
 CONFIG_CFI_BUFFER_WRITE=y
-CONFIG_MTD=y
 CONFIG_FS_CRAMFS=y
+CONFIG_FS_TFTP=y
 CONFIG_FS_FAT=y
 CONFIG_FS_FAT_WRITE=y
 CONFIG_FS_FAT_LFN=y
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox