dmaengine: qcom: bam_dma: Add "powered remotely" mode
authorStephan Gerhold <stephan@gerhold.net>
Mon, 18 Oct 2021 10:24:21 +0000 (12:24 +0200)
committerVinod Koul <vkoul@kernel.org>
Thu, 28 Oct 2021 17:12:30 +0000 (22:42 +0530)
commit9502ffcda0491c2079e2f6e3278b3c7377fd81fb
treec9e64f88f585211ad3867ed4477591e52a47cabf
parent37aef53f5ccf789a87006e0dcbce187ce3427f63
dmaengine: qcom: bam_dma: Add "powered remotely" mode

In some configurations, the BAM DMA controller is set up by a remote
processor and the local processor can simply start making use of it
without setting up the BAM. This is already supported using the
"qcom,controlled-remotely" property.

However, for some reason another possible configuration is that the
remote processor is responsible for powering up the BAM, but we are
still responsible for initializing it (e.g. resetting it etc).

This configuration is quite challenging to handle properly because
the power control is handled through separate channels
(e.g. device-specific SMSM interrupts / smem-states). Great care
must be taken to ensure the BAM registers are not accessed while
the BAM is powered off since this results in a bus stall.

Attempt to support this configuration with minimal device-specific
code in the bam_dma driver by tracking the number of requested
channels. Consumers of DMA channels are responsible to only request
DMA channels when the BAM was powered on by the remote processor,
and to release them before the BAM is powered off.

When the first channel is requested the BAM is initialized (reset)
and it is also put into reset when the last channel was released.

Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Reviewed-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
Link: https://lore.kernel.org/r/20211018102421.19848-3-stephan@gerhold.net
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/qcom/bam_dma.c