Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3069178pxj; Mon, 17 May 2021 17:00:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9Y2X4+TWhU3tA+xibTBMh8qvaQCmmVCT6iaRS65ZyCccV4y9aEQexdXyMd8kqCESKvi9R X-Received: by 2002:a17:906:685:: with SMTP id u5mr2701283ejb.449.1621296001564; Mon, 17 May 2021 17:00:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621296001; cv=none; d=google.com; s=arc-20160816; b=gPuMGj+zoXa9lEwU7VptYHa0IQH6bsQEsM9N8DJvAkD+2i0duDuALRW7jZRaodEBXb zxvg/qEGBUnEFXxoKNrQEtgnBZjrYDClop0WkmDdLWY8Ua1FYjJCGvs3nHR6I6yAmwXG 4M15QJJMjLC/sdQVTL8fdL/ZGEoijtZSgv7RXksD56ynBlEPZbmTNDWl1nz8JLsUStwB mV4LuOwmvL/DgyRf2QrlpNqbQmVCsWXxyPBocC6qNDTVQuCCRzsiluo5F83QKDh4y3TW 123BbadQQTB03jfaHaIpFz6TEfxoVUFMKN4lVR+QDZIWX+bIS0/U8rmXTECTalyqsIP5 lhHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kECkWi439y+E95i+IqX5oU8FiIiXCiJq1zBzylb7/IU=; b=YQr+48UVgR34+YhOd+a9q3OW4UkfpMPXbq5vAF4PALfLdlSJVFreKKj5FcHzGsmHJL Zh17Zw/vi69nl4Y0ORxy7QS0E1w/IOKHwBc5gJZSBDKepbBM7cn0oD9hBpNjuAFYJmHJ B6rGMLZcGHh9kqPpUHEMTIuta6hyXAXJllg+KNvbx29cGEXlF1UcYaNG9y9vKscoxkOX +7YcazMJICxDUCiBg/pXCHVwKz1qWN4vu8Pj+ezO7KcNZvYmP7vTYqMVlva4wcHIIJ0N XaY9sbrYvYgpJ1gM2HazpHF3aFsuSu18sXdxCwL3HCdomQFDIM2nJvyqRQ40vhWBYqXE I80g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="HIo1fx/N"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f17si12347053edd.61.2021.05.17.16.59.38; Mon, 17 May 2021 17:00:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="HIo1fx/N"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237504AbhEQOZi (ORCPT + 99 others); Mon, 17 May 2021 10:25:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:35962 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239204AbhEQOWT (ORCPT ); Mon, 17 May 2021 10:22:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 226AD610CB; Mon, 17 May 2021 14:11:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260710; bh=LSyJ0nUKHPe0cCFG6u5p6HPaHIU32sXINdzx/z6TiW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HIo1fx/NOQGYLdp+1efMTv6mg6OCUIfi7yz6Cdo7756Y/Hdevas+GS5mXOSk+Cmm9 gU67yIwdbfR7jWvBhG/DBITHFYJ9lT68WhpzxDC/Y3h+VQKdPxbM5WNCo31kq6w896 0ZwCn8LU+WPWZlJ6BqxDsrxVV+Pcd8DgAU1pmKX0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jim Quinlan , Bjorn Helgaas , Jens Axboe , Florian Fainelli , Sasha Levin Subject: [PATCH 5.12 205/363] ata: ahci_brcm: Fix use of BCM7216 reset controller Date: Mon, 17 May 2021 16:01:11 +0200 Message-Id: <20210517140309.508923897@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jim Quinlan [ Upstream commit e8d6f9e56187c101b325e8d18f1d4032420d08ff ] This driver may use one of two resets controllers. Keep them in separate variables to keep things simple. The reset controller "rescal" is shared between the AHCI driver and the PCIe driver for the BrcmSTB 7216 chip. Use devm_reset_control_get_optional_shared() to handle this sharing. [bhelgaas: add Jens' ack from v5 posting] Fixes: 272ecd60a636 ("ata: ahci_brcm: BCM7216 reset is self de-asserting") Fixes: c345ec6a50e9 ("ata: ahci_brcm: Support BCM7216 reset controller name") Link: https://lore.kernel.org/r/20210430152156.21162-3-jim2101024@gmail.com Signed-off-by: Jim Quinlan Signed-off-by: Bjorn Helgaas Acked-by: Jens Axboe Acked-by: Florian Fainelli Signed-off-by: Sasha Levin --- drivers/ata/ahci_brcm.c | 46 ++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/ata/ahci_brcm.c b/drivers/ata/ahci_brcm.c index 5b32df5d33ad..6e9c5ade4c2e 100644 --- a/drivers/ata/ahci_brcm.c +++ b/drivers/ata/ahci_brcm.c @@ -86,7 +86,8 @@ struct brcm_ahci_priv { u32 port_mask; u32 quirks; enum brcm_ahci_version version; - struct reset_control *rcdev; + struct reset_control *rcdev_rescal; + struct reset_control *rcdev_ahci; }; static inline u32 brcm_sata_readreg(void __iomem *addr) @@ -352,8 +353,8 @@ static int brcm_ahci_suspend(struct device *dev) else ret = 0; - if (priv->version != BRCM_SATA_BCM7216) - reset_control_assert(priv->rcdev); + reset_control_assert(priv->rcdev_ahci); + reset_control_rearm(priv->rcdev_rescal); return ret; } @@ -365,10 +366,10 @@ static int __maybe_unused brcm_ahci_resume(struct device *dev) struct brcm_ahci_priv *priv = hpriv->plat_data; int ret = 0; - if (priv->version == BRCM_SATA_BCM7216) - ret = reset_control_reset(priv->rcdev); - else - ret = reset_control_deassert(priv->rcdev); + ret = reset_control_deassert(priv->rcdev_ahci); + if (ret) + return ret; + ret = reset_control_reset(priv->rcdev_rescal); if (ret) return ret; @@ -434,7 +435,6 @@ static int brcm_ahci_probe(struct platform_device *pdev) { const struct of_device_id *of_id; struct device *dev = &pdev->dev; - const char *reset_name = NULL; struct brcm_ahci_priv *priv; struct ahci_host_priv *hpriv; struct resource *res; @@ -456,15 +456,15 @@ static int brcm_ahci_probe(struct platform_device *pdev) if (IS_ERR(priv->top_ctrl)) return PTR_ERR(priv->top_ctrl); - /* Reset is optional depending on platform and named differently */ - if (priv->version == BRCM_SATA_BCM7216) - reset_name = "rescal"; - else - reset_name = "ahci"; - - priv->rcdev = devm_reset_control_get_optional(&pdev->dev, reset_name); - if (IS_ERR(priv->rcdev)) - return PTR_ERR(priv->rcdev); + if (priv->version == BRCM_SATA_BCM7216) { + priv->rcdev_rescal = devm_reset_control_get_optional_shared( + &pdev->dev, "rescal"); + if (IS_ERR(priv->rcdev_rescal)) + return PTR_ERR(priv->rcdev_rescal); + } + priv->rcdev_ahci = devm_reset_control_get_optional(&pdev->dev, "ahci"); + if (IS_ERR(priv->rcdev_ahci)) + return PTR_ERR(priv->rcdev_ahci); hpriv = ahci_platform_get_resources(pdev, 0); if (IS_ERR(hpriv)) @@ -485,10 +485,10 @@ static int brcm_ahci_probe(struct platform_device *pdev) break; } - if (priv->version == BRCM_SATA_BCM7216) - ret = reset_control_reset(priv->rcdev); - else - ret = reset_control_deassert(priv->rcdev); + ret = reset_control_reset(priv->rcdev_rescal); + if (ret) + return ret; + ret = reset_control_deassert(priv->rcdev_ahci); if (ret) return ret; @@ -539,8 +539,8 @@ out_disable_regulators: out_disable_clks: ahci_platform_disable_clks(hpriv); out_reset: - if (priv->version != BRCM_SATA_BCM7216) - reset_control_assert(priv->rcdev); + reset_control_assert(priv->rcdev_ahci); + reset_control_rearm(priv->rcdev_rescal); return ret; } -- 2.30.2