Skip to contentSkip to conversation

Add devicetree support for i.MX27 SoCs

PATCH New Sascha Hauer 4 participants 9 messages Feb 29, 2012 – Apr 12, 2012

Subsystems (4)
lore
Share & tools
lore

Sascha Hauer

author maintainer
#0 lore raw

PATCH 1/1 Add devicetree support for i.MX27 SoCs

Hi all,

I created the following mainly out of curiosity to find out what's missing to support a new i.MX SoC in the devicetree. It turned out it's not much thanks to the driver bindings which already exist for the bigger i.MXes. So here it is.

Sascha

Sascha Hauer (3):
ARM i.MX27: Add devicetree support
ARM i.MX: Add phytec phycore-i.MX27 (aka pcm038) devicetree support
devicetree-bindings: Add documentation for i.MX generic boards

 Documentation/devicetree/bindings/arm/fsl.txt |   22 +++
 arch/arm/boot/dts/imx27-phytec-phycore.dts    |   76 +++++++++
 arch/arm/boot/dts/imx27.dtsi                  |  217 +++++++++++++++++++++++++
 arch/arm/mach-imx/Kconfig                     |    8 +
 arch/arm/mach-imx/Makefile                    |    1 +
 arch/arm/mach-imx/clock-imx27.c               |   18 ++
 arch/arm/mach-imx/imx27-dt.c                  |   89 ++++++++++
 arch/arm/plat-mxc/include/mach/common.h       |    1 +
 8 files changed, 432 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/boot/dts/imx27-phytec-phycore.dts
 create mode 100644 arch/arm/boot/dts/imx27.dtsi
 create mode 100644 arch/arm/mach-imx/imx27-dt.c
author maintainer
#1 lore raw

PATCH 1/3 ARM i.MX27: Add devicetree support

This patch adds basic devicetree support for i.MX27 based SoCs. Only the bindings for which drivers exist are added here:

- UART
- fec
- CSPI
- I2C
- watchdog
- gpio

---
 arch/arm/boot/dts/imx27.dtsi            |  217 +++++++++++++++++++++++++++++++
 arch/arm/mach-imx/Kconfig               |    8 +
 arch/arm/mach-imx/Makefile              |    1 +
 arch/arm/mach-imx/clock-imx27.c         |   18 +++
 arch/arm/mach-imx/imx27-dt.c            |   89 +++++++++++++
 arch/arm/plat-mxc/include/mach/common.h |    1 +
 6 files changed, 334 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/boot/dts/imx27.dtsi
 create mode 100644 arch/arm/mach-imx/imx27-dt.c
arch/arm/boot/dts/imx27.dtsi new file +217 -0
new file mode 100644
index 0000000..bc5e7d5
@@ -0,0 +1,217 @@
+/*
+ * Copyright 2012 Sascha Hauer, Pengutronix
+ *
+ * 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
+ */
+
+/include/ "skeleton.dtsi"
+
+/ {
+	aliases {
+		serial0 = &uart1;
+		serial1 = &uart2;
+		serial2 = &uart3;
+		serial3 = &uart4;
+		serial4 = &uart5;
+		serial5 = &uart6;
+	};
+
+	avic: avic-interrupt-controller at e0000000 {
+		compatible = "fsl,imx27-avic", "fsl,avic";
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		reg = <0x10040000 0x1000>;
+	};
+
+	clocks {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		osc26m {
+			compatible = "fsl,imx-osc26m", "fixed-clock";
+			clock-frequency = <26000000>;
+		};
+	};
+
+	soc {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "simple-bus";
+		interrupt-parent = <&avic>;
+		ranges;
+
+		aipi at 10000000 { /* AIPI1 */
+			compatible = "fsl,aipi-bus", "simple-bus";
+			#address-cells = <1>;
+			#size-cells = <1>;
+			reg = <0x10000000 0x10000000>;
+			ranges;
+
+			wdog at 10002000 {
+				compatible = "fsl,imx27-wdt", "fsl,imx21-wdt";
+				reg = <0x10002000 0x4000>;
+				interrupts = <27>;
+				status = "disabled";
+			};
+
+			uart1: uart at 1000a000 {
+				compatible = "fsl,imx27-uart", "fsl,imx21-uart";
+				reg = <0x1000a000 0x1000>;
+				interrupts = <20>;
+				status = "disabled";
+			};
+
+			uart2: uart at 1000b000 {
+				compatible = "fsl,imx27-uart", "fsl,imx21-uart";
+				reg = <0x1000b000 0x1000>;
+				interrupts = <19>;
+				status = "disabled";
+			};
+
+			uart3: uart at 1000c000 {
+				compatible = "fsl,imx27-uart", "fsl,imx21-uart";
+				reg = <0x1000c000 0x1000>;
+				interrupts = <18>;
+				status = "disabled";
+			};
+
+			uart4: uart at 1000d000 {
+				compatible = "fsl,imx27-uart", "fsl,imx21-uart";
+				reg = <0x1000d000 0x1000>;
+				interrupts = <17>;
+				status = "disabled";
+			};
+
+			cspi1: cspi at 1000e000 {
+				#address-cells = <1>;
+				#size-cells = <0>;
+				compatible = "fsl,imx27-cspi";
+				reg = <0x1000e000 0x1000>;
+				interrupts = <16>;
+				status = "disabled";
+			};
+
+			cspi2: cspi at 1000f000 {
+				#address-cells = <1>;
+				#size-cells = <0>;
+				compatible = "fsl,imx27-cspi";
+				reg = <0x1000f000 0x1000>;
+				interrupts = <15>;
+				status = "disabled";
+			};
+
+			i2c1: i2c at 10012000 {
+				#address-cells = <1>;
+				#size-cells = <0>;
+				compatible = "fsl,imx27-i2c", "fsl,imx1-i2c";
+				reg = <0x10012000 0x1000>;
+				interrupts = <12>;
+				status = "disabled";
+			};
+
+			gpio1: gpio at 10015000 {
+				compatible = "fsl,imx27-gpio", "fsl,imx21-gpio";
+				reg = <0x10015000 0x100>;
+				interrupts = <8>;
+				gpio-controller;
+				#gpio-cells = <2>;
+				interrupt-controller;
+				#interrupt-cells = <1>;
+			};
+
+			gpio2: gpio at 10015100 {
+				compatible = "fsl,imx27-gpio", "fsl,imx21-gpio";
+				reg = <0x10015100 0x100>;
+				interrupts = <8>;
+				gpio-controller;
+				#gpio-cells = <2>;
+				interrupt-controller;
+				#interrupt-cells = <1>;
+			};
+
+			gpio3: gpio at 10015200 {
+				compatible = "fsl,imx27-gpio", "fsl,imx21-gpio";
+				reg = <0x10015200 0x100>;
+				interrupts = <8>;
+				gpio-controller;
+				#gpio-cells = <2>;
+				interrupt-controller;
+				#interrupt-cells = <1>;
+			};
+
+			gpio4: gpio at 10015300 {
+				compatible = "fsl,imx27-gpio", "fsl,imx21-gpio";
+				reg = <0x10015300 0x100>;
+				interrupts = <8>;
+				gpio-controller;
+				#gpio-cells = <2>;
+				interrupt-controller;
+				#interrupt-cells = <1>;
+			};
+
+			gpio5: gpio at 10015400 {
+				compatible = "fsl,imx27-gpio", "fsl,imx21-gpio";
+				reg = <0x10015400 0x100>;
+				interrupts = <8>;
+				gpio-controller;
+				#gpio-cells = <2>;
+				interrupt-controller;
+				#interrupt-cells = <1>;
+			};
+
+			gpio6: gpio at 10015500 {
+				compatible = "fsl,imx27-gpio", "fsl,imx21-gpio";
+				reg = <0x10015500 0x100>;
+				interrupts = <8>;
+				gpio-controller;
+				#gpio-cells = <2>;
+				interrupt-controller;
+				#interrupt-cells = <1>;
+			};
+
+			cspi3: cspi at 10017000 {
+				#address-cells = <1>;
+				#size-cells = <0>;
+				compatible = "fsl,imx27-cspi";
+				reg = <0x10017000 0x1000>;
+				interrupts = <6>;
+				status = "disabled";
+			};
+
+			uart5: uart at 1001b000 {
+				compatible = "fsl,imx27-uart", "fsl,imx21-uart";
+				reg = <0x1001b000 0x1000>;
+				interrupts = <49>;
+				status = "disabled";
+			};
+
+			uart6: uart at 1001c000 {
+				compatible = "fsl,imx27-uart", "fsl,imx21-uart";
+				reg = <0x1001c000 0x1000>;
+				interrupts = <48>;
+				status = "disabled";
+			};
+
+			i2c2: i2c at 1001d000 {
+				#address-cells = <1>;
+				#size-cells = <0>;
+				compatible = "fsl,imx27-i2c", "fsl,imx1-i2c";
+				reg = <0x1001d000 0x1000>;
+				interrupts = <1>;
+				status = "disabled";
+			};
+
+			fec: fec at 1002b000 {
+				compatible = "fsl,imx27-fec";
+				reg = <0x1002b000 0x4000>;
+				interrupts = <50>;
+				status = "disabled";
+			};
+		};
+	};
+};
arch/arm/mach-imx/Kconfig +8 -0
index 4defb97..85433b9 100644
@@ -376,6 +376,14 @@ config MACH_IMX27IPCAM
 	  Include support for IMX27 IPCAM platform. This includes specific
 	  configurations for the board and its peripherals.
 
+config MACH_IMX27_DT
+	bool "Support i.MX27 platforms from device tree"
+	select SOC_IMX27
+	select USE_OF
+	help
+	  Include support for Freescale i.MX27 based platforms
+	  using the device tree for discovery
+
 endif
 
 if ARCH_IMX_V6_V7
arch/arm/mach-imx/Makefile +1 -0
index 55db9c4..4ffeca7 100644
@@ -41,6 +41,7 @@ obj-$(CONFIG_MACH_EUKREA_MBIMX27_BASEBOARD) += eukrea_mbimx27-baseboard.o
 obj-$(CONFIG_MACH_PCA100) += mach-pca100.o
 obj-$(CONFIG_MACH_MXT_TD60) += mach-mxt_td60.o
 obj-$(CONFIG_MACH_IMX27IPCAM) += mach-imx27ipcam.o
+obj-$(CONFIG_MACH_IMX27_DT) += imx27-dt.o
 
 # i.MX31 based machines
 obj-$(CONFIG_MACH_MX31ADS) += mach-mx31ads.o
arch/arm/mach-imx/clock-imx27.c +18 -0
index 88fe00a..01ae3a4 100644
@@ -22,6 +22,7 @@
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/clkdev.h>
+#include <linux/of.h>
 
 #include <asm/div64.h>
 
@@ -764,3 +765,20 @@ int __init mx27_clocks_init(unsigned long fref)
 	return 0;
 }
 
+#ifdef CONFIG_OF
+int __init mx27_clocks_init_dt(void)
+{
+	struct device_node *np;
+	u32 fref = 26000000; /* default */
+
+	for_each_compatible_node(np, NULL, "fixed-clock") {
+		if (!of_device_is_compatible(np, "fsl,imx-osc26m"))
+			continue;
+
+		if (!of_property_read_u32(np, "clock-frequency", &fref))
+			break;
+	}
+
+	return mx27_clocks_init(fref);
+}
+#endif
arch/arm/mach-imx/imx27-dt.c new file +89 -0

89 lines not on this page · raw message

arch/arm/plat-mxc/include/mach/common.h +1 -0
index 1bf0df8..16d10a8 100644
@@ -65,6 +65,7 @@ extern int mx51_clocks_init(unsigned long ckil, unsigned long osc,
 			unsigned long ckih1, unsigned long ckih2);
 extern int mx53_clocks_init(unsigned long ckil, unsigned long osc,
 			unsigned long ckih1, unsigned long ckih2);
+extern int mx27_clocks_init_dt(void);
 extern int mx51_clocks_init_dt(void);
 extern int mx53_clocks_init_dt(void);
 extern int mx6q_clocks_init(void);
Signature · 1 line
1.7.9.1
#2 lore raw

PATCH 1/3 ARM i.MX27: Add devicetree support

Hi Sascha,

Quoted 36 lines · Sascha Hauer

This patch adds basic devicetree support for i.MX27 based SoCs. Only the bindings for which drivers exist are added here:

- UART
- fec
- CSPI
- I2C
- watchdog
- gpio

---
 arch/arm/boot/dts/imx27.dtsi            |  217 +++++++++++++++++++++++++++++++
 arch/arm/mach-imx/Kconfig               |    8 +
 arch/arm/mach-imx/Makefile              |    1 +
 arch/arm/mach-imx/clock-imx27.c         |   18 +++
 arch/arm/mach-imx/imx27-dt.c            |   89 +++++++++++++
 arch/arm/plat-mxc/include/mach/common.h |    1 +
 6 files changed, 334 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/boot/dts/imx27.dtsi
 create mode 100644 arch/arm/mach-imx/imx27-dt.c

[...]

arch/arm/mach-imx/imx27-dt.c new file +6 -0
new file mode 100644
index 0000000..861ceb8
 
[...]
+static int __init imx27_avic_add_irq_domain(struct device_node *np,
+				struct device_node *interrupt_parent)
+{
+	irq_domain_add_simple(np, 0);
+	return 0;
+}

arch/arm/mach-imx/imx27-dt.c line 50

Quoted 10 lines
arch/arm/mach-imx/imx27-dt.c new file +10 -0
+
+static int __init imx27_gpio_add_irq_domain(struct device_node *np,
+				struct device_node *interrupt_parent)
+{
+	static int gpio_irq_base = MXC_GPIO_IRQ_START + ARCH_NR_GPIOS;
+
+	irq_domain_add_simple(np, gpio_irq_base);
+
+	return 0;
+}

This patch was merged for 3.4-rc1, but it fails to compile because Grant removed irq_domain_add_simple() in 3.4-rc1.

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
author maintainer
#3 lore raw

PATCH 1/3 ARM i.MX27: Add devicetree support

Hi Chris,

Quoted 13 lines · Chris Ball
Quoted 13 lines

[...]

arch/arm/mach-imx/imx27-dt.c new file +11 -0
+static int __init imx27_avic_add_irq_domain(struct device_node *np,
+				struct device_node *interrupt_parent)
+{
+	irq_domain_add_simple(np, 0);
+	return 0;
+}
+
+static int __init imx27_gpio_add_irq_domain(struct device_node *np,
+				struct device_node *interrupt_parent)
+{
+	static int gpio_irq_base = MXC_GPIO_IRQ_START + ARCH_NR_GPIOS;
Quoted 8 lines

arch/arm/mach-imx/imx27-dt.c line 50

Quoted 5 lines
arch/arm/mach-imx/imx27-dt.c new file +5 -0
+
+	irq_domain_add_simple(np, gpio_irq_base);
+
+	return 0;
+}

This patch was merged for 3.4-rc1, but it fails to compile because Grant removed irq_domain_add_simple() in 3.4-rc1.

Thanks for noting. I assume that irq_domain_add_legacy is the right approach here, just like the other i.MX boards do, right?

Sascha

Signature · 4 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 |
#4 lore raw

PATCH 1/3 ARM i.MX27: Add devicetree support

Hi,

Quoted 23 lines · Sascha Hauer
Quoted 13 lines · Chris Ball
Quoted 13 lines

[...]

arch/arm/mach-imx/imx27-dt.c new file +11 -0
+static int __init imx27_avic_add_irq_domain(struct device_node *np,
+				struct device_node *interrupt_parent)
+{
+	irq_domain_add_simple(np, 0);
+	return 0;
+}
+
+static int __init imx27_gpio_add_irq_domain(struct device_node *np,
+				struct device_node *interrupt_parent)
+{
+	static int gpio_irq_base = MXC_GPIO_IRQ_START + ARCH_NR_GPIOS;
Quoted 8 lines

arch/arm/mach-imx/imx27-dt.c line 50

Quoted 5 lines
arch/arm/mach-imx/imx27-dt.c new file +5 -0
+
+	irq_domain_add_simple(np, gpio_irq_base);
+
+	return 0;
+}

This patch was merged for 3.4-rc1, but it fails to compile because Grant removed irq_domain_add_simple() in 3.4-rc1.

Quoted 2 lines

Thanks for noting. I assume that irq_domain_add_legacy is the right approach here, just like the other i.MX boards do, right?

Yeah, if you look at Grant's removal patch:

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=6b783f7c5dde2648fa0bbe7fc8ac80d78699e67f

.. he converted all of the in-tree uses to irq_domain_add_legacy() at the time of removal, so that looks right.

Thanks,

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
reviewer
#5 lore raw

PATCH 1/3 ARM i.MX27: Add devicetree support

Sascha,

Quoted 9 lines · Chris Ball
Quoted 2 lines

Thanks for noting. I assume that irq_domain_add_legacy is the right approach here, just like the other i.MX boards do, right?

Yeah, if you look at Grant's removal patch:

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=6b783f7c5dde2648fa0bbe7fc8ac80d78699e67f

.. he converted all of the in-tree uses to irq_domain_add_legacy() at the time of removal, so that looks right.

I managed to get mx27pdk booting from dt (thanks Shawn for the tips!) and I fixed this problem.

Will send the fix soon.

author maintainer
#6 lore raw

PATCH 2/3 ARM i.MX: Add phytec phycore-i.MX27 (aka pcm038) devicetree support

In reply to Sascha Hauer
---
 arch/arm/boot/dts/imx27-phytec-phycore.dts |   76 ++++++++++++++++++++++++++++
 1 files changed, 76 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/boot/dts/imx27-phytec-phycore.dts
arch/arm/boot/dts/imx27-phytec-phycore.dts new file +76 -0
new file mode 100644
index 0000000..a51a08f
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2012 Sascha Hauer, Pengutronix
+ *
+ * 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/ "imx27.dtsi"
+
+/ {
+	model = "Phytec pcm038";
+	compatible = "phytec,imx27-pcm038", "fsl,imx27";
+
+	memory {
+		reg = <0x0 0x0>;
+	};
+
+	soc {
+		aipi at 10000000 { /* aipi */
+
+			wdog at 10002000 {
+				status = "okay";
+			};
+
+			uart at 1000a000 {
+				fsl,uart-has-rtscts;
+				status = "okay";
+			};
+
+			uart at 1000b000 {
+				fsl,uart-has-rtscts;
+				status = "okay";
+			};
+
+			uart at 1000c000 {
+				fsl,uart-has-rtscts;
+				status = "okay";
+			};
+
+			fec at 1002b000 {
+				status = "okay";
+			};
+
+			i2c at 1001d000 {
+				clock-frequency = <400000>;
+				status = "okay";
+				at24 at 4c {
+					compatible = "at,24c32";
+					pagesize = <32>;
+					reg = <0x52>;
+				};
+				pcf8563 at 51 {
+					compatible = "nxp,pcf8563";
+					reg = <0x51>;
+				};
+				lm75 at 4a {
+					compatible = "national,lm75";
+					reg = <0x4a>;
+				};
+			};
+		};
+	};
+
+	nor_flash at c0000000 {
+		compatible = "cfi-flash";
+		bank-width = <2>;
+		reg = <0xc0000000 0x02000000>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+	};
+};
Signature · 1 line
1.7.9.1
author maintainer
#7 lore raw

PATCH 3/3 devicetree-bindings: Add documentation for i.MX generic boards

In reply to Sascha Hauer
---
 Documentation/devicetree/bindings/arm/fsl.txt |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
Documentation/devicetree/bindings/arm/fsl.txt +22 -0
index 54bddda..bfbc771 100644
@@ -28,3 +28,25 @@ Required root node properties:
 i.MX6 Quad SABRE Lite Board
 Required root node properties:
     - compatible = "fsl,imx6q-sabrelite", "fsl,imx6q";
+
+Generic i.MX boards
+-------------------
+
+No iomux setup is done for these boards, so this must have been configured
+by the bootloader for boards to work with the generic bindings.
+
+i.MX27 generic board
+Required root node properties:
+    - compatible = "fsl,imx27";
+
+i.MX51 generic board
+Required root node properties:
+    - compatible = "fsl,imx51";
+
+i.MX53 generic board
+Required root node properties:
+    - compatible = "fsl,imx53";
+
+i.MX6q generic board
+Required root node properties:
+    - compatible = "fsl,imx6q";
Signature · 1 line
1.7.9.1
#8 lore raw

PATCH 1/1 Add devicetree support for i.MX27 SoCs

In reply to Sascha Hauer
Quoted 7 lines · Sascha Hauer

Hi all,

I created the following mainly out of curiosity to find out what's missing to support a new i.MX SoC in the devicetree. It turned out it's not much thanks to the driver bindings which already exist for the bigger i.MXes. So here it is.

Quoted 6 lines

Sascha

Sascha Hauer (3):
ARM i.MX27: Add devicetree support
ARM i.MX: Add phytec phycore-i.MX27 (aka pcm038) devicetree support
devicetree-bindings: Add documentation for i.MX generic boards

For the series,

Regards,
Shawn

Quoted 13 lines
 Documentation/devicetree/bindings/arm/fsl.txt |   22 +++
 arch/arm/boot/dts/imx27-phytec-phycore.dts    |   76 +++++++++
 arch/arm/boot/dts/imx27.dtsi                  |  217 +++++++++++++++++++++++++
 arch/arm/mach-imx/Kconfig                     |    8 +
 arch/arm/mach-imx/Makefile                    |    1 +
 arch/arm/mach-imx/clock-imx27.c               |   18 ++
 arch/arm/mach-imx/imx27-dt.c                  |   89 ++++++++++
 arch/arm/plat-mxc/include/mach/common.h       |    1 +
 8 files changed, 432 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/boot/dts/imx27-phytec-phycore.dts
 create mode 100644 arch/arm/boot/dts/imx27.dtsi
 create mode 100644 arch/arm/mach-imx/imx27-dt.c