1*4882a593SmuzhiyunSPI (Serial Peripheral Interface) busses 2*4882a593Smuzhiyun 3*4882a593SmuzhiyunSPI busses can be described with a node for the SPI master device 4*4882a593Smuzhiyunand a set of child nodes for each SPI slave on the bus. For this 5*4882a593Smuzhiyundiscussion, it is assumed that the system's SPI controller is in 6*4882a593SmuzhiyunSPI master mode. This binding does not describe SPI controllers 7*4882a593Smuzhiyunin slave mode. 8*4882a593Smuzhiyun 9*4882a593SmuzhiyunThe SPI master node requires the following properties: 10*4882a593Smuzhiyun- #address-cells - number of cells required to define a chip select 11*4882a593Smuzhiyun address on the SPI bus. 12*4882a593Smuzhiyun- #size-cells - should be zero. 13*4882a593Smuzhiyun- compatible - name of SPI bus controller following generic names 14*4882a593Smuzhiyun recommended practice. 15*4882a593Smuzhiyun- cs-gpios - (optional) gpios chip select. 16*4882a593SmuzhiyunNo other properties are required in the SPI bus node. It is assumed 17*4882a593Smuzhiyunthat a driver for an SPI bus device will understand that it is an SPI bus. 18*4882a593SmuzhiyunHowever, the binding does not attempt to define the specific method for 19*4882a593Smuzhiyunassigning chip select numbers. Since SPI chip select configuration is 20*4882a593Smuzhiyunflexible and non-standardized, it is left out of this binding with the 21*4882a593Smuzhiyunassumption that board specific platform code will be used to manage 22*4882a593Smuzhiyunchip selects. Individual drivers can define additional properties to 23*4882a593Smuzhiyunsupport describing the chip select layout. 24*4882a593Smuzhiyun 25*4882a593SmuzhiyunOptional property: 26*4882a593Smuzhiyun- num-cs : total number of chipselects 27*4882a593Smuzhiyun 28*4882a593SmuzhiyunIf cs-gpios is used the number of chip select will automatically increased 29*4882a593Smuzhiyunwith max(cs-gpios > hw cs) 30*4882a593Smuzhiyun 31*4882a593SmuzhiyunSo if for example the controller has 2 CS lines, and the cs-gpios 32*4882a593Smuzhiyunproperty looks like this: 33*4882a593Smuzhiyun 34*4882a593Smuzhiyuncs-gpios = <&gpio1 0 0> <0> <&gpio1 1 0> <&gpio1 2 0>; 35*4882a593Smuzhiyun 36*4882a593SmuzhiyunThen it should be configured so that num_chipselect = 4 with the 37*4882a593Smuzhiyunfollowing mapping: 38*4882a593Smuzhiyun 39*4882a593Smuzhiyuncs0 : &gpio1 0 0 40*4882a593Smuzhiyuncs1 : native 41*4882a593Smuzhiyuncs2 : &gpio1 1 0 42*4882a593Smuzhiyuncs3 : &gpio1 2 0 43*4882a593Smuzhiyun 44*4882a593SmuzhiyunSPI slave nodes must be children of the SPI master node and can 45*4882a593Smuzhiyuncontain the following properties. 46*4882a593Smuzhiyun- reg - (required) chip select address of device. 47*4882a593Smuzhiyun- compatible - (required) name of SPI device following generic names 48*4882a593Smuzhiyun recommended practice 49*4882a593Smuzhiyun- spi-max-frequency - (required) Maximum SPI clocking speed of device in Hz 50*4882a593Smuzhiyun- spi-cpol - (optional) Empty property indicating device requires 51*4882a593Smuzhiyun inverse clock polarity (CPOL) mode 52*4882a593Smuzhiyun- spi-cpha - (optional) Empty property indicating device requires 53*4882a593Smuzhiyun shifted clock phase (CPHA) mode 54*4882a593Smuzhiyun- spi-cs-high - (optional) Empty property indicating device requires 55*4882a593Smuzhiyun chip select active high 56*4882a593Smuzhiyun- spi-3wire - (optional) Empty property indicating device requires 57*4882a593Smuzhiyun 3-wire mode. 58*4882a593Smuzhiyun- spi-tx-bus-width - (optional) The bus width(number of data wires) that 59*4882a593Smuzhiyun used for MOSI. Defaults to 1 if not present. 60*4882a593Smuzhiyun- spi-rx-bus-width - (optional) The bus width(number of data wires) that 61*4882a593Smuzhiyun used for MISO. Defaults to 1 if not present. 62*4882a593Smuzhiyun- spi-half-duplex - (optional) Indicates that the SPI bus should wait for 63*4882a593Smuzhiyun a header byte before reading data from the slave. 64*4882a593Smuzhiyun 65*4882a593SmuzhiyunSome SPI controllers and devices support Dual and Quad SPI transfer mode. 66*4882a593SmuzhiyunIt allows data in SPI system transferred in 2 wires(DUAL) or 4 wires(QUAD). 67*4882a593SmuzhiyunNow the value that spi-tx-bus-width and spi-rx-bus-width can receive is 68*4882a593Smuzhiyunonly 1(SINGLE), 2(DUAL) and 4(QUAD). 69*4882a593SmuzhiyunDual/Quad mode is not allowed when 3-wire mode is used. 70*4882a593Smuzhiyun 71*4882a593SmuzhiyunIf a gpio chipselect is used for the SPI slave the gpio number will be passed 72*4882a593Smuzhiyunvia the cs_gpio 73*4882a593Smuzhiyun 74*4882a593SmuzhiyunSPI example for an MPC5200 SPI bus: 75*4882a593Smuzhiyun spi@f00 { 76*4882a593Smuzhiyun #address-cells = <1>; 77*4882a593Smuzhiyun #size-cells = <0>; 78*4882a593Smuzhiyun compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi"; 79*4882a593Smuzhiyun reg = <0xf00 0x20>; 80*4882a593Smuzhiyun interrupts = <2 13 0 2 14 0>; 81*4882a593Smuzhiyun interrupt-parent = <&mpc5200_pic>; 82*4882a593Smuzhiyun 83*4882a593Smuzhiyun ethernet-switch@0 { 84*4882a593Smuzhiyun compatible = "micrel,ks8995m"; 85*4882a593Smuzhiyun spi-max-frequency = <1000000>; 86*4882a593Smuzhiyun reg = <0>; 87*4882a593Smuzhiyun }; 88*4882a593Smuzhiyun 89*4882a593Smuzhiyun codec@1 { 90*4882a593Smuzhiyun compatible = "ti,tlv320aic26"; 91*4882a593Smuzhiyun spi-max-frequency = <100000>; 92*4882a593Smuzhiyun reg = <1>; 93*4882a593Smuzhiyun }; 94*4882a593Smuzhiyun }; 95