From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754638AbcATV0b (ORCPT ); Wed, 20 Jan 2016 16:26:31 -0500 Received: from mail-by2on0089.outbound.protection.outlook.com ([207.46.100.89]:39040 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751773AbcATV00 (ORCPT ); Wed, 20 Jan 2016 16:26:26 -0500 Authentication-Results: spf=none (sender IP is 165.204.84.221) smtp.mailfrom=amd.com; arndb.de; dkim=none (message not signed) header.d=none;arndb.de; dmarc=permerror action=none header.from=amd.com; X-WSS-ID: 0O19SVY-07-9FK-02 X-M-MSG: Subject: Re: [PATCH v2] ata: add AMD Seattle platform driver To: , , References: <1452789071-4090-1-git-send-email-brijesh.singh@amd.com> CC: , , From: Brijesh Singh Message-ID: <569FFAF4.6020807@amd.com> Date: Wed, 20 Jan 2016 15:24:04 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1452789071-4090-1-git-send-email-brijesh.singh@amd.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.180.168.240] X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.221;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(428002)(199003)(479174004)(24454002)(377454003)(189002)(87266999)(76176999)(50986999)(54356999)(101416001)(33656002)(86362001)(59896002)(64126003)(65806001)(65956001)(80316001)(105586002)(575784001)(19580395003)(87936001)(2201001)(19580405001)(50466002)(106466001)(5008740100001)(83506001)(1220700001)(4001350100001)(36756003)(2950100001)(23746002)(97736004)(1096002)(3846002)(47776003)(5001770100001)(230700001)(586003)(11100500001)(2906002)(6116002)(4326007)(77096005)(92566002)(5004730100002)(15975445007)(189998001)(65816999)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR12MB0709;H:atltwp01.amd.com;FPR:;SPF:None;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0709;2:MM/jYtX3pKNIHM+SBDCddbLyxb9lM6+VwKRW8XzOfnr2thyFBIuLzE3ZqyCvIdHAeuBam0GuhqJwZeq3Ot4aXS0GvKslXZCAXQyIwhrkSQgATv0Y2demKqdvLawsXV1/hDXmkG0qiS27fPUog117RA==;3:gNepyr9ecFNn1TQxIIAsZfzOdnzjeOXzFNEftEGdguOSHJM7sr0Jh6i3IUJuZYfJ/6xlin8pMwtjdDMIQyh82Oa2Xc37o+9w6HFJgaga6k+fbdRgWcVuX8NZCs02GuLapPhWAsm4Ge6JPEf9TRqKB1h15QuUPoG/GQmvaG2f6zFtnTGYA4hbQVMu/oygfDSU7y5HyM81nYkCup+Ci0eHPBMTgc0ECKOtyyb0eXLIymg=;25:pUExq97g9TE6yRnyx2czq0P1ABJz5lz+m46vQHA6ArhYRTllBInSYcuRGcHncofahfj5sQWaFAbZYUDQszTzb/pwExF5XWrm3NrACos46XO+0u5X9gDsNarZCE+vIlssRRG9xi4PrBIRoGAzOXsHM/H7qgkGUEJuyBXJD7buxktZF9l9Wb9sN8bqlAlPqsloyI7sDcGG62YwK/V1RbxFoActRRdTGPX86V4/De1Fj5lwm82DfDxpOUITchogHuFY X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR12MB0709; X-MS-Office365-Filtering-Correlation-Id: 573b2124-6430-4a7f-0c2d-08d321e058d0 X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0709;20:otXxreeEpY2HrCP5uh4bsgHn4F2kspkjz6Tjv+kQsuwJVEqOmb0Q2ex32jzhk7akTbAyS0rNkO9sZz0GwqbndGsQGQu1pfTECVy1xMxNA3GypncgKXSHlLYwzhQUedELqpz1JAeHgkyzTjuhv0vDuLaTUcTWbbPl5S1pE7gg43AXWtZOA3KGv9t7T6RkNGqHbkjfaEOxKvHMuVP+JeztNDgNw7y2u4qfvYFUTOt474i+nUo3baHOmfyyjB7KV4fQISc+Od3eHjriNN5N85NgrQkYe0JmZiVlkruHbdIDs1Uhk9ukMfcmHpwCJpBPmFoVDvTg5TaQfsVxKgm3XtTRIigpICOpDWYqQoESWxIQcqVva22pNGyogwtAhH8Z+JZKfyiALhkZIigFnpP7aYyqiP2FoWB1e+0VgafQs/pyNrsdKAmLx/1NPNSSxE+VM77iDVF532K95Am7tR7Sw62IZMl575rZ6g8ZxCUIn/AZv2T3mMUArdmSOc3H0dmyqO1P X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(13024025)(13018025)(13017025)(520078)(13015025)(13023025)(8121501046)(10201501046)(3002001);SRVR:BY2PR12MB0709;BCL:0;PCL:0;RULEID:;SRVR:BY2PR12MB0709; X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0709;4:rqyiXfFMRBW3WyPzJtKPvnib6a7DWVewxpf9PjYboqevjzsnC8DhkXHAoaYyzVNT1BQKVuB1ra4lM3I+p7hGtzOUrZ6Bc4ntkcJrDm5sK/oXtGyVTep4OjCV5lIVrTxMPqVSZFQgXDmOVAjZXxjZi6pes5P5BudG8OjXjvQKNH9+2RgAVZVmqSbYzuzSeHQyV9CSVHphOq/Uw7E8cMEtqopefq4vEdbDlIfT0/RAvYueKdJJIHJmii2lNTecMVqq6hjfBX52R9gckNksUgmwlw0tFs03yO8qLuEU7CTDxGnahgh6VNpEMAauWVIlgv37BDcPCfbQLZRAquLaZYrNhFIMXdldfhKELQS86aH7zCeU8tgdSDsadVF3niuBDhbj5F5LtQZtvDjzGheBwDdBUB60BEEpyAIeioIMbQH1KbgBbSeZFL5SgXGufru62YIBo/0qK9rQA2U9NCSn91fvD8qIrBsvmkzzjVEBDFCO/TfRH6cpKpEO/d3EFM7je2JMNEe9XILM3PuF5fZE0cNjFg== X-Forefront-PRVS: 0827D7ACB9 X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;BY2PR12MB0709;23:hrl7SIBj2dklnWIeLi3/z/Rp0Fo6J3ky96WQY?= =?Windows-1252?Q?r5mp15nxTT+SzRfdX9ENsdUKHOBV180+SHN+ddORsEC3gKJpIh3/PrQK?= =?Windows-1252?Q?Y1//O3Vw0AlViGaBYTKj1r8LSky79mLorGKCqsQ89eYIfil7BTFKjcDK?= =?Windows-1252?Q?4LbiU8Pc8JfKhPphsANllvuAVRdCEUz94CUzT+a8/kjedAuZ/ddnzceV?= =?Windows-1252?Q?RFkGOJpyodTliLt0cdTL1pkXSwD9dIVEYM3kSSbtCoQGd7Ad9TUOf7En?= =?Windows-1252?Q?NJ6PYMUlvThcoE9dcrf6Q4tzscfn3z1imNUmtFyHWnmXhAzz/fzL1nJH?= =?Windows-1252?Q?AsoZVunXGDRIVN30giSiQxZr79RWRA9S2tvGvzOOP7wu0QOcx7eIzDnv?= =?Windows-1252?Q?kUk7O2mo3T/CNHnb4i6iLArx9eLcTGHDkFbeuPyfDcC6QOv1o69senWZ?= =?Windows-1252?Q?1qxso0zYSlf9o4xjuzHD6dAcrhW8YWKY4A9kGeMzxfySX8H9G3UD7dQ0?= =?Windows-1252?Q?Jl17PkMPovQ22AS4FpX5zM+9HWAKEk3EA6JGemJwPnyHHUJS2zi+5UN4?= =?Windows-1252?Q?Kx1r+7xwAXP1AZjmEZWkViXiLWdyVWGhBlfXLuj/oY4mywrDBPjgW/xn?= =?Windows-1252?Q?OwGQN9aPPRbnUkxSZY0mUXOR+1YFZe+ZA9ncxQjbrHTMs7vTg/LMTBvh?= =?Windows-1252?Q?VupRun3tKFP0xYgr2T81DCjhessC9Z7++OSQ3IBKPzHHHzpWw8ertmCp?= =?Windows-1252?Q?D4nG+Q5IFwmZ7ea1aBXT0MsV+zH+pDPs0ePHL+hYgdFUk2KEwTPVgL2x?= =?Windows-1252?Q?lW9euQnQvX+qxpW3voZdYHFt5q3NTIO4aT2Hw3xjeavW5E4RR8OvoQ9F?= =?Windows-1252?Q?3jnWE+IgbxxTh0WONEn+QQEpdl9TdIexM6gzVd2sR1VSKeA/c3P+P4JH?= =?Windows-1252?Q?9SUCAOsYM25olVKN+fdy2tRTEmQcXJbeZoCzKMuebwzknTIoCbpgAu5M?= =?Windows-1252?Q?GP2AUaJgsKb/+bjxkuvWE3xXsZY2LcgZ6o3zsXmT9709PKwTkAncuO5L?= =?Windows-1252?Q?kpH7r1kCJ/iFXRUiHfLbXvkqe16h+qsElB8wndKZUpCCxXmnRblGTB/U?= =?Windows-1252?Q?jTxJmxE56or1/go03JfPyAQyQrmJ6TiciVuTH7MpVjtcJhZ4pG4HSN7j?= =?Windows-1252?Q?Vj7ZucTb25DOU/YPs7ZkjYPsv/2bk+CZAwc1DUpcXPtSNdjlHEb7TWdw?= =?Windows-1252?Q?8U2/ns9urZNtp3j9CYQEoCfZqokWoJ4CptU2SiYBBWlGNJdc4v8jtUh8?= =?Windows-1252?Q?B3hbE2mJleMgis39gh7LNCi9GVOCwPValMBe2Xih+ydovpb3Dm2PyIDi?= =?Windows-1252?Q?ofYFb3dF7BaCpRE6YzWn88I8jFIXHdGU3QihXqW08a9if+21POFyVDrS?= =?Windows-1252?Q?pZYPtA7BwQYbLPRIhTtkBtA1p+MRHMokkoP1ANK/w=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0709;5:L4W394rA8xXcwuyAo188+77KgKdjv5c4hQkjJUKONA3+c2ydoec5QUogZGYwSd+4uU9Uisn7mR9kZdD/kT6tYLMMNxocvkp6dlqtaIfUm2bNEfHNYjrIBe0BSXxDl6Z+DDb0M7f0/W53GvWIgr/SoQ==;24:bZj80A7ohagOnT5UsqQhVGAGQL+2s7hVQX/A1cjP8YsV58F/LOzFrYhCxxL2M1opH2r0JaGsB14hAZG7MjXaULN33oS8+uNndRsYJmajgoQ=;20:QHccDyxt015/50RnCmophwxNJ/Oeqg/yrE0E9f0jEW/7etT9VyQYz4O/e31R+GU2X/FjeMgDgjChU6W2eznohEiPUh/cNhfP81nWtGldPYM+fL6SQ9O5Pz3/tVqZVCeK+aBYUVH2TDQfuur019OlHLFc2V83IDrS9AX5CEWRmAe3AKt/7M2h5Qds1M6/YHsO8xhnDvTtKgmay2913eUsh1u9LkPvzWjbKzi2sryla0KeIsN9gCozV4yXD85sB1qc SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2016 21:26:23.0948 (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.221];Helo=[atltwp01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0709 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tejun, Ping ? -Brijesh On 01/14/2016 10:31 AM, Brijesh Singh wrote: > 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 > Acked-by: Hans de Goede > CC: tj@kernel.org > CC: linux-ide@vger.kernel.org > --- > v1 patch and discussion is available here [1]. > > Changes since v1: > * use intverted test (fixes per Joe Perches review feedback) > * remove the DT binding, the DT support will be implemented by > extending the generic driver to use LED trigger frameworks > (recommend by Arnd Bergmann) > > [1] https://lkml.org/lkml/2016/1/7/681 > > drivers/ata/Kconfig | 8 ++ > drivers/ata/Makefile | 1 + > drivers/ata/ahci_seattle.c | 210 +++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 219 insertions(+) > create mode 100644 drivers/ata/ahci_seattle.c > > diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig > index 861643ea..f2ba9c0 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..6e702ab > --- /dev/null > +++ b/drivers/ata/ahci_seattle.c > @@ -0,0 +1,210 @@ > +/* > + * 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) > + return -EINVAL; > + emp = &pp->em_priv[pmp]; > + > + 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); > + > +static const struct acpi_device_id ahci_acpi_match[] = { > + { "AMDI0600", 0 }, > + {} > +}; > +MODULE_DEVICE_TABLE(acpi, ahci_acpi_match); > + > +static struct platform_driver ahci_seattle_driver = { > + .probe = ahci_seattle_probe, > + .remove = ata_platform_remove_one, > + .driver = { > + .name = DRV_NAME, > + .acpi_match_table = ahci_acpi_match, > + .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); >