mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 0/4] MIPS: add initial device tree support
@ 2013-05-12 19:54 Antony Pavlov
  2013-05-12 19:54 ` [PATCH v2 1/4] of: separate out "generic" memory bank adding Antony Pavlov
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Antony Pavlov @ 2013-05-12 19:54 UTC (permalink / raw)
  To: barebox

v2: fix PPC compilation

[PATCH v2 1/4] of: separate out "generic" memory bank adding
[PATCH v2 2/4] MIPS: add initial device tree support
[PATCH v2 3/4] MIPS: qemu-malta: add device tree support
[PATCH v2 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

* [PATCH v2 1/4] of: separate out "generic" memory bank adding
  2013-05-12 19:54 [PATCH v2 0/4] MIPS: add initial device tree support Antony Pavlov
@ 2013-05-12 19:54 ` Antony Pavlov
  2013-05-12 19:54 ` [PATCH v2 2/4] MIPS: add initial device tree support Antony Pavlov
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Antony Pavlov @ 2013-05-12 19:54 UTC (permalink / raw)
  To: barebox

This patch separates out the "generic" memory
segment registration function (of_add_memory_bank())
from of_add_memory().
The MIPS architecture has different view on memory
resources than the ARM and PPC architectures
so the "generic" of_add_memory_bank() is
unusable for the MIPS architecture.
We can add MIPS-specific of_add_memory_bank()
into arch/mips code.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 drivers/of/Kconfig       |    5 +++++
 drivers/of/Makefile      |    1 +
 drivers/of/base.c        |    8 +-------
 drivers/of/mem_generic.c |   15 +++++++++++++++
 include/of.h             |    2 ++
 5 files changed, 24 insertions(+), 7 deletions(-)
 create mode 100644 drivers/of/mem_generic.c

diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index 56762e4..ffe063e 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -1,6 +1,11 @@
 config OFTREE
 	bool
 
+config OFTREE_MEM_GENERIC
+	depends on OFTREE
+	depends on PPC || ARM
+	def_bool y
+
 config DTC
 	bool
 
diff --git a/drivers/of/Makefile b/drivers/of/Makefile
index d16a946..c81bbec 100644
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
@@ -1,4 +1,5 @@
 obj-y += base.o fdt.o
+obj-$(CONFIG_OFTREE_MEM_GENERIC) += mem_generic.o
 obj-$(CONFIG_GPIOLIB) += gpio.o
 obj-y += partition.o
 obj-y += of_net.o
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/drivers/of/mem_generic.c b/drivers/of/mem_generic.c
new file mode 100644
index 0000000..9094243
--- /dev/null
+++ b/drivers/of/mem_generic.c
@@ -0,0 +1,15 @@
+#include <common.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);
+}
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

* [PATCH v2 2/4] MIPS: add initial device tree support
  2013-05-12 19:54 [PATCH v2 0/4] MIPS: add initial device tree support Antony Pavlov
  2013-05-12 19:54 ` [PATCH v2 1/4] of: separate out "generic" memory bank adding Antony Pavlov
@ 2013-05-12 19:54 ` Antony Pavlov
  2013-05-12 19:54 ` [PATCH v2 3/4] MIPS: qemu-malta: add " Antony Pavlov
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Antony Pavlov @ 2013-05-12 19:54 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        |   61 +++++++++++++++++++++++++++++++++++++++++++
 arch/mips/dts/Makefile      |   10 +++++++
 arch/mips/dts/skeleton.dtsi |   13 +++++++++
 arch/mips/lib/barebox.lds.S |    2 ++
 7 files changed, 108 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..c1962bf
--- /dev/null
+++ b/arch/mips/boot/dtb.c
@@ -0,0 +1,61 @@
+/*
+ * 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>
+#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[];
+
+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

* [PATCH v2 3/4] MIPS: qemu-malta: add device tree support
  2013-05-12 19:54 [PATCH v2 0/4] MIPS: add initial device tree support Antony Pavlov
  2013-05-12 19:54 ` [PATCH v2 1/4] of: separate out "generic" memory bank adding Antony Pavlov
  2013-05-12 19:54 ` [PATCH v2 2/4] MIPS: add initial device tree support Antony Pavlov
@ 2013-05-12 19:54 ` Antony Pavlov
  2013-05-12 19:54 ` [PATCH v2 4/4] MIPS: qemu-malta_defconfig: enable OF support Antony Pavlov
  2013-05-14  5:14 ` [PATCH v2 0/4] MIPS: add initial device tree support Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Antony Pavlov @ 2013-05-12 19:54 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

* [PATCH v2 4/4] MIPS: qemu-malta_defconfig: enable OF support
  2013-05-12 19:54 [PATCH v2 0/4] MIPS: add initial device tree support Antony Pavlov
                   ` (2 preceding siblings ...)
  2013-05-12 19:54 ` [PATCH v2 3/4] MIPS: qemu-malta: add " Antony Pavlov
@ 2013-05-12 19:54 ` Antony Pavlov
  2013-05-14  5:14 ` [PATCH v2 0/4] MIPS: add initial device tree support Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Antony Pavlov @ 2013-05-12 19:54 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: [PATCH v2 0/4] MIPS: add initial device tree support
  2013-05-12 19:54 [PATCH v2 0/4] MIPS: add initial device tree support Antony Pavlov
                   ` (3 preceding siblings ...)
  2013-05-12 19:54 ` [PATCH v2 4/4] MIPS: qemu-malta_defconfig: enable OF support Antony Pavlov
@ 2013-05-14  5:14 ` Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2013-05-14  5:14 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

On Sun, May 12, 2013 at 11:54:02PM +0400, Antony Pavlov wrote:
> v2: fix PPC compilation
> 
> [PATCH v2 1/4] of: separate out "generic" memory bank adding
> [PATCH v2 2/4] MIPS: add initial device tree support
> [PATCH v2 3/4] MIPS: qemu-malta: add device tree support
> [PATCH v2 4/4] MIPS: qemu-malta_defconfig: enable OF support

Applied, thanks

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-14  5:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-12 19:54 [PATCH v2 0/4] MIPS: add initial device tree support Antony Pavlov
2013-05-12 19:54 ` [PATCH v2 1/4] of: separate out "generic" memory bank adding Antony Pavlov
2013-05-12 19:54 ` [PATCH v2 2/4] MIPS: add initial device tree support Antony Pavlov
2013-05-12 19:54 ` [PATCH v2 3/4] MIPS: qemu-malta: add " Antony Pavlov
2013-05-12 19:54 ` [PATCH v2 4/4] MIPS: qemu-malta_defconfig: enable OF support Antony Pavlov
2013-05-14  5:14 ` [PATCH v2 0/4] MIPS: add initial device tree support Sascha Hauer

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