spi-controller.yaml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. fifo-depth:
  58. $ref: /schemas/types.yaml#/definitions/uint32
  59. description:
  60. Size of the RX and TX data FIFOs in bytes.
  61. rx-fifo-depth:
  62. $ref: /schemas/types.yaml#/definitions/uint32
  63. description:
  64. Size of the RX data FIFO in bytes.
  65. tx-fifo-depth:
  66. $ref: /schemas/types.yaml#/definitions/uint32
  67. description:
  68. Size of the TX data FIFO in bytes.
  69. num-cs:
  70. $ref: /schemas/types.yaml#/definitions/uint32
  71. description:
  72. Total number of chip selects.
  73. spi-slave:
  74. $ref: /schemas/types.yaml#/definitions/flag
  75. description:
  76. The SPI controller acts as a slave, instead of a master.
  77. slave:
  78. type: object
  79. properties:
  80. compatible:
  81. description:
  82. Compatible of the SPI device.
  83. required:
  84. - compatible
  85. patternProperties:
  86. "^.*@[0-9a-f]+$":
  87. type: object
  88. $ref: spi-peripheral-props.yaml
  89. additionalProperties: true
  90. properties:
  91. spi-3wire:
  92. $ref: /schemas/types.yaml#/definitions/flag
  93. description:
  94. The device requires 3-wire mode.
  95. spi-cpha:
  96. $ref: /schemas/types.yaml#/definitions/flag
  97. description:
  98. The device requires shifted clock phase (CPHA) mode.
  99. spi-cpol:
  100. $ref: /schemas/types.yaml#/definitions/flag
  101. description:
  102. The device requires inverse clock polarity (CPOL) mode.
  103. required:
  104. - compatible
  105. - reg
  106. dependencies:
  107. rx-fifo-depth: [ tx-fifo-depth ]
  108. tx-fifo-depth: [ rx-fifo-depth ]
  109. allOf:
  110. - if:
  111. not:
  112. required:
  113. - spi-slave
  114. then:
  115. properties:
  116. "#address-cells":
  117. const: 1
  118. else:
  119. properties:
  120. "#address-cells":
  121. const: 0
  122. - not:
  123. required:
  124. - fifo-depth
  125. - rx-fifo-depth
  126. - not:
  127. required:
  128. - fifo-depth
  129. - tx-fifo-depth
  130. additionalProperties: true
  131. examples:
  132. - |
  133. spi@80010000 {
  134. #address-cells = <1>;
  135. #size-cells = <0>;
  136. compatible = "fsl,imx28-spi";
  137. reg = <0x80010000 0x2000>;
  138. interrupts = <96>;
  139. dmas = <&dma_apbh 0>;
  140. dma-names = "rx-tx";
  141. display@0 {
  142. compatible = "lg,lg4573";
  143. spi-max-frequency = <1000000>;
  144. reg = <0>;
  145. };
  146. sensor@1 {
  147. compatible = "bosch,bme680";
  148. spi-max-frequency = <100000>;
  149. reg = <1>;
  150. };
  151. flash@2 {
  152. compatible = "jedec,spi-nor";
  153. spi-max-frequency = <50000000>;
  154. reg = <2>, <3>;
  155. stacked-memories = /bits/ 64 <0x10000000 0x10000000>;
  156. };
  157. };