{"id":1641677,"url":"http://patchwork.ozlabs.org/api/patches/1641677/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ide/patch/20220610081801.11854-22-Sergey.Semin@baikalelectronics.ru/","project":{"id":13,"url":"http://patchwork.ozlabs.org/api/projects/13/?format=json","name":"Linux IDE development","link_name":"linux-ide","list_id":"linux-ide.vger.kernel.org","list_email":"linux-ide@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20220610081801.11854-22-Sergey.Semin@baikalelectronics.ru>","list_archive_url":null,"date":"2022-06-10T08:17:59","name":"[v4,21/23] ata: ahci-dwc: Add platform-specific quirks support","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"89303faaed4bbc38789940f25884c39507013ebb","submitter":{"id":78624,"url":"http://patchwork.ozlabs.org/api/people/78624/?format=json","name":"Serge Semin","email":"Sergey.Semin@baikalelectronics.ru"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-ide/patch/20220610081801.11854-22-Sergey.Semin@baikalelectronics.ru/mbox/","series":[{"id":304159,"url":"http://patchwork.ozlabs.org/api/series/304159/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ide/list/?series=304159","date":"2022-06-10T08:17:42","name":"ata: ahci: Add DWC/Baikal-T1 AHCI SATA support","version":4,"mbox":"http://patchwork.ozlabs.org/series/304159/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/1641677/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/1641677/checks/","tags":{},"related":[],"headers":{"Return-Path":"<linux-ide-owner@vger.kernel.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["bilbo.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=baikalelectronics.ru header.i=@baikalelectronics.ru\n header.a=rsa-sha256 header.s=mail header.b=i8xAiVdu;\n\tdkim-atps=neutral","ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2620:137:e000::1:20; helo=out1.vger.email;\n envelope-from=linux-ide-owner@vger.kernel.org; receiver=<UNKNOWN>)"],"Received":["from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20])\n\tby bilbo.ozlabs.org (Postfix) with ESMTP id 4LKDQ160z4z9s09\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Jun 2022 18:19:05 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n        id S1347501AbiFJITE (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n        Fri, 10 Jun 2022 04:19:04 -0400","from lindbergh.monkeyblade.net ([23.128.96.19]:36212 \"EHLO\n        lindbergh.monkeyblade.net\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n        with ESMTP id S1347342AbiFJISp (ORCPT\n        <rfc822;linux-ide@vger.kernel.org>); Fri, 10 Jun 2022 04:18:45 -0400","from mail.baikalelectronics.com (mail.baikalelectronics.com\n [87.245.175.230])\n        by lindbergh.monkeyblade.net (Postfix) with ESMTP id 777EC253812;\n        Fri, 10 Jun 2022 01:18:43 -0700 (PDT)","from mail (mail.baikal.int [192.168.51.25])\n        by mail.baikalelectronics.com (Postfix) with ESMTP id 86BC016C0;\n        Fri, 10 Jun 2022 11:19:12 +0300 (MSK)","from localhost (192.168.53.207) by mail (192.168.51.25) with\n Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 10 Jun 2022 11:18:20 +0300"],"DKIM-Filter":"OpenDKIM Filter v2.11.0 mail.baikalelectronics.com 86BC016C0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=baikalelectronics.ru; s=mail; t=1654849152;\n        bh=J2syxJxPBxl/O9ELEC45e3GC4/7pOxuTZBZ19Urz1aA=;\n        h=From:To:CC:Subject:Date:In-Reply-To:References:From;\n        b=i8xAiVduBqO1BNwKL26BBmtgk8hsiX/veoSUjgmCYK5rK18JD0ZGVopEhmDNVLA/k\n         Avgd+ZS93zVDRNMVfg6cAbSNYwSoyVm/WdxhJ44n1cpGfWQ62Yz2yMLB4yAMEMrbgE\n         VxqZpcISmKtZaAXTNF5yjFauesZT5enYvJnBEJtg=","From":"Serge Semin <Sergey.Semin@baikalelectronics.ru>","To":"Damien Le Moal <damien.lemoal@opensource.wdc.com>,\n        Hans de Goede <hdegoede@redhat.com>,\n        Jens Axboe <axboe@kernel.dk>, Hannes Reinecke <hare@suse.de>,\n        Serge Semin <fancer.lancer@gmail.com>","CC":"Serge Semin <Sergey.Semin@baikalelectronics.ru>,\n        Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>,\n        Pavel Parkhomenko <Pavel.Parkhomenko@baikalelectronics.ru>,\n        Rob Herring <robh+dt@kernel.org>, <linux-ide@vger.kernel.org>,\n        <linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>","Subject":"[PATCH v4 21/23] ata: ahci-dwc: Add platform-specific quirks support","Date":"Fri, 10 Jun 2022 11:17:59 +0300","Message-ID":"<20220610081801.11854-22-Sergey.Semin@baikalelectronics.ru>","In-Reply-To":"<20220610081801.11854-1-Sergey.Semin@baikalelectronics.ru>","References":"<20220610081801.11854-1-Sergey.Semin@baikalelectronics.ru>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Content-Type":"text/plain","X-ClientProxiedBy":"MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25)","X-Spam-Status":"No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,\n        DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS,\n        T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no\n        version=3.4.6","X-Spam-Checker-Version":"SpamAssassin 3.4.6 (2021-04-09) on\n        lindbergh.monkeyblade.net","Precedence":"bulk","List-ID":"<linux-ide.vger.kernel.org>","X-Mailing-List":"linux-ide@vger.kernel.org"},"content":"Some DWC AHCI SATA IP-core derivatives require to perform small platform\nor IP-core specific setups. They are too small to be placed in a dedicated\ndriver. It's just much easier to have a set of quirks for them right in\nthe DWC AHCI driver code. Since we are about to add such platform support,\nas a pre-requisite we introduce a platform-data based DWC AHCI quirks API.\nThe platform data can be used to define the flags passed to the\nahci_platform_get_resources() method, additional AHCI host-flags and a set\nof callbacks to initialize, re-initialize and clear the platform settings.\n\nSigned-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>\n\n---\n\nChangelog v2:\n- Change the local objects prefix from 'dwc_ahci_' to 'ahci_dwc_'.\n  (@Damien)\n\nChangelog v4:\n- Convert ahci_dwc_plat to being statically defined. (@kbot)\n---\n drivers/ata/ahci_dwc.c | 52 ++++++++++++++++++++++++++++++++++++++----\n 1 file changed, 48 insertions(+), 4 deletions(-)","diff":"diff --git a/drivers/ata/ahci_dwc.c b/drivers/ata/ahci_dwc.c\nindex 8c2510933a31..ab4180b7ed23 100644\n--- a/drivers/ata/ahci_dwc.c\n+++ b/drivers/ata/ahci_dwc.c\n@@ -90,7 +90,16 @@\n #define AHCI_DWC_PORT_PHYCR\t\t0x74\n #define AHCI_DWC_PORT_PHYSR\t\t0x78\n \n+struct ahci_dwc_plat_data {\n+\tunsigned int pflags;\n+\tunsigned int hflags;\n+\tint (*init)(struct ahci_host_priv *hpriv);\n+\tint (*reinit)(struct ahci_host_priv *hpriv);\n+\tvoid (*clear)(struct ahci_host_priv *hpriv);\n+};\n+\n struct ahci_dwc_host_priv {\n+\tconst struct ahci_dwc_plat_data *pdata;\n \tstruct platform_device *pdev;\n \n \tu32 timv;\n@@ -107,11 +116,15 @@ static struct ahci_host_priv *ahci_dwc_get_resources(struct platform_device *pde\n \t\treturn ERR_PTR(-ENOMEM);\n \n \tdpriv->pdev = pdev;\n+\tdpriv->pdata = device_get_match_data(&pdev->dev);\n+\tif (!dpriv->pdata)\n+\t\treturn ERR_PTR(-EINVAL);\n \n-\thpriv = ahci_platform_get_resources(pdev, AHCI_PLATFORM_GET_RESETS);\n+\thpriv = ahci_platform_get_resources(pdev, dpriv->pdata->pflags);\n \tif (IS_ERR(hpriv))\n \t\treturn hpriv;\n \n+\thpriv->flags |= dpriv->pdata->hflags;\n \thpriv->plat_data = (void *)dpriv;\n \n \treturn hpriv;\n@@ -242,22 +255,33 @@ static int ahci_dwc_init_dmacr(struct ahci_host_priv *hpriv)\n \n static int ahci_dwc_init_host(struct ahci_host_priv *hpriv)\n {\n+\tstruct ahci_dwc_host_priv *dpriv = hpriv->plat_data;\n \tint rc;\n \n \trc = ahci_platform_enable_resources(hpriv);\n \tif (rc)\n \t\treturn rc;\n \n+\tif (dpriv->pdata->init) {\n+\t\trc = dpriv->pdata->init(hpriv);\n+\t\tif (rc)\n+\t\t\tgoto err_disable_resources;\n+\t}\n+\n \tahci_dwc_check_cap(hpriv);\n \n \tahci_dwc_init_timer(hpriv);\n \n \trc = ahci_dwc_init_dmacr(hpriv);\n \tif (rc)\n-\t\tgoto err_disable_resources;\n+\t\tgoto err_clear_platform;\n \n \treturn 0;\n \n+err_clear_platform:\n+\tif (dpriv->pdata->clear)\n+\t\tdpriv->pdata->clear(hpriv);\n+\n err_disable_resources:\n \tahci_platform_disable_resources(hpriv);\n \n@@ -275,6 +299,12 @@ static int ahci_dwc_reinit_host(struct ahci_host_priv *hpriv)\n \tif (rc)\n \t\treturn rc;\n \n+\tif (dpriv->pdata->reinit) {\n+\t\trc = dpriv->pdata->reinit(hpriv);\n+\t\tif (rc)\n+\t\t\tgoto err_disable_resources;\n+\t}\n+\n \twritel(dpriv->timv, hpriv->mmio + AHCI_DWC_HOST_TIMER1MS);\n \n \tfor_each_set_bit(i, &port_map, AHCI_MAX_PORTS) {\n@@ -283,10 +313,20 @@ static int ahci_dwc_reinit_host(struct ahci_host_priv *hpriv)\n \t}\n \n \treturn 0;\n+\n+err_disable_resources:\n+\tahci_platform_disable_resources(hpriv);\n+\n+\treturn rc;\n }\n \n static void ahci_dwc_clear_host(struct ahci_host_priv *hpriv)\n {\n+\tstruct ahci_dwc_host_priv *dpriv = hpriv->plat_data;\n+\n+\tif (dpriv->pdata->clear)\n+\t\tdpriv->pdata->clear(hpriv);\n+\n \tahci_platform_disable_resources(hpriv);\n }\n \n@@ -371,9 +411,13 @@ static int ahci_dwc_resume(struct device *dev)\n \n static SIMPLE_DEV_PM_OPS(ahci_dwc_pm_ops, ahci_dwc_suspend, ahci_dwc_resume);\n \n+static struct ahci_dwc_plat_data ahci_dwc_plat = {\n+\t.pflags = AHCI_PLATFORM_GET_RESETS,\n+};\n+\n static const struct of_device_id ahci_dwc_of_match[] = {\n-\t{ .compatible = \"snps,dwc-ahci\", },\n-\t{ .compatible = \"snps,spear-ahci\", },\n+\t{ .compatible = \"snps,dwc-ahci\", &ahci_dwc_plat },\n+\t{ .compatible = \"snps,spear-ahci\", &ahci_dwc_plat },\n \t{},\n };\n MODULE_DEVICE_TABLE(of, ahci_dwc_of_match);\n","prefixes":["v4","21/23"]}