From patchwork Tue Mar 27 07:28:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunihiko Hayashi X-Patchwork-Id: 132467 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp4748872ljb; Tue, 27 Mar 2018 00:28:54 -0700 (PDT) X-Google-Smtp-Source: AG47ELvv/fpHaLvHVUGm4biPYD5swXXfT80J5M3w9wrEQGA6YCtWODLg6bd+9P40uYMAY9vpYe89 X-Received: by 10.99.100.196 with SMTP id y187mr18074761pgb.83.1522135734495; Tue, 27 Mar 2018 00:28:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522135734; cv=none; d=google.com; s=arc-20160816; b=bJduHuixd0t9OY8W3cr2BIn5BglSm0QOVvUxJUHJAs9sr1J/hrJhdDPDRqpl4+uflY ThYWEvTwLwZJ2TBWTsehJffv/uvCMo0ZFhmH3az3LCR3vyTk/iMjmH9WbW4HAdeTxzoU BuGAyQljhW213rxzW5aZk4x88bXK1v0mwBkQGJ2KoEv62gQMumzoFxG2tYOc8KZNAFRg ZBaAPveXaoS2gsMp4Sov0JS0DlFqWh87ZCL9SSO1TNmbH1l/d+Wy9u7QbaSTJYnyRKFg fJdBPhkWJpz1Hb0UJI0Cw4orMOFKGsKHuNTBTt2Z5SVC0+PKsHrzrSX1v8lEztbqbMpp 1kuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Udbz0T1EZnyKWvuU+QdB9vYhYjBFYly3ytQ9L5eZk0k=; b=qJXiOEaYYcAEAGZYw4rW5iZDSENYb+sB+e2dcLKIv1IBl6WqShAei5ERfBf3oR00yR fAdIB+0o28xgyzS153j6HM8zAZbrwUmVvoDNvh5hvAQNgct31zWAO9QZEiSbMzb8t4Bn vbv5Bg/AHgLakXNflQcoSUxH0rKAu4KXFY2E+3rfY4Rxr5h0RcQ06to0Cm4gY50UaPcA 44WrqEcfDSpftOufNPvTxvmh/vVSKuOGgvv88wFcy5f03i5jzdHemGavpP49XWifi5tz l6CIU4rwCRY7onUH8mFfg/OXuS8vIZC4ybXL+Rgy2dZjbsU1ekgL+KDxErzhBdBnLD5+ 3OZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x66si490169pfx.398.2018.03.27.00.28.54; Tue, 27 Mar 2018 00:28:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750947AbeC0H2x (ORCPT + 6 others); Tue, 27 Mar 2018 03:28:53 -0400 Received: from mx.socionext.com ([202.248.49.38]:55241 "EHLO mx.socionext.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750939AbeC0H2w (ORCPT ); Tue, 27 Mar 2018 03:28:52 -0400 Received: from unknown (HELO kinkan-ex.css.socionext.com) ([172.31.9.52]) by mx.socionext.com with ESMTP; 27 Mar 2018 16:28:51 +0900 Received: from mail.mfilter.local (m-filter-1 [10.213.24.61]) by kinkan-ex.css.socionext.com (Postfix) with ESMTP id 0F4FD180C0A; Tue, 27 Mar 2018 16:28:51 +0900 (JST) Received: from 172.31.9.51 (172.31.9.51) by m-FILTER with ESMTP; Tue, 27 Mar 2018 16:28:51 +0900 Received: from plum.e01.socionext.com (unknown [10.213.132.32]) by kinkan.css.socionext.com (Postfix) with ESMTP id 5E4E71A2088; Tue, 27 Mar 2018 16:28:50 +0900 (JST) From: Kunihiko Hayashi To: Tejun Heo , Hans de Goede , Rob Herring , Mark Rutland Cc: linux-ide@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Kunihiko Hayashi Subject: [RESEND PATCH v2] ata: ahci-platform: add reset control support Date: Tue, 27 Mar 2018 16:28:21 +0900 Message-Id: <1522135701-9964-1-git-send-email-hayashi.kunihiko@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add support to get and control a list of resets for the device as optional and shared. These resets must be kept de-asserted until the device is enabled. This is specified as shared because some SoCs like UniPhier series have common reset controls with all ahci controller instances. Signed-off-by: Kunihiko Hayashi Reviewed-by: Hans de Goede Reviewed-by: Rob Herring --- Changes since v1: - add 'Reviewed-by:' lines .../devicetree/bindings/ata/ahci-platform.txt | 1 + drivers/ata/ahci.h | 1 + drivers/ata/libahci_platform.c | 24 +++++++++++++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/devicetree/bindings/ata/ahci-platform.txt b/Documentation/devicetree/bindings/ata/ahci-platform.txt index c760ecb..f4006d3 100644 --- a/Documentation/devicetree/bindings/ata/ahci-platform.txt +++ b/Documentation/devicetree/bindings/ata/ahci-platform.txt @@ -30,6 +30,7 @@ compatible: Optional properties: - dma-coherent : Present if dma operations are coherent - clocks : a list of phandle + clock specifier pairs +- resets : a list of phandle + reset specifier pairs - target-supply : regulator for SATA target power - phys : reference to the SATA PHY node - phy-names : must be "sata-phy" diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h index 749fd94..47ec77a2 100644 --- a/drivers/ata/ahci.h +++ b/drivers/ata/ahci.h @@ -347,6 +347,7 @@ struct ahci_host_priv { u32 em_msg_type; /* EM message type */ bool got_runtime_pm; /* Did we do pm_runtime_get? */ struct clk *clks[AHCI_MAX_CLKS]; /* Optional */ + struct reset_control *rsts; /* Optional */ struct regulator **target_pwrs; /* Optional */ /* * If platform uses PHYs. There is a 1:1 relation between the port number and diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c index 341d0ef..3130db9 100644 --- a/drivers/ata/libahci_platform.c +++ b/drivers/ata/libahci_platform.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "ahci.h" static void ahci_host_stop(struct ata_host *host); @@ -195,7 +196,8 @@ EXPORT_SYMBOL_GPL(ahci_platform_disable_regulators); * following order: * 1) Regulator * 2) Clocks (through ahci_platform_enable_clks) - * 3) Phys + * 3) Resets + * 4) Phys * * If resource enabling fails at any point the previous enabled resources * are disabled in reverse order. @@ -215,12 +217,19 @@ int ahci_platform_enable_resources(struct ahci_host_priv *hpriv) if (rc) goto disable_regulator; - rc = ahci_platform_enable_phys(hpriv); + rc = reset_control_deassert(hpriv->rsts); if (rc) goto disable_clks; + rc = ahci_platform_enable_phys(hpriv); + if (rc) + goto disable_resets; + return 0; +disable_resets: + reset_control_assert(hpriv->rsts); + disable_clks: ahci_platform_disable_clks(hpriv); @@ -239,12 +248,15 @@ EXPORT_SYMBOL_GPL(ahci_platform_enable_resources); * following order: * 1) Phys * 2) Clocks (through ahci_platform_disable_clks) - * 3) Regulator + * 3) Resets + * 4) Regulator */ void ahci_platform_disable_resources(struct ahci_host_priv *hpriv) { ahci_platform_disable_phys(hpriv); + reset_control_assert(hpriv->rsts); + ahci_platform_disable_clks(hpriv); ahci_platform_disable_regulators(hpriv); @@ -393,6 +405,12 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev) hpriv->clks[i] = clk; } + hpriv->rsts = devm_reset_control_array_get_optional_shared(dev); + if (IS_ERR(hpriv->rsts)) { + rc = PTR_ERR(hpriv->rsts); + goto err_out; + } + hpriv->nports = child_nodes = of_get_child_count(dev->of_node); /*