linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: andrew@lunn.ch (Andrew Lunn)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 7/16] ATA: sata_mv: Add device tree support
Date: Fri, 20 Jul 2012 19:35:42 +0200	[thread overview]
Message-ID: <1342805751-18048-8-git-send-email-andrew@lunn.ch> (raw)
In-Reply-To: <1342805751-18048-1-git-send-email-andrew@lunn.ch>

Add support for instantiating this driver from device tree, and add
the necassary DT information to the kirkwood.dtsi file.

This is based on previous work by Michael Walle and Jason Cooper.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Josh Coombs <josh.coombs@gmail.com>
---
 Documentation/devicetree/bindings/ata/marvell.txt |   16 ++++++++
 arch/arm/boot/dts/kirkwood.dtsi                   |    7 ++++
 arch/arm/mach-kirkwood/board-dt.c                 |    1 +
 drivers/ata/sata_mv.c                             |   42 ++++++++++++++-------
 4 files changed, 53 insertions(+), 13 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/ata/marvell.txt

diff --git a/Documentation/devicetree/bindings/ata/marvell.txt b/Documentation/devicetree/bindings/ata/marvell.txt
new file mode 100644
index 0000000..b5cdd20
--- /dev/null
+++ b/Documentation/devicetree/bindings/ata/marvell.txt
@@ -0,0 +1,16 @@
+* Marvell Orion SATA
+
+Required Properties:
+- compatibility : "marvell,orion-sata"
+- reg           : Address range of controller
+- interrupts    : Interrupt controller is using
+- nr-ports      : Number of SATA ports in use.
+
+Example:
+
+	sata at 80000 {
+		compatible = "marvell,orion-sata";
+		reg = <0x80000 0x5000>;
+		interrupts = <21>;
+		nr-ports = <2>;
+	}
diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi
index 3e0e9b9..fbb96ce 100644
--- a/arch/arm/boot/dts/kirkwood.dtsi
+++ b/arch/arm/boot/dts/kirkwood.dtsi
@@ -76,6 +76,13 @@
 			status = "okay";
 		};
 
+		sata at 80000 {
+			compatible = "marvell,orion-sata";
+			reg = <0x80000 0x5000>;
+			interrupts = <21>;
+			status = "disabled";
+		};
+
 		nand at 3000000 {
 			#address-cells = <1>;
 			#size-cells = <1>;
diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c
index 73e75cf..d0ad250 100644
--- a/arch/arm/mach-kirkwood/board-dt.c
+++ b/arch/arm/mach-kirkwood/board-dt.c
@@ -31,6 +31,7 @@ struct of_dev_auxdata kirkwood_auxdata_lookup[] __initdata = {
 	OF_DEV_AUXDATA("marvell,mv64xxx-i2c", 0xf1011000, "mv64xxx_i2c.0",
 		       NULL),
 	OF_DEV_AUXDATA("marvell,orion-wdt", 0xf1020300, "orion_wdt", NULL),
+	OF_DEV_AUXDATA("marvell,orion-sata", 0xf1080000, "sata_mv.0", NULL),
 	{},
 };
 
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index 24712ad..311be18 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -65,6 +65,8 @@
 #include <linux/mbus.h>
 #include <linux/bitops.h>
 #include <linux/gfp.h>
+#include <linux/of.h>
+#include <linux/of_irq.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_device.h>
@@ -4026,7 +4028,7 @@ static int mv_platform_probe(struct platform_device *pdev)
 	struct ata_host *host;
 	struct mv_host_priv *hpriv;
 	struct resource *res;
-	int n_ports = 0;
+	int n_ports = 0, irq = 0;
 	int rc;
 #if defined(CONFIG_HAVE_CLK)
 	int port;
@@ -4050,8 +4052,14 @@ static int mv_platform_probe(struct platform_device *pdev)
 		return -EINVAL;
 
 	/* allocate host */
-	mv_platform_data = pdev->dev.platform_data;
-	n_ports = mv_platform_data->n_ports;
+	if (pdev->dev.of_node) {
+		of_property_read_u32(pdev->dev.of_node, "nr-ports", &n_ports);
+		irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
+	} else {
+		mv_platform_data = pdev->dev.platform_data;
+		n_ports = mv_platform_data->n_ports;
+		irq = platform_get_irq(pdev, 0);
+	}
 
 	host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports);
 	hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL);
@@ -4109,8 +4117,7 @@ static int mv_platform_probe(struct platform_device *pdev)
 	dev_info(&pdev->dev, "slots %u ports %d\n",
 		 (unsigned)MV_MAX_Q_DEPTH, host->n_ports);
 
-	rc = ata_host_activate(host, platform_get_irq(pdev, 0), mv_interrupt,
-			       IRQF_SHARED, &mv6_sht);
+	rc = ata_host_activate(host, irq, mv_interrupt, IRQF_SHARED, &mv6_sht);
 	if (!rc)
 		return 0;
 
@@ -4205,15 +4212,24 @@ static int mv_platform_resume(struct platform_device *pdev)
 #define mv_platform_resume NULL
 #endif
 
+#ifdef CONFIG_OF
+static struct of_device_id mv_sata_dt_ids[] __devinitdata = {
+	{ .compatible = "marvell,orion-sata", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, mv_sata_dt_ids);
+#endif
+
 static struct platform_driver mv_platform_driver = {
-	.probe			= mv_platform_probe,
-	.remove			= __devexit_p(mv_platform_remove),
-	.suspend		= mv_platform_suspend,
-	.resume			= mv_platform_resume,
-	.driver			= {
-				   .name = DRV_NAME,
-				   .owner = THIS_MODULE,
-				  },
+	.probe		= mv_platform_probe,
+	.remove		= __devexit_p(mv_platform_remove),
+	.suspend	= mv_platform_suspend,
+	.resume		= mv_platform_resume,
+	.driver		= {
+		.name = DRV_NAME,
+		.owner = THIS_MODULE,
+		.of_match_table = of_match_ptr(mv_sata_dt_ids),
+	},
 };
 
 
-- 
1.7.10

  parent reply	other threads:[~2012-07-20 17:35 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-20 17:35 [PATCH 00/16] Orion DT conversions and fixes Andrew Lunn
2012-07-20 17:35 ` [PATCH 1/16] ARM: Orion: DT support for IRQ and GPIO Controllers Andrew Lunn
2012-07-20 17:35 ` [PATCH 2/16] SPI: Refactor spi-orion to use SPI framework queue Andrew Lunn
2012-07-22  7:22   ` Linus Walleij
2012-07-22  9:53     ` Andrew Lunn
2012-07-22 19:07       ` Mark Brown
2012-07-22 19:32         ` Andrew Lunn
2012-07-22 22:42           ` Mark Brown
2012-07-23  7:27             ` Andrew Lunn
2012-07-23  9:37               ` Mark Brown
2012-07-23 10:08                 ` [PATCH] spi-orion: add device tree binding Andrew Lunn
2012-07-23 10:43                   ` Mark Brown
2012-07-23 10:59                     ` Andrew Lunn
2012-07-23 11:12                       ` Mark Brown
2012-07-23 17:43                         ` Arnd Bergmann
2012-07-23 10:44                   ` Mark Brown
2012-07-23 10:50                     ` Andrew Lunn
2012-07-23 10:16                 ` [PATCH 2/16] SPI: Refactor spi-orion to use SPI framework queue Andrew Lunn
2012-07-23 10:23                   ` Mark Brown
2012-07-23 10:49                     ` Andrew Lunn
2012-07-23 11:11                       ` Mark Brown
2012-07-23 10:53           ` Sergei Shtylyov
2012-07-23 11:02             ` Andrew Lunn
2012-07-20 17:35 ` [PATCH 3/16] ARM: Kirkwood: Ensure runit clock always ticks Andrew Lunn
2012-07-20 17:35 ` [PATCH 4/16] ARM: Orion: Add arch support needed for I2C via DT Andrew Lunn
2012-07-20 17:35 ` [PATCH 5/16] Kirkwood: Add basic device tree support for QNAP TS219 Andrew Lunn
2012-07-20 17:35 ` [PATCH 6/16] ARM: Orion: DTify the watchdog timer Andrew Lunn
2012-07-20 17:35 ` Andrew Lunn [this message]
2012-07-20 17:35 ` [PATCH 8/16] ARM: Kirkwood: Use DT to configure SATA device Andrew Lunn
2012-07-20 17:35 ` [PATCH 9/16] ARM: Kirkwood: Describe DNS325 temperature sensor in DT Andrew Lunn
2012-07-20 17:35 ` [PATCH 10/16] ARM: Kirkwood: Describe IB62x0 gpio-keys " Andrew Lunn
2012-07-20 17:35 ` [PATCH 11/16] ARM: Kirkwood: Describe iConnects temperature sensor " Andrew Lunn
2012-07-20 17:35 ` [PATCH 12/16] ARM: Kirkwood: Describe Dreamplug LEDs " Andrew Lunn
2012-07-20 17:35 ` [PATCH 13/16] ARM: Kirkwood: Describe GoFlex Net LEDs and SATA " Andrew Lunn
2012-07-20 17:35 ` [PATCH 14/16] ARM: Kirkwood: Describe ib62x0 LEDs " Andrew Lunn
2012-07-20 17:35 ` [PATCH 15/16] ARM: Kirkwood: Describe iConnect " Andrew Lunn
2012-07-30 21:35   ` Adam Baker
2012-07-31  6:36     ` Andrew Lunn
2012-07-31  7:08       ` Arnaud Patard (Rtp)
2012-07-31  7:20         ` Andrew Lunn
2012-07-31  8:59           ` Arnaud Patard (Rtp)
2012-07-20 17:35 ` [PATCH 16/16] ARM: Kirkwood: Replace mrvl with marvell Andrew Lunn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1342805751-18048-8-git-send-email-andrew@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).