Patchwork [2/2] SAUCE: imx6: dts: Add IMX6Q AHCI support

login
register
mail settings
Submitter Paolo Pisati
Date Jan. 31, 2013, 5:33 p.m.
Message ID <1359653627-14310-3-git-send-email-paolo.pisati@canonical.com>
Download mbox | patch
Permalink /patch/217223/
State New
Headers show

Comments

Paolo Pisati - Jan. 31, 2013, 5:33 p.m.
From: Allen Ibara <allen@zee.aero>

Adds device tree node and ahci_platform bits to make AHCI work on sabrelite IMX6Q board.

Signed-off-by: Allen Ibara <allen@zee.aero>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |    5 +++++
 arch/arm/boot/dts/imx6q.dtsi          |    8 ++++++++
 drivers/ata/ahci_platform.c           |   28 +++++++++++++++++++++-------
 3 files changed, 34 insertions(+), 7 deletions(-)

Patch

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts b/arch/arm/boot/dts/imx6q-sabrelite.dts
index d152328..5740885 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -131,6 +131,11 @@ 
 				};
 			};
 		};
+
+		ahci@0x02200000 { /* AHCI SATA */
+			status = "okay";
+		};
+
 	};
 
 	regulators {
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index d6265ca..e0ca764 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -1056,5 +1056,13 @@ 
 			clocks = <&clks 133>, <&clks 134>, <&clks 137>;
 			clock-names = "bus", "di0", "di1";
 		};
+
+		ahci@0x02200000 { /* AHCI SATA */
+			compatible = "fsl,imx6q-ahci";
+			reg = <0x02200000 0x4000>;
+			interrupts = <0 39 0x04>;
+			clocks = <&clks 154>;
+			status = "disabled";
+		};
 	};
 };
diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c
index 7a8a284..7d22da2 100644
--- a/drivers/ata/ahci_platform.c
+++ b/drivers/ata/ahci_platform.c
@@ -23,6 +23,9 @@ 
 #include <linux/platform_device.h>
 #include <linux/libata.h>
 #include <linux/ahci_platform.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
 #include "ahci.h"
 
 static void ahci_host_stop(struct ata_host *host);
@@ -30,6 +33,7 @@  static void ahci_host_stop(struct ata_host *host);
 enum ahci_type {
 	AHCI,		/* standard platform ahci */
 	IMX53_AHCI,	/* ahci on i.mx53 */
+	IMX6Q_AHCI,	/* ahci on i.mx6q */
 	STRICT_AHCI,	/* delayed DMA engine start */
 };
 
@@ -41,6 +45,10 @@  static struct platform_device_id ahci_devtype[] = {
 		.name = "imx53-ahci",
 		.driver_data = IMX53_AHCI,
 	}, {
+	}, {
+		.name = "imx6q-ahci",
+		.driver_data = IMX53_AHCI,
+	}, {
 		.name = "strict-ahci",
 		.driver_data = STRICT_AHCI,
 	}, {
@@ -86,12 +94,24 @@  static struct scsi_host_template ahci_platform_sht = {
 	AHCI_SHT("ahci_platform"),
 };
 
+static const struct of_device_id ahci_of_match[] = {
+	{ .compatible = "calxeda,hb-ahci",  .data = &ahci_devtype[AHCI],},
+	{ .compatible = "fsl,imx6q-ahci",   .data = &ahci_devtype[IMX6Q_AHCI],},
+	{ .compatible = "snps,spear-ahci", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, ahci_of_match);
+
 static int ahci_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct ahci_platform_data *pdata = dev_get_platdata(dev);
+	const struct of_device_id *of_id =
+			of_match_device(ahci_of_match, &pdev->dev);
+	const struct platform_device_id	*id_entry = of_id->data;
 	const struct platform_device_id *id = platform_get_device_id(pdev);
-	struct ata_port_info pi = ahci_port_info[id ? id->driver_data : 0];
+	struct ata_port_info pi = ahci_port_info[id ? id->driver_data : \
+		id_entry->driver_data];
 	const struct ata_port_info *ppi[] = { &pi, NULL };
 	struct ahci_host_priv *hpriv;
 	struct ata_host *host;
@@ -325,12 +345,6 @@  disable_unprepare_clk:
 
 static SIMPLE_DEV_PM_OPS(ahci_pm_ops, ahci_suspend, ahci_resume);
 
-static const struct of_device_id ahci_of_match[] = {
-	{ .compatible = "snps,spear-ahci", },
-	{},
-};
-MODULE_DEVICE_TABLE(of, ahci_of_match);
-
 static struct platform_driver ahci_driver = {
 	.probe = ahci_probe,
 	.remove = ata_platform_remove_one,