From patchwork Thu Sep 19 13:05:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 2911681 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E7BCF9F1E1 for ; Thu, 19 Sep 2013 13:41:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9CA7C20418 for ; Thu, 19 Sep 2013 13:41:38 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 311DF2029B for ; Thu, 19 Sep 2013 13:41:37 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VMdyH-0005kp-JN; Thu, 19 Sep 2013 13:08:39 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VMdxZ-0005TZ-I1; Thu, 19 Sep 2013 13:07:53 +0000 Received: from arroyo.ext.ti.com ([192.94.94.40]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VMdwL-0005JY-Gh for linux-arm-kernel@lists.infradead.org; Thu, 19 Sep 2013 13:06:42 +0000 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id r8JD6ERc017420; Thu, 19 Sep 2013 08:06:14 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id r8JD6DJr027425; Thu, 19 Sep 2013 08:06:13 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.2.342.3; Thu, 19 Sep 2013 08:06:13 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id r8JD5jMj023592; Thu, 19 Sep 2013 08:06:11 -0500 From: Roger Quadros To: , , Subject: [RFC PATCH 09/15] ata: ti_sata: Add Texas Instruments SATA Wrapper driver Date: Thu, 19 Sep 2013 16:05:37 +0300 Message-ID: <1379595943-14622-10-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1379595943-14622-1-git-send-email-rogerq@ti.com> References: <1379595943-14622-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130919_090637_896541_6F7B3279 X-CRM114-Status: GOOD ( 19.41 ) X-Spam-Score: -4.0 (----) Cc: devicetree@vger.kernel.org, balajitk@ti.com, linux-kernel@vger.kernel.org, kishon@ti.com, linux-ide@vger.kernel.org, Tejun Heo , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Roger Quadros X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Texas Instruments SoCs like OMAP5 and DRA7 contain a SATA wrapper around the AHCI SATA core. This driver will manage that. CC: Tejun Heo Signed-off-by: Roger Quadros --- 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 = ; + 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 + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * 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 "); +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("TI SATA Glue Layer");