Lines Matching full:dfsdm
3 * This file is the ADC part of the STM32 DFSDM driver
11 #include <linux/iio/adc/stm32-dfsdm-adc.h>
22 #include "stm32-dfsdm.h"
54 struct stm32_dfsdm *dfsdm; member
83 /* DFSDM channel serial interface type */
92 /* DFSDM channel clock source */
203 static int stm32_dfsdm_start_channel(struct stm32_dfsdm *dfsdm, in stm32_dfsdm_start_channel() argument
206 return regmap_update_bits(dfsdm->regmap, DFSDM_CHCFGR1(ch_id), in stm32_dfsdm_start_channel()
211 static void stm32_dfsdm_stop_channel(struct stm32_dfsdm *dfsdm, in stm32_dfsdm_stop_channel() argument
214 regmap_update_bits(dfsdm->regmap, DFSDM_CHCFGR1(ch_id), in stm32_dfsdm_stop_channel()
218 static int stm32_dfsdm_chan_configure(struct stm32_dfsdm *dfsdm, in stm32_dfsdm_chan_configure() argument
222 struct regmap *regmap = dfsdm->regmap; in stm32_dfsdm_chan_configure()
240 static int stm32_dfsdm_start_filter(struct stm32_dfsdm *dfsdm, in stm32_dfsdm_start_filter() argument
246 ret = regmap_update_bits(dfsdm->regmap, DFSDM_CR1(fl_id), in stm32_dfsdm_start_filter()
252 return regmap_update_bits(dfsdm->regmap, DFSDM_CR1(fl_id), in stm32_dfsdm_start_filter()
257 static void stm32_dfsdm_stop_filter(struct stm32_dfsdm *dfsdm, in stm32_dfsdm_stop_filter() argument
261 regmap_update_bits(dfsdm->regmap, DFSDM_CR1(fl_id), in stm32_dfsdm_stop_filter()
265 static int stm32_dfsdm_filter_configure(struct stm32_dfsdm *dfsdm, in stm32_dfsdm_filter_configure() argument
268 struct regmap *regmap = dfsdm->regmap; in stm32_dfsdm_filter_configure()
269 struct stm32_dfsdm_filter *fl = &dfsdm->fl_list[fl_id]; in stm32_dfsdm_filter_configure()
300 static int stm32_dfsdm_channel_parse_of(struct stm32_dfsdm *dfsdm, in stm32_dfsdm_channel_parse_of() argument
318 if (ch->channel >= dfsdm->num_chs) { in stm32_dfsdm_channel_parse_of()
321 ch->channel, dfsdm->num_chs); in stm32_dfsdm_channel_parse_of()
335 df_ch = &dfsdm->ch_list[ch->channel]; in stm32_dfsdm_channel_parse_of()
387 struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[adc->fl_id]; in dfsdm_adc_audio_set_spiclk()
388 struct stm32_dfsdm_channel *ch = &adc->dfsdm->ch_list[chan->channel]; in dfsdm_adc_audio_set_spiclk()
394 /* If DFSDM is master on SPI, SPI freq can not be updated */ in dfsdm_adc_audio_set_spiclk()
427 struct regmap *regmap = adc->dfsdm->regmap; in stm32_dfsdm_start_conv()
431 ret = stm32_dfsdm_start_channel(adc->dfsdm, chan->channel); in stm32_dfsdm_start_conv()
435 ret = stm32_dfsdm_filter_configure(adc->dfsdm, adc->fl_id, in stm32_dfsdm_start_conv()
458 ret = stm32_dfsdm_start_filter(adc->dfsdm, adc->fl_id); in stm32_dfsdm_start_conv()
470 stm32_dfsdm_stop_channel(adc->dfsdm, chan->channel); in stm32_dfsdm_start_conv()
478 struct regmap *regmap = adc->dfsdm->regmap; in stm32_dfsdm_stop_conv()
480 stm32_dfsdm_stop_filter(adc->dfsdm, adc->fl_id); in stm32_dfsdm_stop_conv()
489 stm32_dfsdm_stop_channel(adc->dfsdm, chan->channel); in stm32_dfsdm_stop_conv()
622 ret = stm32_dfsdm_start_dfsdm(adc->dfsdm); in stm32_dfsdm_postenable()
645 stm32_dfsdm_stop_dfsdm(adc->dfsdm); in stm32_dfsdm_postenable()
660 stm32_dfsdm_stop_dfsdm(adc->dfsdm); in stm32_dfsdm_predisable()
730 ret = stm32_dfsdm_start_dfsdm(adc->dfsdm); in stm32_dfsdm_single_conv()
734 ret = regmap_update_bits(adc->dfsdm->regmap, DFSDM_CR2(adc->fl_id), in stm32_dfsdm_single_conv()
741 regmap_update_bits(adc->dfsdm->regmap, DFSDM_CR2(adc->fl_id), in stm32_dfsdm_single_conv()
750 regmap_update_bits(adc->dfsdm->regmap, DFSDM_CR2(adc->fl_id), in stm32_dfsdm_single_conv()
763 stm32_dfsdm_stop_dfsdm(adc->dfsdm); in stm32_dfsdm_single_conv()
773 struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[adc->fl_id]; in stm32_dfsdm_write_raw()
774 struct stm32_dfsdm_channel *ch = &adc->dfsdm->ch_list[chan->channel]; in stm32_dfsdm_write_raw()
792 spi_freq = adc->dfsdm->spi_master_freq; in stm32_dfsdm_write_raw()
796 spi_freq = adc->dfsdm->spi_master_freq / 2; in stm32_dfsdm_write_raw()
876 struct regmap *regmap = adc->dfsdm->regmap; in stm32_dfsdm_irq()
931 .src_addr = (dma_addr_t)adc->dfsdm->phys_base + in stm32_dfsdm_dma_request()
974 ret = stm32_dfsdm_channel_parse_of(adc->dfsdm, indio_dev, ch); in stm32_dfsdm_adc_chan_init_one()
997 return stm32_dfsdm_chan_configure(adc->dfsdm, in stm32_dfsdm_adc_chan_init_one()
998 &adc->dfsdm->ch_list[ch->channel]); in stm32_dfsdm_adc_chan_init_one()
1024 d_ch = &adc->dfsdm->ch_list[ch->channel]; in stm32_dfsdm_audio_init()
1026 adc->spi_freq = adc->dfsdm->spi_master_freq; in stm32_dfsdm_audio_init()
1042 ret = stm32_dfsdm_set_osrs(&adc->dfsdm->fl_list[adc->fl_id], 0, in stm32_dfsdm_adc_init()
1049 if (num_ch < 0 || num_ch > adc->dfsdm->num_chs) { in stm32_dfsdm_adc_init()
1093 .compatible = "st,stm32-dfsdm-adc",
1097 .compatible = "st,stm32-dfsdm-dmic",
1121 adc->dfsdm = dev_get_drvdata(dev->parent); in stm32_dfsdm_adc_probe()
1130 if (ret != 0 || adc->fl_id >= adc->dfsdm->num_fls) { in stm32_dfsdm_adc_probe()
1135 name = devm_kzalloc(dev, sizeof("dfsdm-adc0"), GFP_KERNEL); in stm32_dfsdm_adc_probe()
1140 snprintf(name, sizeof("dfsdm-pdm0"), "dfsdm-pdm%d", adc->fl_id); in stm32_dfsdm_adc_probe()
1143 snprintf(name, sizeof("dfsdm-adc0"), "dfsdm-adc%d", adc->fl_id); in stm32_dfsdm_adc_probe()
1171 adc->dfsdm->fl_list[adc->fl_id].ford = val; in stm32_dfsdm_adc_probe()
1175 adc->dfsdm->fl_list[adc->fl_id].sync_mode = val; in stm32_dfsdm_adc_probe()
1219 .name = "stm32-dfsdm-adc",