Skip to contentSkip to conversation

openrisc: add device tree support

PATCH Applied Antony Pavlov 3 participants 12 messages Sep 8, 2014 – Sep 9, 2014

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover openrisc: add device tree support

This patch series adds device tree support for openrisc generic board. The barebox mips device tree support is used as a sample.

Changes since v1:

* rebase over latest next;
* add 'Documentation: add OpenRISC or1ksim emulator section'.

Antony Pavlov (7):
openrisc: generic board: reserve 512K for barebox
net: ethoc: add device tree support
openrisc: add initial device tree support
openrisc: dts: import or1ksim.dts from linux-3.16
openrisc: generic board: reduce platform code
openrisc: generic_defconfig: enable device tree stuff
Documentation: add OpenRISC or1ksim emulator section

 Documentation/boards/openrisc.rst       | 51 +++++++++++++++++++++++++++++++++
 arch/openrisc/Kconfig                   |  9 ++++++
 arch/openrisc/Makefile                  |  7 +++++
 arch/openrisc/boards/generic/config.h   |  9 ++----
 arch/openrisc/boards/generic/generic.c  | 24 ++--------------
 arch/openrisc/configs/generic_defconfig | 35 +++++++++++++---------
 arch/openrisc/cpu/barebox.lds.S         |  2 ++
 arch/openrisc/dts/Makefile              |  5 ++++
 arch/openrisc/dts/or1ksim.dts           | 51 +++++++++++++++++++++++++++++++++
 arch/openrisc/lib/Makefile              |  1 +
 arch/openrisc/lib/dtb.c                 | 44 ++++++++++++++++++++++++++++
 drivers/net/ethoc.c                     |  6 ++++
 drivers/of/Kconfig                      |  2 +-
 13 files changed, 203 insertions(+), 43 deletions(-)
 create mode 100644 Documentation/boards/openrisc.rst
 create mode 100644 arch/openrisc/dts/Makefile
 create mode 100644 arch/openrisc/dts/or1ksim.dts
 create mode 100644 arch/openrisc/lib/dtb.c
Signature · 7 lines
2.1.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH v2 1/7 openrisc: generic board: reserve 512K for barebox

Here is a linker's error message for some configurations:

or1k-elf-ld: barebox section .eh_frame' will not fit in region ram'
or1k-elf-ld: region `ram' overflowed by 16868 bytes

This patch increases space reserved for barebox from 256K to 512K so the error's probability is dramatically decreased.

---
 arch/openrisc/boards/generic/config.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/openrisc/boards/generic/config.h +2 -2
index 6ebab42..10c33a1 100644
@@ -13,8 +13,8 @@
 
 #define OPENRISC_SOPC_ETHOC_BASE	0x92000000
 
-/* We reserve 256K for barebox */
-#define BAREBOX_RESERVED_SIZE		0x40000
+/* We reserve 512K for barebox */
+#define BAREBOX_RESERVED_SIZE		0x80000
 
 /* Barebox will be at top of main memory */
 #define OPENRISC_SOPC_TEXT_BASE		(OPENRISC_SOPC_MEMORY_BASE + OPENRISC_SOPC_MEMORY_SIZE - BAREBOX_RESERVED_SIZE)
Signature · 7 lines
2.1.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH v2 2/7 net: ethoc: add device tree support

In reply to Antony Pavlov
---
 drivers/net/ethoc.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/ethoc.c +6 -0
index 679e1e5..35d7d46 100644
@@ -565,8 +565,14 @@ static int ethoc_probe(struct device_d *dev)
 	return 0;
 }
 
+static struct of_device_id ethoc_dt_ids[] = {
+	{ .compatible = "opencores,ethoc", },
+	{ }
+};
+
 static struct driver_d ethoc_driver = {
 	.name  = "ethoc",
 	.probe = ethoc_probe,
+	.of_compatible = DRV_OF_COMPAT(ethoc_dt_ids),
 };
 device_platform_driver(ethoc_driver);
Signature · 7 lines
2.1.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH v2 3/7 openrisc: add initial device tree support

In reply to Antony Pavlov
---
 arch/openrisc/Kconfig           |  9 +++++++++
 arch/openrisc/Makefile          |  7 +++++++
 arch/openrisc/cpu/barebox.lds.S |  2 ++
 arch/openrisc/dts/Makefile      |  5 +++++
 arch/openrisc/lib/Makefile      |  1 +
 arch/openrisc/lib/dtb.c         | 44 +++++++++++++++++++++++++++++++++++++++++
 drivers/of/Kconfig              |  2 +-
 7 files changed, 69 insertions(+), 1 deletion(-)
arch/openrisc/Kconfig +9 -0
index 23c6a71..483ae6d 100644
@@ -1,5 +1,6 @@
 config OPENRISC
 	bool
+	select OFTREE
 	select HAS_CACHE
 	select HAVE_CONFIGURABLE_MEMORY_LAYOUT
 	select HAVE_DEFAULT_ENVIRONMENT_NEW
@@ -11,6 +12,14 @@ config ARCH_TEXT_BASE
 	hex
 	default 0x00000000
 
+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 "Select your board"
 
arch/openrisc/Makefile +7 -0
index fd8bbbf..b0c8566 100644
@@ -19,3 +19,10 @@ common-y += arch/openrisc/lib/
 common-y += arch/openrisc/cpu/
 
 lds-y += arch/openrisc/cpu/barebox.lds
+
+common-$(CONFIG_BUILTIN_DTB) += arch/openrisc/dts/
+
+dts := arch/openrisc/dts
+
+%.dtb: scripts
+	$(Q)$(MAKE) $(build)=$(dts) $(dts)/$@
arch/openrisc/cpu/barebox.lds.S +2 -0
index d71df46..d4b6359 100644
@@ -69,6 +69,8 @@ SECTIONS
 	__usymtab : { BAREBOX_SYMS } > ram
 	___usymtab_end = .;
 
+	.dtb : { BAREBOX_DTB() } > ram
+
 	__etext = .; /* End of text and rodata section */
 
 	. = ALIGN(4);
arch/openrisc/dts/Makefile new file +5 -0
new file mode 100644
index 0000000..6d6c9a3
@@ -0,0 +1,5 @@
+
+BUILTIN_DTB := $(patsubst "%",%,$(CONFIG_BUILTIN_DTB_NAME))
+obj-$(CONFIG_BUILTIN_DTB) += $(BUILTIN_DTB).dtb.o
+
+clean-files := *.dtb *.dtb.S
arch/openrisc/lib/Makefile +1 -0
index 0b3cc50..62082fe 100644
@@ -5,3 +5,4 @@ obj-y                 += muldi3.o
 obj-y                 += lshrdi3.o
 obj-y                 += ashldi3.o
 obj-y                 += ashrdi3.o
+obj-$(CONFIG_BUILTIN_DTB) += dtb.o
arch/openrisc/lib/dtb.c new file +44 -0

44 lines not on this page · raw message

drivers/of/Kconfig +1 -1
index 8195506..97a1d93 100644
@@ -4,7 +4,7 @@ config OFTREE
 
 config OFTREE_MEM_GENERIC
 	depends on OFTREE
-	depends on PPC || ARM || ARCH_EFI
+	depends on PPC || ARM || ARCH_EFI || OPENRISC
 	def_bool y
 
 config DTC
Signature · 7 lines
2.1.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

PATCH v2 4/7 openrisc: dts: import or1ksim.dts from linux-3.16

In reply to Antony Pavlov

There are some minor changes with original linux-3.16 file:

* the 'model' attribute is added (it used for barebox banner board name);
* all "opencores,*-rtlsvn*" 'compatible' attribute values are dropped; these values are not actually used in the device drivers.

---
 arch/openrisc/dts/or1ksim.dts | 51 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
arch/openrisc/dts/or1ksim.dts new file +51 -0
new file mode 100644
index 0000000..7316cc6
@@ -0,0 +1,51 @@
+/dts-v1/;
+/ {
+	model = "or1ksim";
+	compatible = "opencores,or1ksim";
+	#address-cells = <1>;
+	#size-cells = <1>;
+	interrupt-parent = <&pic>;
+
+	chosen {
+		bootargs = "console=uart,mmio,0x90000000,115200";
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0x00000000 0x02000000>;
+	};
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		cpu@0 {
+			compatible = "opencores,or1200-rtlsvn481";
+			reg = <0>;
+			clock-frequency = <20000000>;
+		};
+	};
+
+	/*
+	 * OR1K PIC is built into CPU and accessed via special purpose
+	 * registers.  It is not addressable and, hence, has no 'reg'
+	 * property.
+	 */
+	pic: pic {
+		compatible = "opencores,or1k-pic";
+		#interrupt-cells = <1>;
+		interrupt-controller;
+	};
+
+	serial0: serial@90000000 {
+		compatible = "ns16550a";
+		reg = <0x90000000 0x100>;
+		interrupts = <2>;
+		clock-frequency = <50000000>;
+	};
+
+	enet0: ethoc@92000000 {
+		compatible = "opencores,ethoc";
+		reg = <0x92000000 0x100>;
+		interrupts = <4>;
+	};
+};
Signature · 7 lines
2.1.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

PATCH v2 5/7 openrisc: generic board: reduce platform code

In reply to Antony Pavlov
---
 arch/openrisc/boards/generic/config.h  |  5 -----
 arch/openrisc/boards/generic/generic.c | 24 ++----------------------
 2 files changed, 2 insertions(+), 27 deletions(-)
arch/openrisc/boards/generic/config.h +0 -5
index 10c33a1..f6a054b 100644
@@ -8,11 +8,6 @@
 #define OPENRISC_SOPC_MEMORY_BASE	0x00000000
 #define OPENRISC_SOPC_MEMORY_SIZE	0x02000000
 
-#define OPENRISC_SOPC_UART_FREQ		CONFIG_SYS_CLK_FREQ
-#define OPENRISC_SOPC_UART_BASE		0x90000000
-
-#define OPENRISC_SOPC_ETHOC_BASE	0x92000000
-
 /* We reserve 512K for barebox */
 #define BAREBOX_RESERVED_SIZE		0x80000
 
arch/openrisc/boards/generic/generic.c +2 -22
index 9f68007..ff6f9f4 100644
@@ -1,30 +1,10 @@
 #include <common.h>
 #include <init.h>
-#include <driver.h>
-#include <partition.h>
-#include <ns16550.h>
 
-static struct NS16550_plat serial_plat = {
-	.clock = OPENRISC_SOPC_UART_FREQ,
-	.shift = 0,
-};
-
-static int openrisc_console_init(void)
+static int openrisc_core_init(void)
 {
-	barebox_set_model("OpenRISC or1k");
 	barebox_set_hostname("or1k");
 
-	/* Register the serial port */
-	add_ns16550_device(DEVICE_ID_DYNAMIC, OPENRISC_SOPC_UART_BASE, 1024,
-			   IORESOURCE_MEM | IORESOURCE_MEM_8BIT, &serial_plat);
-
-#ifdef CONFIG_DRIVER_NET_ETHOC
-	add_generic_device("ethoc", DEVICE_ID_DYNAMIC, NULL,
-			   OPENRISC_SOPC_ETHOC_BASE, 0x1000,
-			   IORESOURCE_MEM, NULL);
-#endif
-
 	return 0;
 }
-
-console_initcall(openrisc_console_init);
+core_initcall(openrisc_core_init);
Signature · 7 lines
2.1.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#6 lore raw

PATCH v2 6/7 openrisc: generic_defconfig: enable device tree stuff

In reply to Antony Pavlov

Also enable iomem and miitool.

---
 arch/openrisc/configs/generic_defconfig | 35 +++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 13 deletions(-)
arch/openrisc/configs/generic_defconfig +22 -13
index deaef2a..1f2d40e 100644
@@ -1,26 +1,35 @@
-CONFIG_LONGHELP=y
+CONFIG_BUILTIN_DTB=y
+CONFIG_BUILTIN_DTB_NAME="or1ksim"
 CONFIG_HUSH_FANCY_PROMPT=y
 CONFIG_CMDLINE_EDITING=y
 CONFIG_AUTO_COMPLETE=y
 CONFIG_PARTITION=y
 CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
-CONFIG_CMD_EDIT=y
-CONFIG_CMD_SAVEENV=y
-CONFIG_CMD_EXPORT=y
-CONFIG_CMD_PRINTENV=y
-CONFIG_CMD_TIME=y
-CONFIG_CMD_ECHO_E=y
+CONFIG_LONGHELP=y
+CONFIG_CMD_IOMEM=y
 CONFIG_CMD_MEMINFO=y
-CONFIG_CMD_FLASH=y
 # CONFIG_CMD_BOOTM is not set
-CONFIG_CMD_RESET=y
 CONFIG_CMD_GO=y
-CONFIG_CMD_TIMEOUT=y
+CONFIG_CMD_RESET=y
 CONFIG_CMD_PARTITION=y
-CONFIG_DRIVER_SERIAL_NS16550=y
-CONFIG_NET=y
+CONFIG_CMD_EXPORT=y
+CONFIG_CMD_PRINTENV=y
+CONFIG_CMD_SAVEENV=y
 CONFIG_CMD_DHCP=y
+CONFIG_CMD_MIITOOL=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_TFTP=y
-CONFIG_FS_TFTP=y
+CONFIG_CMD_ECHO_E=y
+CONFIG_CMD_EDIT=y
+CONFIG_CMD_TIMEOUT=y
+CONFIG_CMD_FLASH=y
+CONFIG_CMD_OF_NODE=y
+CONFIG_CMD_OF_PROPERTY=y
+CONFIG_CMD_OFTREE=y
+CONFIG_CMD_TIME=y
+CONFIG_NET=y
+CONFIG_OFDEVICE=y
+CONFIG_OF_BAREBOX_DRIVERS=y
+CONFIG_DRIVER_SERIAL_NS16550=y
 CONFIG_DRIVER_NET_ETHOC=y
+CONFIG_FS_TFTP=y
Signature · 7 lines
2.1.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#7 lore raw

PATCH v2 7/7 Documentation: add OpenRISC or1ksim emulator section

In reply to Antony Pavlov
---
 Documentation/boards/openrisc.rst | 51 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
Documentation/boards/openrisc.rst new file +51 -0
new file mode 100644
index 0000000..0b36712
@@ -0,0 +1,51 @@
+OpenRISC
+========
+
+or1ksim
+-------
+
+Compile or1ksim emulator::
+
+ $ cd ~/
+ $ git clone https://github.com/fjullien/or1ksim
+ $ cd or1ksim
+ $ ./configure
+ $ make
+
+Create minimal or1ksim.cfg file::
+
+ section cpu
+   ver = 0x12
+   cfgr = 0x20
+   rev = 0x0001
+ end
+ 
+ section memory
+   name = "RAM"
+   type = unknown
+   baseaddr = 0x00000000
+   size = 0x02000000
+   delayr = 1
+   delayw = 2
+ end
+ 
+ section uart
+   enabled = 1
+   baseaddr = 0x90000000
+   irq = 2
+   16550 = 1
+   /* channel = "tcp:10084" */
+   channel = "xterm:"
+ end
+ 
+ section ethernet
+   enabled = 1
+   baseaddr = 0x92000000
+   irq = 4
+   rtx_type = "tap"
+   tap_dev = "tap0"
+ end
+
+Run or1ksim::
+
+ $ ~/or1ksim/sim -f or1ksim.cfg barebox
Signature · 7 lines
2.1.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#8 lore raw

Re: [PATCH v2 7/7] Documentation: add OpenRISC or1ksim emulator section

Hi Antony,

2014-09-08 8:53 GMT+02:00 Antony Pavlov <[email protected]>:

Quoted 12 lines
---
 Documentation/boards/openrisc.rst | 51 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
Documentation/boards/openrisc.rst new file +0 -0
new file mode 100644
index 0000000..0b36712

Documentation/boards/openrisc.rst line 10

Quoted 10 lines
Documentation/boards/openrisc.rst new file +10 -0
@@ -0,0 +1,51 @@
+OpenRISC
+========
+
+or1ksim
+-------
+
+Compile or1ksim emulator::
+
+ $ cd ~/
+ $ git clone https://github.com/fjullien/or1ksim

You should use this repo: https://github.com/openrisc/or1ksim

Quoted 42 lines
Documentation/boards/openrisc.rst new file +41 -1
+ $ cd or1ksim
+ $ ./configure
+ $ make
+
+Create minimal or1ksim.cfg file::
+
+ section cpu
+   ver = 0x12
+   cfgr = 0x20
+   rev = 0x0001
+ end
+
+ section memory
+   name = "RAM"
+   type = unknown
+   baseaddr = 0x00000000
+   size = 0x02000000
+   delayr = 1
+   delayw = 2
+ end
+
+ section uart
+   enabled = 1
+   baseaddr = 0x90000000
+   irq = 2
+   16550 = 1
+   /* channel = "tcp:10084" */
+   channel = "xterm:"
+ end
+
+ section ethernet
+   enabled = 1
+   baseaddr = 0x92000000
+   irq = 4
+   rtx_type = "tap"
+   tap_dev = "tap0"
+ end
+
+Run or1ksim::
+
+ $ ~/or1ksim/sim -f or1ksim.cfg barebox
--
Quoted 2 lines

2.1.0

Franck.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#9 lore raw

Re: [PATCH v2 7/7] Documentation: add OpenRISC or1ksim emulator section

Quoted 19 lines · Franck Jullien

Hi Antony,

2014-09-08 8:53 GMT+02:00 Antony Pavlov <[email protected]>:

Quoted 16 lines
---
 Documentation/boards/openrisc.rst | 51 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
Documentation/boards/openrisc.rst new file +4 -0
new file mode 100644
index 0000000..0b36712
@@ -0,0 +1,51 @@
+OpenRISC
+========
+
+or1ksim
Quoted 8 lines

Documentation/boards/openrisc.rst line 10

Quoted 6 lines
Documentation/boards/openrisc.rst new file +6 -0
+-------
+
+Compile or1ksim emulator::
+
+ $ cd ~/
+ $ git clone https://github.com/fjullien/or1ksim

You should use this repo: https://github.com/openrisc/or1ksim

I changed while this applying.

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
#10 lore raw

Re: [PATCH v2 7/7] Documentation: add OpenRISC or1ksim emulator section

Quoted 29 lines · On Tue, 9 Sep 2014 10:29:25 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 19 lines · Franck Jullien

Hi Antony,

2014-09-08 8:53 GMT+02:00 Antony Pavlov <[email protected]>:

Quoted 16 lines
---
 Documentation/boards/openrisc.rst | 51 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
Documentation/boards/openrisc.rst new file +4 -0
new file mode 100644
index 0000000..0b36712
@@ -0,0 +1,51 @@
+OpenRISC
+========
+
+or1ksim
Quoted 8 lines

Documentation/boards/openrisc.rst line 10

Quoted 6 lines
Documentation/boards/openrisc.rst new file +6 -0
+-------
+
+Compile or1ksim emulator::
+
+ $ cd ~/
+ $ git clone https://github.com/fjullien/or1ksim

You should use this repo: https://github.com/openrisc/or1ksim

Quoted 1 line

I changed while this applying.

Thanks!

Just in case I have tested barebox with https://github.com/openrisc/or1ksim repo emulator. It works fine.

--
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Applied
#11 lore raw
In reply to Antony Pavlov
Quoted 8 lines · Antony Pavlov

This patch series adds device tree support for openrisc generic board. The barebox mips device tree support is used as a sample.

Changes since v1:

* rebase over latest next;
* add 'Documentation: add OpenRISC or1ksim emulator section'.

Quoted 8 lines

Antony Pavlov (7):
openrisc: generic board: reserve 512K for barebox
net: ethoc: add device tree support
openrisc: add initial device tree support
openrisc: dts: import or1ksim.dts from linux-3.16
openrisc: generic board: reduce platform code
openrisc: generic_defconfig: enable device tree stuff
Documentation: add OpenRISC or1ksim emulator section

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