summaryrefslogtreecommitdiff
path: root/Documentation/devicetree/bindings/spi/spi-controller.yaml
blob: 5f505810104ddc1da4812f821ec1bd107e297b66 (plain)
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
# SPDX-License-Identifier: GPL-2.0
%YAML 1.2
---
$id: http://devicetree.org/schemas/spi/spi-controller.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: SPI Controller Generic Binding

maintainers:
  - Mark Brown <broonie@kernel.org>

description: |
  SPI busses can be described with a node for the SPI controller device
  and a set of child nodes for each SPI slave on the bus. The system SPI
  controller may be described for use in SPI master mode or in SPI slave mode,
  but not for both at the same time.

properties:
  $nodename:
    pattern: "^spi(@.*|-[0-9a-f])*$"

  "#address-cells":
    enum: [0, 1]

  "#size-cells":
    const: 0

  cs-gpios:
    description: |
      GPIOs used as chip selects.
      If that property is used, the number of chip selects will be
      increased automatically with max(cs-gpios, hardware chip selects).

      So if, for example, the controller has 4 CS lines, and the
      cs-gpios looks like this
        cs-gpios = <&gpio1 0 0>, <0>, <&gpio1 1 0>, <&gpio1 2 0>;

      Then it should be configured so that num_chipselect = 4, with
      the following mapping
        cs0 : &gpio1 0 0
        cs1 : native
        cs2 : &gpio1 1 0
        cs3 : &gpio1 2 0

      The second flag of a gpio descriptor can be GPIO_ACTIVE_HIGH (0)
      or GPIO_ACTIVE_LOW(1). Legacy device trees often use 0.

      There is a special rule set for combining the second flag of an
      cs-gpio with the optional spi-cs-high flag for SPI slaves.

      Each table entry defines how the CS pin is to be physically
      driven (not considering potential gpio inversions by pinmux):

      device node     | cs-gpio       | CS pin state active | Note
      ================+===============+=====================+=====
      spi-cs-high     | -             | H                   |
      -               | -             | L                   |
      spi-cs-high     | ACTIVE_HIGH   | H                   |
      -               | ACTIVE_HIGH   | L                   | 1
      spi-cs-high     | ACTIVE_LOW    | H                   | 2
      -               | ACTIVE_LOW    | L                   |

      Notes:
      1) Should print a warning about polarity inversion.
         Here it would be wise to avoid and define the gpio as
         ACTIVE_LOW.
      2) Should print a warning about polarity inversion
         because ACTIVE_LOW is overridden by spi-cs-high.
         Should be generally avoided and be replaced by
         spi-cs-high + ACTIVE_HIGH.

  num-cs:
    $ref: /schemas/types.yaml#/definitions/uint32
    description:
      Total number of chip selects.

  spi-slave:
    $ref: /schemas/types.yaml#/definitions/flag
    description:
      The SPI controller acts as a slave, instead of a master.

allOf:
  - if:
      not:
        required:
          - spi-slave
    then:
      properties:
        "#address-cells":
          const: 1
    else:
      properties:
        "#address-cells":
          const: 0

patternProperties:
  "^slave$":
    type: object

    properties:
      compatible:
        description:
          Compatible of the SPI device.

    required:
      - compatible

  "^.*@[0-9a-f]+$":
    type: object

    properties:
      compatible:
        description:
          Compatible of the SPI device.

      reg:
        minimum: 0
        maximum: 256
        description:
          Chip select used by the device.

      spi-3wire:
        $ref: /schemas/types.yaml#/definitions/flag
        description:
          The device requires 3-wire mode.

      spi-cpha:
        $ref: /schemas/types.yaml#/definitions/flag
        description:
          The device requires shifted clock phase (CPHA) mode.

      spi-cpol:
        $ref: /schemas/types.yaml#/definitions/flag
        description:
          The device requires inverse clock polarity (CPOL) mode.

      spi-cs-high:
        $ref: /schemas/types.yaml#/definitions/flag
        description:
          The device requires the chip select active high.

      spi-lsb-first:
        $ref: /schemas/types.yaml#/definitions/flag
        description:
          The device requires the LSB first mode.

      spi-max-frequency:
        $ref: /schemas/types.yaml#/definitions/uint32
        description:
          Maximum SPI clocking speed of the device in Hz.

      spi-rx-bus-width:
        description:
          Bus width to the SPI bus used for read transfers.
        $ref: /schemas/types.yaml#/definitions/uint32
        enum: [1, 2, 4, 8]
        default: 1

      spi-rx-delay-us:
        description:
          Delay, in microseconds, after a read transfer.

      spi-tx-bus-width:
        description:
          Bus width to the SPI bus used for write transfers.
        $ref: /schemas/types.yaml#/definitions/uint32
        enum: [1, 2, 4, 8]
        default: 1

      spi-tx-delay-us:
        description:
          Delay, in microseconds, after a write transfer.

    required:
      - compatible
      - reg

additionalProperties: true

examples:
  - |
    spi@f00 {
        #address-cells = <1>;
        #size-cells = <0>;
        compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
        reg = <0xf00 0x20>;
        interrupts = <2 13 0 2 14 0>;
        interrupt-parent = <&mpc5200_pic>;

        ethernet-switch@0 {
            compatible = "micrel,ks8995m";
            spi-max-frequency = <1000000>;
            reg = <0>;
        };

        codec@1 {
            compatible = "ti,tlv320aic26";
            spi-max-frequency = <100000>;
            reg = <1>;
        };
    };