devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roger Quadros <rogerq@ti.com>
To: balbi@ti.com, bcousson@baylibre.com, tony@atomide.com
Cc: balajitk@ti.com, kishon@ti.com, linux-omap@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-ide@vger.kernel.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	Roger Quadros <rogerq@ti.com>, Tejun Heo <tj@kernel.org>
Subject: [RFC PATCH 09/15] ata: ti_sata: Add Texas Instruments SATA Wrapper driver
Date: Thu, 19 Sep 2013 16:05:37 +0300	[thread overview]
Message-ID: <1379595943-14622-10-git-send-email-rogerq@ti.com> (raw)
In-Reply-To: <1379595943-14622-1-git-send-email-rogerq@ti.com>

Texas Instruments SoCs like OMAP5 and DRA7 contain a SATA wrapper
around the AHCI SATA core. This driver will manage that.

CC: Tejun Heo <tj@kernel.org>
Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 Documentation/devicetree/bindings/ata/ti-sata.txt |   31 ++++
 drivers/ata/Kconfig                               |    7 +
 drivers/ata/Makefile                              |    1 +
 drivers/ata/sata_ti.c                             |  160 +++++++++++++++++++++
 4 files changed, 199 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/ata/ti-sata.txt
 create mode 100644 drivers/ata/sata_ti.c

diff --git a/Documentation/devicetree/bindings/ata/ti-sata.txt b/Documentation/devicetree/bindings/ata/ti-sata.txt
new file mode 100644
index 0000000..bf0ea3b
--- /dev/null
+++ b/Documentation/devicetree/bindings/ata/ti-sata.txt
@@ -0,0 +1,31 @@
+* Texas Instruments SATA Controller Wrapper
+
+Required properties:
+- compatible	: "ti,sata"
+- ti,hwmods	: "sata"
+- reg		: Register mapping
+- #address-cells: <1>
+- #size-cells	: <1>
+- ranges	: allows valid translation between child's address space and parent's
+		  address space.
+- Must contain at least one child node for the SATA controller core
+
+Example:
+
+	sata: sata@4a141100 {
+		compatible = "ti,sata";
+		ti,hwmods = "sata";
+		reg = <0x4a141100 0x7>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+		dwc-ahci@4a140000 {
+			compatible = "snps,dwc-ahci";
+			reg = <0x4a140000 0x1100>;
+			interrupts = <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>;
+			phys = <&sata_phy>;
+			phy-names = "sata-phy";
+			clocks = <&sata_ref_clk>;
+			clock-names = "optclk";
+		};
+	};
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index a53ef27..a3de4d2 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -138,6 +138,13 @@ config SATA_SIL24
 
 	  If unsure, say N.
 
+config SATA_TI
+	tristate "Texas Instruments SATA Wrapper driver"
+	depends on ARCH_OMAP
+	help
+	  This options enables SATA Wrapper driver for Texas Instruments SoCs.
+	  It is found on OMAP5 and DRA7.
+
 config ATA_SFF
 	bool "ATA SFF support (for legacy IDE and PATA)"
 	default y
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 46518c6..673ba5e 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_SATA_SIL24)	+= sata_sil24.o
 obj-$(CONFIG_SATA_DWC)		+= sata_dwc_460ex.o
 obj-$(CONFIG_SATA_HIGHBANK)	+= sata_highbank.o libahci.o
 obj-$(CONFIG_AHCI_IMX)		+= ahci_imx.o
+obj-$(CONFIG_SATA_TI)		+= sata_ti.o
 
 # SFF w/ custom DMA
 obj-$(CONFIG_PDC_ADMA)		+= pdc_adma.o
diff --git a/drivers/ata/sata_ti.c b/drivers/ata/sata_ti.c
new file mode 100644
index 0000000..0b9093d
--- /dev/null
+++ b/drivers/ata/sata_ti.c
@@ -0,0 +1,160 @@
+/**
+ * sata-ti.c - Texas Instruments Specific SATA Glue layer
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com
+ *
+ * Authors: Roger Quadros <rogerq@ti.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2  of
+ * the License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/platform_device.h>
+#include <linux/ioport.h>
+#include <linux/io.h>
+#include <linux/pm_runtime.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+
+/*
+ * All these registers belong to OMAP's Wrapper around the
+ * DesignWare SATA Core.
+ */
+
+#define SATA_SYSCONFIG				0x0000
+#define SATA_CDRLOCK				0x0004
+
+struct ti_sata {
+	struct device *dev;
+	void __iomem *base;
+};
+
+static int ti_sata_probe(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct device *dev = &pdev->dev;
+	struct ti_sata *sata;
+	struct resource *res;
+	void __iomem *base;
+	int ret;
+
+	if (!np) {
+		dev_err(dev, "device node not found\n");
+		return -EINVAL;
+	}
+
+	sata = devm_kzalloc(dev, sizeof(*sata), GFP_KERNEL);
+	if (!sata)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, sata);
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res) {
+		dev_err(dev, "missing memory base resource\n");
+		return -EINVAL;
+	}
+
+	base = devm_ioremap_resource(dev, res);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
+
+	sata->dev = dev;
+	sata->base = base;
+
+	pm_runtime_enable(dev);
+	ret = pm_runtime_get_sync(dev);
+	if (ret < 0) {
+		dev_err(dev, "pm_runtime_get_sync failed with err %d\n",
+									ret);
+		goto runtime_disable;
+	}
+
+	ret = of_platform_populate(np, NULL, NULL, dev);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to create TI SATA children\n");
+		goto runtime_put;
+	}
+
+	return 0;
+
+runtime_put:
+	pm_runtime_put_sync(dev);
+
+runtime_disable:
+	pm_runtime_disable(dev);
+
+	return ret;
+}
+
+static int ti_sata_remove_child(struct device *dev, void *c)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+
+	platform_device_unregister(pdev);
+
+	return 0;
+}
+
+static int ti_sata_remove(struct platform_device *pdev)
+{
+	pm_runtime_put_sync(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
+	device_for_each_child(&pdev->dev, NULL, ti_sata_remove_child);
+
+	return 0;
+}
+
+static const struct of_device_id of_ti_sata_match[] = {
+	{
+		.compatible =	"ti,sata"
+	},
+	{ },
+};
+MODULE_DEVICE_TABLE(of, of_ti_sata_match);
+
+#ifdef CONFIG_PM
+
+static int ti_sata_resume(struct device *dev)
+{
+	pm_runtime_disable(dev);
+	pm_runtime_set_active(dev);
+	pm_runtime_enable(dev);
+
+	return 0;
+}
+
+static const struct dev_pm_ops ti_sata_dev_pm_ops = {
+	.resume = ti_sata_resume,
+};
+
+#define DEV_PM_OPS	(&ti_sata_dev_pm_ops)
+#else
+#define DEV_PM_OPS	NULL
+#endif /* CONFIG_PM */
+
+static struct platform_driver ti_sata_driver = {
+	.probe		= ti_sata_probe,
+	.remove		= ti_sata_remove,
+	.driver		= {
+		.name	= "ti-sata",
+		.of_match_table	= of_ti_sata_match,
+		.pm	= DEV_PM_OPS,
+	},
+};
+
+module_platform_driver(ti_sata_driver);
+
+MODULE_ALIAS("platform:ti-sata");
+MODULE_AUTHOR("Roger Quadros <rogerq@ti.com>");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("TI SATA Glue Layer");
-- 
1.7.4.1

  parent reply	other threads:[~2013-09-19 13:05 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-19 13:05 [RFC PATCH 00/15] Add SATA support for TI OMAP5 and DRA7 SoCs Roger Quadros
2013-09-19 13:05 ` [RFC PATCH 01/15] phy: rename struct omap_control_usb to struct omap_control_phy Roger Quadros
     [not found]   ` <1379595943-14622-2-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2013-09-19 14:25     ` Daniel Mack
2013-09-19 13:05 ` [RFC PATCH 02/15] phy: omap-control: Update DT binding information Roger Quadros
2013-09-19 13:05 ` [RFC PATCH 03/15] ARM: dts: omap5: Add clocks to usb3_phy node Roger Quadros
2013-09-19 13:05 ` [RFC PATCH 05/15] phy: omap-pipe3: Add SATA DPLL support Roger Quadros
2013-09-19 13:05 ` [RFC PATCH 06/15] phy: omap-pipe3: update compatibility string and DT binding Roger Quadros
2013-09-19 13:05 ` [RFC PATCH 07/15] ARM: dts: omap5: Update usb3phy node Roger Quadros
     [not found] ` <1379595943-14622-1-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2013-09-19 13:05   ` [RFC PATCH 04/15] phy: omap-pipe3: use generic clock names Roger Quadros
2013-09-19 13:05   ` [RFC PATCH 08/15] ata: ahci_platform: Manage SATA PHY Roger Quadros
     [not found]     ` <1379595943-14622-9-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2013-09-22 16:58       ` Tejun Heo
2013-09-22 18:24         ` Sergei Shtylyov
2013-09-22 21:51           ` Tejun Heo
2013-09-23  7:37             ` Roger Quadros
     [not found]               ` <523FEFC2.801-l0cyMroinI0@public.gmane.org>
2013-09-23 12:59                 ` Sergei Shtylyov
2013-09-23 13:59                   ` Roger Quadros
2014-02-07 10:33                     ` Roger Quadros
2014-02-07 10:39                       ` Arnd Bergmann
2014-02-07 10:44                         ` Roger Quadros
     [not found]             ` <20130922215107.GD27616-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-09-23 12:53               ` Sergei Shtylyov
     [not found]                 ` <524039E0.2060205-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2013-09-25 12:16                   ` Bartlomiej Zolnierkiewicz
2013-09-22 18:22     ` Sergei Shtylyov
     [not found]       ` <523F3567.80303-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2013-09-22 21:48         ` Tejun Heo
2013-09-23 14:10           ` Sergei Shtylyov
2013-09-23 14:12             ` Tejun Heo
2013-09-23  7:42       ` Roger Quadros
2013-09-19 13:05 ` Roger Quadros [this message]
2013-09-25 12:37   ` [RFC PATCH 09/15] ata: ti_sata: Add Texas Instruments SATA Wrapper driver Bartlomiej Zolnierkiewicz
2013-09-25 12:49     ` Bartlomiej Zolnierkiewicz
2013-09-25 13:29       ` Roger Quadros
2013-09-19 13:22 ` [RFC PATCH 10/15] ARM: omap5: hwmod: Add ocp2scp3 and sata hwmods Roger Quadros
2013-09-19 13:23 ` [RFC PATCH 11/15] arm: omap5: hwmod: add missing ocp2scp hwmod data Roger Quadros
2013-09-19 13:23 ` [RFC PATCH 12/15] ARM: dts: omap5: add ocp2scp1 address resource Roger Quadros
     [not found]   ` <1379597019-15294-1-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2013-09-19 14:17     ` Sergei Shtylyov
     [not found]       ` <523B0782.7050501-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2013-09-20  9:22         ` Roger Quadros
2013-09-19 13:23 ` [RFC PATCH 13/15] arm: dts: omap5: add sata node Roger Quadros
2013-09-19 13:24 ` [RFC PATCH 14/15] ARM: DRA7: hwmod: Add ocp2scp3 and sata hwmods Roger Quadros
2013-09-19 13:24 ` [RFC PATCH 15/15] arm: dts: dra7: add sata node Roger Quadros
     [not found]   ` <1379597059-15405-1-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2013-09-19 14:11     ` Sergei Shtylyov
     [not found]       ` <523B05FD.7020200-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2013-09-20 10:19         ` Roger Quadros
2013-09-22 18:45           ` Sergei Shtylyov
2013-09-23  8:24             ` Roger Quadros

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=1379595943-14622-10-git-send-email-rogerq@ti.com \
    --to=rogerq@ti.com \
    --cc=balajitk@ti.com \
    --cc=balbi@ti.com \
    --cc=bcousson@baylibre.com \
    --cc=devicetree@vger.kernel.org \
    --cc=kishon@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=tony@atomide.com \
    /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).