All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jim Quinlan <jim2101024@gmail.com>
To: Bjorn Helgaas <helgaas@kernel.org>,
	linux-pci@vger.kernel.org,
	Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
	bcm-kernel-feedback-list@broadcom.com,
	james.quinlan@broadcom.com, jim2101024@gmail.com
Cc: Jens Axboe <axboe@kernel.dk>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Hans de Goede <hdegoede@redhat.com>,
	linux-ide@vger.kernel.org (open list:LIBATA SUBSYSTEM (Serial
	and Parallel ATA drivers)),
	linux-kernel@vger.kernel.org (open list)
Subject: [PATCH v5 1/2] ata: ahci_brcm: Fix use of BCM7216 reset controller
Date: Fri, 12 Mar 2021 15:45:54 -0500	[thread overview]
Message-ID: <20210312204556.5387-2-jim2101024@gmail.com> (raw)
In-Reply-To: <20210312204556.5387-1-jim2101024@gmail.com>

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.

Fixes: 272ecd60a636 ("ata: ahci_brcm: BCM7216 reset is self de-asserting")
Fixes: c345ec6a50e9 ("ata: ahci_brcm: Support BCM7216 reset controller name")
Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
---
 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 @@ static int brcm_ahci_probe(struct platform_device *pdev)
 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.17.1


  reply	other threads:[~2021-03-12 20:47 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-12 20:45 [PATCH v5 0/2] ata: ahci_brcm: Fix use of BCM7216 reset controller Jim Quinlan
2021-03-12 20:45 ` Jim Quinlan
2021-03-12 20:45 ` Jim Quinlan [this message]
2021-04-06 15:16   ` [PATCH v5 1/2] " Lorenzo Pieralisi
2021-04-06 15:26     ` Jens Axboe
2021-03-12 20:45 ` [PATCH v5 2/2] PCI: brcmstb: Use reset/rearm instead of deassert/assert Jim Quinlan
2021-03-12 20:45   ` Jim Quinlan
2021-03-29 16:06   ` Lorenzo Pieralisi
2021-03-29 16:06     ` Lorenzo Pieralisi
2021-03-29 16:10   ` Lorenzo Pieralisi
2021-03-29 16:10     ` Lorenzo Pieralisi
2021-03-29 16:50     ` Florian Fainelli
2021-03-29 16:50       ` Florian Fainelli
2021-03-29 16:58       ` Lorenzo Pieralisi
2021-03-29 16:58         ` Lorenzo Pieralisi
2021-03-29 17:01         ` Florian Fainelli
2021-03-29 17:01           ` Florian Fainelli
2021-04-06 15:42 ` [PATCH v5 0/2] ata: ahci_brcm: Fix use of BCM7216 reset controller Lorenzo Pieralisi
2021-04-06 15:42   ` Lorenzo Pieralisi
2021-04-06 16:38   ` Florian Fainelli
2021-04-06 16:38     ` Florian Fainelli
2021-04-28 20:00 ` Bjorn Helgaas
2021-04-28 20:34   ` Jim Quinlan
2021-04-28 20:53     ` Bjorn Helgaas
2021-04-28 20:53       ` Bjorn Helgaas
2021-04-28 21:03       ` Florian Fainelli
2021-04-28 21:03         ` Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210312204556.5387-2-jim2101024@gmail.com \
    --to=jim2101024@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=f.fainelli@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=helgaas@kernel.org \
    --cc=james.quinlan@broadcom.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=nsaenzjulienne@suse.de \
    --cc=p.zabel@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.