xref: /rk3399_rockchip-uboot/doc/device-tree-bindings/spi/spi-bus.txt (revision a6f70a3d1456e6ce97e0f00ac2d5ff8ae22027d6)
1afb6134fSSimon GlassSPI (Serial Peripheral Interface) busses
2afb6134fSSimon Glass
3afb6134fSSimon GlassSPI busses can be described with a node for the SPI master device
4afb6134fSSimon Glassand a set of child nodes for each SPI slave on the bus.  For this
5afb6134fSSimon Glassdiscussion, it is assumed that the system's SPI controller is in
6afb6134fSSimon GlassSPI master mode.  This binding does not describe SPI controllers
7afb6134fSSimon Glassin slave mode.
8afb6134fSSimon Glass
9afb6134fSSimon GlassThe SPI master node requires the following properties:
10afb6134fSSimon Glass- #address-cells  - number of cells required to define a chip select
11afb6134fSSimon Glass    		address on the SPI bus.
12afb6134fSSimon Glass- #size-cells     - should be zero.
13afb6134fSSimon Glass- compatible      - name of SPI bus controller following generic names
14afb6134fSSimon Glass    		recommended practice.
15afb6134fSSimon Glass- cs-gpios	  - (optional) gpios chip select.
16afb6134fSSimon GlassNo other properties are required in the SPI bus node.  It is assumed
17afb6134fSSimon Glassthat a driver for an SPI bus device will understand that it is an SPI bus.
18afb6134fSSimon GlassHowever, the binding does not attempt to define the specific method for
19afb6134fSSimon Glassassigning chip select numbers.  Since SPI chip select configuration is
20afb6134fSSimon Glassflexible and non-standardized, it is left out of this binding with the
21afb6134fSSimon Glassassumption that board specific platform code will be used to manage
22afb6134fSSimon Glasschip selects.  Individual drivers can define additional properties to
23afb6134fSSimon Glasssupport describing the chip select layout.
24afb6134fSSimon Glass
25afb6134fSSimon GlassOptional property:
26afb6134fSSimon Glass- num-cs : total number of chipselects
27afb6134fSSimon Glass
28afb6134fSSimon GlassIf cs-gpios is used the number of chip select will automatically increased
29afb6134fSSimon Glasswith max(cs-gpios > hw cs)
30afb6134fSSimon Glass
31afb6134fSSimon GlassSo if for example the controller has 2 CS lines, and the cs-gpios
32afb6134fSSimon Glassproperty looks like this:
33afb6134fSSimon Glass
34afb6134fSSimon Glasscs-gpios = <&gpio1 0 0> <0> <&gpio1 1 0> <&gpio1 2 0>;
35afb6134fSSimon Glass
36afb6134fSSimon GlassThen it should be configured so that num_chipselect = 4 with the
37afb6134fSSimon Glassfollowing mapping:
38afb6134fSSimon Glass
39afb6134fSSimon Glasscs0 : &gpio1 0 0
40afb6134fSSimon Glasscs1 : native
41afb6134fSSimon Glasscs2 : &gpio1 1 0
42afb6134fSSimon Glasscs3 : &gpio1 2 0
43afb6134fSSimon Glass
44afb6134fSSimon GlassSPI slave nodes must be children of the SPI master node and can
45afb6134fSSimon Glasscontain the following properties.
46afb6134fSSimon Glass- reg             - (required) chip select address of device.
47afb6134fSSimon Glass- compatible      - (required) name of SPI device following generic names
48afb6134fSSimon Glass    		recommended practice
49afb6134fSSimon Glass- spi-max-frequency - (required) Maximum SPI clocking speed of device in Hz
50afb6134fSSimon Glass- spi-cpol        - (optional) Empty property indicating device requires
51afb6134fSSimon Glass    		inverse clock polarity (CPOL) mode
52afb6134fSSimon Glass- spi-cpha        - (optional) Empty property indicating device requires
53afb6134fSSimon Glass    		shifted clock phase (CPHA) mode
54afb6134fSSimon Glass- spi-cs-high     - (optional) Empty property indicating device requires
55afb6134fSSimon Glass    		chip select active high
56afb6134fSSimon Glass- spi-3wire       - (optional) Empty property indicating device requires
57afb6134fSSimon Glass    		    3-wire mode.
58afb6134fSSimon Glass- spi-tx-bus-width - (optional) The bus width(number of data wires) that
59afb6134fSSimon Glass                      used for MOSI. Defaults to 1 if not present.
60afb6134fSSimon Glass- spi-rx-bus-width - (optional) The bus width(number of data wires) that
61afb6134fSSimon Glass                      used for MISO. Defaults to 1 if not present.
6222052c62SSimon Glass- spi-half-duplex  - (optional) Indicates that the SPI bus should wait for
6322052c62SSimon Glass		      a header byte before reading data from the slave.
64afb6134fSSimon Glass
65afb6134fSSimon GlassSome SPI controllers and devices support Dual and Quad SPI transfer mode.
66*a6f70a3dSVagrant CascadianIt allows data in SPI system transferred in 2 wires(DUAL) or 4 wires(QUAD).
67afb6134fSSimon GlassNow the value that spi-tx-bus-width and spi-rx-bus-width can receive is
68afb6134fSSimon Glassonly 1(SINGLE), 2(DUAL) and 4(QUAD).
69afb6134fSSimon GlassDual/Quad mode is not allowed when 3-wire mode is used.
70afb6134fSSimon Glass
71afb6134fSSimon GlassIf a gpio chipselect is used for the SPI slave the gpio number will be passed
72afb6134fSSimon Glassvia the cs_gpio
73afb6134fSSimon Glass
74afb6134fSSimon GlassSPI example for an MPC5200 SPI bus:
75afb6134fSSimon Glass	spi@f00 {
76afb6134fSSimon Glass		#address-cells = <1>;
77afb6134fSSimon Glass		#size-cells = <0>;
78afb6134fSSimon Glass		compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
79afb6134fSSimon Glass		reg = <0xf00 0x20>;
80afb6134fSSimon Glass		interrupts = <2 13 0 2 14 0>;
81afb6134fSSimon Glass		interrupt-parent = <&mpc5200_pic>;
82afb6134fSSimon Glass
83afb6134fSSimon Glass		ethernet-switch@0 {
84afb6134fSSimon Glass			compatible = "micrel,ks8995m";
85afb6134fSSimon Glass			spi-max-frequency = <1000000>;
86afb6134fSSimon Glass			reg = <0>;
87afb6134fSSimon Glass		};
88afb6134fSSimon Glass
89afb6134fSSimon Glass		codec@1 {
90afb6134fSSimon Glass			compatible = "ti,tlv320aic26";
91afb6134fSSimon Glass			spi-max-frequency = <100000>;
92afb6134fSSimon Glass			reg = <1>;
93afb6134fSSimon Glass		};
94afb6134fSSimon Glass	};
95