···11+What: /sys/bus/iio/devices/iio:deviceX/in_voltage_spi_clk_freq22+KernelVersion: 4.1433+Contact: arnaud.pouliquen@st.com44+Description:55+ For audio purpose only.66+ Used by audio driver to set/get the spi input frequency.77+ This is mandatory if DFSDM is slave on SPI bus, to88+ provide information on the SPI clock frequency during runtime99+ Notice that the SPI frequency should be a multiple of sample1010+ frequency to ensure the precision.1111+ if DFSDM input is SPI master1212+ Reading SPI clkout frequency,1313+ error on writing1414+ If DFSDM input is SPI Slave:1515+ Reading returns value previously set.1616+ Writing value before starting conversions.
···11+Device-Tree bindings for sigma delta modulator22+33+Required properties:44+- compatible: should be "ads1201", "sd-modulator". "sd-modulator" can be use55+ as a generic SD modulator if modulator not specified in compatible list.66+- #io-channel-cells = <1>: See the IIO bindings section "IIO consumers".77+88+Example node:99+1010+ ads1202: adc@0 {1111+ compatible = "sd-modulator";1212+ #io-channel-cells = <1>;1313+ };
···11+STMicroelectronics STM32 DFSDM ADC device driver22+33+44+STM32 DFSDM ADC is a sigma delta analog-to-digital converter dedicated to55+interface external sigma delta modulators to STM32 micro controllers.66+It is mainly targeted for:77+- Sigma delta modulators (motor control, metering...)88+- PDM microphones (audio digital microphone)99+1010+It features up to 8 serial digital interfaces (SPI or Manchester) and1111+up to 4 filters on stm32h7.1212+1313+Each child node match with a filter instance.1414+1515+Contents of a STM32 DFSDM root node:1616+------------------------------------1717+Required properties:1818+- compatible: Should be "st,stm32h7-dfsdm".1919+- reg: Offset and length of the DFSDM block register set.2020+- clocks: IP and serial interfaces clocking. Should be set according2121+ to rcc clock ID and "clock-names".2222+- clock-names: Input clock name "dfsdm" must be defined,2323+ "audio" is optional. If defined CLKOUT is based on the audio2424+ clock, else "dfsdm" is used.2525+- #interrupt-cells = <1>;2626+- #address-cells = <1>;2727+- #size-cells = <0>;2828+2929+Optional properties:3030+- spi-max-frequency: Requested only for SPI master mode.3131+ SPI clock OUT frequency (Hz). This clock must be set according3232+ to "clock" property. Frequency must be a multiple of the rcc3333+ clock frequency. If not, SPI CLKOUT frequency will not be3434+ accurate.3535+3636+Contents of a STM32 DFSDM child nodes:3737+--------------------------------------3838+3939+Required properties:4040+- compatible: Must be:4141+ "st,stm32-dfsdm-adc" for sigma delta ADCs4242+ "st,stm32-dfsdm-dmic" for audio digital microphone.4343+- reg: Specifies the DFSDM filter instance used.4444+- interrupts: IRQ lines connected to each DFSDM filter instance.4545+- st,adc-channels: List of single-ended channels muxed for this ADC.4646+ valid values:4747+ "st,stm32h7-dfsdm" compatibility: 0 to 7.4848+- st,adc-channel-names: List of single-ended channel names.4949+- st,filter-order: SinC filter order from 0 to 5.5050+ 0: FastSinC5151+ [1-5]: order 1 to 5.5252+ For audio purpose it is recommended to use order 3 to 5.5353+- #io-channel-cells = <1>: See the IIO bindings section "IIO consumers".5454+5555+Required properties for "st,stm32-dfsdm-adc" compatibility:5656+- io-channels: From common IIO binding. Used to pipe external sigma delta5757+ modulator or internal ADC output to DFSDM channel.5858+ This is not required for "st,stm32-dfsdm-pdm" compatibility as5959+ PDM microphone is binded in Audio DT node.6060+6161+Required properties for "st,stm32-dfsdm-pdm" compatibility:6262+- #sound-dai-cells: Must be set to 0.6363+- dma: DMA controller phandle and DMA request line associated to the6464+ filter instance (specified by the field "reg")6565+- dma-names: Must be "rx"6666+6767+Optional properties:6868+- st,adc-channel-types: Single-ended channel input type.6969+ - "SPI_R": SPI with data on rising edge (default)7070+ - "SPI_F": SPI with data on falling edge7171+ - "MANCH_R": manchester codec, rising edge = logic 07272+ - "MANCH_F": manchester codec, falling edge = logic 17373+- st,adc-channel-clk-src: Conversion clock source.7474+ - "CLKIN": external SPI clock (CLKIN x)7575+ - "CLKOUT": internal SPI clock (CLKOUT) (default)7676+ - "CLKOUT_F": internal SPI clock divided by 2 (falling edge).7777+ - "CLKOUT_R": internal SPI clock divided by 2 (rising edge).7878+7979+- st,adc-alt-channel: Must be defined if two sigma delta modulator are8080+ connected on same SPI input.8181+ If not set, channel n is connected to SPI input n.8282+ If set, channel n is connected to SPI input n + 1.8383+8484+- st,filter0-sync: Set to 1 to synchronize with DFSDM filter instance 0.8585+ Used for multi microphones synchronization.8686+8787+Example of a sigma delta adc connected on DFSDM SPI port 08888+and a pdm microphone connected on DFSDM SPI port 1:8989+9090+ ads1202: simple_sd_adc@0 {9191+ compatible = "ads1202";9292+ #io-channel-cells = <1>;9393+ };9494+9595+ dfsdm: dfsdm@40017000 {9696+ compatible = "st,stm32h7-dfsdm";9797+ reg = <0x40017000 0x400>;9898+ clocks = <&rcc DFSDM1_CK>;9999+ clock-names = "dfsdm";100100+ #interrupt-cells = <1>;101101+ #address-cells = <1>;102102+ #size-cells = <0>;103103+104104+ dfsdm_adc0: filter@0 {105105+ compatible = "st,stm32-dfsdm-adc";106106+ #io-channel-cells = <1>;107107+ reg = <0>;108108+ interrupts = <110>;109109+ st,adc-channels = <0>;110110+ st,adc-channel-names = "sd_adc0";111111+ st,adc-channel-types = "SPI_F";112112+ st,adc-channel-clk-src = "CLKOUT";113113+ io-channels = <&ads1202 0>;114114+ st,filter-order = <3>;115115+ };116116+ dfsdm_pdm1: filter@1 {117117+ compatible = "st,stm32-dfsdm-dmic";118118+ reg = <1>;119119+ interrupts = <111>;120120+ dmas = <&dmamux1 102 0x400 0x00>;121121+ dma-names = "rx";122122+ st,adc-channels = <1>;123123+ st,adc-channel-names = "dmic1";124124+ st,adc-channel-types = "SPI_R";125125+ st,adc-channel-clk-src = "CLKOUT";126126+ st,filter-order = <5>;127127+ };128128+ }
···11+Maxim Integrated MAX98373 Speaker Amplifier22+33+This device supports I2C.44+55+Required properties:66+77+ - compatible : "maxim,max98373"88+99+ - reg : the I2C address of the device.1010+1111+Optional properties:1212+1313+ - maxim,vmon-slot-no : slot number used to send voltage information1414+ or in inteleave mode this will be used as1515+ interleave slot.1616+ slot range : 0 ~ 15, Default : 01717+1818+ - maxim,imon-slot-no : slot number used to send current information1919+ slot range : 0 ~ 15, Default : 02020+2121+ - maxim,spkfb-slot-no : slot number used to send speaker feedback information2222+ slot range : 0 ~ 15, Default : 02323+2424+ - maxim,interleave-mode : For cases where a single combined channel2525+ for the I/V sense data is not sufficient, the device can also be configured2626+ to share a single data output channel on alternating frames.2727+ In this configuration, the current and voltage data will be frame interleaved2828+ on a single output channel.2929+ Boolean, define to enable the interleave mode, Default : false3030+3131+Example:3232+3333+codec: max98373@31 {3434+ compatible = "maxim,max98373";3535+ reg = <0x31>;3636+ maxim,vmon-slot-no = <0>;3737+ maxim,imon-slot-no = <1>;3838+ maxim,spkfb-slot-no = <2>;3939+ maxim,interleave-mode;4040+};
+51
Documentation/driver-api/iio/hw-consumer.rst
···11+===========22+HW consumer33+===========44+An IIO device can be directly connected to another device in hardware. in this55+case the buffers between IIO provider and IIO consumer are handled by hardware.66+The Industrial I/O HW consumer offers a way to bond these IIO devices without77+software buffer for data. The implementation can be found under88+:file:`drivers/iio/buffer/hw-consumer.c`99+1010+1111+* struct :c:type:`iio_hw_consumer` — Hardware consumer structure1212+* :c:func:`iio_hw_consumer_alloc` — Allocate IIO hardware consumer1313+* :c:func:`iio_hw_consumer_free` — Free IIO hardware consumer1414+* :c:func:`iio_hw_consumer_enable` — Enable IIO hardware consumer1515+* :c:func:`iio_hw_consumer_disable` — Disable IIO hardware consumer1616+1717+1818+HW consumer setup1919+=================2020+2121+As standard IIO device the implementation is based on IIO provider/consumer.2222+A typical IIO HW consumer setup looks like this::2323+2424+ static struct iio_hw_consumer *hwc;2525+2626+ static const struct iio_info adc_info = {2727+ .read_raw = adc_read_raw,2828+ };2929+3030+ static int adc_read_raw(struct iio_dev *indio_dev,3131+ struct iio_chan_spec const *chan, int *val,3232+ int *val2, long mask)3333+ {3434+ ret = iio_hw_consumer_enable(hwc);3535+3636+ /* Acquire data */3737+3838+ ret = iio_hw_consumer_disable(hwc);3939+ }4040+4141+ static int adc_probe(struct platform_device *pdev)4242+ {4343+ hwc = devm_iio_hw_consumer_alloc(&iio->dev);4444+ }4545+4646+More details4747+============4848+.. kernel-doc:: include/linux/iio/hw-consumer.h4949+.. kernel-doc:: drivers/iio/buffer/industrialio-hw-consumer.c5050+ :export:5151+
···629629 To compile this driver as a module, choose M here: the630630 module will be called spear_adc.631631632632+config SD_ADC_MODULATOR633633+ tristate "Generic sigma delta modulator"634634+ depends on OF635635+ select IIO_BUFFER636636+ select IIO_TRIGGERED_BUFFER637637+ help638638+ Select this option to enables sigma delta modulator. This driver can639639+ support generic sigma delta modulators.640640+641641+ This driver can also be built as a module. If so, the module642642+ will be called sd_adc_modulator.643643+632644config STM32_ADC_CORE633645 tristate "STMicroelectronics STM32 adc core"634646 depends on ARCH_STM32 || COMPILE_TEST···667655668656 This driver can also be built as a module. If so, the module669657 will be called stm32-adc.658658+659659+config STM32_DFSDM_CORE660660+ tristate "STMicroelectronics STM32 DFSDM core"661661+ depends on (ARCH_STM32 && OF) || COMPILE_TEST662662+ select REGMAP663663+ select REGMAP_MMIO664664+ help665665+ Select this option to enable the driver for STMicroelectronics666666+ STM32 digital filter for sigma delta converter.667667+668668+ This driver can also be built as a module. If so, the module669669+ will be called stm32-dfsdm-core.670670+671671+config STM32_DFSDM_ADC672672+ tristate "STMicroelectronics STM32 dfsdm adc"673673+ depends on (ARCH_STM32 && OF) || COMPILE_TEST674674+ select STM32_DFSDM_CORE675675+ select REGMAP_MMIO676676+ select IIO_BUFFER_HW_CONSUMER677677+ help678678+ Select this option to support ADCSigma delta modulator for679679+ STMicroelectronics STM32 digital filter for sigma delta converter.680680+681681+ This driver can also be built as a module. If so, the module682682+ will be called stm32-dfsdm-adc.670683671684config STX104672685 tristate "Apex Embedded Systems STX104 driver"
···29293030 Should be selected by drivers that want to use this functionality.31313232+config IIO_BUFFER_HW_CONSUMER3333+ tristate "Industrial I/O HW buffering"3434+ help3535+ Provides a way to bonding when an IIO device has a direct connection3636+ to another device in hardware. In this case buffers for data transfers3737+ are handled by hardware.3838+3939+ Should be selected by drivers that want to use the generic Hw consumer4040+ interface.4141+3242config IIO_KFIFO_BUF3343 tristate "Industrial I/O buffering based on kfifo"3444 help
···664664}665665EXPORT_SYMBOL_GPL(iio_convert_raw_to_processed);666666667667-static int iio_read_channel_attribute(struct iio_channel *chan,668668- int *val, int *val2,669669- enum iio_chan_info_enum attribute)667667+int iio_read_channel_attribute(struct iio_channel *chan, int *val, int *val2,668668+ enum iio_chan_info_enum attribute)670669{671670 int ret;672671···681682682683 return ret;683684}685685+EXPORT_SYMBOL_GPL(iio_read_channel_attribute);684686685687int iio_read_channel_offset(struct iio_channel *chan, int *val, int *val2)686688{···850850 chan->channel, val, val2, info);851851}852852853853-int iio_write_channel_raw(struct iio_channel *chan, int val)853853+int iio_write_channel_attribute(struct iio_channel *chan, int val, int val2,854854+ enum iio_chan_info_enum attribute)854855{855856 int ret;856857···861860 goto err_unlock;862861 }863862864864- ret = iio_channel_write(chan, val, 0, IIO_CHAN_INFO_RAW);863863+ ret = iio_channel_write(chan, val, val2, attribute);865864err_unlock:866865 mutex_unlock(&chan->indio_dev->info_exist_lock);867866868867 return ret;868868+}869869+EXPORT_SYMBOL_GPL(iio_write_channel_attribute);870870+871871+int iio_write_channel_raw(struct iio_channel *chan, int val)872872+{873873+ return iio_write_channel_attribute(chan, val, 0, IIO_CHAN_INFO_RAW);869874}870875EXPORT_SYMBOL_GPL(iio_write_channel_raw);871876
+18
include/linux/iio/adc/stm32-dfsdm-adc.h
···11+/* SPDX-License-Identifier: GPL-2.0 */22+/*33+ * This file discribe the STM32 DFSDM IIO driver API for audio part44+ *55+ * Copyright (C) 2017, STMicroelectronics - All Rights Reserved66+ * Author(s): Arnaud Pouliquen <arnaud.pouliquen@st.com>.77+ */88+99+#ifndef STM32_DFSDM_ADC_H1010+#define STM32_DFSDM_ADC_H1111+1212+int stm32_dfsdm_get_buff_cb(struct iio_dev *iio_dev,1313+ int (*cb)(const void *data, size_t size,1414+ void *private),1515+ void *private);1616+int stm32_dfsdm_release_buff_cb(struct iio_dev *iio_dev);1717+1818+#endif
+37
include/linux/iio/consumer.h
···134134 void *private),135135 void *private);136136/**137137+ * iio_channel_cb_set_buffer_watermark() - set the buffer watermark.138138+ * @cb_buffer: The callback buffer from whom we want the channel139139+ * information.140140+ * @watermark: buffer watermark in bytes.141141+ *142142+ * This function allows to configure the buffer watermark.143143+ */144144+int iio_channel_cb_set_buffer_watermark(struct iio_cb_buffer *cb_buffer,145145+ size_t watermark);146146+147147+/**137148 * iio_channel_release_all_cb() - release and unregister the callback.138149 * @cb_buffer: The callback buffer that was allocated.139150 */···225214 * do the appropriate transformation.226215 */227216int iio_read_channel_processed(struct iio_channel *chan, int *val);217217+218218+/**219219+ * iio_write_channel_attribute() - Write values to the device attribute.220220+ * @chan: The channel being queried.221221+ * @val: Value being written.222222+ * @val2: Value being written.val2 use depends on attribute type.223223+ * @attribute: info attribute to be read.224224+ *225225+ * Returns an error code or 0.226226+ */227227+int iio_write_channel_attribute(struct iio_channel *chan, int val,228228+ int val2, enum iio_chan_info_enum attribute);229229+230230+/**231231+ * iio_read_channel_attribute() - Read values from the device attribute.232232+ * @chan: The channel being queried.233233+ * @val: Value being written.234234+ * @val2: Value being written.Val2 use depends on attribute type.235235+ * @attribute: info attribute to be written.236236+ *237237+ * Returns an error code if failed. Else returns a description of what is in val238238+ * and val2, such as IIO_VAL_INT_PLUS_MICRO telling us we have a value of val239239+ * + val2/1e6240240+ */241241+int iio_read_channel_attribute(struct iio_channel *chan, int *val,242242+ int *val2, enum iio_chan_info_enum attribute);228243229244/**230245 * iio_write_channel_raw() - write to a given channel