diff mbox series

[4/4] dmaengine: apple-admac: Trigger shared reset

Message ID 20220918095845.68860-5-povik+lin@cutebit.org
State Accepted
Commit 6aed75d7ccb3288029287c50fc594a4314698be0
Headers show
Series Apple ADMAC peripheral reset clean-up | expand

Commit Message

Martin Povišer Sept. 18, 2022, 9:58 a.m. UTC
If a reset domain is attached to the device, obtain a shared reference
to it and trigger it. Typically on a chip the ADMAC controller will
share a reset domain with the MCA peripheral.

Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
---
 drivers/dma/apple-admac.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

Comments

Philipp Zabel Sept. 30, 2022, 9:01 a.m. UTC | #1
Hi Martin,

On So, 2022-09-18 at 11:58 +0200, Martin Povišer wrote:
> If a reset domain is attached to the device, obtain a shared reference
> to it and trigger it. Typically on a chip the ADMAC controller will
> share a reset domain with the MCA peripheral.
> 
> Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
> ---
>  drivers/dma/apple-admac.c | 22 +++++++++++++++++++---
>  1 file changed, 19 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/dma/apple-admac.c b/drivers/dma/apple-admac.c
> index 7d1b76678032..317ca76ccafd 100644
> --- a/drivers/dma/apple-admac.c
> +++ b/drivers/dma/apple-admac.c
> @@ -12,8 +12,9 @@
>  #include <linux/module.h>
>  #include <linux/of_device.h>
>  #include <linux/of_dma.h>
> -#include <linux/interrupt.h>
> +#include <linux/reset.h>
>  #include <linux/spinlock.h>
> +#include <linux/interrupt.h>

Moving around the linux/interrupt.h include doesn't belong in this
patch. Otherwise this looks good to me, assuming the MCA driver does
the same reset/rearm dance.

regards
Philipp
diff mbox series

Patch

diff --git a/drivers/dma/apple-admac.c b/drivers/dma/apple-admac.c
index 7d1b76678032..317ca76ccafd 100644
--- a/drivers/dma/apple-admac.c
+++ b/drivers/dma/apple-admac.c
@@ -12,8 +12,9 @@ 
 #include <linux/module.h>
 #include <linux/of_device.h>
 #include <linux/of_dma.h>
-#include <linux/interrupt.h>
+#include <linux/reset.h>
 #include <linux/spinlock.h>
+#include <linux/interrupt.h>
 
 #include "dmaengine.h"
 
@@ -95,6 +96,7 @@  struct admac_data {
 	struct dma_device dma;
 	struct device *dev;
 	__iomem void *base;
+	struct reset_control *rstc;
 
 	int irq;
 	int irq_index;
@@ -732,6 +734,10 @@  static int admac_probe(struct platform_device *pdev)
 		return dev_err_probe(&pdev->dev, PTR_ERR(ad->base),
 				     "unable to obtain MMIO resource\n");
 
+	ad->rstc = devm_reset_control_get_optional_shared(&pdev->dev, NULL);
+	if (IS_ERR(ad->rstc))
+		return PTR_ERR(ad->rstc);
+
 	dma = &ad->dma;
 
 	dma_cap_set(DMA_PRIVATE, dma->cap_mask);
@@ -770,10 +776,17 @@  static int admac_probe(struct platform_device *pdev)
 		tasklet_setup(&adchan->tasklet, admac_chan_tasklet);
 	}
 
-	err = request_irq(irq, admac_interrupt, 0, dev_name(&pdev->dev), ad);
+	err = reset_control_reset(ad->rstc);
 	if (err)
 		return dev_err_probe(&pdev->dev, err,
-				     "unable to register interrupt\n");
+				     "unable to trigger reset\n");
+
+	err = request_irq(irq, admac_interrupt, 0, dev_name(&pdev->dev), ad);
+	if (err) {
+		dev_err_probe(&pdev->dev, err,
+				"unable to register interrupt\n");
+		goto free_reset;
+	}
 
 	err = dma_async_device_register(&ad->dma);
 	if (err) {
@@ -792,6 +805,8 @@  static int admac_probe(struct platform_device *pdev)
 
 free_irq:
 	free_irq(ad->irq, ad);
+free_reset:
+	reset_control_rearm(ad->rstc);
 	return err;
 }
 
@@ -802,6 +817,7 @@  static int admac_remove(struct platform_device *pdev)
 	of_dma_controller_free(pdev->dev.of_node);
 	dma_async_device_unregister(&ad->dma);
 	free_irq(ad->irq, ad);
+	reset_control_rearm(ad->rstc);
 
 	return 0;
 }