spi-controller.yaml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. title: SPI Controller Common Properties
  7. maintainers:
  8. - Mark Brown <broonie@kernel.org>
  9. description: |
  10. SPI busses can be described with a node for the SPI controller device
  11. and a set of child nodes for each SPI slave on the bus. The system SPI
  12. controller may be described for use in SPI master mode or in SPI slave mode,
  13. but not for both at the same time.
  14. properties:
  15. $nodename:
  16. pattern: "^spi(@.*|-([0-9]|[1-9][0-9]+))?$"
  17. "#address-cells":
  18. enum: [0, 1]
  19. "#size-cells":
  20. const: 0
  21. cs-gpios:
  22. description: |
  23. GPIOs used as chip selects.
  24. If that property is used, the number of chip selects will be
  25. increased automatically with max(cs-gpios, hardware chip selects).
  26. So if, for example, the controller has 4 CS lines, and the
  27. cs-gpios looks like this
  28. cs-gpios = <&gpio1 0 0>, <0>, <&gpio1 1 0>, <&gpio1 2 0>;
  29. Then it should be configured so that num_chipselect = 4, with
  30. the following mapping
  31. cs0 : &gpio1 0 0
  32. cs1 : native
  33. cs2 : &gpio1 1 0
  34. cs3 : &gpio1 2 0
  35. The second flag of a gpio descriptor can be GPIO_ACTIVE_HIGH (0)
  36. or GPIO_ACTIVE_LOW(1). Legacy device trees often use 0.
  37. There is a special rule set for combining the second flag of an
  38. cs-gpio with the optional spi-cs-high flag for SPI slaves.
  39. Each table entry defines how the CS pin is to be physically
  40. driven (not considering potential gpio inversions by pinmux):
  41. device node | cs-gpio | CS pin state active | Note
  42. ================+===============+=====================+=====
  43. spi-cs-high | - | H |
  44. - | - | L |
  45. spi-cs-high | ACTIVE_HIGH | H |
  46. - | ACTIVE_HIGH | L | 1
  47. spi-cs-high | ACTIVE_LOW | H | 2
  48. - | ACTIVE_LOW | L |
  49. Notes:
  50. 1) Should print a warning about polarity inversion.
  51. Here it would be wise to avoid and define the gpio as
  52. ACTIVE_LOW.
  53. 2) Should print a warning about polarity inversion
  54. because ACTIVE_LOW is overridden by spi-cs-high.
  55. Should be generally avoided and be replaced by
  56. spi-cs-high + ACTIVE_HIGH.
  57. The simplest way to obtain an active-high CS signal is to configure the
  58. controller's cs-gpio property with the ACTIVE_HIGH flag and set the
  59. peripheral's spi-cs-high property. See example below for a better
  60. understanding.
  61. fifo-depth:
  62. $ref: /schemas/types.yaml#/definitions/uint32
  63. description:
  64. Size of the RX and TX data FIFOs in bytes.
  65. rx-fifo-depth:
  66. $ref: /schemas/types.yaml#/definitions/uint32
  67. description:
  68. Size of the RX data FIFO in bytes.
  69. tx-fifo-depth:
  70. $ref: /schemas/types.yaml#/definitions/uint32
  71. description:
  72. Size of the TX data FIFO in bytes.
  73. num-cs:
  74. $ref: /schemas/types.yaml#/definitions/uint32
  75. description:
  76. Total number of chip selects.
  77. spi-slave:
  78. $ref: /schemas/types.yaml#/definitions/flag
  79. description:
  80. The SPI controller acts as a slave, instead of a master.
  81. slave:
  82. type: object
  83. properties:
  84. compatible:
  85. description:
  86. Compatible of the SPI device.
  87. required:
  88. - compatible
  89. patternProperties:
  90. "@[0-9a-f]+$":
  91. type: object
  92. $ref: spi-peripheral-props.yaml
  93. additionalProperties: true
  94. properties:
  95. spi-3wire:
  96. $ref: /schemas/types.yaml#/definitions/flag
  97. description:
  98. The device requires 3-wire mode.
  99. spi-cpha:
  100. $ref: /schemas/types.yaml#/definitions/flag
  101. description:
  102. The device requires shifted clock phase (CPHA) mode.
  103. spi-cpol:
  104. $ref: /schemas/types.yaml#/definitions/flag
  105. description:
  106. The device requires inverse clock polarity (CPOL) mode.
  107. required:
  108. - compatible
  109. - reg
  110. dependencies:
  111. rx-fifo-depth: [ tx-fifo-depth ]
  112. tx-fifo-depth: [ rx-fifo-depth ]
  113. allOf:
  114. - if:
  115. not:
  116. required:
  117. - spi-slave
  118. then:
  119. properties:
  120. "#address-cells":
  121. const: 1
  122. else:
  123. properties:
  124. "#address-cells":
  125. const: 0
  126. - not:
  127. required:
  128. - fifo-depth
  129. - rx-fifo-depth
  130. - not:
  131. required:
  132. - fifo-depth
  133. - tx-fifo-depth
  134. additionalProperties: true
  135. examples:
  136. - |
  137. spi@80010000 {
  138. #address-cells = <1>;
  139. #size-cells = <0>;
  140. compatible = "fsl,imx28-spi";
  141. reg = <0x80010000 0x2000>;
  142. interrupts = <96>;
  143. dmas = <&dma_apbh 0>;
  144. dma-names = "rx-tx";
  145. display@0 {
  146. compatible = "lg,lg4573";
  147. spi-max-frequency = <1000000>;
  148. reg = <0>;
  149. };
  150. sensor@1 {
  151. compatible = "bosch,bme680";
  152. spi-max-frequency = <100000>;
  153. reg = <1>;
  154. };
  155. flash@2 {
  156. compatible = "jedec,spi-nor";
  157. spi-max-frequency = <50000000>;
  158. reg = <2>, <3>;
  159. stacked-memories = /bits/ 64 <0x10000000 0x10000000>;
  160. };
  161. };
  162. - |
  163. #include <dt-bindings/gpio/gpio.h>
  164. spi@20204000 {
  165. #address-cells = <1>;
  166. #size-cells = <0>;
  167. compatible = "brcm,bcm2835-spi";
  168. reg = <0x7e204000 0x1000>;
  169. interrupts = <2 22>;
  170. clocks = <&clk_spi>;
  171. cs-gpios = <&gpio 8 GPIO_ACTIVE_HIGH>;
  172. display@0 {
  173. compatible = "lg,lg4573";
  174. spi-max-frequency = <1000000>;
  175. reg = <0>;
  176. spi-cs-high;
  177. };
  178. };