Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: Add YAML schemas for the generic SPI options

The SPI controllers have a bunch of generic options that are needed in a
device tree. Add a YAML schemas for those.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Maxime Ripard and committed by
Mark Brown
0a1b9293 9783da23

+162 -111
+1 -111
Documentation/devicetree/bindings/spi/spi-bus.txt
··· 1 - SPI (Serial Peripheral Interface) busses 2 - 3 - SPI busses can be described with a node for the SPI controller device 4 - and a set of child nodes for each SPI slave on the bus. The system's SPI 5 - controller may be described for use in SPI master mode or in SPI slave mode, 6 - but not for both at the same time. 7 - 8 - The SPI controller node requires the following properties: 9 - - compatible - Name of SPI bus controller following generic names 10 - recommended practice. 11 - 12 - In master mode, the SPI controller node requires the following additional 13 - properties: 14 - - #address-cells - number of cells required to define a chip select 15 - address on the SPI bus. 16 - - #size-cells - should be zero. 17 - 18 - In slave mode, the SPI controller node requires one additional property: 19 - - spi-slave - Empty property. 20 - 21 - No other properties are required in the SPI bus node. It is assumed 22 - that a driver for an SPI bus device will understand that it is an SPI bus. 23 - However, the binding does not attempt to define the specific method for 24 - assigning chip select numbers. Since SPI chip select configuration is 25 - flexible and non-standardized, it is left out of this binding with the 26 - assumption that board specific platform code will be used to manage 27 - chip selects. Individual drivers can define additional properties to 28 - support describing the chip select layout. 29 - 30 - Optional properties (master mode only): 31 - - cs-gpios - gpios chip select. 32 - - num-cs - total number of chipselects. 33 - 34 - If cs-gpios is used the number of chip selects will be increased automatically 35 - with max(cs-gpios > hw cs). 36 - 37 - So if for example the controller has 2 CS lines, and the cs-gpios 38 - property looks like this: 39 - 40 - cs-gpios = <&gpio1 0 0>, <0>, <&gpio1 1 0>, <&gpio1 2 0>; 41 - 42 - Then it should be configured so that num_chipselect = 4 with the 43 - following mapping: 44 - 45 - cs0 : &gpio1 0 0 46 - cs1 : native 47 - cs2 : &gpio1 1 0 48 - cs3 : &gpio1 2 0 49 - 50 - 51 - SPI slave nodes must be children of the SPI controller node. 52 - 53 - In master mode, one or more slave nodes (up to the number of chip selects) can 54 - be present. Required properties are: 55 - - compatible - Name of SPI device following generic names recommended 56 - practice. 57 - - reg - Chip select address of device. 58 - - spi-max-frequency - Maximum SPI clocking speed of device in Hz. 59 - 60 - In slave mode, the (single) slave node is optional. 61 - If present, it must be called "slave". Required properties are: 62 - - compatible - Name of SPI device following generic names recommended 63 - practice. 64 - 65 - All slave nodes can contain the following optional properties: 66 - - spi-cpol - Empty property indicating device requires inverse clock 67 - polarity (CPOL) mode. 68 - - spi-cpha - Empty property indicating device requires shifted clock 69 - phase (CPHA) mode. 70 - - spi-cs-high - Empty property indicating device requires chip select 71 - active high. 72 - - spi-3wire - Empty property indicating device requires 3-wire mode. 73 - - spi-lsb-first - Empty property indicating device requires LSB first mode. 74 - - spi-tx-bus-width - The bus width (number of data wires) that is used for MOSI. 75 - Defaults to 1 if not present. 76 - - spi-rx-bus-width - The bus width (number of data wires) that is used for MISO. 77 - Defaults to 1 if not present. 78 - - spi-rx-delay-us - Microsecond delay after a read transfer. 79 - - spi-tx-delay-us - Microsecond delay after a write transfer. 80 - 81 - Some SPI controllers and devices support Dual and Quad SPI transfer mode. 82 - It allows data in the SPI system to be transferred using 2 wires (DUAL) or 4 83 - wires (QUAD). 84 - Now the value that spi-tx-bus-width and spi-rx-bus-width can receive is 85 - only 1 (SINGLE), 2 (DUAL) and 4 (QUAD). 86 - Dual/Quad mode is not allowed when 3-wire mode is used. 87 - 88 - If a gpio chipselect is used for the SPI slave the gpio number will be passed 89 - via the SPI master node cs-gpios property. 90 - 91 - SPI example for an MPC5200 SPI bus: 92 - spi@f00 { 93 - #address-cells = <1>; 94 - #size-cells = <0>; 95 - compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi"; 96 - reg = <0xf00 0x20>; 97 - interrupts = <2 13 0 2 14 0>; 98 - interrupt-parent = <&mpc5200_pic>; 99 - 100 - ethernet-switch@0 { 101 - compatible = "micrel,ks8995m"; 102 - spi-max-frequency = <1000000>; 103 - reg = <0>; 104 - }; 105 - 106 - codec@1 { 107 - compatible = "ti,tlv320aic26"; 108 - spi-max-frequency = <100000>; 109 - reg = <1>; 110 - }; 111 - }; 1 + This file has moved to spi-controller.yaml.
+161
Documentation/devicetree/bindings/spi/spi-controller.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/spi/spi-controller.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: SPI Controller Generic Binding 8 + 9 + maintainers: 10 + - Mark Brown <broonie@kernel.org> 11 + 12 + description: | 13 + SPI busses can be described with a node for the SPI controller device 14 + and a set of child nodes for each SPI slave on the bus. The system SPI 15 + controller may be described for use in SPI master mode or in SPI slave mode, 16 + but not for both at the same time. 17 + 18 + properties: 19 + $nodename: 20 + pattern: "^spi(@.*|-[0-9a-f])*$" 21 + 22 + "#address-cells": 23 + const: 1 24 + 25 + "#size-cells": 26 + const: 0 27 + 28 + cs-gpios: 29 + description: | 30 + GPIOs used as chip selects. 31 + If that property is used, the number of chip selects will be 32 + increased automatically with max(cs-gpios, hardware chip selects). 33 + 34 + So if, for example, the controller has 2 CS lines, and the 35 + cs-gpios looks like this 36 + cs-gpios = <&gpio1 0 0>, <0>, <&gpio1 1 0>, <&gpio1 2 0>; 37 + 38 + Then it should be configured so that num_chipselect = 4, with 39 + the following mapping 40 + cs0 : &gpio1 0 0 41 + cs1 : native 42 + cs2 : &gpio1 1 0 43 + cs3 : &gpio1 2 0 44 + 45 + num-cs: 46 + $ref: /schemas/types.yaml#/definitions/uint32 47 + description: 48 + Total number of chip selects. 49 + 50 + spi-slave: 51 + $ref: /schemas/types.yaml#/definitions/flag 52 + description: 53 + The SPI controller acts as a slave, instead of a master. 54 + 55 + patternProperties: 56 + "^slave$": 57 + type: object 58 + 59 + properties: 60 + compatible: 61 + description: 62 + Compatible of the SPI device. 63 + 64 + required: 65 + - compatible 66 + 67 + "^.*@[0-9a-f]+$": 68 + type: object 69 + 70 + properties: 71 + compatible: 72 + description: 73 + Compatible of the SPI device. 74 + 75 + reg: 76 + maxItems: 1 77 + minimum: 0 78 + maximum: 256 79 + description: 80 + Chip select used by the device. 81 + 82 + spi-3wire: 83 + $ref: /schemas/types.yaml#/definitions/flag 84 + description: 85 + The device requires 3-wire mode. 86 + 87 + spi-cpha: 88 + $ref: /schemas/types.yaml#/definitions/flag 89 + description: 90 + The device requires shifted clock phase (CPHA) mode. 91 + 92 + spi-cpol: 93 + $ref: /schemas/types.yaml#/definitions/flag 94 + description: 95 + The device requires inverse clock polarity (CPOL) mode. 96 + 97 + spi-cs-high: 98 + $ref: /schemas/types.yaml#/definitions/flag 99 + description: 100 + The device requires the chip select active high. 101 + 102 + spi-lsb-first: 103 + $ref: /schemas/types.yaml#/definitions/flag 104 + description: 105 + The device requires the LSB first mode. 106 + 107 + spi-max-frequency: 108 + $ref: /schemas/types.yaml#/definitions/uint32 109 + description: 110 + Maximum SPI clocking speed of the device in Hz. 111 + 112 + spi-rx-bus-width: 113 + allOf: 114 + - $ref: /schemas/types.yaml#/definitions/uint32 115 + - enum: [ 1, 2, 4 ] 116 + - default: 1 117 + description: 118 + Bus width to the SPI bus used for MISO. 119 + 120 + spi-rx-delay-us: 121 + description: 122 + Delay, in microseconds, after a read transfer. 123 + 124 + spi-tx-bus-width: 125 + allOf: 126 + - $ref: /schemas/types.yaml#/definitions/uint32 127 + - enum: [ 1, 2, 4 ] 128 + - default: 1 129 + description: 130 + Bus width to the SPI bus used for MOSI. 131 + 132 + spi-tx-delay-us: 133 + description: 134 + Delay, in microseconds, after a write transfer. 135 + 136 + required: 137 + - compatible 138 + - reg 139 + 140 + examples: 141 + - | 142 + spi@f00 { 143 + #address-cells = <1>; 144 + #size-cells = <0>; 145 + compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi"; 146 + reg = <0xf00 0x20>; 147 + interrupts = <2 13 0 2 14 0>; 148 + interrupt-parent = <&mpc5200_pic>; 149 + 150 + ethernet-switch@0 { 151 + compatible = "micrel,ks8995m"; 152 + spi-max-frequency = <1000000>; 153 + reg = <0>; 154 + }; 155 + 156 + codec@1 { 157 + compatible = "ti,tlv320aic26"; 158 + spi-max-frequency = <100000>; 159 + reg = <1>; 160 + }; 161 + };