Documentation / devicetree / bindings / iio / adc / st,stm32-dfsdm-adc.yaml


Based on kernel version 6.15. Page generated on 2025-05-29 09:08 EST.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/iio/adc/st,stm32-dfsdm-adc.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: STMicroelectronics STM32 DFSDM ADC device driver

maintainers:
  - Fabrice Gasnier <fabrice.gasnier@foss.st.com>
  - Olivier Moysan <olivier.moysan@foss.st.com>

description: |
  STM32 DFSDM ADC is a sigma delta analog-to-digital converter dedicated to
  interface external sigma delta modulators to STM32 micro controllers.
  It is mainly targeted for:
  - Sigma delta modulators (motor control, metering...)
  - PDM microphones (audio digital microphone)
 
  It features up to 8 serial digital interfaces (SPI or Manchester) and
  up to 4 filters on stm32h7 or 6 filters on stm32mp1.
 
  Each child node matches with a filter instance.

properties:
  compatible:
    enum:
      - st,stm32h7-dfsdm
      - st,stm32mp1-dfsdm

  reg:
    maxItems: 1

  clocks:
    items:
      - description:
          Internal clock used for DFSDM digital processing and control blocks.
          dfsdm clock can also feed CLKOUT, when CLKOUT is used.
      - description: audio clock can be used as an alternate to feed CLKOUT.
    minItems: 1

  clock-names:
    items:
      - const: dfsdm
      - const: audio
    minItems: 1
 
  "#address-cells":
    const: 1
 
  "#size-cells":
    const: 0

  spi-max-frequency:
    description:
      SPI clock OUT frequency (Hz). Requested only for SPI master mode.
      This clock must be set according to the "clock" property.
      Frequency must be a multiple of the rcc clock frequency.
      If not, SPI CLKOUT frequency will not be accurate.
    maximum: 20000000

  access-controllers:
    minItems: 1
    maxItems: 2

required:
  - compatible
  - reg
  - clocks
  - clock-names
  - "#address-cells"
  - "#size-cells"

additionalProperties: false

patternProperties:
  "^filter@[0-9]+$":
    type: object
    unevaluatedProperties: false
    description: child node

    properties:
      compatible:
        enum:
          - st,stm32-dfsdm-adc
          - st,stm32-dfsdm-dmic

      reg:
        description: Specifies the DFSDM filter instance used.
        maxItems: 1

      interrupts:
        maxItems: 1

      st,adc-channels:
        description: |
          List of single-ended channels muxed for this ADC.
          On stm32h7 and stm32mp1:
          - For st,stm32-dfsdm-adc: up to 8 channels numbered from 0 to 7.
          - For st,stm32-dfsdm-dmic: 1 channel numbered from 0 to 7.
        $ref: /schemas/types.yaml#/definitions/uint32-array
        items:
          minimum: 0
          maximum: 7
        deprecated: true

      st,adc-channel-names:
        description: List of single-ended channel names.
        deprecated: true

      st,filter-order:
        description: |
          SinC filter order from 0 to 5.
          - 0: FastSinC
          - [1-5]: order 1 to 5.
          For audio purpose it is recommended to use order 3 to 5.
        $ref: /schemas/types.yaml#/definitions/uint32
        maximum: 5
 
      "#io-channel-cells":
        const: 1
 
      '#address-cells':
        const: 1
 
      '#size-cells':
        const: 0

      st,adc-channel-types:
        description: |
          Single-ended channel input type.
          - "SPI_R": SPI with data on rising edge (default)
          - "SPI_F": SPI with data on falling edge
          - "MANCH_R": manchester codec, rising edge = logic 0, falling edge = logic 1
          - "MANCH_F": manchester codec, rising edge = logic 1, falling edge = logic 0
        items:
          enum: [ SPI_R, SPI_F, MANCH_R, MANCH_F ]
        $ref: /schemas/types.yaml#/definitions/non-unique-string-array
        deprecated: true

      st,adc-channel-clk-src:
        description: |
          Conversion clock source.
          - "CLKIN": external SPI clock (CLKIN x)
          - "CLKOUT": internal SPI clock (CLKOUT) (default)
          - "CLKOUT_F": internal SPI clock divided by 2 (falling edge).
          - "CLKOUT_R": internal SPI clock divided by 2 (rising edge).
        items:
          enum: [ CLKIN, CLKOUT, CLKOUT_F, CLKOUT_R ]
        $ref: /schemas/types.yaml#/definitions/non-unique-string-array
        deprecated: true

      st,adc-alt-channel:
        description:
          Must be defined if two sigma delta modulators are
          connected on same SPI input.
          If not set, channel n is connected to SPI input n.
          If set, channel n is connected to SPI input n + 1.
        type: boolean
        deprecated: true

      st,filter0-sync:
        description:
          Set to 1 to synchronize with DFSDM filter instance 0.
          Used for multi microphones synchronization.
        type: boolean

      dmas:
        maxItems: 1

      dma-names:
        items:
          - const: rx

    required:
      - compatible
      - reg
      - interrupts
      - st,filter-order
      - "#io-channel-cells"

    patternProperties:
      "^channel@[0-7]$":
        type: object
        $ref: adc.yaml
        unevaluatedProperties: false
        description: Represents the external channels which are connected to the DFSDM.

        properties:
          reg:
            maximum: 7

          label:
            description:
              Unique name to identify which channel this is.

          st,adc-channel-type:
            description: |
              Single-ended channel input type.
              - "SPI_R": SPI with data on rising edge (default)
              - "SPI_F": SPI with data on falling edge
              - "MANCH_R": manchester codec, rising edge = logic 0, falling edge = logic 1
              - "MANCH_F": manchester codec, rising edge = logic 1, falling edge = logic 0
            $ref: /schemas/types.yaml#/definitions/string
            enum: [ SPI_R, SPI_F, MANCH_R, MANCH_F ]

          st,adc-channel-clk-src:
            description: |
              Conversion clock source.
              - "CLKIN": external SPI clock (CLKIN x)
              - "CLKOUT": internal SPI clock (CLKOUT) (default)
              - "CLKOUT_F": internal SPI clock divided by 2 (falling edge).
              - "CLKOUT_R": internal SPI clock divided by 2 (rising edge).
            $ref: /schemas/types.yaml#/definitions/string
            enum: [ CLKIN, CLKOUT, CLKOUT_F, CLKOUT_R ]

          st,adc-alt-channel:
            description:
              Must be defined if two sigma delta modulators are
              connected on same SPI input.
              If not set, channel n is connected to SPI input n.
              If set, channel n is connected to SPI input n + 1.
            type: boolean

          io-backends:
            description:
              Used to pipe external sigma delta modulator or internal ADC backend to DFSDM channel.
            maxItems: 1

        required:
          - reg

    allOf:
      - if:
          properties:
            compatible:
              contains:
                const: st,stm32-dfsdm-adc

        then:
          properties:
            st,adc-channels:
              minItems: 1
              maxItems: 8

            st,adc-channel-names:
              minItems: 1
              maxItems: 8

            st,adc-channel-types:
              minItems: 1
              maxItems: 8

            st,adc-channel-clk-src:
              minItems: 1
              maxItems: 8

            io-channels:
              description:
                From common IIO binding. Used to pipe external sigma delta
                modulator or internal ADC output to DFSDM channel.
              deprecated: true

          if:
            required:
              - st,adc-channels
          then:
            required:
              - io-channels

          patternProperties:
            "^channel@[0-7]$":
              required:
                - io-backends

      - if:
          properties:
            compatible:
              contains:
                const: st,stm32-dfsdm-dmic

        then:
          properties:
            st,adc-channels:
              maxItems: 1

            st,adc-channel-names:
              maxItems: 1

            st,adc-channel-types:
              maxItems: 1

            st,adc-channel-clk-src:
              maxItems: 1

          required:
            - dmas
            - dma-names

          patternProperties:
            "^dfsdm-dai+$":
              type: object
              additionalProperties: false
              description: child node

              properties:
                compatible:
                  enum:
                    - st,stm32h7-dfsdm-dai
 
                "#sound-dai-cells":
                  const: 0

                io-channels:
                  description:
                    From common IIO binding. Used to pipe external sigma delta
                    modulator or internal ADC output to DFSDM channel.

                port:
                  $ref: /schemas/sound/audio-graph-port.yaml#
                  unevaluatedProperties: false

              required:
                - compatible
                - "#sound-dai-cells"
                - io-channels

allOf:
  - if:
      properties:
        compatible:
          contains:
            const: st,stm32h7-dfsdm

    then:
      patternProperties:
        "^filter@[0-9]+$":
          properties:
            reg:
              items:
                minimum: 0
                maximum: 3

  - if:
      properties:
        compatible:
          contains:
            const: st,stm32mp1-dfsdm

    then:
      patternProperties:
        "^filter@[0-9]+$":
          properties:
            reg:
              items:
                minimum: 0
                maximum: 5

examples:
  - |
    #include <dt-bindings/interrupt-controller/arm-gic.h>
    #include <dt-bindings/clock/stm32mp1-clks.h>
    dfsdm: dfsdm@4400d000 {
      compatible = "st,stm32mp1-dfsdm";
      reg = <0x4400d000 0x800>;
      clocks = <&rcc DFSDM_K>, <&rcc ADFSDM_K>;
      clock-names = "dfsdm", "audio";
      #address-cells = <1>;
      #size-cells = <0>;
 
      // Example 1: Audio use case with generic binding
      dfsdm0: filter@0 {
        compatible = "st,stm32-dfsdm-dmic";
        reg = <0>;
        interrupts = <GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>;
        dmas = <&dmamux1 101 0x400 0x01>;
        dma-names = "rx";
        #io-channel-cells = <1>;
        #address-cells = <1>;
        #size-cells = <0>;
        st,filter-order = <5>;
 
        channel@1 {
          reg = <1>;
          label = "dmic0";
          st,adc-channel-type = "SPI_R";
          st,adc-channel-clk-src = "CLKOUT";
          st,adc-alt-channel;
        };
 
        asoc_pdm0: dfsdm-dai {
          compatible = "st,stm32h7-dfsdm-dai";
          #sound-dai-cells = <0>;
          io-channels = <&dfsdm0 0>;
        };
      };
 
      // Example 2: Analog use case with generic binding
      dfsdm1: filter@1 {
        compatible = "st,stm32-dfsdm-adc";
        reg = <1>;
        interrupts = <GIC_SPI 111 IRQ_TYPE_LEVEL_HIGH>;
        dmas = <&dmamux1 102 0x400 0x01>;
        dma-names = "rx";
        st,filter-order = <1>;
        #io-channel-cells = <1>;
        #address-cells = <1>;
        #size-cells = <0>;
 
        channel@2 {
          reg = <2>;
          label = "in2";
          st,adc-channel-type = "SPI_F";
          st,adc-channel-clk-src = "CLKOUT";
          st,adc-alt-channel;
          io-backends = <&sd_adc2>;
        };
 
        channel@3 {
          reg = <3>;
          label = "in3";
          st,adc-channel-type = "SPI_R";
          st,adc-channel-clk-src = "CLKOUT";
          io-backends = <&sd_adc3>;
        };
      };
    };

...