From 3d63a0efdaab5bb79dbb2f03e82cb3faef89fc37 Mon Sep 17 00:00:00 2001
From: Valentin Raevsky <valentin@compulab.co.il>
Date: Sun, 26 Jun 2016 17:22:41 +0300
Subject: ARM: i.MX6: pcie refactoring

PCIe refactoring.
Separate the board specific and the common code.

Signed-off-by: Valentin Raevsky <valentin@compulab.co.il>
---
 arch/arm/boot/dts/imx6qdl-cm-fx6.dtsi  | 15 ++-------------
 arch/arm/boot/dts/imx6qdl-sb-fx6.dtsi  | 12 ++++++++++++
 arch/arm/boot/dts/imx6qdl-sb-fx6m.dtsi | 29 +++++++++++++++++++++++------
 arch/arm/boot/dts/imx6qdl-sb-fx6x.dtsi |  5 +++++
 4 files changed, 42 insertions(+), 19 deletions(-)

diff --git a/arch/arm/boot/dts/imx6qdl-cm-fx6.dtsi b/arch/arm/boot/dts/imx6qdl-cm-fx6.dtsi
index bd08a40..db89991 100644
--- a/arch/arm/boot/dts/imx6qdl-cm-fx6.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-cm-fx6.dtsi
@@ -15,6 +15,7 @@
 #define MX6QDL_GPR1	0x04 0x04 0x000 0x0 0x0
 #define MX6QDL_GPR6	0x18 0x18 0x000 0x0 0x0
 #define MX6QDL_GPR7	0x1c 0x1c 0x000 0x0 0x0
+#define MX6QDL_GPR1    0x04 0x04 0x000 0x0 0x0
 
 / {
 	memory {
@@ -45,16 +46,6 @@
 			enable-active-high;
 		};
 
-		/* regulator1 for pcie power-on-gpio */
-		pcie_power_on_gpio: regulator-pcie-power-on-gpio {
-			compatible = "regulator-fixed";
-			regulator-name = "regulator-pcie-power-on-gpio";
-			regulator-min-microvolt = <3300000>;
-			regulator-max-microvolt = <3300000>;
-			gpio = <&gpio2 24 0>;
-			enable-active-high;
-		};
-
 		/* regulator for usb hub1 */
 		reg_usb_h1_vbus: usb_h1_vbus {
 			compatible = "regulator-fixed";
@@ -417,7 +408,6 @@
 		pinctrl_pcie: pciegrp {
 			fsl,pins = <
 				MX6QDL_PAD_ENET_RXD1__GPIO1_IO26 0x80000000
-				MX6QDL_PAD_EIM_CS1__GPIO2_IO24 0x80000000
 			>;
 		};
 
@@ -616,8 +606,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_pcie>;
 	reset-gpio = <&gpio1 26 0>;
-	vdd-supply = <&pcie_power_on_gpio>;
-	status = "okay";
+	status = "disabled";
 };
 
 /* console */
diff --git a/arch/arm/boot/dts/imx6qdl-sb-fx6.dtsi b/arch/arm/boot/dts/imx6qdl-sb-fx6.dtsi
index e96b732..84934f6 100644
--- a/arch/arm/boot/dts/imx6qdl-sb-fx6.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-sb-fx6.dtsi
@@ -93,6 +93,18 @@
 		reset-delay-us = <100>;
 		#reset-cells = <0>;
 	};
+
+	pcie_power_on_gpio: regulator-pcie-power-on-gpio {
+		compatible = "regulator-fixed";
+		regulator-name = "regulator-pcie-power-on-gpio";
+		gpio = <&pca9555 4 GPIO_ACTIVE_LOW>;
+		enable-active-low;
+	};
+};
+
+&pcie {
+	vdd-supply = <&pcie_power_on_gpio>;
+	status = "okay";
 };
 
 &i2c1 {
diff --git a/arch/arm/boot/dts/imx6qdl-sb-fx6m.dtsi b/arch/arm/boot/dts/imx6qdl-sb-fx6m.dtsi
index b700499..ff35479 100644
--- a/arch/arm/boot/dts/imx6qdl-sb-fx6m.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-sb-fx6m.dtsi
@@ -11,6 +11,8 @@
  * http://www.gnu.org/copyleft/gpl.html
  */
 
+#include <dt-bindings/gpio/gpio.h>
+
 / {
 	iomux_uart2: pinmux@20E0924 {
 		compatible = "pinctrl-single";
@@ -21,12 +23,6 @@
 		pinctrl-single,function-mask = <0x4>;
 	};
 
-	eth@pcie {
-		compatible = "intel,i211";
-		local-mac-address = [FF FF FF FF FF FF];
-		status = "okay";
-	};
-
 	gpio-keys {
 		compatible = "gpio-keys";
 		power {
@@ -73,6 +69,13 @@
 			};
 		};
 	};
+
+	pcie_power_on_gpio: regulator-pcie-power-on-gpio {
+		compatible = "regulator-fixed";
+		regulator-name = "regulator-pcie-power-on-gpio";
+		gpio = <&gpio2 24 GPIO_ACTIVE_HIGH>;
+		enable-active-high;
+	};
 };
 
 &iomuxc {
@@ -86,9 +89,23 @@
 				MX6QDL_PAD_SD4_DAT6__UART2_CTS_B 0x1b0b1
 		>;
 		};
+
+		/* pins for pcie */
+		pinctrl_fx6m_pcie: pciefx6mgrp {
+			fsl,pins = <
+				MX6QDL_PAD_EIM_CS1__GPIO2_IO24 0x80000000
+			>;
+		};
 	};
 };
 
+&pcie {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_pcie>, <&pinctrl_fx6m_pcie>;
+	vdd-supply = <&pcie_power_on_gpio>;
+	status = "okay";
+};
+
 &i2c1 {
 	status = "okay";
 };
diff --git a/arch/arm/boot/dts/imx6qdl-sb-fx6x.dtsi b/arch/arm/boot/dts/imx6qdl-sb-fx6x.dtsi
index f98a87d..77a77fe 100644
--- a/arch/arm/boot/dts/imx6qdl-sb-fx6x.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-sb-fx6x.dtsi
@@ -27,6 +27,11 @@
 		};
 	};
 
+	eth@pcie {
+		compatible = "intel,i211";
+		local-mac-address = [FF FF FF FF FF FF];
+		status = "okay";
+	};
 };
 
 &iomuxc {
-- 
1.9.1

