stm32-dfsdm-adc.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * This file is the ADC part of the STM32 DFSDM driver
  4. *
  5. * Copyright (C) 2017, STMicroelectronics - All Rights Reserved
  6. * Author: Arnaud Pouliquen <arnaud.pouliquen@st.com>.
  7. */
  8. #include <linux/dmaengine.h>
  9. #include <linux/dma-mapping.h>
  10. #include <linux/interrupt.h>
  11. #include <linux/iio/buffer.h>
  12. #include <linux/iio/hw-consumer.h>
  13. #include <linux/iio/iio.h>
  14. #include <linux/iio/sysfs.h>
  15. #include <linux/module.h>
  16. #include <linux/of_device.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/regmap.h>
  19. #include <linux/slab.h>
  20. #include "stm32-dfsdm.h"
  21. #define DFSDM_DMA_BUFFER_SIZE (4 * PAGE_SIZE)
  22. /* Conversion timeout */
  23. #define DFSDM_TIMEOUT_US 100000
  24. #define DFSDM_TIMEOUT (msecs_to_jiffies(DFSDM_TIMEOUT_US / 1000))
  25. /* Oversampling attribute default */
  26. #define DFSDM_DEFAULT_OVERSAMPLING 100
  27. /* Oversampling max values */
  28. #define DFSDM_MAX_INT_OVERSAMPLING 256
  29. #define DFSDM_MAX_FL_OVERSAMPLING 1024
  30. /* Max sample resolutions */
  31. #define DFSDM_MAX_RES BIT(31)
  32. #define DFSDM_DATA_RES BIT(23)
  33. enum sd_converter_type {
  34. DFSDM_AUDIO,
  35. DFSDM_IIO,
  36. };
  37. struct stm32_dfsdm_dev_data {
  38. int type;
  39. int (*init)(struct iio_dev *indio_dev);
  40. unsigned int num_channels;
  41. const struct regmap_config *regmap_cfg;
  42. };
  43. struct stm32_dfsdm_adc {
  44. struct stm32_dfsdm *dfsdm;
  45. const struct stm32_dfsdm_dev_data *dev_data;
  46. unsigned int fl_id;
  47. /* ADC specific */
  48. unsigned int oversamp;
  49. struct iio_hw_consumer *hwc;
  50. struct completion completion;
  51. u32 *buffer;
  52. /* Audio specific */
  53. unsigned int spi_freq; /* SPI bus clock frequency */
  54. unsigned int sample_freq; /* Sample frequency after filter decimation */
  55. int (*cb)(const void *data, size_t size, void *cb_priv);
  56. void *cb_priv;
  57. /* DMA */
  58. u8 *rx_buf;
  59. unsigned int bufi; /* Buffer current position */
  60. unsigned int buf_sz; /* Buffer size */
  61. struct dma_chan *dma_chan;
  62. dma_addr_t dma_buf;
  63. };
  64. struct stm32_dfsdm_str2field {
  65. const char *name;
  66. unsigned int val;
  67. };
  68. /* DFSDM channel serial interface type */
  69. static const struct stm32_dfsdm_str2field stm32_dfsdm_chan_type[] = {
  70. { "SPI_R", 0 }, /* SPI with data on rising edge */
  71. { "SPI_F", 1 }, /* SPI with data on falling edge */
  72. { "MANCH_R", 2 }, /* Manchester codec, rising edge = logic 0 */
  73. { "MANCH_F", 3 }, /* Manchester codec, falling edge = logic 1 */
  74. {},
  75. };
  76. /* DFSDM channel clock source */
  77. static const struct stm32_dfsdm_str2field stm32_dfsdm_chan_src[] = {
  78. /* External SPI clock (CLKIN x) */
  79. { "CLKIN", DFSDM_CHANNEL_SPI_CLOCK_EXTERNAL },
  80. /* Internal SPI clock (CLKOUT) */
  81. { "CLKOUT", DFSDM_CHANNEL_SPI_CLOCK_INTERNAL },
  82. /* Internal SPI clock divided by 2 (falling edge) */
  83. { "CLKOUT_F", DFSDM_CHANNEL_SPI_CLOCK_INTERNAL_DIV2_FALLING },
  84. /* Internal SPI clock divided by 2 (falling edge) */
  85. { "CLKOUT_R", DFSDM_CHANNEL_SPI_CLOCK_INTERNAL_DIV2_RISING },
  86. {},
  87. };
  88. static int stm32_dfsdm_str2val(const char *str,
  89. const struct stm32_dfsdm_str2field *list)
  90. {
  91. const struct stm32_dfsdm_str2field *p = list;
  92. for (p = list; p && p->name; p++)
  93. if (!strcmp(p->name, str))
  94. return p->val;
  95. return -EINVAL;
  96. }
  97. static int stm32_dfsdm_set_osrs(struct stm32_dfsdm_filter *fl,
  98. unsigned int fast, unsigned int oversamp)
  99. {
  100. unsigned int i, d, fosr, iosr;
  101. u64 res;
  102. s64 delta;
  103. unsigned int m = 1; /* multiplication factor */
  104. unsigned int p = fl->ford; /* filter order (ford) */
  105. pr_debug("%s: Requested oversampling: %d\n", __func__, oversamp);
  106. /*
  107. * This function tries to compute filter oversampling and integrator
  108. * oversampling, base on oversampling ratio requested by user.
  109. *
  110. * Decimation d depends on the filter order and the oversampling ratios.
  111. * ford: filter order
  112. * fosr: filter over sampling ratio
  113. * iosr: integrator over sampling ratio
  114. */
  115. if (fl->ford == DFSDM_FASTSINC_ORDER) {
  116. m = 2;
  117. p = 2;
  118. }
  119. /*
  120. * Look for filter and integrator oversampling ratios which allows
  121. * to reach 24 bits data output resolution.
  122. * Leave as soon as if exact resolution if reached.
  123. * Otherwise the higher resolution below 32 bits is kept.
  124. */
  125. for (fosr = 1; fosr <= DFSDM_MAX_FL_OVERSAMPLING; fosr++) {
  126. for (iosr = 1; iosr <= DFSDM_MAX_INT_OVERSAMPLING; iosr++) {
  127. if (fast)
  128. d = fosr * iosr;
  129. else if (fl->ford == DFSDM_FASTSINC_ORDER)
  130. d = fosr * (iosr + 3) + 2;
  131. else
  132. d = fosr * (iosr - 1 + p) + p;
  133. if (d > oversamp)
  134. break;
  135. else if (d != oversamp)
  136. continue;
  137. /*
  138. * Check resolution (limited to signed 32 bits)
  139. * res <= 2^31
  140. * Sincx filters:
  141. * res = m * fosr^p x iosr (with m=1, p=ford)
  142. * FastSinc filter
  143. * res = m * fosr^p x iosr (with m=2, p=2)
  144. */
  145. res = fosr;
  146. for (i = p - 1; i > 0; i--) {
  147. res = res * (u64)fosr;
  148. if (res > DFSDM_MAX_RES)
  149. break;
  150. }
  151. if (res > DFSDM_MAX_RES)
  152. continue;
  153. res = res * (u64)m * (u64)iosr;
  154. if (res > DFSDM_MAX_RES)
  155. continue;
  156. delta = res - DFSDM_DATA_RES;
  157. if (res >= fl->res) {
  158. fl->res = res;
  159. fl->fosr = fosr;
  160. fl->iosr = iosr;
  161. fl->fast = fast;
  162. pr_debug("%s: fosr = %d, iosr = %d\n",
  163. __func__, fl->fosr, fl->iosr);
  164. }
  165. if (!delta)
  166. return 0;
  167. }
  168. }
  169. if (!fl->fosr)
  170. return -EINVAL;
  171. return 0;
  172. }
  173. static int stm32_dfsdm_start_channel(struct stm32_dfsdm *dfsdm,
  174. unsigned int ch_id)
  175. {
  176. return regmap_update_bits(dfsdm->regmap, DFSDM_CHCFGR1(ch_id),
  177. DFSDM_CHCFGR1_CHEN_MASK,
  178. DFSDM_CHCFGR1_CHEN(1));
  179. }
  180. static void stm32_dfsdm_stop_channel(struct stm32_dfsdm *dfsdm,
  181. unsigned int ch_id)
  182. {
  183. regmap_update_bits(dfsdm->regmap, DFSDM_CHCFGR1(ch_id),
  184. DFSDM_CHCFGR1_CHEN_MASK, DFSDM_CHCFGR1_CHEN(0));
  185. }
  186. static int stm32_dfsdm_chan_configure(struct stm32_dfsdm *dfsdm,
  187. struct stm32_dfsdm_channel *ch)
  188. {
  189. unsigned int id = ch->id;
  190. struct regmap *regmap = dfsdm->regmap;
  191. int ret;
  192. ret = regmap_update_bits(regmap, DFSDM_CHCFGR1(id),
  193. DFSDM_CHCFGR1_SITP_MASK,
  194. DFSDM_CHCFGR1_SITP(ch->type));
  195. if (ret < 0)
  196. return ret;
  197. ret = regmap_update_bits(regmap, DFSDM_CHCFGR1(id),
  198. DFSDM_CHCFGR1_SPICKSEL_MASK,
  199. DFSDM_CHCFGR1_SPICKSEL(ch->src));
  200. if (ret < 0)
  201. return ret;
  202. return regmap_update_bits(regmap, DFSDM_CHCFGR1(id),
  203. DFSDM_CHCFGR1_CHINSEL_MASK,
  204. DFSDM_CHCFGR1_CHINSEL(ch->alt_si));
  205. }
  206. static int stm32_dfsdm_start_filter(struct stm32_dfsdm *dfsdm,
  207. unsigned int fl_id)
  208. {
  209. int ret;
  210. /* Enable filter */
  211. ret = regmap_update_bits(dfsdm->regmap, DFSDM_CR1(fl_id),
  212. DFSDM_CR1_DFEN_MASK, DFSDM_CR1_DFEN(1));
  213. if (ret < 0)
  214. return ret;
  215. /* Start conversion */
  216. return regmap_update_bits(dfsdm->regmap, DFSDM_CR1(fl_id),
  217. DFSDM_CR1_RSWSTART_MASK,
  218. DFSDM_CR1_RSWSTART(1));
  219. }
  220. static void stm32_dfsdm_stop_filter(struct stm32_dfsdm *dfsdm, unsigned int fl_id)
  221. {
  222. /* Disable conversion */
  223. regmap_update_bits(dfsdm->regmap, DFSDM_CR1(fl_id),
  224. DFSDM_CR1_DFEN_MASK, DFSDM_CR1_DFEN(0));
  225. }
  226. static int stm32_dfsdm_filter_configure(struct stm32_dfsdm *dfsdm,
  227. unsigned int fl_id, unsigned int ch_id)
  228. {
  229. struct regmap *regmap = dfsdm->regmap;
  230. struct stm32_dfsdm_filter *fl = &dfsdm->fl_list[fl_id];
  231. int ret;
  232. /* Average integrator oversampling */
  233. ret = regmap_update_bits(regmap, DFSDM_FCR(fl_id), DFSDM_FCR_IOSR_MASK,
  234. DFSDM_FCR_IOSR(fl->iosr - 1));
  235. if (ret)
  236. return ret;
  237. /* Filter order and Oversampling */
  238. ret = regmap_update_bits(regmap, DFSDM_FCR(fl_id), DFSDM_FCR_FOSR_MASK,
  239. DFSDM_FCR_FOSR(fl->fosr - 1));
  240. if (ret)
  241. return ret;
  242. ret = regmap_update_bits(regmap, DFSDM_FCR(fl_id), DFSDM_FCR_FORD_MASK,
  243. DFSDM_FCR_FORD(fl->ford));
  244. if (ret)
  245. return ret;
  246. /* No scan mode supported for the moment */
  247. ret = regmap_update_bits(regmap, DFSDM_CR1(fl_id), DFSDM_CR1_RCH_MASK,
  248. DFSDM_CR1_RCH(ch_id));
  249. if (ret)
  250. return ret;
  251. return regmap_update_bits(regmap, DFSDM_CR1(fl_id),
  252. DFSDM_CR1_RSYNC_MASK,
  253. DFSDM_CR1_RSYNC(fl->sync_mode));
  254. }
  255. static int stm32_dfsdm_channel_parse_of(struct stm32_dfsdm *dfsdm,
  256. struct iio_dev *indio_dev,
  257. struct iio_chan_spec *ch)
  258. {
  259. struct stm32_dfsdm_channel *df_ch;
  260. const char *of_str;
  261. int chan_idx = ch->scan_index;
  262. int ret, val;
  263. ret = of_property_read_u32_index(indio_dev->dev.of_node,
  264. "st,adc-channels", chan_idx,
  265. &ch->channel);
  266. if (ret < 0) {
  267. dev_err(&indio_dev->dev,
  268. " Error parsing 'st,adc-channels' for idx %d\n",
  269. chan_idx);
  270. return ret;
  271. }
  272. if (ch->channel >= dfsdm->num_chs) {
  273. dev_err(&indio_dev->dev,
  274. " Error bad channel number %d (max = %d)\n",
  275. ch->channel, dfsdm->num_chs);
  276. return -EINVAL;
  277. }
  278. ret = of_property_read_string_index(indio_dev->dev.of_node,
  279. "st,adc-channel-names", chan_idx,
  280. &ch->datasheet_name);
  281. if (ret < 0) {
  282. dev_err(&indio_dev->dev,
  283. " Error parsing 'st,adc-channel-names' for idx %d\n",
  284. chan_idx);
  285. return ret;
  286. }
  287. df_ch = &dfsdm->ch_list[ch->channel];
  288. df_ch->id = ch->channel;
  289. ret = of_property_read_string_index(indio_dev->dev.of_node,
  290. "st,adc-channel-types", chan_idx,
  291. &of_str);
  292. if (!ret) {
  293. val = stm32_dfsdm_str2val(of_str, stm32_dfsdm_chan_type);
  294. if (val < 0)
  295. return val;
  296. } else {
  297. val = 0;
  298. }
  299. df_ch->type = val;
  300. ret = of_property_read_string_index(indio_dev->dev.of_node,
  301. "st,adc-channel-clk-src", chan_idx,
  302. &of_str);
  303. if (!ret) {
  304. val = stm32_dfsdm_str2val(of_str, stm32_dfsdm_chan_src);
  305. if (val < 0)
  306. return val;
  307. } else {
  308. val = 0;
  309. }
  310. df_ch->src = val;
  311. ret = of_property_read_u32_index(indio_dev->dev.of_node,
  312. "st,adc-alt-channel", chan_idx,
  313. &df_ch->alt_si);
  314. if (ret < 0)
  315. df_ch->alt_si = 0;
  316. return 0;
  317. }
  318. static ssize_t dfsdm_adc_audio_get_spiclk(struct iio_dev *indio_dev,
  319. uintptr_t priv,
  320. const struct iio_chan_spec *chan,
  321. char *buf)
  322. {
  323. struct stm32_dfsdm_adc *adc = iio_priv(indio_dev);
  324. return snprintf(buf, PAGE_SIZE, "%d\n", adc->spi_freq);
  325. }
  326. static ssize_t dfsdm_adc_audio_set_spiclk(struct iio_dev *indio_dev,
  327. uintptr_t priv,
  328. const struct iio_chan_spec *chan,
  329. const char *buf, size_t len)
  330. {
  331. struct stm32_dfsdm_adc *adc = iio_priv(indio_dev);
  332. struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[adc->fl_id];
  333. struct stm32_dfsdm_channel *ch = &adc->dfsdm->ch_list[chan->channel];
  334. unsigned int sample_freq = adc->sample_freq;
  335. unsigned int spi_freq;
  336. int ret;
  337. dev_err(&indio_dev->dev, "enter %s\n", __func__);
  338. /* If DFSDM is master on SPI, SPI freq can not be updated */
  339. if (ch->src != DFSDM_CHANNEL_SPI_CLOCK_EXTERNAL)
  340. return -EPERM;
  341. ret = kstrtoint(buf, 0, &spi_freq);
  342. if (ret)
  343. return ret;
  344. if (!spi_freq)
  345. return -EINVAL;
  346. if (sample_freq) {
  347. if (spi_freq % sample_freq)
  348. dev_warn(&indio_dev->dev,
  349. "Sampling rate not accurate (%d)\n",
  350. spi_freq / (spi_freq / sample_freq));
  351. ret = stm32_dfsdm_set_osrs(fl, 0, (spi_freq / sample_freq));
  352. if (ret < 0) {
  353. dev_err(&indio_dev->dev,
  354. "No filter parameters that match!\n");
  355. return ret;
  356. }
  357. }
  358. adc->spi_freq = spi_freq;
  359. return len;
  360. }
  361. static int stm32_dfsdm_start_conv(struct stm32_dfsdm_adc *adc,
  362. const struct iio_chan_spec *chan,
  363. bool dma)
  364. {
  365. struct regmap *regmap = adc->dfsdm->regmap;
  366. int ret;
  367. unsigned int dma_en = 0, cont_en = 0;
  368. ret = stm32_dfsdm_start_channel(adc->dfsdm, chan->channel);
  369. if (ret < 0)
  370. return ret;
  371. ret = stm32_dfsdm_filter_configure(adc->dfsdm, adc->fl_id,
  372. chan->channel);
  373. if (ret < 0)
  374. goto stop_channels;
  375. if (dma) {
  376. /* Enable DMA transfer*/
  377. dma_en = DFSDM_CR1_RDMAEN(1);
  378. /* Enable conversion triggered by SPI clock*/
  379. cont_en = DFSDM_CR1_RCONT(1);
  380. }
  381. /* Enable DMA transfer*/
  382. ret = regmap_update_bits(regmap, DFSDM_CR1(adc->fl_id),
  383. DFSDM_CR1_RDMAEN_MASK, dma_en);
  384. if (ret < 0)
  385. goto stop_channels;
  386. /* Enable conversion triggered by SPI clock*/
  387. ret = regmap_update_bits(regmap, DFSDM_CR1(adc->fl_id),
  388. DFSDM_CR1_RCONT_MASK, cont_en);
  389. if (ret < 0)
  390. goto stop_channels;
  391. ret = stm32_dfsdm_start_filter(adc->dfsdm, adc->fl_id);
  392. if (ret < 0)
  393. goto stop_channels;
  394. return 0;
  395. stop_channels:
  396. regmap_update_bits(regmap, DFSDM_CR1(adc->fl_id),
  397. DFSDM_CR1_RDMAEN_MASK, 0);
  398. regmap_update_bits(regmap, DFSDM_CR1(adc->fl_id),
  399. DFSDM_CR1_RCONT_MASK, 0);
  400. stm32_dfsdm_stop_channel(adc->dfsdm, chan->channel);
  401. return ret;
  402. }
  403. static void stm32_dfsdm_stop_conv(struct stm32_dfsdm_adc *adc,
  404. const struct iio_chan_spec *chan)
  405. {
  406. struct regmap *regmap = adc->dfsdm->regmap;
  407. stm32_dfsdm_stop_filter(adc->dfsdm, adc->fl_id);
  408. /* Clean conversion options */
  409. regmap_update_bits(regmap, DFSDM_CR1(adc->fl_id),
  410. DFSDM_CR1_RDMAEN_MASK, 0);
  411. regmap_update_bits(regmap, DFSDM_CR1(adc->fl_id),
  412. DFSDM_CR1_RCONT_MASK, 0);
  413. stm32_dfsdm_stop_channel(adc->dfsdm, chan->channel);
  414. }
  415. static int stm32_dfsdm_set_watermark(struct iio_dev *indio_dev,
  416. unsigned int val)
  417. {
  418. struct stm32_dfsdm_adc *adc = iio_priv(indio_dev);
  419. unsigned int watermark = DFSDM_DMA_BUFFER_SIZE / 2;
  420. /*
  421. * DMA cyclic transfers are used, buffer is split into two periods.
  422. * There should be :
  423. * - always one buffer (period) DMA is working on
  424. * - one buffer (period) driver pushed to ASoC side.
  425. */
  426. watermark = min(watermark, val * (unsigned int)(sizeof(u32)));
  427. adc->buf_sz = watermark * 2;
  428. return 0;
  429. }
  430. static unsigned int stm32_dfsdm_adc_dma_residue(struct stm32_dfsdm_adc *adc)
  431. {
  432. struct dma_tx_state state;
  433. enum dma_status status;
  434. status = dmaengine_tx_status(adc->dma_chan,
  435. adc->dma_chan->cookie,
  436. &state);
  437. if (status == DMA_IN_PROGRESS) {
  438. /* Residue is size in bytes from end of buffer */
  439. unsigned int i = adc->buf_sz - state.residue;
  440. unsigned int size;
  441. /* Return available bytes */
  442. if (i >= adc->bufi)
  443. size = i - adc->bufi;
  444. else
  445. size = adc->buf_sz + i - adc->bufi;
  446. return size;
  447. }
  448. return 0;
  449. }
  450. static void stm32_dfsdm_audio_dma_buffer_done(void *data)
  451. {
  452. struct iio_dev *indio_dev = data;
  453. struct stm32_dfsdm_adc *adc = iio_priv(indio_dev);
  454. int available = stm32_dfsdm_adc_dma_residue(adc);
  455. size_t old_pos;
  456. /*
  457. * FIXME: In Kernel interface does not support cyclic DMA buffer,and
  458. * offers only an interface to push data samples per samples.
  459. * For this reason IIO buffer interface is not used and interface is
  460. * bypassed using a private callback registered by ASoC.
  461. * This should be a temporary solution waiting a cyclic DMA engine
  462. * support in IIO.
  463. */
  464. dev_dbg(&indio_dev->dev, "%s: pos = %d, available = %d\n", __func__,
  465. adc->bufi, available);
  466. old_pos = adc->bufi;
  467. while (available >= indio_dev->scan_bytes) {
  468. u32 *buffer = (u32 *)&adc->rx_buf[adc->bufi];
  469. /* Mask 8 LSB that contains the channel ID */
  470. *buffer = (*buffer & 0xFFFFFF00) << 8;
  471. available -= indio_dev->scan_bytes;
  472. adc->bufi += indio_dev->scan_bytes;
  473. if (adc->bufi >= adc->buf_sz) {
  474. if (adc->cb)
  475. adc->cb(&adc->rx_buf[old_pos],
  476. adc->buf_sz - old_pos, adc->cb_priv);
  477. adc->bufi = 0;
  478. old_pos = 0;
  479. }
  480. }
  481. if (adc->cb)
  482. adc->cb(&adc->rx_buf[old_pos], adc->bufi - old_pos,
  483. adc->cb_priv);
  484. }
  485. static int stm32_dfsdm_adc_dma_start(struct iio_dev *indio_dev)
  486. {
  487. struct stm32_dfsdm_adc *adc = iio_priv(indio_dev);
  488. struct dma_async_tx_descriptor *desc;
  489. dma_cookie_t cookie;
  490. int ret;
  491. if (!adc->dma_chan)
  492. return -EINVAL;
  493. dev_dbg(&indio_dev->dev, "%s size=%d watermark=%d\n", __func__,
  494. adc->buf_sz, adc->buf_sz / 2);
  495. /* Prepare a DMA cyclic transaction */
  496. desc = dmaengine_prep_dma_cyclic(adc->dma_chan,
  497. adc->dma_buf,
  498. adc->buf_sz, adc->buf_sz / 2,
  499. DMA_DEV_TO_MEM,
  500. DMA_PREP_INTERRUPT);
  501. if (!desc)
  502. return -EBUSY;
  503. desc->callback = stm32_dfsdm_audio_dma_buffer_done;
  504. desc->callback_param = indio_dev;
  505. cookie = dmaengine_submit(desc);
  506. ret = dma_submit_error(cookie);
  507. if (ret) {
  508. dmaengine_terminate_all(adc->dma_chan);
  509. return ret;
  510. }
  511. /* Issue pending DMA requests */
  512. dma_async_issue_pending(adc->dma_chan);
  513. return 0;
  514. }
  515. static int stm32_dfsdm_postenable(struct iio_dev *indio_dev)
  516. {
  517. struct stm32_dfsdm_adc *adc = iio_priv(indio_dev);
  518. const struct iio_chan_spec *chan = &indio_dev->channels[0];
  519. int ret;
  520. /* Reset adc buffer index */
  521. adc->bufi = 0;
  522. ret = stm32_dfsdm_start_dfsdm(adc->dfsdm);
  523. if (ret < 0)
  524. return ret;
  525. ret = stm32_dfsdm_start_conv(adc, chan, true);
  526. if (ret) {
  527. dev_err(&indio_dev->dev, "Can't start conversion\n");
  528. goto stop_dfsdm;
  529. }
  530. if (adc->dma_chan) {
  531. ret = stm32_dfsdm_adc_dma_start(indio_dev);
  532. if (ret) {
  533. dev_err(&indio_dev->dev, "Can't start DMA\n");
  534. goto err_stop_conv;
  535. }
  536. }
  537. return 0;
  538. err_stop_conv:
  539. stm32_dfsdm_stop_conv(adc, chan);
  540. stop_dfsdm:
  541. stm32_dfsdm_stop_dfsdm(adc->dfsdm);
  542. return ret;
  543. }
  544. static int stm32_dfsdm_predisable(struct iio_dev *indio_dev)
  545. {
  546. struct stm32_dfsdm_adc *adc = iio_priv(indio_dev);
  547. const struct iio_chan_spec *chan = &indio_dev->channels[0];
  548. if (adc->dma_chan)
  549. dmaengine_terminate_all(adc->dma_chan);
  550. stm32_dfsdm_stop_conv(adc, chan);
  551. stm32_dfsdm_stop_dfsdm(adc->dfsdm);
  552. return 0;
  553. }
  554. static const struct iio_buffer_setup_ops stm32_dfsdm_buffer_setup_ops = {
  555. .postenable = &stm32_dfsdm_postenable,
  556. .predisable = &stm32_dfsdm_predisable,
  557. };
  558. /**
  559. * stm32_dfsdm_get_buff_cb() - register a callback that will be called when
  560. * DMA transfer period is achieved.
  561. *
  562. * @iio_dev: Handle to IIO device.
  563. * @cb: Pointer to callback function:
  564. * - data: pointer to data buffer
  565. * - size: size in byte of the data buffer
  566. * - private: pointer to consumer private structure.
  567. * @private: Pointer to consumer private structure.
  568. */
  569. int stm32_dfsdm_get_buff_cb(struct iio_dev *iio_dev,
  570. int (*cb)(const void *data, size_t size,
  571. void *private),
  572. void *private)
  573. {
  574. struct stm32_dfsdm_adc *adc;
  575. if (!iio_dev)
  576. return -EINVAL;
  577. adc = iio_priv(iio_dev);
  578. adc->cb = cb;
  579. adc->cb_priv = private;
  580. return 0;
  581. }
  582. EXPORT_SYMBOL_GPL(stm32_dfsdm_get_buff_cb);
  583. /**
  584. * stm32_dfsdm_release_buff_cb - unregister buffer callback
  585. *
  586. * @iio_dev: Handle to IIO device.
  587. */
  588. int stm32_dfsdm_release_buff_cb(struct iio_dev *iio_dev)
  589. {
  590. struct stm32_dfsdm_adc *adc;
  591. if (!iio_dev)
  592. return -EINVAL;
  593. adc = iio_priv(iio_dev);
  594. adc->cb = NULL;
  595. adc->cb_priv = NULL;
  596. return 0;
  597. }
  598. EXPORT_SYMBOL_GPL(stm32_dfsdm_release_buff_cb);
  599. static int stm32_dfsdm_single_conv(struct iio_dev *indio_dev,
  600. const struct iio_chan_spec *chan, int *res)
  601. {
  602. struct stm32_dfsdm_adc *adc = iio_priv(indio_dev);
  603. long timeout;
  604. int ret;
  605. reinit_completion(&adc->completion);
  606. adc->buffer = res;
  607. ret = stm32_dfsdm_start_dfsdm(adc->dfsdm);
  608. if (ret < 0)
  609. return ret;
  610. ret = regmap_update_bits(adc->dfsdm->regmap, DFSDM_CR2(adc->fl_id),
  611. DFSDM_CR2_REOCIE_MASK, DFSDM_CR2_REOCIE(1));
  612. if (ret < 0)
  613. goto stop_dfsdm;
  614. ret = stm32_dfsdm_start_conv(adc, chan, false);
  615. if (ret < 0) {
  616. regmap_update_bits(adc->dfsdm->regmap, DFSDM_CR2(adc->fl_id),
  617. DFSDM_CR2_REOCIE_MASK, DFSDM_CR2_REOCIE(0));
  618. goto stop_dfsdm;
  619. }
  620. timeout = wait_for_completion_interruptible_timeout(&adc->completion,
  621. DFSDM_TIMEOUT);
  622. /* Mask IRQ for regular conversion achievement*/
  623. regmap_update_bits(adc->dfsdm->regmap, DFSDM_CR2(adc->fl_id),
  624. DFSDM_CR2_REOCIE_MASK, DFSDM_CR2_REOCIE(0));
  625. if (timeout == 0)
  626. ret = -ETIMEDOUT;
  627. else if (timeout < 0)
  628. ret = timeout;
  629. else
  630. ret = IIO_VAL_INT;
  631. stm32_dfsdm_stop_conv(adc, chan);
  632. stop_dfsdm:
  633. stm32_dfsdm_stop_dfsdm(adc->dfsdm);
  634. return ret;
  635. }
  636. static int stm32_dfsdm_write_raw(struct iio_dev *indio_dev,
  637. struct iio_chan_spec const *chan,
  638. int val, int val2, long mask)
  639. {
  640. struct stm32_dfsdm_adc *adc = iio_priv(indio_dev);
  641. struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[adc->fl_id];
  642. struct stm32_dfsdm_channel *ch = &adc->dfsdm->ch_list[chan->channel];
  643. unsigned int spi_freq = adc->spi_freq;
  644. int ret = -EINVAL;
  645. switch (mask) {
  646. case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
  647. ret = stm32_dfsdm_set_osrs(fl, 0, val);
  648. if (!ret)
  649. adc->oversamp = val;
  650. return ret;
  651. case IIO_CHAN_INFO_SAMP_FREQ:
  652. if (!val)
  653. return -EINVAL;
  654. if (ch->src != DFSDM_CHANNEL_SPI_CLOCK_EXTERNAL)
  655. spi_freq = adc->dfsdm->spi_master_freq;
  656. if (spi_freq % val)
  657. dev_warn(&indio_dev->dev,
  658. "Sampling rate not accurate (%d)\n",
  659. spi_freq / (spi_freq / val));
  660. ret = stm32_dfsdm_set_osrs(fl, 0, (spi_freq / val));
  661. if (ret < 0) {
  662. dev_err(&indio_dev->dev,
  663. "Not able to find parameter that match!\n");
  664. return ret;
  665. }
  666. adc->sample_freq = val;
  667. return 0;
  668. }
  669. return -EINVAL;
  670. }
  671. static int stm32_dfsdm_read_raw(struct iio_dev *indio_dev,
  672. struct iio_chan_spec const *chan, int *val,
  673. int *val2, long mask)
  674. {
  675. struct stm32_dfsdm_adc *adc = iio_priv(indio_dev);
  676. int ret;
  677. switch (mask) {
  678. case IIO_CHAN_INFO_RAW:
  679. ret = iio_hw_consumer_enable(adc->hwc);
  680. if (ret < 0) {
  681. dev_err(&indio_dev->dev,
  682. "%s: IIO enable failed (channel %d)\n",
  683. __func__, chan->channel);
  684. return ret;
  685. }
  686. ret = stm32_dfsdm_single_conv(indio_dev, chan, val);
  687. iio_hw_consumer_disable(adc->hwc);
  688. if (ret < 0) {
  689. dev_err(&indio_dev->dev,
  690. "%s: Conversion failed (channel %d)\n",
  691. __func__, chan->channel);
  692. return ret;
  693. }
  694. return IIO_VAL_INT;
  695. case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
  696. *val = adc->oversamp;
  697. return IIO_VAL_INT;
  698. case IIO_CHAN_INFO_SAMP_FREQ:
  699. *val = adc->sample_freq;
  700. return IIO_VAL_INT;
  701. }
  702. return -EINVAL;
  703. }
  704. static const struct iio_info stm32_dfsdm_info_audio = {
  705. .hwfifo_set_watermark = stm32_dfsdm_set_watermark,
  706. .read_raw = stm32_dfsdm_read_raw,
  707. .write_raw = stm32_dfsdm_write_raw,
  708. };
  709. static const struct iio_info stm32_dfsdm_info_adc = {
  710. .read_raw = stm32_dfsdm_read_raw,
  711. .write_raw = stm32_dfsdm_write_raw,
  712. };
  713. static irqreturn_t stm32_dfsdm_irq(int irq, void *arg)
  714. {
  715. struct stm32_dfsdm_adc *adc = arg;
  716. struct iio_dev *indio_dev = iio_priv_to_dev(adc);
  717. struct regmap *regmap = adc->dfsdm->regmap;
  718. unsigned int status, int_en;
  719. regmap_read(regmap, DFSDM_ISR(adc->fl_id), &status);
  720. regmap_read(regmap, DFSDM_CR2(adc->fl_id), &int_en);
  721. if (status & DFSDM_ISR_REOCF_MASK) {
  722. /* Read the data register clean the IRQ status */
  723. regmap_read(regmap, DFSDM_RDATAR(adc->fl_id), adc->buffer);
  724. complete(&adc->completion);
  725. }
  726. if (status & DFSDM_ISR_ROVRF_MASK) {
  727. if (int_en & DFSDM_CR2_ROVRIE_MASK)
  728. dev_warn(&indio_dev->dev, "Overrun detected\n");
  729. regmap_update_bits(regmap, DFSDM_ICR(adc->fl_id),
  730. DFSDM_ICR_CLRROVRF_MASK,
  731. DFSDM_ICR_CLRROVRF_MASK);
  732. }
  733. return IRQ_HANDLED;
  734. }
  735. /*
  736. * Define external info for SPI Frequency and audio sampling rate that can be
  737. * configured by ASoC driver through consumer.h API
  738. */
  739. static const struct iio_chan_spec_ext_info dfsdm_adc_audio_ext_info[] = {
  740. /* spi_clk_freq : clock freq on SPI/manchester bus used by channel */
  741. {
  742. .name = "spi_clk_freq",
  743. .shared = IIO_SHARED_BY_TYPE,
  744. .read = dfsdm_adc_audio_get_spiclk,
  745. .write = dfsdm_adc_audio_set_spiclk,
  746. },
  747. {},
  748. };
  749. static void stm32_dfsdm_dma_release(struct iio_dev *indio_dev)
  750. {
  751. struct stm32_dfsdm_adc *adc = iio_priv(indio_dev);
  752. if (adc->dma_chan) {
  753. dma_free_coherent(adc->dma_chan->device->dev,
  754. DFSDM_DMA_BUFFER_SIZE,
  755. adc->rx_buf, adc->dma_buf);
  756. dma_release_channel(adc->dma_chan);
  757. }
  758. }
  759. static int stm32_dfsdm_dma_request(struct iio_dev *indio_dev)
  760. {
  761. struct stm32_dfsdm_adc *adc = iio_priv(indio_dev);
  762. struct dma_slave_config config = {
  763. .src_addr = (dma_addr_t)adc->dfsdm->phys_base +
  764. DFSDM_RDATAR(adc->fl_id),
  765. .src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
  766. };
  767. int ret;
  768. adc->dma_chan = dma_request_slave_channel(&indio_dev->dev, "rx");
  769. if (!adc->dma_chan)
  770. return -EINVAL;
  771. adc->rx_buf = dma_alloc_coherent(adc->dma_chan->device->dev,
  772. DFSDM_DMA_BUFFER_SIZE,
  773. &adc->dma_buf, GFP_KERNEL);
  774. if (!adc->rx_buf) {
  775. ret = -ENOMEM;
  776. goto err_release;
  777. }
  778. ret = dmaengine_slave_config(adc->dma_chan, &config);
  779. if (ret)
  780. goto err_free;
  781. return 0;
  782. err_free:
  783. dma_free_coherent(adc->dma_chan->device->dev, DFSDM_DMA_BUFFER_SIZE,
  784. adc->rx_buf, adc->dma_buf);
  785. err_release:
  786. dma_release_channel(adc->dma_chan);
  787. return ret;
  788. }
  789. static int stm32_dfsdm_adc_chan_init_one(struct iio_dev *indio_dev,
  790. struct iio_chan_spec *ch)
  791. {
  792. struct stm32_dfsdm_adc *adc = iio_priv(indio_dev);
  793. int ret;
  794. ret = stm32_dfsdm_channel_parse_of(adc->dfsdm, indio_dev, ch);
  795. if (ret < 0)
  796. return ret;
  797. ch->type = IIO_VOLTAGE;
  798. ch->indexed = 1;
  799. /*
  800. * IIO_CHAN_INFO_RAW: used to compute regular conversion
  801. * IIO_CHAN_INFO_OVERSAMPLING_RATIO: used to set oversampling
  802. */
  803. ch->info_mask_separate = BIT(IIO_CHAN_INFO_RAW);
  804. ch->info_mask_shared_by_all = BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO);
  805. if (adc->dev_data->type == DFSDM_AUDIO) {
  806. ch->scan_type.sign = 's';
  807. ch->ext_info = dfsdm_adc_audio_ext_info;
  808. } else {
  809. ch->scan_type.sign = 'u';
  810. }
  811. ch->scan_type.realbits = 24;
  812. ch->scan_type.storagebits = 32;
  813. return stm32_dfsdm_chan_configure(adc->dfsdm,
  814. &adc->dfsdm->ch_list[ch->channel]);
  815. }
  816. static int stm32_dfsdm_audio_init(struct iio_dev *indio_dev)
  817. {
  818. struct iio_chan_spec *ch;
  819. struct stm32_dfsdm_adc *adc = iio_priv(indio_dev);
  820. struct stm32_dfsdm_channel *d_ch;
  821. int ret;
  822. indio_dev->modes |= INDIO_BUFFER_SOFTWARE;
  823. indio_dev->setup_ops = &stm32_dfsdm_buffer_setup_ops;
  824. ch = devm_kzalloc(&indio_dev->dev, sizeof(*ch), GFP_KERNEL);
  825. if (!ch)
  826. return -ENOMEM;
  827. ch->scan_index = 0;
  828. ret = stm32_dfsdm_adc_chan_init_one(indio_dev, ch);
  829. if (ret < 0) {
  830. dev_err(&indio_dev->dev, "Channels init failed\n");
  831. return ret;
  832. }
  833. ch->info_mask_separate = BIT(IIO_CHAN_INFO_SAMP_FREQ);
  834. d_ch = &adc->dfsdm->ch_list[ch->channel];
  835. if (d_ch->src != DFSDM_CHANNEL_SPI_CLOCK_EXTERNAL)
  836. adc->spi_freq = adc->dfsdm->spi_master_freq;
  837. indio_dev->num_channels = 1;
  838. indio_dev->channels = ch;
  839. return stm32_dfsdm_dma_request(indio_dev);
  840. }
  841. static int stm32_dfsdm_adc_init(struct iio_dev *indio_dev)
  842. {
  843. struct iio_chan_spec *ch;
  844. struct stm32_dfsdm_adc *adc = iio_priv(indio_dev);
  845. int num_ch;
  846. int ret, chan_idx;
  847. adc->oversamp = DFSDM_DEFAULT_OVERSAMPLING;
  848. ret = stm32_dfsdm_set_osrs(&adc->dfsdm->fl_list[adc->fl_id], 0,
  849. adc->oversamp);
  850. if (ret < 0)
  851. return ret;
  852. num_ch = of_property_count_u32_elems(indio_dev->dev.of_node,
  853. "st,adc-channels");
  854. if (num_ch < 0 || num_ch > adc->dfsdm->num_chs) {
  855. dev_err(&indio_dev->dev, "Bad st,adc-channels\n");
  856. return num_ch < 0 ? num_ch : -EINVAL;
  857. }
  858. /* Bind to SD modulator IIO device */
  859. adc->hwc = devm_iio_hw_consumer_alloc(&indio_dev->dev);
  860. if (IS_ERR(adc->hwc))
  861. return -EPROBE_DEFER;
  862. ch = devm_kcalloc(&indio_dev->dev, num_ch, sizeof(*ch),
  863. GFP_KERNEL);
  864. if (!ch)
  865. return -ENOMEM;
  866. for (chan_idx = 0; chan_idx < num_ch; chan_idx++) {
  867. ch[chan_idx].scan_index = chan_idx;
  868. ret = stm32_dfsdm_adc_chan_init_one(indio_dev, &ch[chan_idx]);
  869. if (ret < 0) {
  870. dev_err(&indio_dev->dev, "Channels init failed\n");
  871. return ret;
  872. }
  873. }
  874. indio_dev->num_channels = num_ch;
  875. indio_dev->channels = ch;
  876. init_completion(&adc->completion);
  877. return 0;
  878. }
  879. static const struct stm32_dfsdm_dev_data stm32h7_dfsdm_adc_data = {
  880. .type = DFSDM_IIO,
  881. .init = stm32_dfsdm_adc_init,
  882. };
  883. static const struct stm32_dfsdm_dev_data stm32h7_dfsdm_audio_data = {
  884. .type = DFSDM_AUDIO,
  885. .init = stm32_dfsdm_audio_init,
  886. };
  887. static const struct of_device_id stm32_dfsdm_adc_match[] = {
  888. {
  889. .compatible = "st,stm32-dfsdm-adc",
  890. .data = &stm32h7_dfsdm_adc_data,
  891. },
  892. {
  893. .compatible = "st,stm32-dfsdm-dmic",
  894. .data = &stm32h7_dfsdm_audio_data,
  895. },
  896. {}
  897. };
  898. static int stm32_dfsdm_adc_probe(struct platform_device *pdev)
  899. {
  900. struct device *dev = &pdev->dev;
  901. struct stm32_dfsdm_adc *adc;
  902. struct device_node *np = dev->of_node;
  903. const struct stm32_dfsdm_dev_data *dev_data;
  904. struct iio_dev *iio;
  905. char *name;
  906. int ret, irq, val;
  907. dev_data = of_device_get_match_data(dev);
  908. iio = devm_iio_device_alloc(dev, sizeof(*adc));
  909. if (!iio) {
  910. dev_err(dev, "%s: Failed to allocate IIO\n", __func__);
  911. return -ENOMEM;
  912. }
  913. adc = iio_priv(iio);
  914. adc->dfsdm = dev_get_drvdata(dev->parent);
  915. iio->dev.parent = dev;
  916. iio->dev.of_node = np;
  917. iio->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE;
  918. platform_set_drvdata(pdev, adc);
  919. ret = of_property_read_u32(dev->of_node, "reg", &adc->fl_id);
  920. if (ret != 0) {
  921. dev_err(dev, "Missing reg property\n");
  922. return -EINVAL;
  923. }
  924. name = devm_kzalloc(dev, sizeof("dfsdm-adc0"), GFP_KERNEL);
  925. if (!name)
  926. return -ENOMEM;
  927. if (dev_data->type == DFSDM_AUDIO) {
  928. iio->info = &stm32_dfsdm_info_audio;
  929. snprintf(name, sizeof("dfsdm-pdm0"), "dfsdm-pdm%d", adc->fl_id);
  930. } else {
  931. iio->info = &stm32_dfsdm_info_adc;
  932. snprintf(name, sizeof("dfsdm-adc0"), "dfsdm-adc%d", adc->fl_id);
  933. }
  934. iio->name = name;
  935. /*
  936. * In a first step IRQs generated for channels are not treated.
  937. * So IRQ associated to filter instance 0 is dedicated to the Filter 0.
  938. */
  939. irq = platform_get_irq(pdev, 0);
  940. ret = devm_request_irq(dev, irq, stm32_dfsdm_irq,
  941. 0, pdev->name, adc);
  942. if (ret < 0) {
  943. dev_err(dev, "Failed to request IRQ\n");
  944. return ret;
  945. }
  946. ret = of_property_read_u32(dev->of_node, "st,filter-order", &val);
  947. if (ret < 0) {
  948. dev_err(dev, "Failed to set filter order\n");
  949. return ret;
  950. }
  951. adc->dfsdm->fl_list[adc->fl_id].ford = val;
  952. ret = of_property_read_u32(dev->of_node, "st,filter0-sync", &val);
  953. if (!ret)
  954. adc->dfsdm->fl_list[adc->fl_id].sync_mode = val;
  955. adc->dev_data = dev_data;
  956. ret = dev_data->init(iio);
  957. if (ret < 0)
  958. return ret;
  959. ret = iio_device_register(iio);
  960. if (ret < 0)
  961. goto err_cleanup;
  962. dev_err(dev, "of_platform_populate\n");
  963. if (dev_data->type == DFSDM_AUDIO) {
  964. ret = of_platform_populate(np, NULL, NULL, dev);
  965. if (ret < 0) {
  966. dev_err(dev, "Failed to find an audio DAI\n");
  967. goto err_unregister;
  968. }
  969. }
  970. return 0;
  971. err_unregister:
  972. iio_device_unregister(iio);
  973. err_cleanup:
  974. stm32_dfsdm_dma_release(iio);
  975. return ret;
  976. }
  977. static int stm32_dfsdm_adc_remove(struct platform_device *pdev)
  978. {
  979. struct stm32_dfsdm_adc *adc = platform_get_drvdata(pdev);
  980. struct iio_dev *indio_dev = iio_priv_to_dev(adc);
  981. if (adc->dev_data->type == DFSDM_AUDIO)
  982. of_platform_depopulate(&pdev->dev);
  983. iio_device_unregister(indio_dev);
  984. stm32_dfsdm_dma_release(indio_dev);
  985. return 0;
  986. }
  987. static struct platform_driver stm32_dfsdm_adc_driver = {
  988. .driver = {
  989. .name = "stm32-dfsdm-adc",
  990. .of_match_table = stm32_dfsdm_adc_match,
  991. },
  992. .probe = stm32_dfsdm_adc_probe,
  993. .remove = stm32_dfsdm_adc_remove,
  994. };
  995. module_platform_driver(stm32_dfsdm_adc_driver);
  996. MODULE_DESCRIPTION("STM32 sigma delta ADC");
  997. MODULE_AUTHOR("Arnaud Pouliquen <arnaud.pouliquen@st.com>");
  998. MODULE_LICENSE("GPL v2");