Skip to contentSkip to conversation

ARM: SPEAr600: Add device-tree support to SPEAr600 boards

PATCH Superseded Stefan Roese 3 participants 4 messages Mar 15, 2012 – Mar 16, 2012

Subsystems (3)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ARM: SPEAr600: Add device-tree support to SPEAr600 boards

This patch adds a generic target for SPEAr600 board that can be configured via the device-tree. Currently the following devices are supported via the devicetree:

- VIC interrupts
- PL011 UART
- PL061 GPIO
- Synopsys DW I2C
- Synopsys DW ethernet

Other peripheral devices (e.g. SMI flash, FSMC NAND flash etc) will follow in later patches.

Only the spear600-evb is currently supported. Other SPEAr600 based boards will follow later.

Since the current mainline SPEAr600 code only supports the SPEAr600 evaluation board, with nearly zero peripheral devices (only UART and GPIO), it makes sense to switch over to DT based configuration completely now. So this patch also removes all non-DT stuff, mainly platform device data. The files spear600.c and spear600_evb.c are removed completely.

Cc Viresh Kumar <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Jean-Christophe PLAGNIOL-VILLARD <[email protected]>

---
Arnd, I didn't add your reviewed-by, since this patch version has changed quite a bit. Please review again. Thanks.

v3:
- Removed non-DT SPEAr600 board support completely
- Removed OF_DEV_AUXDATA and changed clkdev instead, since we don't support non-DT targets any more
- Changed gmac0 -> gmac etc for single instance devices in the dts
- Added max memory size to memory node (instead of 0)
- Dropped mac-address property
- Removed some headers from spear6xx.c

v2:
- Added DT support to spear6xx.c instead of creating board-dt.c
- Removed UART (PL011) and GPIO (PL061) platform data for devicetree board port. This works now via DT probing
- Added OF_DEV_AUXDATA for clock device name matching for some device drivers
- Removed sper600.c file completely
- Added DW I2C and ethernet nodes to the dts files
- Added other DT nodes (SMI, FSMC, ECHI, OHCI), currently disabled since the corresponding device drivers don't support DT probing
- Removed Linaro/FSL copyright notice from SPEAr DT files (copy-paste cruft)
- Many smaller modification to the dts/dtsi files
- Changed Documentation/devicetree/bindings/arm/spear.txt to match the changed bindings

 Documentation/devicetree/bindings/arm/spear.txt |    8 ++
 arch/arm/boot/dts/spear600-evb.dts              |   30 +++++
 arch/arm/boot/dts/spear600.dtsi                 |  161 +++++++++++++++++++++++
 arch/arm/mach-spear6xx/Kconfig                  |    7 +-
 arch/arm/mach-spear6xx/Makefile                 |    6 -
 arch/arm/mach-spear6xx/clock.c                  |   14 +-
 arch/arm/mach-spear6xx/spear600.c               |   25 ----
 arch/arm/mach-spear6xx/spear600_evb.c           |   54 --------
 arch/arm/mach-spear6xx/spear6xx.c               |  132 +++++--------------
 9 files changed, 246 insertions(+), 191 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/spear.txt
 create mode 100644 arch/arm/boot/dts/spear600-evb.dts
 create mode 100644 arch/arm/boot/dts/spear600.dtsi
 delete mode 100644 arch/arm/mach-spear6xx/spear600.c
 delete mode 100644 arch/arm/mach-spear6xx/spear600_evb.c
Documentation/devicetree/bindings/arm/spear.txt new file +8 -0
new file mode 100644
index 0000000..f8e54f0
@@ -0,0 +1,8 @@
+ST SPEAr Platforms Device Tree Bindings
+---------------------------------------
+
+Boards with the ST SPEAr600 SoC shall have the following properties:
+
+Required root node property:
+
+compatible = "st,spear600";
arch/arm/boot/dts/spear600-evb.dts new file +30 -0
new file mode 100644
index 0000000..cc594ed
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2012 Stefan Roese <[email protected]>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/dts-v1/;
+/include/ "spear600.dtsi"
+
+/ {
+	model = "ST SPEAr600 Evaluation Board";
+	compatible = "st,spear600-evb", "st,spear600";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	ahb {
+		gmac: ethernet at e0800000 {
+			phy-mode = "gmii";
+		};
+
+		i2c at d0200000 {
+			clock-frequency = <400000>;
+		};
+	};
+};
arch/arm/boot/dts/spear600.dtsi new file +161 -0

161 lines not on this page · raw message

arch/arm/mach-spear6xx/Kconfig +4 -3
index ff4ae5b..fbe298b 100644
@@ -5,11 +5,12 @@
 if ARCH_SPEAR6XX
 
 menu "SPEAr6xx Implementations"
-config BOARD_SPEAR600_EVB
-	bool "SPEAr600 Evaluation Board"
+config BOARD_SPEAR600_DT
+	bool "SPEAr600 generic board configured via device-tree"
 	select MACH_SPEAR600
+	select USE_OF
 	help
-	  Supports ST SPEAr600 Evaluation Board
+	  Supports ST SPEAr600 boards configured via the device-tree
 
 endmenu
 
arch/arm/mach-spear6xx/Makefile +0 -6
index cc1a4d8..76e5750 100644
@@ -4,9 +4,3 @@
 
 # common files
 obj-y	+= clock.o spear6xx.o
-
-# spear600 specific files
-obj-$(CONFIG_MACH_SPEAR600) += spear600.o
-
-# spear600 boards files
-obj-$(CONFIG_BOARD_SPEAR600_EVB) += spear600_evb.o
arch/arm/mach-spear6xx/clock.c +7 -7
index ac70e0d..358f280 100644
@@ -641,8 +641,8 @@ static struct clk_lookup spear_clk_lookups[] = {
 	{ .con_id = "gpt0_synth_clk",	.clk = &gpt0_synth_clk},
 	{ .con_id = "gpt2_synth_clk",	.clk = &gpt2_synth_clk},
 	{ .con_id = "gpt3_synth_clk",	.clk = &gpt3_synth_clk},
-	{ .dev_id = "uart0",		.clk = &uart0_clk},
-	{ .dev_id = "uart1",		.clk = &uart1_clk},
+	{ .dev_id = "d0000000.serial",	.clk = &uart0_clk},
+	{ .dev_id = "d0080000.serial",	.clk = &uart1_clk},
 	{ .dev_id = "firda",		.clk = &firda_clk},
 	{ .dev_id = "clcd",		.clk = &clcd_clk},
 	{ .dev_id = "gpt0",		.clk = &gpt0_clk},
@@ -655,20 +655,20 @@ static struct clk_lookup spear_clk_lookups[] = {
 	{ .con_id = "usbh.1_clk",	.clk = &usbh1_clk},
 	/* clock derived from ahb clk */
 	{ .con_id = "apb_clk",		.clk = &apb_clk},
-	{ .dev_id = "i2c_designware.0",	.clk = &i2c_clk},
+	{ .dev_id = "d0200000.i2c",	.clk = &i2c_clk},
 	{ .dev_id = "dma",		.clk = &dma_clk},
 	{ .dev_id = "jpeg",		.clk = &jpeg_clk},
 	{ .dev_id = "gmac",		.clk = &gmac_clk},
 	{ .dev_id = "smi",		.clk = &smi_clk},
-	{ .con_id = "fsmc",		.clk = &fsmc_clk},
+	{ .dev_id = "fsmc-nand",	.clk = &fsmc_clk},
 	/* clock derived from apb clk */
 	{ .dev_id = "adc",		.clk = &adc_clk},
 	{ .dev_id = "ssp-pl022.0",	.clk = &ssp0_clk},
 	{ .dev_id = "ssp-pl022.1",	.clk = &ssp1_clk},
 	{ .dev_id = "ssp-pl022.2",	.clk = &ssp2_clk},
-	{ .dev_id = "gpio0",		.clk = &gpio0_clk},
-	{ .dev_id = "gpio1",		.clk = &gpio1_clk},
-	{ .dev_id = "gpio2",		.clk = &gpio2_clk},
+	{ .dev_id = "f0100000.gpio",	.clk = &gpio0_clk},
+	{ .dev_id = "fc980000.gpio",	.clk = &gpio1_clk},
+	{ .dev_id = "d8100000.gpio",	.clk = &gpio2_clk},
 };
 
 void __init spear6xx_clk_init(void)
arch/arm/mach-spear6xx/spear600.c deleted +0 -25
deleted file mode 100644
index d0e6eea..0000000
@@ -1,25 +0,0 @@
-/*
- * arch/arm/mach-spear6xx/spear600.c
- *
- * SPEAr600 machine source file
- *
- * Copyright (C) 2009 ST Microelectronics
- * Rajeev Kumar<[email protected]>
- *
- * This file is licensed under the terms of the GNU General Public
- * License version 2. This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- */
-
-#include <linux/ptrace.h>
-#include <asm/irq.h>
-#include <mach/generic.h>
-#include <mach/hardware.h>
-
-/* Add spear600 specific devices here */
-
-void __init spear600_init(void)
-{
-	/* call spear6xx family common init function */
-	spear6xx_init();
-}
arch/arm/mach-spear6xx/spear600_evb.c deleted +0 -54

54 lines not on this page · raw message

arch/arm/mach-spear6xx/spear6xx.c +36 -96

150 lines not on this page · raw message

Signature · 1 line
1.7.9.2
#1 lore raw

PATCH v3 1/1 ARM: SPEAr600: Add device-tree support to SPEAr600 boards

Quoted 7 lines · Stefan Roese
arch/arm/boot/dts/spear600.dtsi +5 -0
 
+/ {
+       compatible = "st,spear600";
+
+       cpus {
+               cpu at 0 {

arch/arm/boot/dts/spear600.dtsi line 28

Quoted 10 lines
arch/arm/boot/dts/spear600.dtsi +10 -0
+                       compatible = "arm,arm926ejs";
+               };
+       };
+
+       memory {
+               device_type = "memory";
+               reg = <0 0x40000000>; /* Real value updated by U-Boot */
+       };
+
+       ahb {

What is the significance of this name? As i see gpio/spi etc in this list, which are on apb bus.

Quoted 44 lines
arch/arm/boot/dts/spear600.dtsi +36 -0
+               #address-cells = <1>;
+               #size-cells = <1>;
+               compatible = "simple-bus";
+               ranges;
+
 
+               /* local/cpu GPIO */
+               gpio0: gpio at f0100000 {
+                       #gpio-cells = <2>;
+                       compatible = "arm,pl061", "arm,primecell";
+                       gpio-controller;
+                       reg = <0xf0100000 0x1000>;
+                       interrupt-parent = <&vic0>;
+                       interrupts = <18>;
+               };
+
+               /* basic GPIO */
+               gpio1: gpio at fc980000 {
+                       #gpio-cells = <2>;
+                       compatible = "arm,pl061", "arm,primecell";
+                       gpio-controller;
+                       reg = <0xfc980000 0x1000>;
+                       interrupt-parent = <&vic1>;
+                       interrupts = <19>;
+               };
+
+               /* appl GPIO */
+               gpio2: gpio at d8100000 {
+                       #gpio-cells = <2>;
+                       compatible = "arm,pl061", "arm,primecell";
+                       gpio-controller;
+                       reg = <0xd8100000 0x1000>;
+                       interrupt-parent = <&vic1>;
+                       interrupts = <4>;
+               };
+
 
+};
arch/arm/mach-spear6xx/clock.c +0 -0
index ac70e0d..358f280 100644

arch/arm/mach-spear6xx/clock.c static struct clk_lookup spear_clk_lookups[] = { · line 645

Quoted 7 lines
arch/arm/mach-spear6xx/clock.c +2 -2
@@ -641,8 +641,8 @@ static struct clk_lookup spear_clk_lookups[] = {
        { .con_id = "gpt0_synth_clk",   .clk = &gpt0_synth_clk},
        { .con_id = "gpt2_synth_clk",   .clk = &gpt2_synth_clk},
        { .con_id = "gpt3_synth_clk",   .clk = &gpt3_synth_clk},
-       { .dev_id = "uart0",            .clk = &uart0_clk},
-       { .dev_id = "uart1",            .clk = &uart1_clk},
+       { .dev_id = "d0000000.serial",  .clk = &uart0_clk},
+       { .dev_id = "d0080000.serial",  .clk = &uart1_clk},

I didn't got Jean's comment at that time, but now it is ultra clear.

Signature · 1 line
viresh
#2 lore raw

PATCH v3 1/1 ARM: SPEAr600: Add device-tree support to SPEAr600 boards

Quoted 14 lines · Viresh Kumar
Quoted 12 lines · Stefan Roese
arch/arm/boot/dts/spear600.dtsi +10 -0
 
+/ {
+       compatible = "st,spear600";
+
+       cpus {
+               cpu at 0 {
+                       compatible = "arm,arm926ejs";
+               };
+       };
+
+       memory {
Quoted 8 lines

arch/arm/boot/dts/spear600.dtsi line 28

Quoted 5 lines
arch/arm/boot/dts/spear600.dtsi +5 -0
+               device_type = "memory";
+               reg = <0 0x40000000>; /* Real value updated by U-Boot */
+       };
+
+       ahb {

What is the significance of this name? As i see gpio/spi etc in this list, which are on apb bus.

That sounds like it should be corrected, the device tree should reflect the physical hierarchy where possible, e.g.

	ahb0 {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "simple-bus";
		ranges = <0xe0000000 0xe0000000 0x10000000>;

		ethernet at e0800000 {
			...
		};

		...
	};

	ahb1 {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "simple-bus";
		ranges = <0xd0000000 0xd0000000 0x10000000>;
		ranges = <0xf0000000 0xf0000000 0x10000000>;

		apb {
			#address-cells = <1>;
			#size-cells = <1>;
			compatible = "simple-bus";
			ranges = <0x0 0xf0000000 0x10000000>;
	
			gpio at f0100000 {
				/* note: reg relative to local ranges property */
				reg = <0x100000 0x1000>;
				...
			};
			...
		};
		...


               i2c at d0200000 {
                        reg = <0xd0200000 0x1000>;
			...
               };

	};

I don't have the data sheet, so the bus hierarchy above is completely made up, but I guess you get the idea. If each bus has its own local register range, it may be helpful to use the ranges property to remap the reg properties in the way that I did in the apb example above.

Arnd

#3 lore raw

PATCH v3 1/1 ARM: SPEAr600: Add device-tree support to SPEAr600 boards

Quoted 4 lines · Arnd Bergmann

I don't have the data sheet, so the bus hierarchy above is completely made up, but I guess you get the idea. If each bus has its own local register range, it may be helpful to use the ranges property to remap the reg properties in the way that I did in the apb example above.

Got your point.

@Stefan: You can get this information from clock.c to see which clocks have ahb as parent and which have apb as parent.

Over that i have kept them in groups/order in the lookup array too. So that would also be very helpful.

Signature · 1 line
viresh