Skip to content

Commit e8d6f9e

Browse files
jim2101024bjorn-helgaas
authored andcommitted
ata: ahci_brcm: Fix use of BCM7216 reset controller
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: 272ecd6 ("ata: ahci_brcm: BCM7216 reset is self de-asserting") Fixes: c345ec6 ("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 <jim2101024@gmail.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Jens Axboe <axboe@kernel.dk> Acked-by: Florian Fainelli <f.fainelli@gmail.com>
1 parent 48582b2 commit e8d6f9e

1 file changed

Lines changed: 23 additions & 23 deletions

File tree

drivers/ata/ahci_brcm.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ struct brcm_ahci_priv {
8686
u32 port_mask;
8787
u32 quirks;
8888
enum brcm_ahci_version version;
89-
struct reset_control *rcdev;
89+
struct reset_control *rcdev_rescal;
90+
struct reset_control *rcdev_ahci;
9091
};
9192

9293
static inline u32 brcm_sata_readreg(void __iomem *addr)
@@ -352,8 +353,8 @@ static int brcm_ahci_suspend(struct device *dev)
352353
else
353354
ret = 0;
354355

355-
if (priv->version != BRCM_SATA_BCM7216)
356-
reset_control_assert(priv->rcdev);
356+
reset_control_assert(priv->rcdev_ahci);
357+
reset_control_rearm(priv->rcdev_rescal);
357358

358359
return ret;
359360
}
@@ -365,10 +366,10 @@ static int __maybe_unused brcm_ahci_resume(struct device *dev)
365366
struct brcm_ahci_priv *priv = hpriv->plat_data;
366367
int ret = 0;
367368

368-
if (priv->version == BRCM_SATA_BCM7216)
369-
ret = reset_control_reset(priv->rcdev);
370-
else
371-
ret = reset_control_deassert(priv->rcdev);
369+
ret = reset_control_deassert(priv->rcdev_ahci);
370+
if (ret)
371+
return ret;
372+
ret = reset_control_reset(priv->rcdev_rescal);
372373
if (ret)
373374
return ret;
374375

@@ -434,7 +435,6 @@ static int brcm_ahci_probe(struct platform_device *pdev)
434435
{
435436
const struct of_device_id *of_id;
436437
struct device *dev = &pdev->dev;
437-
const char *reset_name = NULL;
438438
struct brcm_ahci_priv *priv;
439439
struct ahci_host_priv *hpriv;
440440
struct resource *res;
@@ -456,15 +456,15 @@ static int brcm_ahci_probe(struct platform_device *pdev)
456456
if (IS_ERR(priv->top_ctrl))
457457
return PTR_ERR(priv->top_ctrl);
458458

459-
/* Reset is optional depending on platform and named differently */
460-
if (priv->version == BRCM_SATA_BCM7216)
461-
reset_name = "rescal";
462-
else
463-
reset_name = "ahci";
464-
465-
priv->rcdev = devm_reset_control_get_optional(&pdev->dev, reset_name);
466-
if (IS_ERR(priv->rcdev))
467-
return PTR_ERR(priv->rcdev);
459+
if (priv->version == BRCM_SATA_BCM7216) {
460+
priv->rcdev_rescal = devm_reset_control_get_optional_shared(
461+
&pdev->dev, "rescal");
462+
if (IS_ERR(priv->rcdev_rescal))
463+
return PTR_ERR(priv->rcdev_rescal);
464+
}
465+
priv->rcdev_ahci = devm_reset_control_get_optional(&pdev->dev, "ahci");
466+
if (IS_ERR(priv->rcdev_ahci))
467+
return PTR_ERR(priv->rcdev_ahci);
468468

469469
hpriv = ahci_platform_get_resources(pdev, 0);
470470
if (IS_ERR(hpriv))
@@ -485,10 +485,10 @@ static int brcm_ahci_probe(struct platform_device *pdev)
485485
break;
486486
}
487487

488-
if (priv->version == BRCM_SATA_BCM7216)
489-
ret = reset_control_reset(priv->rcdev);
490-
else
491-
ret = reset_control_deassert(priv->rcdev);
488+
ret = reset_control_reset(priv->rcdev_rescal);
489+
if (ret)
490+
return ret;
491+
ret = reset_control_deassert(priv->rcdev_ahci);
492492
if (ret)
493493
return ret;
494494

@@ -539,8 +539,8 @@ static int brcm_ahci_probe(struct platform_device *pdev)
539539
out_disable_clks:
540540
ahci_platform_disable_clks(hpriv);
541541
out_reset:
542-
if (priv->version != BRCM_SATA_BCM7216)
543-
reset_control_assert(priv->rcdev);
542+
reset_control_assert(priv->rcdev_ahci);
543+
reset_control_rearm(priv->rcdev_rescal);
544544
return ret;
545545
}
546546

0 commit comments

Comments
 (0)