Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754117AbbEUD5h (ORCPT ); Wed, 20 May 2015 23:57:37 -0400 Received: from mail-bl2on0077.outbound.protection.outlook.com ([65.55.169.77]:48190 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751338AbbEUD5c (ORCPT ); Wed, 20 May 2015 23:57:32 -0400 Authentication-Results: spf=pass (sender IP is 149.199.60.83) 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 2/2] drivers: ata: add support for Ceva sata host controller Date: Thu, 21 May 2015 09:27:05 +0530 Message-ID: <1432180625-25159-3-git-send-email-suneel.garapati@xilinx.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1432180625-25159-1-git-send-email-suneel.garapati@xilinx.com> References: <1432180625-25159-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-21556.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD012;1:z3YS/WmvXuLhJH6i+5jVFk8MXrKGAxB35IrRGE9BMCbuWkljjs3uxtnnGK7NW03V2bB+VMpwz3KCSqvLQhupO1cXkjJO7zw75FTrkiNFxMH2huZbsm1AV0+Rprqn1RehgS729fqgWDK3LK2g5GYgqT5TnganEjI5gdDH+bds+LXpMM58UvBj/EldtD8ObyQzt0Cm8rsDfWEaz8AvxYN9KbdC9iSMfpx48B3kbDIPRz1K9oHHEJKdNwRjuoTis5isTapMgKi+y43tuy8LHoNeWp5yWOMVzK3Bxp7jRKn0oBcxHj/xHxOKJodgFwcafie7 X-Forefront-Antispam-Report: CIP:149.199.60.83;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(438002)(189002)(199003)(229853001)(62966003)(77156002)(15975445007)(92566002)(19580405001)(107886002)(189998001)(36756003)(87936001)(81156007)(4001540100001)(36386004)(19580395003)(33646002)(5001860100001)(5001830100001)(5001770100001)(48376002)(50466002)(5001960100002)(63266004)(50226001)(2950100001)(64706001)(47776003)(106466001)(76176999)(6806004)(575784001)(46102003)(77096005)(50986999)(86362001)(2004002)(107986001)(4001430100001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2FFO11HUB015;H:xsj-pvapsmtpgw01;FPR:;SPF:Pass;PTR:unknown-60-83.xilinx.com;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11HUB015;2:Rkg09vt4gBSA/YfCSp0yAj/LkErs1QLPBDWHlzI9o+Z1fHHHACmexNC6sN5xnPdZ;2:Sw3ZPsFV4ODh3jXdn+Ci8Fa8zLx0gVh9ZY8F4K7VaWxMKegvVz8omwsCmgxVZYmmRgjw0Uy/9vVL6XFobagse0jHRdV61o8z1PYpL/4aHnYI0MK5GT2dXR2uTK52+7Uu4424Qbe0yP9I/08hojNZ86essgitREBoBK8NbvY8JtEiq85LBxUzNPn93ewSegrN4BFRR3jgX+G2CBQwAZvHrrnaujQwUCNwoH+0jTdcAmk=;6:rUDLrdtJ4OLKq274tgd71Pd9hukED3rbwwA+0EWGHnoZvKpjhTFgMexRcFiJwx3rdY46DnGgAbBEmgPcCPxTRHq88kDAddEsdlQNS6kp9RSzimU1mOP9V8YbT0KXVhQnnlJNWOokasKTj5C/XDJgydcsZhbJrJyxKbbU4JhtWeh788qGlE47+r+0GYacrrtYCEHFD+R0VBNJrTS7TtBFt9tm/uBMcxLFj/93qc5rRlZa8ZinHBhpZ/Ejbn+cw/g1oCGVcv5ANq85Q/YQwYPcBpJPANWa9LJj53/hsQKgiInjWm5XTrWP8ekxTwKOGrKUi6J0FcQbWgzQ08ENCRk32eFPLWCoHOJlRZjXtP+G8JQaTfTZ7WXN89kMWi4RmCfehMGac7sZUaV5f9DwCOrO6tlgnoEa+qimBDJxAMeCByI3obmWIhXbK493ivIN/51+JDB3KfxrPnamH+iYOTPTDnWvL2y4+/4cElH0Zu1aYp9b/RpoUyP+AsL5xro3c8sg X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2FFO11HUB015; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BY2FFO11HUB015;BCL:0;PCL:0;RULEID:;SRVR:BY2FFO11HUB015; X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11HUB015;3:IX4okpe40uLg5d+ofwmz3AKJIy9sP0MflqgNgsJ5oCB1ZPzpOoSaVxbDFmvPvxMvI0ZbnjS9nTWUqgJILSYKFPy5RS0iVIwFGyY+Xmgp0pTihTu/uvHJ03HPXvIQwJfXTSA6mVzPk/543DIegMlCOZSHK7kIOPTjw4ZxHURc2IpnZytRo4OBDaPl+Px6jYPN0MwvSqzXk7wzNb1CP3A3pyyX2i75lKJL2Q5+ZorS/xNSUIaZdMiH/XvRz9+/YZaloFJAKpzufCanuNbBdWqwQ5HgwBrP09qqhE1rq8Lls/g= X-Forefront-PRVS: 0583A86C08 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2FFO11HUB015;9:TKLTIdxO9RyoefRTlfMgnEANS/AjparVXAmy/98Eb?= =?us-ascii?Q?7r/dRJEvCcC7Bf6QTrYOxo/mMnrxb+PCH08sAwqzPZiVav0yRcGJMFa/JZnU?= =?us-ascii?Q?Sf2KEC98AT3eft+JqenE9AuSPM2DM0Uee3+Cn2etKKXbMVgVw6xVX5nQz26v?= =?us-ascii?Q?lhD1nvp1NlMISdkETycARlEYGdzS9dnumlfDUMfVFPAhgHQVifR8cgsbuTAZ?= =?us-ascii?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EQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11HUB015;3:h1vVEm+ND7LFqNTqCsrFNmBjummOnqYBwz6cYABlqHA9G6iKzxOj+EKZbjBPL264mlKWwJ06x+WibDWZfKHPruHHYE78ybkODWw2sGzYjqB7GQxfUeRjKs0PNTZkdb8OOJmTXfRCoIuSz+n17FRp+A==;10:v88notreEGx0/sNTbLQB2QXHLKOahAJiII2d3j/cvIHmoUqWE3JqqatJAhrL5VFqqW6dqZ/Ntnid43FECDK5knxTpnmEwEScjWJ6uE26jSI= X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2015 03:57:29.3146 (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.83];Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2FFO11HUB015 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8248 Lines: 281 Adds support for Ceva sata host controller on Xilinx Zynq UltraScale+ MPSoC. Signed-off-by: Suneel Garapati --- 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 9dca4b9..ef3cfde 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig @@ -124,6 +124,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 40f7865..dc3a320 100644 --- a/drivers/ata/Makefile +++ b/drivers/ata/Makefile @@ -10,6 +10,7 @@ obj-$(CONFIG_SATA_INIC162X) += sata_inic162x.o 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_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..dfcd2f4 --- /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("GPLv2"); -- 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/