Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753907AbbFEGDE (ORCPT ); Fri, 5 Jun 2015 02:03:04 -0400 Received: from mail-bn1on0071.outbound.protection.outlook.com ([157.56.110.71]:11940 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751285AbbFEGCy (ORCPT ); Fri, 5 Jun 2015 02:02:54 -0400 Authentication-Results: spf=pass (sender IP is 149.199.60.100) smtp.mailfrom=xilinx.com; codeaurora.org; dkim=none (message not signed) header.d=none; From: Suneel Garapati To: , CC: , , , , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , "Suneel Garapati" Subject: [PATCH v2 2/2] drivers: ata: add support for Ceva sata host controller Date: Fri, 5 Jun 2015 11:32:28 +0530 Message-ID: <1433484148-7464-3-git-send-email-suneel.garapati@xilinx.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1433484148-7464-1-git-send-email-suneel.garapati@xilinx.com> References: <1433484148-7464-1-git-send-email-suneel.garapati@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-21590.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11OLC004;1:R26U5mF0oywJY0M09wu772up0WnRSgdrXgs4TIwrw3N5wP3DqK2yl7pRKJrVToL/koGcwTmiUtQym/L71RJDB62UePl+2cLB+oeFDi7uB+R19AhMt9hQV52bHprlsuU8Iod2wlQvPqftTp9LH6AoWmDQojEFqLI3BP/HC79MJzl7p4HIuaRyak+zwxIhf1t6Ne+f7C/xN2joXMmYe2O1TG5UYnYX9KzueLE22hEplkA/1rw1WV+DgNU6tcgGntOuzpAZxhXISEYd55ITPWQWva6enW51n9LpeCOESdYDvwfC1Ix9ISHSUKmurAhMdnSA X-Forefront-Antispam-Report: CIP:149.199.60.100;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(438002)(189002)(199003)(63266004)(36386004)(189998001)(50226001)(50986999)(33646002)(575784001)(5001770100001)(48376002)(15975445007)(50466002)(86362001)(5001960100002)(107886002)(106466001)(19580405001)(36756003)(77096005)(87936001)(77156002)(76176999)(19580395003)(229853001)(47776003)(46102003)(92566002)(62966003)(2950100001)(6806004)(107986001)(2004002)(4001430100001);DIR:OUT;SFP:1101;SCL:1;SRVR:BL2FFO11HUB034;H:xsj-pvapsmtpgw02;FPR:;SPF:Pass;MLV:sfv;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11HUB034;2:87E7PDXoFO2MBC/hRceepQNcLAxTFr72N40rHZy6GsgDrlz9CNl04OO054rQHvTl;2:wUKpSvWxi2DLclMazbQijK3SaCtFeFxNb5bsppNtRsnOmzvLVaM6AJNBsXZGJtZyKZb1Td+SMFcV7SGI7Vwvdbii+9WnJ429KZ9sql0r0VmZ3xMYWbpnDc0jHHIj6VcWMfWJ8GlFx8WUfwcL/rYuhSoOUGb3oXBnmqNhpJmwGCg5MUOXtECG7pqRg/9h/J4AtyvYLezgSjjwHoL1KTJh5JiiVYuGSb+QMoRLZSdsP9WUOlGIJAjmzUyuTljEGZeY;6:2TRckk6qW8SJJg/fKwML3kqVDZS5bwQaLUq+Izm7yR9qAujJC6MbWfcAuQYqC3UfmrWzXAnov1r5O+kw6hSiQPb/BgtFPCMA6Fnl5PNXPgfCnl7jM3sGHTVil8OrZ2iAeJTXKbtnHyiKEzuFVff1xvXERKBaKOI4ymq3pWBLfbotGC0zJK/CG1lMbN+qGpeq4QNPJWNHfrH69CDNYacjnX4hb4c0OjJRpCNIp3sUwmIfdxIcvP/9FnbK3P0t++5bXZe6WF3Qyf4agtvBWKYIE8oahvWzn76IpjZx5X9d1G+gNvashpkMoGEERh/Y53MvxZ7dwNoUTjCYhk1TwX4ICJ6g8O7A3gLwq90D8P149yqAGRvyYk1ne9HruDUYRgmsh65VrTUpIl+bAJX9QNpUSQereGYRalAQa2B3KqAJ+vCXKm0aESeomzLlExag6AMZdfAE+PCz1mkyTEPIQ1tceZ3roa/j4p0oPin0obYljA4CITM0DUNmYsFtbo+Qonz+ X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BL2FFO11HUB034; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(520003)(5005006)(3002001);SRVR:BL2FFO11HUB034;BCL:0;PCL:0;RULEID:;SRVR:BL2FFO11HUB034; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11HUB034;3:QRB7UdVwEOW/RYnB5MwRB6fEkHmZeltmNFiQCOcL1cQ9mrEgGoPbkGZ7iOecQxyoiIpeLQmNilwC+VKe1a4uM6NZNPV5f3YTCboYGn/CA1uLl5lJjB3vqZeCBrMfuMK/PpkCb41pkjBxif+vroUHKMjZ5JmxLgtjKUbpcQhnYRY5tI2DYRZ0BK99tLogBFcZ4T2L33XuMfHZNlYSBUh4x2EdraygBb4oTkjEBJoo8W75JZJh0jrdEH9RolJw6R0w8Vlfw60P+/NFjHfLIjIa4Tf0JcBTbwtSNluvSsKk4TxtnSlGjoXgZMtW446Xm9WJ X-Forefront-PRVS: 05986C03E0 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BL2FFO11HUB034;9:oCN3PnFh0+UnUgH7rI1sIhZIzcxtnl+GahYGwFe6Q?= =?us-ascii?Q?tMwg9PXBX9u97RVO4z4ElQxcQ7YEZin5zCwIMQkDIuHu93acxrsQ1hdzDcIO?= =?us-ascii?Q?CRrWsbQ0sItfZxOzV6wF0SFRhhWJvfIZSgblMnPLYccSQCaveV1L0dpm8XM0?= =?us-ascii?Q?AjBXXT9tcocJZrCI1i74gtETWVYbV7UtNOvebmx6fEUl5ak0LxWH+ieIQB+B?= =?us-ascii?Q?ilNKYLCKXQANxEzu18sDhWKZl/6ErP0g7qRFsAD2pmwCL8eSvsFVg0E01+OB?= =?us-ascii?Q?o59G8m3sBJHbrZll22fpfBxCtABAdGR9MpAPpBslQgECYkirKBF8HRV5A0h3?= =?us-ascii?Q?UbZXZyJrYey46GUYSEkdpPwSCrc/VrLHhaGejjZZIlOy0XCbJaemV/BXyDwf?= =?us-ascii?Q?WmDATd23TeCPlQof5uRkSALKoqWw7OwvpDNph3xNPrzI4yaZQBa3RUwuHXnZ?= =?us-ascii?Q?6ZpP3LFmz3euu/KUBa1zsMAwnG8dohEaDHt+zuw+xzWy2BVASYbxZW8BTUds?= =?us-ascii?Q?NfymyHunTUwg/jMN+afcwtS5I9+nNDpDad7I2cQg9iJdoFbApMM6Wx89081q?= =?us-ascii?Q?f1UIifKd+ZpEFwB7fTZmRnQxsGhHK0rkAEo4DKZn9dOd+EhjblqzI36qRnuW?= =?us-ascii?Q?zzWb2uK2u4eEZ0P4QhsCl1jrHQukB7GNNvEDd45thtCitJyo0sj6J1lknLSi?= =?us-ascii?Q?FeuvocBybpHmVWzzOmc2+h7l98O1YP/nxR2a/iohK8tgkEWoAn6vtNmL98I+?= =?us-ascii?Q?Oq3qs+YhcfkuTk0y6aUjNaNSzCbF7tt1lgy0b2u9MzHhm3vFVKbgBme60+xJ?= =?us-ascii?Q?oK6l819pU8UyNhvauoxhWpUK8bhfFR4VzPqDWjwp6osEGFkh7/ms5xUcEkIP?= =?us-ascii?Q?lLbJ6DbofPQ3jmI7UxXLhIV1c1YWgktVDclVCV9sFO22eYeA7TsK70462hQf?= =?us-ascii?Q?2iuf8u7i/svE0kMq6tPGosXbRD4fTHiFZ6wPG35gQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11HUB034;3:vyqu9GwhLxAavp0I+o0oQbJyBqq16P1VsTzkYnn3FQRNAtWfEMGw+WEjeOwdcZhO6RljbTNr0Yi+dYi68yRoDKKweEke8gNKTVhTgrN6eZ9CdZqMvbzKWmb4TkEZlIpRG3qLG99tDuOEn6s1NqPBqQ==;10:MT7+vsH3Vv5s21naNxPR7agVJdZvb15OdJjhmP/LO5Sv9OU5RP/v1p+Hh+qC45q4Q+LOUdHvUvilk20Km9DYX6xkOxJB2Kx93sR+Gd5pHhM= X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2015 06:02:52.2427 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.60.100];Helo=[xsj-pvapsmtpgw02] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2FFO11HUB034 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8333 Lines: 284 Adds support for Ceva sata host controller on Xilinx Zynq UltraScale+ MPSoC. Signed-off-by: Suneel Garapati --- Changes v2 - Change module license string to GPL v2 --- drivers/ata/Kconfig | 9 ++ drivers/ata/Makefile | 1 + drivers/ata/ahci_ceva.c | 225 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 235 insertions(+) create mode 100644 drivers/ata/ahci_ceva.c diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index b4524f4..6d17a3b 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig @@ -133,6 +133,15 @@ config AHCI_IMX If unsure, say N. +config AHCI_CEVA + tristate "CEVA AHCI SATA support" + depends on OF + help + This option enables support for the CEVA AHCI SATA. + It can be found on the Xilinx Zynq UltraScale+ MPSoC. + + If unsure, say N. + config AHCI_MVEBU tristate "Marvell EBU AHCI SATA support" depends on ARCH_MVEBU diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile index 5154753..af70919 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_BRCMSTB) += ahci_brcmstb.o libahci.o libahci_platform.o +obj-$(CONFIG_AHCI_CEVA) += ahci_ceva.o libahci.o libahci_platform.o obj-$(CONFIG_AHCI_DA850) += ahci_da850.o libahci.o libahci_platform.o obj-$(CONFIG_AHCI_IMX) += ahci_imx.o libahci.o libahci_platform.o obj-$(CONFIG_AHCI_MVEBU) += ahci_mvebu.o libahci.o libahci_platform.o diff --git a/drivers/ata/ahci_ceva.c b/drivers/ata/ahci_ceva.c new file mode 100644 index 0000000..559d960 --- /dev/null +++ b/drivers/ata/ahci_ceva.c @@ -0,0 +1,225 @@ +/* + * Copyright (C) 2015 Xilinx, Inc. + * CEVA AHCI SATA platform driver + * + * based on the AHCI SATA platform driver by Jeff Garzik and Anton Vorontsov + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope 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. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include "ahci.h" + +/* Vendor Specific Register Offsets */ +#define AHCI_VEND_PCFG 0xA4 +#define AHCI_VEND_PPCFG 0xA8 +#define AHCI_VEND_PP2C 0xAC +#define AHCI_VEND_PP3C 0xB0 +#define AHCI_VEND_PP4C 0xB4 +#define AHCI_VEND_PP5C 0xB8 +#define AHCI_VEND_PAXIC 0xC0 +#define AHCI_VEND_PTC 0xC8 + +/* Vendor Specific Register bit definitions */ +#define PAXIC_ADBW_BW64 0x1 +#define PAXIC_MAWIDD (1 << 8) +#define PAXIC_MARIDD (1 << 16) +#define PAXIC_OTL (0x4 << 20) + +#define PCFG_TPSS_VAL (0x32 << 16) +#define PCFG_TPRS_VAL (0x2 << 12) +#define PCFG_PAD_VAL 0x2 + +#define PPCFG_TTA 0x1FFFE +#define PPCFG_PSSO_EN (1 << 28) +#define PPCFG_PSS_EN (1 << 29) +#define PPCFG_ESDF_EN (1 << 31) + +#define PP2C_CIBGMN 0x0F +#define PP2C_CIBGMX (0x25 << 8) +#define PP2C_CIBGN (0x18 << 16) +#define PP2C_CINMP (0x29 << 24) + +#define PP3C_CWBGMN 0x04 +#define PP3C_CWBGMX (0x0B << 8) +#define PP3C_CWBGN (0x08 << 16) +#define PP3C_CWNMP (0x0F << 24) + +#define PP4C_BMX 0x0a +#define PP4C_BNM (0x08 << 8) +#define PP4C_SFD (0x4a << 16) +#define PP4C_PTST (0x06 << 24) + +#define PP5C_RIT 0x60216 +#define PP5C_RCT (0x7f0 << 20) + +#define PTC_RX_WM_VAL 0x40 +#define PTC_RSVD (1 << 27) + +#define PORT0_BASE 0x100 +#define PORT1_BASE 0x180 + +/* Port Control Register Bit Definitions */ +#define PORT_SCTL_SPD_GEN2 (0x2 << 4) +#define PORT_SCTL_SPD_GEN1 (0x1 << 4) +#define PORT_SCTL_IPM (0x3 << 8) + +#define PORT_BASE 0x100 +#define PORT_OFFSET 0x80 +#define NR_PORTS 2 +#define DRV_NAME "ahci-ceva" +#define CEVA_FLAG_BROKEN_GEN2 1 + +struct ceva_ahci_priv { + struct platform_device *ahci_pdev; + int flags; +}; + +static struct ata_port_operations ahci_ceva_ops = { + .inherits = &ahci_platform_ops, +}; + +static const struct ata_port_info ahci_ceva_port_info = { + .flags = AHCI_FLAG_COMMON, + .pio_mask = ATA_PIO4, + .udma_mask = ATA_UDMA6, + .port_ops = &ahci_ceva_ops, +}; + +static void ahci_ceva_setup(struct ahci_host_priv *hpriv) +{ + void __iomem *mmio = hpriv->mmio; + struct ceva_ahci_priv *cevapriv = hpriv->plat_data; + u32 tmp; + int i; + + /* + * AXI Data bus width to 64 + * Set Mem Addr Read, Write ID for data transfers + * Transfer limit to 72 DWord + */ + tmp = PAXIC_ADBW_BW64 | PAXIC_MAWIDD | PAXIC_MARIDD | PAXIC_OTL; + writel(tmp, mmio + AHCI_VEND_PAXIC); + + /* Set AHCI Enable */ + tmp = readl(mmio + HOST_CTL); + tmp |= HOST_AHCI_EN; + writel(tmp, mmio + HOST_CTL); + + for (i = 0; i < NR_PORTS; i++) { + /* TPSS TPRS scalars, CISE and Port Addr */ + tmp = PCFG_TPSS_VAL | PCFG_TPRS_VAL | (PCFG_PAD_VAL + i); + writel(tmp, mmio + AHCI_VEND_PCFG); + + /* Port Phy Cfg register enables */ + tmp = PPCFG_TTA | PPCFG_PSS_EN | PPCFG_ESDF_EN; + writel(tmp, mmio + AHCI_VEND_PPCFG); + + /* Phy Control OOB timing parameters COMINIT */ + tmp = PP2C_CIBGMN | PP2C_CIBGMX | PP2C_CIBGN | PP2C_CINMP; + writel(tmp, mmio + AHCI_VEND_PP2C); + + /* Phy Control OOB timing parameters COMWAKE */ + tmp = PP3C_CWBGMN | PP3C_CWBGMX | PP3C_CWBGN | PP3C_CWNMP; + writel(tmp, mmio + AHCI_VEND_PP3C); + + /* Phy Control Burst timing setting */ + tmp = PP4C_BMX | PP4C_BNM | PP4C_SFD | PP4C_PTST; + writel(tmp, mmio + AHCI_VEND_PP4C); + + /* Rate Change Timer and Retry Interval Timer setting */ + tmp = PP5C_RIT | PP5C_RCT; + writel(tmp, mmio + AHCI_VEND_PP5C); + + /* Rx Watermark setting */ + tmp = PTC_RX_WM_VAL | PTC_RSVD; + writel(tmp, mmio + AHCI_VEND_PTC); + + /* Default to Gen 2 Speed and Gen 1 if Gen2 is broken */ + tmp = PORT_SCTL_SPD_GEN2 | PORT_SCTL_IPM; + if (cevapriv->flags & CEVA_FLAG_BROKEN_GEN2) + tmp = PORT_SCTL_SPD_GEN1 | PORT_SCTL_IPM; + writel(tmp, mmio + PORT_SCR_CTL + PORT_BASE + PORT_OFFSET * i); + } +} + +static struct scsi_host_template ahci_platform_sht = { + AHCI_SHT(DRV_NAME), +}; + +static int ceva_ahci_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct device *dev = &pdev->dev; + struct ahci_host_priv *hpriv; + struct ceva_ahci_priv *cevapriv; + + cevapriv = devm_kzalloc(dev, sizeof(*cevapriv), GFP_KERNEL); + if (!cevapriv) + return -ENOMEM; + + cevapriv->ahci_pdev = pdev; + + hpriv = ahci_platform_get_resources(pdev); + if (IS_ERR(hpriv)) + return PTR_ERR(hpriv); + + if (of_property_read_bool(np, "ceva,broken-gen2")) + cevapriv->flags = CEVA_FLAG_BROKEN_GEN2; + + hpriv->plat_data = cevapriv; + + /* CEVA specific initialization */ + ahci_ceva_setup(hpriv); + + return ahci_platform_init_host(pdev, hpriv, &ahci_ceva_port_info, + &ahci_platform_sht); +} + +static int __maybe_unused ceva_ahci_suspend(struct device *dev) +{ + return ahci_platform_suspend_host(dev); +} + +static int __maybe_unused ceva_ahci_resume(struct device *dev) +{ + return ahci_platform_resume_host(dev); +} + +static SIMPLE_DEV_PM_OPS(ahci_ceva_pm_ops, ceva_ahci_suspend, ceva_ahci_resume); + +static const struct of_device_id ceva_ahci_of_match[] = { + { .compatible = "ceva,ahci-1v84" }, + {}, +}; +MODULE_DEVICE_TABLE(of, ceva_ahci_of_match); + +static struct platform_driver ceva_ahci_driver = { + .probe = ceva_ahci_probe, + .remove = ata_platform_remove_one, + .driver = { + .name = DRV_NAME, + .of_match_table = ceva_ahci_of_match, + .pm = &ahci_ceva_pm_ops, + }, +}; +module_platform_driver(ceva_ahci_driver); + +MODULE_DESCRIPTION("CEVA AHCI SATA platform driver"); +MODULE_AUTHOR("Xilinx Inc."); +MODULE_LICENSE("GPL v2"); -- 2.1.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/