Skip to contentSkip to conversation

OF: MIPS: sead3: Implement OF support.

PATCH In review Steven J. Hill 2 participants 2 messages Jan 17, 2013 – Jan 18, 2013 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 OF: MIPS: sead3: Implement OF support.

From: "Steven J. Hill" <[email protected]>

Activate USE_OF for SEAD-3 platform. Add basic DTS file and convert memory detection and reservations to use OF.

---
 arch/mips/Kconfig                           |    1 +
 arch/mips/include/asm/mips-boards/generic.h |    4 +
 arch/mips/mti-sead3/Makefile                |   10 +-
 arch/mips/mti-sead3/sead3-init.c            |    5 +-
 arch/mips/mti-sead3/sead3-memory.c          |  138 ---------------------------
 arch/mips/mti-sead3/sead3-setup.c           |   27 ++++++
 arch/mips/mti-sead3/sead3.dts               |   26 +++++
 7 files changed, 70 insertions(+), 141 deletions(-)
 delete mode 100644 arch/mips/mti-sead3/sead3-memory.c
 create mode 100644 arch/mips/mti-sead3/sead3.dts
arch/mips/Kconfig +1 -0
index 86153b6..88af14c 100644
@@ -355,6 +355,7 @@ config MIPS_SEAD3
 	select USB_ARCH_HAS_EHCI
 	select USB_EHCI_BIG_ENDIAN_DESC
 	select USB_EHCI_BIG_ENDIAN_MMIO
+	select USE_OF
 	help
 	  This enables support for the MIPS Technologies SEAD3 evaluation
 	  board.
arch/mips/include/asm/mips-boards/generic.h +4 -0
index 6e23ceb..c01e286 100644
@@ -87,6 +87,10 @@
 
 extern int mips_revision_sconid;
 
+#ifdef CONFIG_OF
+extern struct boot_param_header __dtb_start;
+#endif
+
 #ifdef CONFIG_PCI
 extern void mips_pcibios_init(void);
 #else
arch/mips/mti-sead3/Makefile +8 -2
index 626afea..10ec701 100644
@@ -5,10 +5,12 @@
 # Copyright (C) 2008 Wind River Systems, Inc.
 #   written by Ralf Baechle <[email protected]>
 #
+# Copyright (C) 2012 MIPS Technoligies, Inc.  All rights reserved.
+# Steven J. Hill <[email protected]>
+#
 obj-y				:= sead3-lcd.o sead3-cmdline.o \
 				   sead3-display.o sead3-init.o sead3-int.o \
-				   sead3-mtd.o sead3-net.o \
-				   sead3-memory.o sead3-platform.o \
+				   sead3-mtd.o sead3-net.o sead3-platform.o \
 				   sead3-reset.o sead3-setup.o sead3-time.o
 
 obj-y				+= sead3-i2c-dev.o sead3-i2c.o \
@@ -17,3 +19,7 @@ obj-y				+= sead3-i2c-dev.o sead3-i2c.o \
 
 obj-$(CONFIG_EARLY_PRINTK)	+= sead3-console.o
 obj-$(CONFIG_USB_EHCI_HCD)	+= sead3-ehci.o
+obj-$(CONFIG_OF)		+= sead3.dtb.o
+
+$(obj)/%.dtb: $(obj)/%.dts
+	$(call if_changed,dtc)
arch/mips/mti-sead3/sead3-init.c +4 -1
index 802fce2..6939254 100644
@@ -125,7 +125,6 @@ void __init prom_init(void)
 	board_ejtag_handler_setup = mips_ejtag_setup;
 
 	prom_init_cmdline();
-	prom_meminit();
 #ifdef CONFIG_EARLY_PRINTK
 	if ((strstr(prom_getcmdline(), "console=ttyS0")) != NULL)
 		prom_init_early_console(0);
@@ -137,3 +136,7 @@ void __init prom_init(void)
 		strcat(prom_getcmdline(), " console=ttyS0,38400n8r");
 #endif
 }
+
+void prom_free_prom_memory(void)
+{
+}
arch/mips/mti-sead3/sead3-memory.c deleted +0 -138

138 lines not on this page · raw message

arch/mips/mti-sead3/sead3-setup.c +27 -0
index 8ad46ad..f012fd1 100644
@@ -6,6 +6,12 @@
  * Copyright (C) 2012 MIPS Technologies, Inc.  All rights reserved.
  */
 #include <linux/init.h>
+#include <linux/of_platform.h>
+#include <linux/of_fdt.h>
+#include <linux/bootmem.h>
+
+#include <asm/mips-boards/generic.h>
+#include <asm/prom.h>
 
 int coherentio;		/* 0 => no DMA cache coherency (may be set by user) */
 int hw_coherentio;	/* 0 => no HW DMA cache coherency (reflects real HW) */
@@ -17,4 +23,25 @@ const char *get_system_type(void)
 
 void __init plat_mem_setup(void)
 {
+	/*
+	 * Load the builtin devicetree. This causes the chosen node to be
+	 * parsed resulting in our memory appearing
+	 */
+	__dt_setup_arch(&__dtb_start);
+}
+
+void __init device_tree_init(void)
+{
+	unsigned long base, size;
+
+	if (!initial_boot_params)
+		return;
+
+	base = virt_to_phys((void *)initial_boot_params);
+	size = be32_to_cpu(initial_boot_params->totalsize);
+
+	/* Before we do anything, lets reserve the dt blob */
+	reserve_bootmem(base, size, BOOTMEM_DEFAULT);
+
+	unflatten_device_tree();
 }
arch/mips/mti-sead3/sead3.dts new file +26 -0
new file mode 100644
index 0000000..658f437
@@ -0,0 +1,26 @@
+/dts-v1/;
+
+/memreserve/ 0x00000000 0x00001000;	// reserved
+/memreserve/ 0x00001000 0x000ef000;	// ROM data
+/memreserve/ 0x000f0000 0x004cc000;	// reserved
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+	compatible = "mti,sead-3";
+
+	cpus {
+		cpu@0 {
+			compatible = "mti,mips14KEc", "mti,mips14Kc";
+		};
+	};
+
+	chosen {
+		bootargs = "console=ttyS1,38400 rootdelay=10 root=/dev/sda3";
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0x0 0x08000000>;
+	};
+};
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 4 lines · Steven J. Hill

From: "Steven J. Hill" <[email protected]>

Activate USE_OF for SEAD-3 platform. Add basic DTS file and convert memory detection and reservations to use OF.

Applied with this little patch on top:

 arch/mips/include/asm/mips-boards/generic.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/mips/include/asm/mips-boards/generic.h +1 -0
index c01e286..3fc764a 100644
@@ -20,6 +20,7 @@
 #ifndef __ASM_MIPS_BOARDS_GENERIC_H
 #define __ASM_MIPS_BOARDS_GENERIC_H
 
+#include <linux/of_fdt.h>
 #include <asm/addrspace.h>
 #include <asm/byteorder.h>
 #include <asm/mips-boards/bonito64.h>

Otherwise including generic.h might result in an error if <linux/of_fdt.h> has not been included before.

@@ -87,9 +88,7 @@

extern int mips_revision_sconid;

-#ifdef CONFIG_OF
extern struct boot_param_header __dtb_start;
-#endif

There's no need to wrap this declaration.

Ralf