From patchwork Thu Jan 7 20:53:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 7979901 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 59AB29F1CC for ; Thu, 7 Jan 2016 20:59:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 15E392015E for ; Thu, 7 Jan 2016 20:59:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2AED720142 for ; Thu, 7 Jan 2016 20:58:58 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aHHcG-0002be-D1; Thu, 07 Jan 2016 20:57:04 +0000 Received: from mail-by2on0083.outbound.protection.outlook.com ([207.46.100.83] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aHHcC-0002Xh-LA for linux-arm-kernel@lists.infradead.org; Thu, 07 Jan 2016 20:57:02 +0000 Received: from CY1PR12CA0076.namprd12.prod.outlook.com (10.163.230.44) by BN4PR12MB0850.namprd12.prod.outlook.com (10.164.59.12) with Microsoft SMTP Server (TLS) id 15.1.365.19; Thu, 7 Jan 2016 20:56:37 +0000 Received: from CO1NAM03FT046.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::209) by CY1PR12CA0076.outlook.office365.com (2a01:111:e400:c42b::44) with Microsoft SMTP Server (TLS) id 15.1.365.19 via Frontend Transport; Thu, 7 Jan 2016 20:56:37 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.222) smtp.mailfrom=amd.com; arm.com; dkim=none (message not signed) header.d=none; arm.com; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from atltwp02.amd.com (165.204.84.222) by CO1NAM03FT046.mail.protection.outlook.com (10.152.81.15) with Microsoft SMTP Server id 15.1.355.15 via Frontend Transport; Thu, 7 Jan 2016 20:56:36 +0000 X-WSS-ID: 0O0LOU6-08-RLQ-02 X-M-MSG: Received: from satlvexedge02.amd.com (satlvexedge02.amd.com [10.177.96.29]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by atltwp02.amd.com (Axway MailGate 5.3.1) with ESMTPS id 2C994D1B348; Thu, 7 Jan 2016 15:56:30 -0500 (EST) Received: from SATLEXDAG06.amd.com (10.181.40.13) by SATLVEXEDGE02.amd.com (10.177.96.29) with Microsoft SMTP Server (TLS) id 14.3.195.1; Thu, 7 Jan 2016 14:57:20 -0600 Received: from aussmtp.amd.com (10.180.168.240) by satlexdag06.amd.com (10.181.40.13) with Microsoft SMTP Server (TLS) id 14.3.266.1; Thu, 7 Jan 2016 15:56:31 -0500 Received: by aussmtp.amd.com (sSMTP sendmail emulation); Thu, 07 Jan 2016 14:54:28 -0600 From: Brijesh Singh To: , Subject: [PATCH] ata: add AMD Seattle platform driver Date: Thu, 7 Jan 2016 14:53:22 -0600 Message-ID: <1452200002-31590-1-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.222; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(428002)(3190300001)(199003)(189002)(575784001)(47776003)(229853001)(106466001)(105586002)(2906002)(33646002)(36756003)(19580395003)(19580405001)(50226001)(101416001)(50986999)(97736004)(5001770100001)(189998001)(4326007)(87936001)(5004730100002)(11100500001)(50466002)(5008740100001)(42186005)(5003940100001)(1096002)(86362001)(1220700001)(586003)(48376002)(92566002)(3846002)(6116002)(2004002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN4PR12MB0850; H:atltwp02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN4PR12MB0850; 2:wbQD4KW5TEdt2Swg93v+Vb+a8/qDdYdwSdjFmevfZWTr6akSMhG7EJ0QUxXxUixqRuQUf+oMrPkKeqOk2AoaVHwWZH83j91lc0h4RXZSifFjJ6lTwQhw9DpppFUYP5wtC5Jcs8Mu08ufobCCLtsEqg==; 3:yfXuM1JyjrF1krf9yO62PeY/1yfefOEMJN+ntgHyyca+yM+H+PFoobWHcITSuPIlnXP7Lc5Q7MQXQEvA4jgNiOYwD1ELDB20QmwD4WqhJStWYNpr6V2zJX8eKIIvDwfITCR0I2Gnh240fwpvL6hIxFGpvRL2mAwCaGQT+36jyMt5Aah09xWBw+0S4trCmIuqqZu7iE0HoinDFdB1JAYv6HI2UuY5Pf9Z+eQvfye4lvs=; 25:p1grvXqVrgBFstCiKmK/HNHQjPEJfnRxMtbXFeGphOvvkMwBN5HnXeYgQer3/vMxr6B+Mi0yhmIY0WNNx2GZZwH1cB5NZFR+C4e+IJ5VAOf59iRj1nuirBnFJdg2APkCX+DeANehGXaAjzGlKpe6mcX8joCa2UEAi/RCTuI56qPxFk2dJriiiWH0BMFfiF5RLMmTEkfbfjOiox2Sp0aRLNx/l8GSAECbnLqdtks59dHrLmkTWfq8tk27SQq3dOvU X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN4PR12MB0850; X-MS-Office365-Filtering-Correlation-Id: 2505f3fb-1cf2-46fa-5606-08d317a508c9 X-Microsoft-Exchange-Diagnostics: 1; BN4PR12MB0850; 20:6AAey5jEMFo25UPch/DPOVsCvM9f6R/mCqY4DEcF8XrVhM/X6/x84h17MsuthCF0Y3r/wm7bbcbEZGcrP3SepWrGtj+ppLbQA8bry/USZeUk3Q6px4obWyuM/yl1ZC9HsMIUK5/hU1me8lJVLc1ozgaOr8x2g6iM3AQKbT7iw99n2IZ+O71cg5F/E9WpPThQwX9NtshgmmfKHBXNCUqBu4VKAZAGBWc1Y3krsYHVagr86XmTHN23UW+W757gKw1LX5qLPmAE4ruULSq/vQjMqjwoqs03JfFR/MItYFCsYqHPbRx53wNScqYodsPmiutjk+R5BZIGAihwWZaH8bcCrO53JRRyQ/sHsjTspHlE3Vg7qmliphMA1oed4kSywYsAn40qmkKYuiUJFizya6taNzNpbh6thEeq8UOZi8sVY2yG+7955z/TQbEVgf6TYWn8Cm0+gvLDRCT8yuPvPD0Vm7eFJ+CyE6u/HdSMuwH+8dP/yhd5AnwKLHkplGI5abwA X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(520078)(13016025)(8121501046)(3002001)(10201501046); SRVR:BN4PR12MB0850; BCL:0; PCL:0; RULEID:; SRVR:BN4PR12MB0850; X-Microsoft-Exchange-Diagnostics: 1; BN4PR12MB0850; 4:rSNIDhyBuMWudDZneQJQ34vgXzj4gEXk7ErdA3cKtOOMSE3CeNd/6lo6ZsLqDOMEOkH2++nne3NzciVrsUz7lYYhnUEG0RLny/xCN9oZf++nVE6cOpexpgZjG9W0QMHyvzzSvTYU+ggQCYCiStodVUu+YSy1On6JtKX9+INShEGvTf3FeAFL+06XWoIdB9+hE1IlpBy4DXN1Bq6VgZ4+1Wk8zfyHltq+zYGHXkctGMrTLCp3rbX3+tnYWtK/wWAvUDNVZDzvhWPI5Bfmro+C5lDDsxgUYyiwvp9m0kyKE9eWqNNnYCBFARYut9WiciASRCjyPxxlU2QAiIYxfYy6Se9Zk1uM4f9ijq9qqcIt9svHJWHChxTstuNql98Da7Uzh+lgnaJqznKXzWOQp0j9J9CkxE70O3HzByqjwKCD53ujuVc7zU+nAqDFB6ZMr/QD8GLfy37+XxPy/B6Tf57dv1KxmC759lU7Z6UecrH1uSU= X-Forefront-PRVS: 0814A2C7A3 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN4PR12MB0850; 23:6/QNzUErSvS359wZ58uUhfffj+0JjEXu3e2pcT/W+?= =?us-ascii?Q?Ckgi1BsEPvXvxtT0Wf+aYTkQBVpa/RJ5I+YMnnUkCxyecTlqL4k+O0rwG4Og?= =?us-ascii?Q?Yu5RcBcJ6gv41HnCU8vVBWSivFPOJ2by0kxUaDx5R/AgvXpF+Yn6F2AHZ7LZ?= =?us-ascii?Q?Nd0GfCIQaAsksm3YfbQSMLBbHs0xldcJyJfh00PRlBIGgi9nMU0chdfM1vlD?= =?us-ascii?Q?RJAS1tAnMVkNilZdF63o8wrhMRGmgvChEVTMs+moGOr2wgD0p2K/QOszLKtL?= =?us-ascii?Q?dJj1yZcnKzmtYkiD1Cdw4lzBFGmDXP+L1MifUaNn6KeN+Hzl0xOpaYVPwXJp?= =?us-ascii?Q?GG3z+ch7geb39izDTyp7ad2XfgiDSVuqnttmz/jFdf/6eS1cs1vBUC1F5tYf?= =?us-ascii?Q?FNKS6bS7npDk5CVAS4Gmmx/Ryu9KSHWlLms32yzRBPgn4b62xpADf8HimBhd?= =?us-ascii?Q?AglbMCpvoDhh7SxWkUHAeQV0AM4EtfaeGKNSOV+rzCynQmCQIvPSu6sPKHTh?= =?us-ascii?Q?0CCJF0AhwR78sHVgCPVe9ixsddnPA+qdsHHH1w9hq4tQXL92PyOE7KJoWNQM?= =?us-ascii?Q?+FkNhqEfhfz7Sy4G4c4k1MbN4X0+lUw/+iI7E1ZXQjeL5060YHoFr80PAJZU?= =?us-ascii?Q?dC6am0Ns8IHExlwW1qV8oc3pmmY1U3yMNCY/mfD7eWl3dNIGvWLLcgFVUpRO?= =?us-ascii?Q?VmXaIetIEVehv07sAtJlJEQQmYYi2gbpay9eaWnkI+7UmNJnVP7S1MPVUNKZ?= =?us-ascii?Q?BooGbHPlCiIIlt4MLQ0kbWw4MeS1gDqq+TkFI2fc0XjFkq7WR+hqlnG0a+He?= =?us-ascii?Q?tLJM19fPUnUko3srrL9RUk3aHNCqeZLoP0H7fNT/pX/aZOw8E8jGscCfEz6B?= =?us-ascii?Q?dtfT5uPqY6n6dBRm8N8KhupqXfSlhqA8VPGsLsqPN3zZ3W5arHKc0s7tL5F6?= =?us-ascii?Q?e9B3XDk9iFuKVQORGLxZyBLitIUrQERlV5iidnLUlBbmTRkRNePi6A0NXluK?= =?us-ascii?Q?Z4N3BCaPEk/F8K7voX6JWYi3Hdkq2/bAgwlyw27ZZYDMZ5BP7WIUdPulZtO1?= =?us-ascii?Q?KbcTgs=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN4PR12MB0850; 5:5wAtTT69iw9DXoNf0DTmKedQmk8XcXg/8PlQj1HO+IqQP285qnlbNBHOJN/xqUTofaiTnpM1+9W91iM6KF1WZoj2z4kGNqeOQx9g+rAuqO+68Y6jgTiON/+OQHrPOpJHcFBr7elJIY63ZWTk8/bneQ==; 24:OhjV+jqgux3WQfCnAeecbFUjHqXDHnoH+X72MOFWWKwKmuELZyd3KQ+REP1MR1g423X4o3PQYz7lC/SebIPqCqWcY1PR6sYAPaHJcXfms+k=; 20:a0sXEj/beJN2BQPSkU9kymQGruCw1utIClrOu6TvacyiDjC8Lc8mynOm3dgIETzg15BmpQlzB2HRf1A0VhMGZVjaGf6TeKwpQQwYwKWorEod9Q57U27E3rPmblgbT/4exP/JNqxuPK1G3Okt8U51RPUqmm1Jd+J1uAuf888OdELIfwYkfPkkQZYu75D/adLoF/HfzAfjtXlSAsw0rOnX1Rwpi3GqdMIB+VBFxMcIGBVIVc1PUxKKaaNaWVEK36wn SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2016 20:56:36.1795 (UTC) X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.222]; Helo=[atltwp02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN4PR12MB0850 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160107_125700_785050_A83D30D9 X-CRM114-Status: GOOD ( 22.23 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, Brijesh Singh , pawel.moll@arm.com, ijc+devicetree@hellion.org.uk, linux-ide@vger.kernel.org, robh+dt@kernel.org, galak@codeaurora.org, tj@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 AMD Seattle SATA controller mostly conforms to AHCI interface with some special register to control SGPIO interface. In the case of an AHCI controller, the SGPIO feature is ideally implemented using the "Enclosure Management" register of the AHCI controller, but those registeres are not implemented in the Seattle SoC. Instead SoC (Rev B0 onwards) provides a 32-bit SGPIO control register which should be programmed to control the activity, locate and fault LEDs. The driver is based on ahci_platform driver. Signed-off-by: Brijesh Singh CC: robh+dt@kernel.org CC: pawel.moll@arm.com CC: mark.rutland@arm.com CC: ijc+devicetree@hellion.org.uk CC: galak@codeaurora.org CC: tj@kernel.org CC: devicetree@vger.kernel.org CC: linux-ide@vger.kernel.org Acked-by: Hans de Goede --- .../devicetree/bindings/ata/sata-seattle.txt | 34 ++++ drivers/ata/Kconfig | 8 + drivers/ata/Makefile | 1 + drivers/ata/ahci_seattle.c | 226 +++++++++++++++++++++ 4 files changed, 269 insertions(+) create mode 100644 Documentation/devicetree/bindings/ata/sata-seattle.txt create mode 100644 drivers/ata/ahci_seattle.c diff --git a/Documentation/devicetree/bindings/ata/sata-seattle.txt b/Documentation/devicetree/bindings/ata/sata-seattle.txt new file mode 100644 index 0000000..5ad46b7 --- /dev/null +++ b/Documentation/devicetree/bindings/ata/sata-seattle.txt @@ -0,0 +1,34 @@ +* AHCI SATA Controller + +SATA nodes are defined to describe on-chip Serial ATA controllers. +The AMD Seattle SATA controller mostly conforms to the AHCI interface +with some special SGPIO register to contro activity LED interfaces. + +In the case of an AHCI controller, the SGPIO feature is ideally implemented +using the "Enclosure Management" register of the AHCI controller, but +those registeres are not implemented in the Seattle SoC. + +Each SATA controller should have its own node. + + +Required properties: +- compatible : compatible string should be "amd,seattle-ahci". +- interrupts : +- reg : + +Optional properties: +- dma-coherent : Present if dma operations are coherent +- clocks : a list of phandle + clock specifier pairs +- target-supply : regulator for SATA target power +- phys : reference to the SATA PHY node +- phy-names : must be "sata-phy" + +Examples: + sata0@e0300000 { + compatible = "amd,seattle-ahci"; + reg = <0x0 0xe0300000 0x0 0xf0000>, <0x0 0xe0000078 0x0 0x1>; + interrupts = <0x0 0x163 0x4>; + clocks = <0x2> + dma-coherent; + }; + diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index 6aaa3f8..56f764d 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig @@ -193,6 +193,14 @@ config SATA_FSL If unsure, say N. +config SATA_AHCI_SEATTLE + tristate "AMD Seattle 6.0Gbps AHCI SATA host controller support" + depends on ARCH_SEATTLE + help + This option enables support for AMD Seattle SATA host controller. + + If unsure, say N + config SATA_INIC162X tristate "Initio 162x SATA support (Very Experimental)" depends on PCI diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile index af45eff..9c0a96a 100644 --- a/drivers/ata/Makefile +++ b/drivers/ata/Makefile @@ -4,6 +4,7 @@ obj-$(CONFIG_ATA) += libata.o # non-SFF interface obj-$(CONFIG_SATA_AHCI) += ahci.o libahci.o obj-$(CONFIG_SATA_ACARD_AHCI) += acard-ahci.o libahci.o +obj-$(CONFIG_SATA_AHCI_SEATTLE) += ahci_seattle.o libahci.o libahci_platform.o obj-$(CONFIG_SATA_AHCI_PLATFORM) += ahci_platform.o libahci.o libahci_platform.o obj-$(CONFIG_SATA_FSL) += sata_fsl.o obj-$(CONFIG_SATA_INIC162X) += sata_inic162x.o diff --git a/drivers/ata/ahci_seattle.c b/drivers/ata/ahci_seattle.c new file mode 100644 index 0000000..8c9ab67 --- /dev/null +++ b/drivers/ata/ahci_seattle.c @@ -0,0 +1,226 @@ +/* + * AMD Seattle AHCI SATA driver + * + * Copyright (c) 2015, Advanced Micro Devices + * Author: Brijesh Singh + * + * 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 of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License. + * + * 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 +#include +#include "ahci.h" + +/* SGPIO Control Register definition + * + * Bit Type Description + * 31 RW OD7.2 (activity) + * 30 RW OD7.1 (locate) + * 29 RW OD7.0 (fault) + * 28...8 RW OD6.2...OD0.0 (3bits per port, 1 bit per LED) + * 7 RO SGPIO feature flag + * 6:4 RO Reserved + * 3:0 RO Number of ports (0 means no port supported) + */ +#define ACTIVITY_BIT_POS(x) (8 + (3 * x)) +#define LOCATE_BIT_POS(x) (ACTIVITY_BIT_POS(x) + 1) +#define FAULT_BIT_POS(x) (LOCATE_BIT_POS(x) + 1) + +#define ACTIVITY_MASK 0x00010000 +#define LOCATE_MASK 0x00080000 +#define FAULT_MASK 0x00400000 + +#define DRV_NAME "ahci-seattle" + +static ssize_t seattle_transmit_led_message(struct ata_port *ap, u32 state, + ssize_t size); + +struct seattle_plat_data { + void __iomem *sgpio_ctrl; +}; + +static struct ata_port_operations ahci_port_ops = { + .inherits = &ahci_ops, +}; + +static const struct ata_port_info ahci_port_info = { + .flags = AHCI_FLAG_COMMON, + .pio_mask = ATA_PIO4, + .udma_mask = ATA_UDMA6, + .port_ops = &ahci_port_ops, +}; + +static struct ata_port_operations ahci_seattle_ops = { + .inherits = &ahci_ops, + .transmit_led_message = seattle_transmit_led_message, +}; + +static const struct ata_port_info ahci_port_seattle_info = { + .flags = AHCI_FLAG_COMMON | ATA_FLAG_EM | ATA_FLAG_SW_ACTIVITY, + .link_flags = ATA_LFLAG_SW_ACTIVITY, + .pio_mask = ATA_PIO4, + .udma_mask = ATA_UDMA6, + .port_ops = &ahci_seattle_ops, +}; + +static struct scsi_host_template ahci_platform_sht = { + AHCI_SHT(DRV_NAME), +}; + +static ssize_t seattle_transmit_led_message(struct ata_port *ap, u32 state, + ssize_t size) +{ + struct ahci_host_priv *hpriv = ap->host->private_data; + struct ahci_port_priv *pp = ap->private_data; + struct seattle_plat_data *plat_data = hpriv->plat_data; + unsigned long flags; + int pmp; + struct ahci_em_priv *emp; + u32 val; + + /* get the slot number from the message */ + pmp = (state & EM_MSG_LED_PMP_SLOT) >> 8; + if (pmp < EM_MAX_SLOTS) + emp = &pp->em_priv[pmp]; + else + return -EINVAL; + + val = ioread32(plat_data->sgpio_ctrl); + if (state & ACTIVITY_MASK) + val |= 1 << ACTIVITY_BIT_POS((ap->port_no)); + else + val &= ~(1 << ACTIVITY_BIT_POS((ap->port_no))); + + if (state & LOCATE_MASK) + val |= 1 << LOCATE_BIT_POS((ap->port_no)); + else + val &= ~(1 << LOCATE_BIT_POS((ap->port_no))); + + if (state & FAULT_MASK) + val |= 1 << FAULT_BIT_POS((ap->port_no)); + else + val &= ~(1 << FAULT_BIT_POS((ap->port_no))); + + iowrite32(val, plat_data->sgpio_ctrl); + + spin_lock_irqsave(ap->lock, flags); + + /* save off new led state for port/slot */ + emp->led_state = state; + + spin_unlock_irqrestore(ap->lock, flags); + + return size; +} + +static const struct ata_port_info *ahci_seattle_get_port_info( + struct platform_device *pdev, struct ahci_host_priv *hpriv) +{ + struct device *dev = &pdev->dev; + struct seattle_plat_data *plat_data; + u32 val; + + plat_data = devm_kzalloc(dev, sizeof(*plat_data), GFP_KERNEL); + if (IS_ERR(plat_data)) + return &ahci_port_info; + + plat_data->sgpio_ctrl = devm_ioremap_resource(dev, + platform_get_resource(pdev, IORESOURCE_MEM, 1)); + if (IS_ERR(plat_data->sgpio_ctrl)) + return &ahci_port_info; + + val = ioread32(plat_data->sgpio_ctrl); + + if (!(val & 0xf)) + return &ahci_port_info; + + hpriv->em_loc = 0; + hpriv->em_buf_sz = 4; + hpriv->em_msg_type = EM_MSG_TYPE_LED; + hpriv->plat_data = plat_data; + + dev_info(dev, "SGPIO LED control is enabled.\n"); + return &ahci_port_seattle_info; +} + +static int ahci_seattle_probe(struct platform_device *pdev) +{ + int rc; + struct ahci_host_priv *hpriv; + + hpriv = ahci_platform_get_resources(pdev); + if (IS_ERR(hpriv)) + return PTR_ERR(hpriv); + + rc = ahci_platform_enable_resources(hpriv); + if (rc) + return rc; + + rc = ahci_platform_init_host(pdev, hpriv, + ahci_seattle_get_port_info(pdev, hpriv), + &ahci_platform_sht); + if (rc) + goto disable_resources; + + return 0; +disable_resources: + ahci_platform_disable_resources(hpriv); + return rc; +} + +static SIMPLE_DEV_PM_OPS(ahci_pm_ops, ahci_platform_suspend, + ahci_platform_resume); + +#ifdef CONFIG_OF +static const struct of_device_id ahci_of_match[] = { + { .compatible = "amd,seattle-ahci", }, + {} +}; +MODULE_DEVICE_TABLE(of, ahci_of_match); +#endif + +#ifdef CONFIG_ACPI +static const struct acpi_device_id ahci_acpi_match[] = { + { "AMDI0600", 0 }, + {} +}; +MODULE_DEVICE_TABLE(acpi, ahci_acpi_match); +#endif + +static struct platform_driver ahci_seattle_driver = { + .probe = ahci_seattle_probe, + .remove = ata_platform_remove_one, + .driver = { + .name = DRV_NAME, +#ifdef CONFIG_OF + .of_match_table = ahci_of_match, +#endif +#ifdef CONFIG_ACPI + .acpi_match_table = ahci_acpi_match, +#endif + .pm = &ahci_pm_ops, + }, +}; +module_platform_driver(ahci_seattle_driver); + +MODULE_DESCRIPTION("Seattle AHCI SATA platform driver"); +MODULE_AUTHOR("Brijesh Singh "); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:" DRV_NAME);