MIPS: add initial device tree support
Subsystems (2)
v2 cover MIPS: add initial device tree support
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 1/4 of: separate out "generic" memory bank adding
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.
--- 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
drivers/of/Kconfig +5 -0
@@ -1,6 +1,11 @@ config OFTREE bool +config OFTREE_MEM_GENERIC + depends on OFTREE + depends on PPC || ARM + def_bool y + config DTC bool
drivers/of/Makefile +1 -0
@@ -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
drivers/of/base.c +1 -7
@@ -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++; }
drivers/of/mem_generic.c new file +15 -0
@@ -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); +}
include/of.h +2 -0
@@ -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
PATCH v2 2/4 MIPS: add initial device tree support
In reply to Antony Pavlov--- 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
arch/mips/Kconfig +8 -0
@@ -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
@@ -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
@@ -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 +61 -0
61 lines not on this page · raw message
arch/mips/dts/Makefile new file +10 -0
@@ -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
@@ -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
@@ -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
PATCH v2 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
@@ -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
@@ -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
PATCH v2 4/4 MIPS: qemu-malta_defconfig: enable OF support
In reply to Antony PavlovAlso enable iomem.
--- arch/mips/configs/qemu-malta_defconfig | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
arch/mips/configs/qemu-malta_defconfig +11 -6
@@ -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
Sascha Hauer
AppliedQuoted 6 lines · Antony Pavlov
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
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