# SPI Controller Common Properties

_Peios Kernel / Hardware and drivers / Device-tree binding reference / Spi bindings_

> Device-tree binding reference for SPI Controller Common Properties.

<!-- SPDX-License-Identifier: GPL-2.0 -->


<a id="dt-root"></a>

**Schema identifier (<code>&#36;id</code>):** <span id="dt-09f478f44eb202ea573e"><code>&#34;http&#58;&#47;&#47;devicetree&#46;org&#47;schemas&#47;spi&#47;spi&#45;controller&#46;yaml&#35;&#34;</code></span>

**Schema dialect (<code>&#36;schema</code>):** <span id="dt-dcb375baab6014763a68"><code>&#34;http&#58;&#47;&#47;devicetree&#46;org&#47;meta&#45;schemas&#47;core&#46;yaml&#35;&#34;</code></span>

<a id="dt-e46b5a5dd81dbd751c9f"></a>

**Maintainers (<code>maintainers</code>):** <a id="dt-fbc39820abb8bb999095"></a> <span id="dt-fb78ddfc22abfc6fe56d"><code>&#34;Mark Brown &#60;broonie&#64;kernel&#46;org&#62;&#34;</code></span>

<div id="dt-6d1c5ef59f0239d38c02">
<p style="white-space: pre-wrap">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.</p>
</div>

<a id="dt-e1f655ed0ff4d595dadc"></a>

## Properties and child nodes (<code>properties</code>)

<a id="dt-5155525ecd924660ec0a"></a>

### <code>&#36;nodename</code> — not listed as required here

**String pattern (<code>pattern</code>):** <span id="dt-0b2111a24a010949ece7"><code>&#34;&#94;spi&#40;&#64;&#46;&#42;&#124;&#45;&#40;&#91;0&#45;9&#93;&#124;&#91;1&#45;9&#93;&#91;0&#45;9&#93;&#43;&#41;&#41;&#63;&#36;&#34;</code></span>

<a id="dt-2efe70314a961a652abe"></a>

### <code>&#35;address&#45;cells</code> — not listed as required here

**Allowed values (<code>enum</code>):** <a id="dt-01d9ce7fc56f712455be"></a> <span id="dt-94d3735d14e27e2d7df1"><code>0</code></span>, <span id="dt-0dda607ef98de398e3f7"><code>1</code></span>

<a id="dt-ee0e5bf71366d312f1dc"></a>

### <code>&#35;size&#45;cells</code> — not listed as required here

**Exact value (<code>const</code>):** <span id="dt-793e842f88ef513a8f93"><code>0</code></span>

<a id="dt-753d71364d8d5e562885"></a>

### <code>cs&#45;gpios</code> — not listed as required here

<div id="dt-dd9e28225d0ed2cf0953">
<p style="white-space: pre-wrap">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).</p>
<pre><code>So if, for example, the controller has 4 CS lines, and the
cs-gpios looks like this
  cs-gpios = &lt;&amp;gpio1 0 0&gt;, &lt;0&gt;, &lt;&amp;gpio1 1 0&gt;, &lt;&amp;gpio1 2 0&gt;;</code></pre>
<pre><code>Then it should be configured so that num_chipselect = 4, with
the following mapping
  cs0 : &amp;gpio1 0 0
  cs1 : native
  cs2 : &amp;gpio1 1 0
  cs3 : &amp;gpio1 2 0</code></pre>
<p style="white-space: pre-wrap">The second flag of a gpio descriptor can be GPIO_ACTIVE_HIGH (0)
or GPIO_ACTIVE_LOW(1). Legacy device trees often use 0.</p>
<p style="white-space: pre-wrap">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.</p>
<p style="white-space: pre-wrap">Each table entry defines how the CS pin is to be physically
driven (not considering potential gpio inversions by pinmux):</p>
<p style="white-space: pre-wrap">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                   |</p>
<pre><code>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.</code></pre>
<p style="white-space: pre-wrap">The simplest way to obtain an active-high CS signal is to configure the
controller's cs-gpio property with the ACTIVE_HIGH flag and set the
peripheral's spi-cs-high property. See example below for a better
understanding.</p>
</div>

<a id="dt-9009089ae7f3a277016d"></a>

### <code>fifo&#45;depth</code> — not listed as required here

**Shared schema rule (<code>&#36;ref</code>):** <span id="dt-463006755219770b9d90">[<code>&#47;schemas&#47;types&#46;yaml&#35;&#47;definitions&#47;uint32</code>](</kernel/hardware/devicetree-bindings/dt-shared/types.md#dt-d57795d6573ee5d67d37>)</span>

<div id="dt-6001d2d747c8109a3155">
<p style="white-space: pre-wrap">Size of the RX and TX data FIFOs in bytes.</p>
</div>

<a id="dt-21f06d74a526f9b7fd66"></a>

### <code>rx&#45;fifo&#45;depth</code> — not listed as required here

**Shared schema rule (<code>&#36;ref</code>):** <span id="dt-9898e4014fcfa6772ee6">[<code>&#47;schemas&#47;types&#46;yaml&#35;&#47;definitions&#47;uint32</code>](</kernel/hardware/devicetree-bindings/dt-shared/types.md#dt-d57795d6573ee5d67d37>)</span>

<div id="dt-d06a5ab3603fa520ed22">
<p style="white-space: pre-wrap">Size of the RX data FIFO in bytes.</p>
</div>

<a id="dt-32fb0597a0aa6823f10f"></a>

### <code>tx&#45;fifo&#45;depth</code> — not listed as required here

**Shared schema rule (<code>&#36;ref</code>):** <span id="dt-02de27648aea5e6ba453">[<code>&#47;schemas&#47;types&#46;yaml&#35;&#47;definitions&#47;uint32</code>](</kernel/hardware/devicetree-bindings/dt-shared/types.md#dt-d57795d6573ee5d67d37>)</span>

<div id="dt-74b9796b86169d212ff4">
<p style="white-space: pre-wrap">Size of the TX data FIFO in bytes.</p>
</div>

<a id="dt-5c31eada7ce55d009584"></a>

### <code>num&#45;cs</code> — not listed as required here

**Shared schema rule (<code>&#36;ref</code>):** <span id="dt-1cb1a79e6a85347597b1">[<code>&#47;schemas&#47;types&#46;yaml&#35;&#47;definitions&#47;uint32</code>](</kernel/hardware/devicetree-bindings/dt-shared/types.md#dt-d57795d6573ee5d67d37>)</span>

<div id="dt-46f5e5ea35effa57911d">
<p style="white-space: pre-wrap">Total number of chip selects.</p>
</div>

<a id="dt-3a14c7423158b2fb4f98"></a>

### <code>spi&#45;slave</code> — not listed as required here

**Shared schema rule (<code>&#36;ref</code>):** <span id="dt-1174bfeed279b1c8540e">[<code>&#47;schemas&#47;types&#46;yaml&#35;&#47;definitions&#47;flag</code>](</kernel/hardware/devicetree-bindings/dt-shared/types.md#dt-4496aa5cdf2440415eba>)</span>

<div id="dt-6876bb6400602781abb1">
<p style="white-space: pre-wrap">The SPI controller acts as a slave, instead of a master.</p>
</div>

<a id="dt-52a60d8f2f14196ab479"></a>

### <code>slave</code> — not listed as required here

**Value type (<code>type</code>):** <span id="dt-a3c8b8b9183136056150"><code>&#34;object&#34;</code></span>

<a id="dt-f25cc43bc84d9e536b9e"></a>

#### Properties and child nodes (<code>properties</code>)

<a id="dt-d7bcdf636f3c0aadc573"></a>

**<code>compatible</code> — required here**

<div id="dt-46c464050f5e03a27ff5">
<p style="white-space: pre-wrap">Compatible of the SPI device.</p>
</div>

**Required in this object (<code>required</code>):** <a id="dt-43af8739f681b20388f7"></a> <span id="dt-2acb283222828aece58d"><code>&#34;compatible&#34;</code></span>

<a id="dt-e92215bd3c2f5373b164"></a>

## Properties matching a name pattern (<code>patternProperties</code>)

<a id="dt-573587cdb3ff39c5b5e0"></a>

### <code>&#64;&#91;0&#45;9a&#45;f&#93;&#43;&#36;</code> — name matches this regular expression

**Value type (<code>type</code>):** <span id="dt-2a128fbeeefbb419a6c3"><code>&#34;object&#34;</code></span>

**Shared schema rule (<code>&#36;ref</code>):** <span id="dt-1fbf03b5c1016547cb52">[<code>spi&#45;peripheral&#45;props&#46;yaml</code>](</kernel/hardware/devicetree-bindings/dt-spi/spi-peripheral-props.md#dt-root>)</span>

<a id="dt-40e29caf708abece0110"></a>

#### Properties not matched by properties or patternProperties in this schema (<code>additionalProperties</code>)

<code>true</code>

Allowed by this rule.

<a id="dt-2086facb1246423cc914"></a>

#### Properties and child nodes (<code>properties</code>)

<a id="dt-1a915969f01bf1d70921"></a>

**<code>spi&#45;3wire</code> — not listed as required here**

**Shared schema rule (<code>&#36;ref</code>):** <span id="dt-9e6d7540823ca328360b">[<code>&#47;schemas&#47;types&#46;yaml&#35;&#47;definitions&#47;flag</code>](</kernel/hardware/devicetree-bindings/dt-shared/types.md#dt-4496aa5cdf2440415eba>)</span>

<div id="dt-0ecb447f95aa746acc44">
<p style="white-space: pre-wrap">The device requires 3-wire mode.</p>
</div>

<a id="dt-582ca07c5cfa43ba82ff"></a>

**<code>spi&#45;cpha</code> — not listed as required here**

**Shared schema rule (<code>&#36;ref</code>):** <span id="dt-e054adb9b35c62e6d4c9">[<code>&#47;schemas&#47;types&#46;yaml&#35;&#47;definitions&#47;flag</code>](</kernel/hardware/devicetree-bindings/dt-shared/types.md#dt-4496aa5cdf2440415eba>)</span>

<div id="dt-1960eb57a5a5f1f1c3c5">
<p style="white-space: pre-wrap">The device requires shifted clock phase (CPHA) mode.</p>
</div>

<a id="dt-be2c9d219de9daab67c5"></a>

**<code>spi&#45;cpol</code> — not listed as required here**

**Shared schema rule (<code>&#36;ref</code>):** <span id="dt-b6b071d3b03299edb31c">[<code>&#47;schemas&#47;types&#46;yaml&#35;&#47;definitions&#47;flag</code>](</kernel/hardware/devicetree-bindings/dt-shared/types.md#dt-4496aa5cdf2440415eba>)</span>

<div id="dt-d75b803caeea37036cbf">
<p style="white-space: pre-wrap">The device requires inverse clock polarity (CPOL) mode.</p>
</div>

**Required in this object (<code>required</code>):** <a id="dt-135aee2a2b59e6c53533"></a> <span id="dt-edfb2b957765627279df"><code>&#34;compatible&#34;</code></span>, <span id="dt-aa7a9deaabe919edc37d"><code>&#34;reg&#34;</code></span>

<a id="dt-3d235861b18e278e9c09"></a>

## Property dependencies (<code>dependencies</code>)

<a id="dt-f1dfa2843c145b1e2e94"></a>

### <code>rx&#45;fifo&#45;depth</code> — applies when this property is present

Also requires: <span id="dt-5a1954a25b5e2c878951"><code>&#34;tx&#45;fifo&#45;depth&#34;</code></span>

<a id="dt-9d98c13dedb52e8484ea"></a>

### <code>tx&#45;fifo&#45;depth</code> — applies when this property is present

Also requires: <span id="dt-32445c710974c46ccd78"><code>&#34;rx&#45;fifo&#45;depth&#34;</code></span>

<a id="dt-935ee547587f3e75de61"></a>

## All of these rules must match (<code>allOf</code>)

<a id="dt-d33de94ac1d3652cd22a"></a>

### Rule 1

> <a id="dt-3bbb54dfa1f05dfb4d25"></a>
>
> #### Condition (<code>if</code>)
>
> > <a id="dt-17723ad0bbc7f42a3e70"></a>
> >
> > **This rule must not match (<code>not</code>)**
> >
> > > **Required in this object (<code>required</code>):** <a id="dt-c545a6526f92d5809228"></a> <span id="dt-b34296239384360387bf"><code>&#34;spi&#45;slave&#34;</code></span>
>
> <a id="dt-1ba25143802b75b74702"></a>
>
> #### When the condition matches (<code>then</code>)
>
> > <a id="dt-b212c2ef78c22fab2e20"></a>
> >
> > **Properties and child nodes (<code>properties</code>)**
> >
> > <a id="dt-c7b7eff4f91ab07c8771"></a>
> >
> > **<code>&#35;address&#45;cells</code> — not listed as required here**
> >
> > **Exact value (<code>const</code>):** <span id="dt-e6325173be98b1c426f7"><code>1</code></span>
>
> <a id="dt-f985d6aaa3f73a650205"></a>
>
> #### When the condition does not match (<code>else</code>)
>
> > <a id="dt-0b56c96a40292905ded0"></a>
> >
> > **Properties and child nodes (<code>properties</code>)**
> >
> > <a id="dt-dd4e1504e829342417e7"></a>
> >
> > **<code>&#35;address&#45;cells</code> — not listed as required here**
> >
> > **Exact value (<code>const</code>):** <span id="dt-29c68a3bdc37dfebeba8"><code>0</code></span>

<a id="dt-22ca5ec5b89308748ecc"></a>

### Rule 2

> <a id="dt-5426fd39d2f0de6e46d7"></a>
>
> #### This rule must not match (<code>not</code>)
>
> > **Required in this object (<code>required</code>):** <a id="dt-275f0e4036375dac7270"></a> <span id="dt-b8af2def5bd0ebbeebd3"><code>&#34;fifo&#45;depth&#34;</code></span>, <span id="dt-ab02b4041f4f70fd1161"><code>&#34;rx&#45;fifo&#45;depth&#34;</code></span>

<a id="dt-317510ea5c8bf789ca60"></a>

### Rule 3

> <a id="dt-dc7820e118f24ba3bef0"></a>
>
> #### This rule must not match (<code>not</code>)
>
> > **Required in this object (<code>required</code>):** <a id="dt-474b1d2b9f9a83beb7dd"></a> <span id="dt-f0b6174e9bc6ee1a6713"><code>&#34;fifo&#45;depth&#34;</code></span>, <span id="dt-46910cc1817ddf1714d0"><code>&#34;tx&#45;fifo&#45;depth&#34;</code></span>

<a id="dt-738c4b4f9e483441138b"></a>

## Properties not matched by properties or patternProperties in this schema (<code>additionalProperties</code>)

<code>true</code>

Allowed by this rule.

<a id="dt-1a130cabaa8a47b058bf"></a>

## Examples (<code>examples</code>)

<pre id="dt-0bd6510295af0c95ff2d"><code class="language-dts">spi@80010000 {
    #address-cells = &lt;1&gt;;
    #size-cells = &lt;0&gt;;
    compatible = "fsl,imx28-spi";
    reg = &lt;0x80010000 0x2000&gt;;
    interrupts = &lt;96&gt;;
    dmas = &lt;&amp;dma_apbh 0&gt;;
    dma-names = "rx-tx";

    display@0 {
        compatible = "lg,lg4573";
        spi-max-frequency = &lt;1000000&gt;;
        reg = &lt;0&gt;;
    };

    sensor@1 {
        compatible = "bosch,bme680";
        spi-max-frequency = &lt;100000&gt;;
        reg = &lt;1&gt;;
    };

    flash@2 {
        compatible = "jedec,spi-nor";
        spi-max-frequency = &lt;50000000&gt;;
        reg = &lt;2&gt;, &lt;3&gt;;
        stacked-memories = /bits/ 64 &lt;0x10000000 0x10000000&gt;;
    };
};
</code></pre>

<pre id="dt-bae0d43ea48e35208b4a"><code class="language-dts">#include &lt;dt-bindings/gpio/gpio.h&gt;

spi@20204000 {
    #address-cells = &lt;1&gt;;
    #size-cells = &lt;0&gt;;
    compatible = "brcm,bcm2835-spi";
    reg = &lt;0x7e204000 0x1000&gt;;
    interrupts = &lt;2 22&gt;;
    clocks = &lt;&amp;clk_spi&gt;;
    cs-gpios = &lt;&amp;gpio 8 GPIO_ACTIVE_HIGH&gt;;

    display@0 {
        compatible = "lg,lg4573";
        spi-max-frequency = &lt;1000000&gt;;
        reg = &lt;0&gt;;
        spi-cs-high;
    };
};
</code></pre>

## Source notes

<details>
<summary>Annotations retained from the schema source</summary>

<p id="dt-comment-0"><strong>Line 1:</strong> <span> SPDX-License-Identifier: GPL-2.0</span></p>

</details>
