Skip to content

Commit

Permalink
iio: adc: stm32: add optional dma support
Browse files Browse the repository at this point in the history
Add DMA optional support to STM32 ADC, as there is a limited number DMA
channels (request lines) that can be assigned to ADC. This way, driver
may fall back using interrupts when all DMA channels are in use for
other IPs.
Use dma cyclic mode with two periods. Allow to tune period length by
using watermark. Coherent memory is used for dma (max buffer size is
fixed to PAGE_SIZE).

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
  • Loading branch information
Fabrice Gasnier authored and Jonathan Cameron committed Jan 29, 2017
1 parent 122b5f4 commit 2763ea0
Show file tree
Hide file tree
Showing 4 changed files with 219 additions and 14 deletions.
1 change: 1 addition & 0 deletions drivers/iio/adc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ config ROCKCHIP_SARADC
config STM32_ADC_CORE
tristate "STMicroelectronics STM32 adc core"
depends on ARCH_STM32 || COMPILE_TEST
depends on HAS_DMA
depends on OF
depends on REGULATOR
select IIO_BUFFER
Expand Down
1 change: 1 addition & 0 deletions drivers/iio/adc/stm32-adc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ static int stm32_adc_probe(struct platform_device *pdev)
priv->common.base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(priv->common.base))
return PTR_ERR(priv->common.base);
priv->common.phys_base = res->start;

priv->vref = devm_regulator_get(&pdev->dev, "vref");
if (IS_ERR(priv->vref)) {
Expand Down
2 changes: 2 additions & 0 deletions drivers/iio/adc/stm32-adc-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@
/**
* struct stm32_adc_common - stm32 ADC driver common data (for all instances)
* @base: control registers base cpu addr
* @phys_base: control registers base physical addr
* @vref_mv: vref voltage (mv)
*/
struct stm32_adc_common {
void __iomem *base;
phys_addr_t phys_base;
int vref_mv;
};

Expand Down
Loading

0 comments on commit 2763ea0

Please sign in to comment.