summaryrefslogtreecommitdiffstats
path: root/arch/mips/boot
diff options
context:
space:
mode:
authorAntony Pavlov <antonynpavlov@gmail.com>2013-05-12 23:54:04 +0400
committerSascha Hauer <s.hauer@pengutronix.de>2013-05-13 21:17:10 +0200
commit6fe6d9fdc2ef89ee92cc40b2114b21cdff9e91ca (patch)
treef4888a9956d132bfe9e24935d4782ca65333c49b /arch/mips/boot
parent74c4acea0dbc8a270e584c01f13f61dcc87e4cbd (diff)
downloadbarebox-6fe6d9fdc2ef89ee92cc40b2114b21cdff9e91ca.tar.gz
barebox-6fe6d9fdc2ef89ee92cc40b2114b21cdff9e91ca.tar.xz
MIPS: add initial device tree support
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/mips/boot')
-rw-r--r--arch/mips/boot/Makefile2
-rw-r--r--arch/mips/boot/dtb.c61
2 files changed, 63 insertions, 0 deletions
diff --git a/arch/mips/boot/Makefile b/arch/mips/boot/Makefile
index 6b093f1e0e..b865b10f8b 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 0000000000..c1962bfd0c
--- /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);