Apple ADMAC peripheral reset clean-up
Subsystems (3)
cover Apple ADMAC peripheral reset clean-up
On Apple SoCs the ADMAC peripheral shares a reset line with another audio-related peripheral which is the MCA.
On the side of the MCA, the reset is described in binding (staged in broonie-sound/for-6.1) and in the soon-to-be-merged series adding new nodes to t8103/t600x SoC device trees [1]. The staged MCA driver does make use of the reset, knowing it's a shared one.
This series catches up on the ADMAC side, adds the reset to the binding and describes it in the t8103/t600x DTs (on top of [1]). It also pulls the shared reset from the driver.
Since [1] already includes another ADMAC binding change and will probably be fully merged into Hector's asahi-soc tree, I propose the binding change here takes the same route. Leaving patches #3 and #4 to go into dmaengine.
[1] https://lore.kernel.org/asahi/[email protected]/T/#t
Martin Povišer (4):
dt-bindings: dma: apple,admac: Add reset
arm64: dts: apple: Add ADMAC resets on t8103/t600x
dmaengine: apple-admac: Do not use devres for IRQs
dmaengine: apple-admac: Trigger shared reset
Signature · 1 line
2.33.0
PATCH 1/4 dt-bindings: dma: apple,admac: Add reset
On the SoCs there is usually a shared audio reset line, so add a property for that.
--- Documentation/devicetree/bindings/dma/apple,admac.yaml | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/dma/apple,admac.yaml +3 -0
@@ -56,6 +56,9 @@ properties: power-domains: maxItems: 1 + resets: + maxItems: 1 + required: - compatible - reg
Signature · 1 line
2.33.0
Re: [PATCH 1/4] dt-bindings: dma: apple,admac: Add reset
Quoted 6 lines · Martin Povišer
On the SoCs there is usually a shared audio reset line, so add a property for that.
Signed-off-by Martin Povišer <[email protected]>--- Documentation/devicetree/bindings/dma/apple,admac.yaml | 3 +++
Best regards,
Krzysztof
PATCH 2/4 arm64: dts: apple: Add ADMAC resets on t8103/t600x
In reply to Martin PovišerThere's a shared reset for the ADMAC and MCA peripherals. The MCA node already describes it, and being a shared reset it is important we describe it on the ADMAC node too.
--- arch/arm64/boot/dts/apple/t600x-die0.dtsi | 1 + arch/arm64/boot/dts/apple/t8103.dtsi | 1 + 2 files changed, 2 insertions(+)
arch/arm64/boot/dts/apple/t600x-die0.dtsi +1 -0
@@ -181,6 +181,7 @@ admac: dma-controller@39b400000 { <0>; iommus = <&dart_sio_0 2>, <&dart_sio_1 2>; power-domains = <&ps_sio_adma>; + resets = <&ps_audio_p>; }; mca: mca@39b600000 {
arch/arm64/boot/dts/apple/t8103.dtsi +1 -0
@@ -249,6 +249,7 @@ admac: dma-controller@238200000 { #dma-cells = <1>; iommus = <&dart_sio 2>; power-domains = <&ps_sio_adma>; + resets = <&ps_audio_p>; }; mca: i2s@238400000 {
Signature · 1 line
2.33.0
PATCH 3/4 dmaengine: apple-admac: Do not use devres for IRQs
In reply to Martin PovišerThis is in advance of adding support for triggering the reset signal to the peripheral, since registering the IRQ handler will have to be sequenced with it.
--- drivers/dma/apple-admac.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
drivers/dma/apple-admac.c +18 -9
@@ -96,6 +96,7 @@ struct admac_data {struct device *dev;__iomem void *base; +int irq;int irq_index;int nchannels;struct admac_chan channels[];
@@ -724,12 +725,7 @@ static int admac_probe(struct platform_device *pdev)if (irq <0 )return dev_err_probe (&pdev->dev, irq,"no usable interrupt\n" ); - - err =devm_request_irq (&pdev->dev, irq, admac_interrupt, -0 ,dev_name (&pdev->dev), ad); -if (err) -return dev_err_probe (&pdev->dev, err, -"unable to register interrupt\n" ); + ad->irq = irq; ad->base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (ad->base))
@@ -774,17 +770,29 @@ static int admac_probe(struct platform_device *pdev)tasklet_setup (&adchan->tasklet, admac_chan_tasklet); } - err =dma_async_device_register (&ad->dma); + err =request_irq (irq, admac_interrupt,0 ,dev_name (&pdev->dev), ad);if (err) -return dev_err_probe (&pdev->dev, err,"failed to register DMA device\n" ); +return dev_err_probe (&pdev->dev, err, +"unable to register interrupt\n" ); + + err =dma_async_device_register (&ad->dma); +if (err) { +dev_err_probe (&pdev->dev, err,"failed to register DMA device\n" ); + goto free_irq; + } err =of_dma_controller_register (pdev->dev.of_node, admac_dma_of_xlate, ad);if (err) {dma_async_device_unregister (&ad->dma); -return dev_err_probe (&pdev->dev, err,"failed to register with OF\n" ); +dev_err_probe (&pdev->dev, err,"failed to register with OF\n" ); + goto free_irq; }return 0 ; + +free_irq: +free_irq (ad->irq, ad); +return err; }static int admac_remove (struct platform_device *pdev)
@@ -793,6 +801,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);return 0 ; }
Signature · 1 line
2.33.0
Vinod Koul
maintainerRe: [PATCH 3/4] dmaengine: apple-admac: Do not use devres for IRQs
Quoted 3 lines · Martin Povišer
This is in advance of adding support for triggering the reset signal to the peripheral, since registering the IRQ handler will have to be sequenced with it.
Applied 3-4, thanks
Signature · 1 line
~Vinod
PATCH 4/4 dmaengine: apple-admac: Trigger shared reset
In reply to Martin PovišerIf 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.
--- drivers/dma/apple-admac.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/dma/apple-admac.c +19 -3
@@ -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 ; }
Signature · 1 line
2.33.0
Re: [PATCH 4/4] dmaengine: apple-admac: Trigger shared reset
Hi Martin,
Quoted 14 lines · Martin Povišer
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 <[email protected]>---
drivers/dma/apple-admac.c | 22 +++++++++++++++++++---1 file changed, 19 insertions(+), 3 deletions(-)drivers/dma/apple-admac.c +0
-0
drivers/dma/apple-admac.c line 17
Quoted 7 lines
drivers/dma/apple-admac.c +2
-1@@ -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
Hector Martin
AppliedQuoted 17 lines · Martin Povišer
On Apple SoCs the ADMAC peripheral shares a reset line with another audio-related peripheral which is the MCA.
On the side of the MCA, the reset is described in binding (staged in broonie-sound/for-6.1) and in the soon-to-be-merged series adding new nodes to t8103/t600x SoC device trees [1]. The staged MCA driver does make use of the reset, knowing it's a shared one.
This series catches up on the ADMAC side, adds the reset to the binding and describes it in the t8103/t600x DTs (on top of [1]). It also pulls the shared reset from the driver.
Since [1] already includes another ADMAC binding change and will probably be fully merged into Hector's asahi-soc tree, I propose the binding change here takes the same route. Leaving patches #3 and #4 to go into dmaengine.
Quoted 8 lines
[1] https://lore.kernel.org/asahi/[email protected]/T/#t
Martin Povišer (4):
dt-bindings: dma: apple,admac: Add reset
arm64: dts: apple: Add ADMAC resets on t8103/t600x
dmaengine: apple-admac: Do not use devres for IRQs
dmaengine: apple-admac: Trigger shared reset
Applied patches #1-#2 to asahi-soc/dt, thanks!
- Hector