···11+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)22+%YAML 1.233+---44+$id: http://devicetree.org/schemas/iio/adc/adi,ad4000.yaml#55+$schema: http://devicetree.org/meta-schemas/core.yaml#66+77+title: Analog Devices AD4000 and similar Analog to Digital Converters88+99+maintainers:1010+ - Marcelo Schmitt <marcelo.schmitt@analog.com>1111+1212+description: |1313+ Analog Devices AD4000 family of Analog to Digital Converters with SPI support.1414+ Specifications can be found at:1515+ https://www.analog.com/media/en/technical-documentation/data-sheets/ad4000-4004-4008.pdf1616+ https://www.analog.com/media/en/technical-documentation/data-sheets/ad4001-4005.pdf1717+ https://www.analog.com/media/en/technical-documentation/data-sheets/ad4002-4006-4010.pdf1818+ https://www.analog.com/media/en/technical-documentation/data-sheets/ad4003-4007-4011.pdf1919+ https://www.analog.com/media/en/technical-documentation/data-sheets/ad4020-4021-4022.pdf2020+ https://www.analog.com/media/en/technical-documentation/data-sheets/adaq4001.pdf2121+ https://www.analog.com/media/en/technical-documentation/data-sheets/adaq4003.pdf2222+2323+$ref: /schemas/spi/spi-peripheral-props.yaml#2424+2525+properties:2626+ compatible:2727+ oneOf:2828+ - const: adi,ad40002929+ - items:3030+ - enum:3131+ - adi,ad40043232+ - adi,ad40083333+ - const: adi,ad40003434+3535+ - const: adi,ad40013636+ - items:3737+ - enum:3838+ - adi,ad40053939+ - const: adi,ad40014040+4141+ - const: adi,ad40024242+ - items:4343+ - enum:4444+ - adi,ad40064545+ - adi,ad40104646+ - const: adi,ad40024747+4848+ - const: adi,ad40034949+ - items:5050+ - enum:5151+ - adi,ad40075252+ - adi,ad40115353+ - const: adi,ad40035454+5555+ - const: adi,ad40205656+ - items:5757+ - enum:5858+ - adi,ad40215959+ - adi,ad40226060+ - const: adi,ad40206161+6262+ - const: adi,adaq40016363+6464+ - const: adi,adaq40036565+6666+ reg:6767+ maxItems: 16868+6969+ spi-max-frequency:7070+ maximum: 102040816 # for VIO > 2.7 V, 81300813 for VIO > 1.7 V7171+7272+ adi,sdi-pin:7373+ $ref: /schemas/types.yaml#/definitions/string7474+ enum: [ high, low, cs, sdi ]7575+ default: sdi7676+ description:7777+ Describes how the ADC SDI pin is wired. A value of "sdi" indicates that7878+ the ADC SDI is connected to host SDO. "high" indicates that the ADC SDI7979+ pin is hard-wired to logic high (VIO). "low" indicates that it is8080+ hard-wired low (GND). "cs" indicates that the ADC SDI pin is connected to8181+ the host CS line.8282+8383+ '#daisy-chained-devices': true8484+8585+ vdd-supply:8686+ description: A 1.8V supply that powers the chip (VDD).8787+8888+ vio-supply:8989+ description:9090+ A 1.8V to 5.5V supply for the digital inputs and outputs (VIO).9191+9292+ ref-supply:9393+ description:9494+ A 2.5 to 5V supply for the external reference voltage (REF).9595+9696+ cnv-gpios:9797+ description:9898+ When provided, this property indicates the GPIO that is connected to the9999+ CNV pin.100100+ maxItems: 1101101+102102+ adi,high-z-input:103103+ type: boolean104104+ description:105105+ High-Z mode allows the amplifier and RC filter in front of the ADC to be106106+ chosen based on the signal bandwidth of interest, rather than the settling107107+ requirements of the switched capacitor SAR ADC inputs.108108+109109+ adi,gain-milli:110110+ description: |111111+ The hardware gain applied to the ADC input (in milli units).112112+ The gain provided by the ADC input scaler is defined by the hardware113113+ connections between chip pins OUT+, R1K-, R1K1-, R1K+, R1K1+, and OUT-.114114+ If not present, default to 1000 (no actual gain applied).115115+ $ref: /schemas/types.yaml#/definitions/uint16116116+ enum: [454, 909, 1000, 1900]117117+ default: 1000118118+119119+ interrupts:120120+ description:121121+ The SDO pin can also function as a busy indicator. This node should be122122+ connected to an interrupt that is triggered when the SDO line goes low123123+ while the SDI line is high and the CNV line is low ("3-wire" mode) or the124124+ SDI line is low and the CNV line is high ("4-wire" mode); or when the SDO125125+ line goes high while the SDI and CNV lines are high (chain mode),126126+ maxItems: 1127127+128128+required:129129+ - compatible130130+ - reg131131+ - vdd-supply132132+ - vio-supply133133+ - ref-supply134134+135135+allOf:136136+ # The configuration register can only be accessed if SDI is connected to MOSI137137+ - if:138138+ required:139139+ - adi,sdi-pin140140+ then:141141+ properties:142142+ adi,high-z-input: false143143+ # chain mode has lower SCLK max rate144144+ - if:145145+ required:146146+ - '#daisy-chained-devices'147147+ then:148148+ properties:149149+ spi-max-frequency:150150+ maximum: 50000000 # for VIO > 2.7 V, 40000000 for VIO > 1.7 V151151+ # Gain property only applies to ADAQ devices152152+ - if:153153+ properties:154154+ compatible:155155+ not:156156+ contains:157157+ enum:158158+ - adi,adaq4001159159+ - adi,adaq4003160160+ then:161161+ properties:162162+ adi,gain-milli: false163163+164164+unevaluatedProperties: false165165+166166+examples:167167+ - |168168+ #include <dt-bindings/gpio/gpio.h>169169+ spi {170170+ #address-cells = <1>;171171+ #size-cells = <0>;172172+ adc@0 {173173+ compatible = "adi,ad4020";174174+ reg = <0>;175175+ spi-max-frequency = <71000000>;176176+ vdd-supply = <&supply_1_8V>;177177+ vio-supply = <&supply_1_8V>;178178+ ref-supply = <&supply_5V>;179179+ adi,sdi-pin = "cs";180180+ cnv-gpios = <&gpio0 88 GPIO_ACTIVE_HIGH>;181181+ };182182+ };183183+ - |184184+ spi {185185+ #address-cells = <1>;186186+ #size-cells = <0>;187187+ adc@0 {188188+ compatible = "adi,adaq4003";189189+ reg = <0>;190190+ spi-max-frequency = <80000000>;191191+ vdd-supply = <&supply_1_8V>;192192+ vio-supply = <&supply_1_8V>;193193+ ref-supply = <&supply_5V>;194194+ adi,high-z-input;195195+ adi,gain-milli = /bits/ 16 <454>;196196+ };197197+ };
+83
Documentation/spi/spi-summary.rst
···614614already running).615615616616617617+Extensions to the SPI protocol618618+------------------------------619619+The fact that SPI doesn't have a formal specification or standard permits chip620620+manufacturers to implement the SPI protocol in slightly different ways. In most621621+cases, SPI protocol implementations from different vendors are compatible among622622+each other. For example, in SPI mode 0 (CPOL=0, CPHA=0) the bus lines may behave623623+like the following:624624+625625+::626626+627627+ nCSx ___ ___628628+ \_________________________________________________________________/629629+ • •630630+ • •631631+ SCLK ___ ___ ___ ___ ___ ___ ___ ___632632+ _______/ \___/ \___/ \___/ \___/ \___/ \___/ \___/ \_____633633+ • : ; : ; : ; : ; : ; : ; : ; : ; •634634+ • : ; : ; : ; : ; : ; : ; : ; : ; •635635+ MOSI XXX__________ _______ _______ ________XXX636636+ 0xA5 XXX__/ 1 \_0_____/ 1 \_0_______0_____/ 1 \_0_____/ 1 \_XXX637637+ • ; ; ; ; ; ; ; ; •638638+ • ; ; ; ; ; ; ; ; •639639+ MISO XXX__________ _______________________ _______ XXX640640+ 0xBA XXX__/ 1 \_____0_/ 1 1 1 \_____0__/ 1 \____0__XXX641641+642642+Legend::643643+644644+ • marks the start/end of transmission;645645+ : marks when data is clocked into the peripheral;646646+ ; marks when data is clocked into the controller;647647+ X marks when line states are not specified.648648+649649+In some few cases, chips extend the SPI protocol by specifying line behaviors650650+that other SPI protocols don't (e.g. data line state for when CS is not651651+asserted). Those distinct SPI protocols, modes, and configurations are supported652652+by different SPI mode flags.653653+654654+MOSI idle state configuration655655+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^656656+657657+Common SPI protocol implementations don't specify any state or behavior for the658658+MOSI line when the controller is not clocking out data. However, there do exist659659+peripherals that require specific MOSI line state when data is not being clocked660660+out. For example, if the peripheral expects the MOSI line to be high when the661661+controller is not clocking out data (``SPI_MOSI_IDLE_HIGH``), then a transfer in662662+SPI mode 0 would look like the following:663663+664664+::665665+666666+ nCSx ___ ___667667+ \_________________________________________________________________/668668+ • •669669+ • •670670+ SCLK ___ ___ ___ ___ ___ ___ ___ ___671671+ _______/ \___/ \___/ \___/ \___/ \___/ \___/ \___/ \_____672672+ • : ; : ; : ; : ; : ; : ; : ; : ; •673673+ • : ; : ; : ; : ; : ; : ; : ; : ; •674674+ MOSI _____ _______ _______ _______________ ___675675+ 0x56 \_0_____/ 1 \_0_____/ 1 \_0_____/ 1 1 \_0_____/676676+ • ; ; ; ; ; ; ; ; •677677+ • ; ; ; ; ; ; ; ; •678678+ MISO XXX__________ _______________________ _______ XXX679679+ 0xBA XXX__/ 1 \_____0_/ 1 1 1 \_____0__/ 1 \____0__XXX680680+681681+Legend::682682+683683+ • marks the start/end of transmission;684684+ : marks when data is clocked into the peripheral;685685+ ; marks when data is clocked into the controller;686686+ X marks when line states are not specified.687687+688688+In this extension to the usual SPI protocol, the MOSI line state is specified to689689+be kept high when CS is asserted but the controller is not clocking out data to690690+the peripheral and also when CS is not asserted.691691+692692+Peripherals that require this extension must request it by setting the693693+``SPI_MOSI_IDLE_HIGH`` bit into the mode attribute of their ``struct694694+spi_device`` and call spi_setup(). Controllers that support this extension695695+should indicate it by setting ``SPI_MOSI_IDLE_HIGH`` in the mode_bits attribute696696+of their ``struct spi_controller``. The configuration to idle MOSI low is697697+analogous but uses the ``SPI_MOSI_IDLE_LOW`` mode bit.698698+699699+617700THANKS TO618701---------619702Contributors to Linux-SPI discussions include (in alphabetical order,
···39213921 (SPI_TX_DUAL | SPI_TX_QUAD | SPI_TX_OCTAL |39223922 SPI_RX_DUAL | SPI_RX_QUAD | SPI_RX_OCTAL)))39233923 return -EINVAL;39243924+ /* Check against conflicting MOSI idle configuration */39253925+ if ((spi->mode & SPI_MOSI_IDLE_LOW) && (spi->mode & SPI_MOSI_IDLE_HIGH)) {39263926+ dev_err(&spi->dev,39273927+ "setup: MOSI configured to idle low and high at the same time.\n");39283928+ return -EINVAL;39293929+ }39243930 /*39253931 * Help drivers fail *cleanly* when they need options39263932 * that aren't supported with their current controller.
+1
include/linux/spi/spi_bitbang.h
···2424#define BITBANG_CS_ACTIVE 1 /* normally nCS, active low */2525#define BITBANG_CS_INACTIVE 026262727+ void (*set_mosi_idle)(struct spi_device *spi);2728 /* txrx_bufs() may handle dma mapping for transfers that don't2829 * already have one (transfer.{tx,rx}_dma is zero), or use PIO2930 */
+3-2
include/uapi/linux/spi/spi.h
···2828#define SPI_RX_OCTAL _BITUL(14) /* receive with 8 wires */2929#define SPI_3WIRE_HIZ _BITUL(15) /* high impedance turnaround */3030#define SPI_RX_CPHA_FLIP _BITUL(16) /* flip CPHA on Rx only xfer */3131-#define SPI_MOSI_IDLE_LOW _BITUL(17) /* leave mosi line low when idle */3131+#define SPI_MOSI_IDLE_LOW _BITUL(17) /* leave MOSI line low when idle */3232+#define SPI_MOSI_IDLE_HIGH _BITUL(18) /* leave MOSI line high when idle */32333334/*3435 * All the bits defined above should be covered by SPI_MODE_USER_MASK.···3938 * These bits must not overlap. A static assert check should make sure of that.4039 * If adding extra bits, make sure to increase the bit index below as well.4140 */4242-#define SPI_MODE_USER_MASK (_BITUL(18) - 1)4141+#define SPI_MODE_USER_MASK (_BITUL(19) - 1)43424443#endif /* _UAPI_SPI_H */