mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [RFC 0/4] MIPS: add initial device tree support
@ 2013-05-07 16:34 Antony Pavlov
  2013-05-07 16:34 ` [RFC 1/4] " Antony Pavlov
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Antony Pavlov @ 2013-05-07 16:34 UTC (permalink / raw)
  To: barebox

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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [RFC 1/4] MIPS: add initial device tree support
  2013-05-07 16:34 [RFC 0/4] MIPS: add initial device tree support Antony Pavlov
@ 2013-05-07 16:34 ` Antony Pavlov
  2013-05-07 16:34 ` [RFC 2/4] of: add MIPS memory bank adding support Antony Pavlov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Antony Pavlov @ 2013-05-07 16:34 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 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

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 947edcf..d58b804 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -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
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 3c565a4..c038933 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -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)
diff --git a/arch/mips/boot/Makefile b/arch/mips/boot/Makefile
index 6b093f1..b865b10 100644
--- a/arch/mips/boot/Makefile
+++ b/arch/mips/boot/Makefile
@@ -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
diff --git a/arch/mips/boot/dtb.c b/arch/mips/boot/dtb.c
new file mode 100644
index 0000000..d20fab3
--- /dev/null
+++ b/arch/mips/boot/dtb.c
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2013 Antony Pavlov <antonynpavlov@gmail.com>
+ *
+ * Based on arch/arm/cpu/dtb.c:
+ * Copyright (C) 2013 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+#include <common.h>
+#include <init.h>
+#include <of.h>
+
+extern char __dtb_start[];
+
+static int of_mips_init(void)
+{
+	struct device_node *root;
+
+	root = of_get_root_node();
+	if (root)
+		return 0;
+
+	root = of_unflatten_dtb(NULL, __dtb_start);
+	if (root) {
+		pr_debug("using internal DTB\n");
+		of_set_root_node(root);
+		if (IS_ENABLED(CONFIG_OFDEVICE))
+			of_probe();
+	}
+
+	return 0;
+}
+core_initcall(of_mips_init);
diff --git a/arch/mips/dts/Makefile b/arch/mips/dts/Makefile
new file mode 100644
index 0000000..3ee8924
--- /dev/null
+++ b/arch/mips/dts/Makefile
@@ -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
diff --git a/arch/mips/dts/skeleton.dtsi b/arch/mips/dts/skeleton.dtsi
new file mode 100644
index 0000000..b41d241
--- /dev/null
+++ b/arch/mips/dts/skeleton.dtsi
@@ -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>; };
+};
diff --git a/arch/mips/lib/barebox.lds.S b/arch/mips/lib/barebox.lds.S
index 5b3d45d..bc78d2b 100644
--- a/arch/mips/lib/barebox.lds.S
+++ b/arch/mips/lib/barebox.lds.S
@@ -69,6 +69,8 @@ SECTIONS
 	__usymtab : { BAREBOX_SYMS }
 	__usymtab_end = .;
 
+	.dtb : { BAREBOX_DTB() }
+
 	_edata = .;
 	. = ALIGN(4);
 	__bss_start = .;
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [RFC 2/4] of: add MIPS memory bank adding support
  2013-05-07 16:34 [RFC 0/4] MIPS: add initial device tree support Antony Pavlov
  2013-05-07 16:34 ` [RFC 1/4] " Antony Pavlov
@ 2013-05-07 16:34 ` Antony Pavlov
  2013-05-08 21:23   ` Sascha Hauer
  2013-05-07 16:34 ` [RFC 3/4] MIPS: qemu-malta: add device tree support Antony Pavlov
  2013-05-07 16:34 ` [RFC 4/4] MIPS: qemu-malta_defconfig: enable OF support Antony Pavlov
  3 siblings, 1 reply; 6+ messages in thread
From: Antony Pavlov @ 2013-05-07 16:34 UTC (permalink / raw)
  To: barebox

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

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 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(-)

diff --git a/arch/arm/cpu/dtb.c b/arch/arm/cpu/dtb.c
index 10b73bd..66346cf 100644
--- a/arch/arm/cpu/dtb.c
+++ b/arch/arm/cpu/dtb.c
@@ -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[];
 
diff --git a/arch/mips/boot/dtb.c b/arch/mips/boot/dtb.c
index d20fab3..c1962bf 100644
--- a/arch/mips/boot/dtb.c
+++ b/arch/mips/boot/dtb.c
@@ -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[];
 
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 8383549..1158132 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -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++;
 	}
diff --git a/include/of.h b/include/of.h
index 4dcf37e..e0fc768 100644
--- a/include/of.h
+++ b/include/of.h
@@ -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)
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [RFC 3/4] MIPS: qemu-malta: add device tree support
  2013-05-07 16:34 [RFC 0/4] MIPS: add initial device tree support Antony Pavlov
  2013-05-07 16:34 ` [RFC 1/4] " Antony Pavlov
  2013-05-07 16:34 ` [RFC 2/4] of: add MIPS memory bank adding support Antony Pavlov
@ 2013-05-07 16:34 ` Antony Pavlov
  2013-05-07 16:34 ` [RFC 4/4] MIPS: qemu-malta_defconfig: enable OF support Antony Pavlov
  3 siblings, 0 replies; 6+ messages in thread
From: Antony Pavlov @ 2013-05-07 16:34 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 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

diff --git a/arch/mips/boards/qemu-malta/init.c b/arch/mips/boards/qemu-malta/init.c
index fb4472f..db26b3b 100644
--- a/arch/mips/boards/qemu-malta/init.c
+++ b/arch/mips/boards/qemu-malta/init.c
@@ -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)
 {
diff --git a/arch/mips/dts/qemu-malta.dts b/arch/mips/dts/qemu-malta.dts
new file mode 100644
index 0000000..c4dcf05
--- /dev/null
+++ b/arch/mips/dts/qemu-malta.dts
@@ -0,0 +1,12 @@
+/dts-v1/;
+
+/include/ "skeleton.dtsi"
+
+/ {
+	model = "qemu malta";
+	compatible = "qemu,malta";
+
+	memory {
+		reg = <0x00000000 0x10000000>;
+	};
+};
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [RFC 4/4] MIPS: qemu-malta_defconfig: enable OF support
  2013-05-07 16:34 [RFC 0/4] MIPS: add initial device tree support Antony Pavlov
                   ` (2 preceding siblings ...)
  2013-05-07 16:34 ` [RFC 3/4] MIPS: qemu-malta: add device tree support Antony Pavlov
@ 2013-05-07 16:34 ` Antony Pavlov
  3 siblings, 0 replies; 6+ messages in thread
From: Antony Pavlov @ 2013-05-07 16:34 UTC (permalink / raw)
  To: barebox

Also enable iomem.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 arch/mips/configs/qemu-malta_defconfig |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/arch/mips/configs/qemu-malta_defconfig b/arch/mips/configs/qemu-malta_defconfig
index 7dab969..18c840d 100644
--- a/arch/mips/configs/qemu-malta_defconfig
+++ b/arch/mips/configs/qemu-malta_defconfig
@@ -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
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [RFC 2/4] of: add MIPS memory bank adding support
  2013-05-07 16:34 ` [RFC 2/4] of: add MIPS memory bank adding support Antony Pavlov
@ 2013-05-08 21:23   ` Sascha Hauer
  0 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2013-05-08 21:23 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

On Tue, May 07, 2013 at 08:34:10PM +0400, Antony Pavlov wrote:
> The MIPS architecture has different view on memory
> resources than the ARM architecture.
> This patch move memory segment registration
> to a arch-specific files.
> 
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> ---
>  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(-)
> 
> diff --git a/arch/arm/cpu/dtb.c b/arch/arm/cpu/dtb.c
> index 10b73bd..66346cf 100644
> --- a/arch/arm/cpu/dtb.c
> +++ b/arch/arm/cpu/dtb.c
> @@ -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);
> +}

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

-- 
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2013-05-08 21:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-07 16:34 [RFC 0/4] MIPS: add initial device tree support Antony Pavlov
2013-05-07 16:34 ` [RFC 1/4] " Antony Pavlov
2013-05-07 16:34 ` [RFC 2/4] of: add MIPS memory bank adding support Antony Pavlov
2013-05-08 21:23   ` Sascha Hauer
2013-05-07 16:34 ` [RFC 3/4] MIPS: qemu-malta: add device tree support Antony Pavlov
2013-05-07 16:34 ` [RFC 4/4] MIPS: qemu-malta_defconfig: enable OF support Antony Pavlov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox