# SPI

Source: [https://docs.qualcomm.com/doc/80-70018-8/topic/spi.html](https://docs.qualcomm.com/doc/80-70018-8/topic/spi.html)

The serial peripheral interface (SPI) is a synchronous serial data link that operates in
            full duplex mode. SPI is also referred as a 4-wire serial bus.
Figure : SPI data flow
                
                <!--?xml version="1.0" encoding="UTF-8" standalone="no"?-->

<!-- Generated by Microsoft Visio, SVG Export spi-data-flow.svg Page-1 -->
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:v="http://schemas.microsoft.com/visio/2003/SVGExtensions/" width="6.821in" height="4.50438in" viewbox="0 0 491.112 324.315" xml:space="preserve" color-interpolation-filters="sRGB" class="st11"><v:documentproperties v:langid="1033" v:metric="true" v:viewmarkup="false">	<v:userdefs>		<v:ud v:nameu="msvNoAutoConnect" v:val="VT0(1):26"></v:ud>	</v:userdefs></v:documentproperties>
<style>.svg-1 .st1 { fill: #ffffff; stroke: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 0.75 }
.svg-1 .st2 { fill: #ffffff; marker-start: url("#mrkr4-6"); stroke: #3253dc; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1 }
.svg-1 .st3 { fill: #3253dc; fill-opacity: 1; stroke: #3253dc; stroke-opacity: 1; stroke-width: 0.28409090909091 }
.svg-1 .st4 { marker-end: url("#mrkr4-15"); stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1 }
.svg-1 .st5 { fill: #000000; fill-opacity: 1; stroke: #000000; stroke-opacity: 1; stroke-width: 0.28409090909091 }
.svg-1 .st6 { marker-start: url("#mrkr4-31"); stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1 }
.svg-1 .st7 { fill: none; marker-start: url("#mrkr4-35"); stroke: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1 }
.svg-1 .st8 { fill: #000000; font-family: Calibri; font-size: 1.24999em; font-weight: bold }
.svg-1 .st9 { fill: #000000; font-family: Calibri; font-size: 1.00001em }
.svg-1 .st10 { fill: none; marker-end: url("#mrkr4-15"); stroke: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1 }
.svg-1 .st11 { fill: none; fill-rule: evenodd; font-size: 12px; overflow: visible; stroke-linecap: square; stroke-miterlimit: 3 }</style>
<defs id="Markers">	<g id="lend4">		<path d="M 2 1 L 0 0 L 2 -1 L 2 1 " style="stroke:none"></path>	</g>	<marker id="mrkr4-6" class="st3" v:arrowtype="4" v:arrowsize="2" v:setback="7.04" refx="7.04" orient="auto" markerunits="strokeWidth" overflow="visible">		<use xlink:href="#lend4" transform="scale(3.52) "></use>	</marker>	<marker id="mrkr4-15" class="st5" v:arrowtype="4" v:arrowsize="2" v:setback="7.04" refx="-7.04" orient="auto" markerunits="strokeWidth" overflow="visible">		<use xlink:href="#lend4" transform="scale(-3.52,-3.52) "></use>	</marker>	<marker id="mrkr4-31" class="st5" v:arrowtype="4" v:arrowsize="2" v:setback="6.68" refx="6.68" orient="auto" markerunits="strokeWidth" overflow="visible">		<use xlink:href="#lend4" transform="scale(3.52) "></use>	</marker>	<marker id="mrkr4-35" class="st5" v:arrowtype="4" v:arrowsize="2" v:setback="7.04" refx="7.04" orient="auto" markerunits="strokeWidth" overflow="visible">		<use xlink:href="#lend4" transform="scale(3.52) "></use>	</marker></defs><g v:mid="4" v:index="1" v:groupcontext="backgroundPage">	<v:userdefs>		<v:ud v:nameu="msvVisioCreated" v:prompt="" v:val="VT0(0):26"></v:ud>	</v:userdefs>	<title>VBackground-1</title>	<v:pageproperties width="6.821" height="4.50438" v:drawingscale="0.0393701" v:pagescale="0.0393701" v:drawingunits="24" v:shadowoffsetx="8.50394" v:shadowoffsety="-8.50394"></v:pageproperties>	<g id="shape1-1" v:mid="1" v:groupcontext="shape">		<title>Solid</title>		<v:userdefs>			<v:ud v:nameu="Background" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>			<v:ud v:nameu="msvShapeCategories" v:prompt="" v:val="VT4(DoNotContain)"></v:ud>			<v:ud v:nameu="msvVisioCreated" v:prompt="" v:val="VT0(0):26"></v:ud>		</v:userdefs>		<rect x="0" y="5.68434E-14" width="491.112" height="324.315" class="st1"></rect>	</g></g><g v:mid="0" v:index="2" v:groupcontext="foregroundPage">	<title>Page-1</title>	<v:pageproperties v:drawingscale="0.0393701" v:pagescale="0.0393701" v:drawingunits="24" v:shadowoffsetx="8.50394" v:shadowoffsety="-8.50394"></v:pageproperties>	<g id="shape1-3" v:mid="1" v:groupcontext="shape" transform="translate(25.871,-25.871)">		<title>Rectangle</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<rect x="0" y="51.7419" width="127.559" height="272.574" class="st2"></rect>	</g>	<g id="shape2-7" v:mid="2" v:groupcontext="shape" transform="translate(337.682,-25.871)">		<title>Rectangle.2</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<rect x="0" y="51.7419" width="127.559" height="272.574" class="st2"></rect>	</g>	<g id="shape3-10" v:mid="3" v:groupcontext="shape" transform="translate(153.43,-232.8)">		<title>Sheet.3</title>		<path d="M0 324.32 L177.21 324.32" class="st4"></path>	</g>	<g id="shape4-16" v:mid="4" v:groupcontext="shape" transform="translate(153.43,-176.107)">		<title>Sheet.4</title>		<path d="M0 324.32 L177.21 324.32" class="st4"></path>	</g>	<g id="shape5-21" v:mid="5" v:groupcontext="shape" transform="translate(153.43,-119.414)">		<title>Sheet.5</title>		<path d="M0 324.32 L177.21 324.32" class="st4"></path>	</g>	<g id="shape6-26" v:mid="6" v:groupcontext="shape" transform="translate(153.43,-62.7214)">		<title>Sheet.6</title>		<path d="M6.68 324.32 L7.04 324.32 L184.25 324.32" class="st6"></path>	</g>	<g id="shape7-32" v:mid="7" v:groupcontext="shape" transform="translate(40.0442,-261.147)">		<title>Sheet.7</title>		<desc>Controller</desc>		<v:textblock v:margins="rect(4,4,4,4)" v:tabspace="42.5197"></v:textblock>		<v:textrect cx="49.6063" cy="310.142" width="99.22" height="28.3465"></v:textrect>		<rect x="0" y="295.969" width="99.2126" height="28.3465" class="st7"></rect>		<text x="18.16" y="314.64" class="st8" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Controller</text>		</g>	<g id="shape8-37" v:mid="8" v:groupcontext="shape" transform="translate(366.028,-261.147)">		<title>Sheet.8</title>		<desc>Target</desc>		<v:textblock v:margins="rect(4,4,4,4)" v:tabspace="42.5197"></v:textblock>		<v:textrect cx="38.2677" cy="312.268" width="76.54" height="24.0945"></v:textrect>		<rect x="0" y="300.221" width="76.5354" height="24.0945" class="st7"></rect>		<text x="18.25" y="316.77" class="st8" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Target</text>		</g>	<g id="shape10-41" v:mid="10" v:groupcontext="shape" transform="translate(74.0599,-225.713)">		<title>Sheet.10</title>		<desc>SPI_CS_N</desc>		<v:textblock v:margins="rect(4,4,4,4)" v:tabspace="42.5197"></v:textblock>		<v:textrect cx="39.685" cy="317.229" width="79.38" height="14.1732"></v:textrect>		<rect x="0" y="310.142" width="79.3701" height="14.1732" class="st7"></rect>		<text x="29.02" y="320.83" class="st9" v:langid="1033"><v:paragraph v:horizalign="2"></v:paragraph><v:tablist></v:tablist>SPI_CS_N</text>		</g>	<g id="shape11-45" v:mid="11" v:groupcontext="shape" transform="translate(78.3119,-169.021)">		<title>Sheet.11</title>		<desc>SPI_CLK</desc>		<v:textblock v:margins="rect(4,4,4,4)" v:tabspace="42.5197"></v:textblock>		<v:textrect cx="37.5591" cy="317.229" width="75.12" height="14.1732"></v:textrect>		<rect x="0" y="310.142" width="75.1181" height="14.1732" class="st7"></rect>		<text x="32.73" y="320.83" class="st9" v:langid="1033"><v:paragraph v:horizalign="2"></v:paragraph><v:tablist></v:tablist>SPI_CLK</text>		</g>	<g id="shape12-49" v:mid="12" v:groupcontext="shape" transform="translate(54.2174,-109.493)">		<title>Sheet.12</title>		<desc>SPI_DATA_MO_SI</desc>		<v:textblock v:margins="rect(4,4,4,4)" v:tabspace="42.5197"></v:textblock>		<v:textrect cx="49.6063" cy="314.394" width="99.22" height="19.8425"></v:textrect>		<rect x="0" y="304.473" width="99.2126" height="19.8425" class="st7"></rect>		<text x="8.69" y="317.99" class="st9" v:langid="1033"><v:paragraph v:horizalign="2"></v:paragraph><v:tablist></v:tablist>SPI_DATA_MO_SI</text>		</g>	<g id="shape13-53" v:mid="13" v:groupcontext="shape" transform="translate(54.2174,-52.8001)">		<title>Sheet.13</title>		<desc>SPI_DATA_MI_SO</desc>		<v:textblock v:margins="rect(4,4,4,4)" v:tabspace="42.5197"></v:textblock>		<v:textrect cx="49.6063" cy="314.394" width="99.22" height="19.8425"></v:textrect>		<rect x="0" y="304.473" width="99.2126" height="19.8425" class="st7"></rect>		<text x="8.69" y="317.99" class="st9" v:langid="1033"><v:paragraph v:horizalign="2"></v:paragraph><v:tablist></v:tablist>SPI_DATA_MI_SO</text>		</g>	<g id="shape14-57" v:mid="14" v:groupcontext="shape" transform="translate(337.682,-222.879)">		<title>Sheet.14</title>		<desc>SPI_CS_N</desc>		<v:textblock v:margins="rect(4,4,4,4)" v:tabspace="42.5197"></v:textblock>		<v:textrect cx="41.1024" cy="314.394" width="82.21" height="19.8425"></v:textrect>		<rect x="0" y="304.473" width="82.2047" height="19.8425" class="st7"></rect>		<text x="4" y="317.99" class="st9" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>SPI_CS_N</text>		</g>	<g id="shape15-61" v:mid="15" v:groupcontext="shape" transform="translate(337.682,-166.186)">		<title>Sheet.15</title>		<desc>SPI_CLK</desc>		<v:textblock v:margins="rect(4,4,4,4)" v:tabspace="42.5197"></v:textblock>		<v:textrect cx="35.4331" cy="314.394" width="70.87" height="19.8425"></v:textrect>		<rect x="0" y="304.473" width="70.8661" height="19.8425" class="st7"></rect>		<text x="4" y="317.99" class="st9" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>SPI_CLK</text>		</g>	<g id="shape16-65" v:mid="16" v:groupcontext="shape" transform="translate(337.682,-109.493)">		<title>Sheet.16</title>		<desc>SPI_DATA_MO_SI</desc>		<v:textblock v:margins="rect(4,4,4,4)" v:tabspace="42.5197"></v:textblock>		<v:textrect cx="49.6063" cy="314.394" width="99.22" height="19.8425"></v:textrect>		<rect x="0" y="304.473" width="99.2126" height="19.8425" class="st7"></rect>		<text x="4" y="317.99" class="st9" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>SPI_DATA_MO_SI</text>		</g>	<g id="shape17-69" v:mid="17" v:groupcontext="shape" transform="translate(337.682,-52.0914)">		<title>Sheet.17</title>		<desc>SPI_DATA_MI_SO</desc>		<v:textblock v:margins="rect(4,4,4,4)" v:tabspace="42.5197"></v:textblock>		<v:textrect cx="49.6063" cy="313.686" width="99.22" height="21.2598"></v:textrect>		<rect x="0" y="303.056" width="99.2126" height="21.2598" class="st7"></rect>		<text x="4" y="317.29" class="st9" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>SPI_DATA_MI_SO</text>		</g>	<g id="shape22-73" v:mid="22" v:groupcontext="shape" transform="translate(181.776,-232.8)">		<title>Sheet.22</title>		<desc>Chip select active low</desc>		<v:textblock v:margins="rect(4,4,4,4)" v:tabspace="42.5197"></v:textblock>		<v:textrect cx="63.7795" cy="314.394" width="127.56" height="19.8425"></v:textrect>		<rect x="0" y="304.473" width="127.559" height="19.8425" class="st10"></rect>		<text x="11.26" y="317.99" class="st9" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Chip select active low</text>		</g>	<g id="shape24-77" v:mid="24" v:groupcontext="shape" transform="translate(187.744,-176.107)">		<title>Sheet.24</title>		<desc>Clock</desc>		<v:textblock v:margins="rect(4,4,4,4)" v:tabspace="42.5197"></v:textblock>		<v:textrect cx="56.6929" cy="317.229" width="113.39" height="14.1732"></v:textrect>		<rect x="0" y="310.142" width="113.386" height="14.1732" class="st10"></rect>		<text x="43.69" y="320.83" class="st9" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Clock</text>		</g>	<g id="shape25-81" v:mid="25" v:groupcontext="shape" transform="translate(181.776,-119.414)">		<title>Sheet.25</title>		<desc>Data</desc>		<v:textblock v:margins="rect(4,4,4,4)" v:tabspace="42.5197"></v:textblock>		<v:textrect cx="59.5276" cy="317.229" width="119.06" height="14.1732"></v:textrect>		<rect x="0" y="310.142" width="119.055" height="14.1732" class="st10"></rect>		<text x="48.08" y="320.83" class="st9" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Data</text>		</g>	<g id="shape26-85" v:mid="26" v:groupcontext="shape" transform="translate(181.776,-62.7214)">		<title>Sheet.26</title>		<desc>Data</desc>		<v:textblock v:margins="rect(4,4,4,4)" v:tabspace="42.5197"></v:textblock>		<v:textrect cx="58.8189" cy="317.229" width="117.64" height="14.1732"></v:textrect>		<rect x="0" y="310.142" width="117.638" height="14.1732" class="st7"></rect>		<text x="47.37" y="320.83" class="st9" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Data</text>		</g></g>
</svg>

The SPI core supports the bidirectional SPI standard, point-to-point, and
            controller-target protocol. The SPI core uses four chip‑select lines
                (<var class="keyword varname">SPI_CS#_N</var>) to select target devices for communication. The
            following two data lines support the bidirectional data transfer.
- SPI\_DATA\_MO\_SI: Controller data output, target data input.
- SPI\_DATA\_MI\_SO: Controller data input, target data output.

| Data signals | MOSI: Controller data output, target data input. |
| --- | --- |
| Data signals | MISO: Controller data input, target data output. |
| Control signals | SCLK: A clock generated by the controller and input to all<br>                            targets. |
| Control signals | CS: Chip-select, a target is selected when the controller asserts its<br>                                <var class="keyword varname">CS_N</var> signal. |
|  |  |

## SPI features

Source: [https://docs.qualcomm.com/doc/80-70018-8/topic/spi.html](https://docs.qualcomm.com/doc/80-70018-8/topic/spi.html)

This section explains the SPI serial engine transfer modes and the different scenarios
            where each mode is used. This section also describes the FIFO and DMA enabled in various
            subsystem SPI drivers.

Table : SPI transfer modes

| Subsystem | Transfer mode | Description |
| --- | --- | --- |
| Linux | <ul class="ul" id="spi_features__ul_xkv_gyg_rcc"><br>                                    <li class="li">FIFO (low speed)</li><br><br>                                    <li class="li">CPU DMA (high speed)</li><br><br>                                    <li class="li">GSI</li><br><br>                                </ul> | Supports a maximum configuration speed  of 50 MHz. |
| Boot | FIFO | <ul class="ul" id="spi_features__ul_xcm_cjh_rcc"><br>                                    <li class="li">Transfer rates up to 50&nbsp;MHz. The host sets the SPI clock<br>                                        frequency nearest to the requested frequency.</li><br><br>                                    <li class="li">4&nbsp;bits to 32&nbsp;bits per word of transfer.</li><br><br>                                    <li class="li">Maximum of 4 chip selects (CS) per bus.</li><br><br>                                    <li class="li">GSI mode isn't supported on boot.</li><br><br>                                    <li class="li">The driver executes in polling mode.</li><br><br>                                </ul> |
| aDSP | <ul class="ul" id="spi_features__ul_qh1_gjh_rcc"><br>                                    <li class="li">Full duplex </li><br><br>                                    <li class="li">Half duplex</li><br><br>                                    <li class="li">Synchronous</li><br><br>                                    <li class="li">Serial communication</li><br><br>                                </ul> | <ul class="ul" id="spi_features__ul_u4m_jjh_rcc"><br>                                    <li class="li">There is no explicit communication framing, error checking,<br>                                        or defined data word length. </li><br><br>                                    <li class="li">The communication is strictly at the raw bit level.</li><br><br>                                    <li class="li">Transfer rates up to 50&nbsp;MHz. The host sets the SPI clock<br>                                        frequency nearest to the requested frequency.</li><br><br>                                    <li class="li">4&nbsp;bits to 32&nbsp;bits per word of transfer.</li><br><br>                                    <li class="li">Maximum of 4 chip selects (CS) per bus.</li><br><br>                                </ul> |

## SPI interface

Source: [https://docs.qualcomm.com/doc/80-70018-8/topic/spi.html](https://docs.qualcomm.com/doc/80-70018-8/topic/spi.html)

This section provides information about the subsystem drivers, kernel device tree nodes,
            and related documentation.

Table : SPI interface: Linux

| File type | Description |
| --- | --- |
| Device tree source | <ul class="ul" id="spi_interface__ul_ysx_dgf_ncc"><br>                                    <li class="li">QCS6490 and QCS5430: <a href="https://git.linaro.org/kernel-org/linux-next.git/tree/arch/arm64/boot/dts/qcom/sc7280.dtsi" target="_blank" class="xref cursorpointer" onclick="Window.BookmapComponent.navigateExternalFile('https://git.linaro.org/kernel-org/linux-next.git/tree/arch/arm64/boot/dts/qcom/sc7280.dtsi')">https://git.linaro.org/kernel-org/linux-next.git/tree/arch/arm64/boot/dts/qcom/sc7280.dtsi</a></li><br><br>                                    <li class="li">QCS9075: <a href="https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/qcom/sa8775p.dtsi" target="_blank" class="xref cursorpointer" onclick="Window.BookmapComponent.navigateExternalFile('https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/qcom/sa8775p.dtsi')">https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/qcom/sa8775p.dtsi</a></li><br><br>                                    <li class="li">For information about QUP v3 serial engine device nodes, see<br>                                        the kernel documentation at&nbsp;<a href="https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/spi/qcom%2Cspi-geni-qcom.yaml" target="_blank" class="xref cursorpointer" onclick="Window.BookmapComponent.navigateExternalFile('https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/spi/qcom%2Cspi-geni-qcom.yaml')">https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/spi/qcom%2Cspi-geni-qcom.yaml</a></li><br><br>                                </ul> |
| `Pinctrl` settings | <ul class="ul" id="spi_interface__ul_o3f_rkf_ncc"><br>                                    <li class="li">QCS6490 and QCS5430: <a href="https://git.linaro.org/kernel-org/linux-next.git/tree/arch/arm64/boot/dts/qcom/sc7280.dtsi" target="_blank" class="xref cursorpointer" onclick="Window.BookmapComponent.navigateExternalFile('https://git.linaro.org/kernel-org/linux-next.git/tree/arch/arm64/boot/dts/qcom/sc7280.dtsi')">https://git.linaro.org/kernel-org/linux-next.git/tree/arch/arm64/boot/dts/qcom/sc7280.dtsi</a></li><br><br>                                    <li class="li">QCS9075: <a href="https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/qcom/sa8775p.dtsi" target="_blank" class="xref cursorpointer" onclick="Window.BookmapComponent.navigateExternalFile('https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/qcom/sa8775p.dtsi')">https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/qcom/sa8775p.dtsi</a></li><br><br>                                </ul> |
| Qualcomm TEE settings | <ul class="ul" id="spi_interface__ul_hxy_tp3_vdc"><br>                                    <li class="li"><span class="ph filepath">/firmware/qualcomm-linux-spf-1-0_ap_standard_oem_nomodem/TZ.XF.5.0/trustzone_images/core/settings/buses/qup_accesscontrol/qupv3/config/&lt;chipset&gt;/QUPAC_Access.c</span></li><br><br>                                </ul> |

Table : SPI interface: Boot

| File type | Description |
| --- | --- |
| QUP v3 serial engine configuration | <ul class="ul" id="spi_interface__ul_fkh_45n_rzb"><br>                                    <li class="li">QUP v3 serial<br>                                            engine:&nbsp;<span class="ph filepath">/firmware/qualcomm-linux-spf-1-0_ap_standard_oem_nomodem/BOOT.MXF.1.0.c1/boot_images/boot/Settings/Soc/&lt;chipset&gt;/Core/Buses/qup_common/&lt;chipset&gt;-qupv3.dtsi</span></li><br><br>                                    <li class="li">GPIO<br>                                            configurations:&nbsp;<span class="ph filepath">/firmware/qualcomm-linux-spf-1-0_ap_standard_oem_nomodem/BOOT.MXF.1.0.c1/boot_images/boot/Settings/Soc/&lt;chipset&gt;/Core/Buses/qup_common/&lt;chipset&gt;-qupv3-pinctrl.dtsi</span></li><br><br>                                </ul> |
| Qualcomm TEE settings | <ul class="ul" id="spi_interface__ul_lml_5p3_vdc"><br>                                    <li class="li"><span class="ph filepath">/firmware/qualcomm-linux-spf-1-0_ap_standard_oem_nomodem/TZ.XF.5.0/trustzone_images/core/settings/buses/qup_accesscontrol/qupv3/config/&lt;chipset&gt;/QUPAC_Access.c</span></li><br><br>                                </ul> |

Table : SPI interface: aDSP/SLPI/SDC

| File type | Description |
| --- | --- |
| QUP v3 serial engine configuration | <ul class="ul" id="spi_interface__ul_vds_kvn_rzb"><br>                                    <li class="li"><span class="ph filepath">/firmware/qualcomm-linux-spf-1-0_ap_standard_oem_nomodem/ADSP.HT.5.5.c8/adsp_proc/core/settings/buses/qup_common/config/&lt;chipset&gt;/adsp/ssc/qup_devcfg.c</span></li><br><br>                                    <li class="li"><span class="ph filepath">/firmware/qualcomm-linux-spf-1-0_ap_standard_oem_nomodem/ADSP.HT.5.5.c8/adsp_proc/core/settings/buses/qup_fw/config/&lt;chipset&gt;/fw_devcfg.c</span></li><br><br>                                    <li class="li"><span class="ph filepath">settings/buses/qup_common/config/&lt;chipset&gt;<br>                                            /adsp/ssc/qup_devcfg.json</span></li><br><br>                                </ul> |
| Firmware configuration settings | <ul class="ul" id="spi_interface__ul_wpr_p5j_51c"><br>                                    <li class="li"><span class="ph filepath">/firmware/qualcomm-linux-spf-1-0_ap_standard_oem_nomodem/ADSP.HT.5.5.c8/adsp_proc/core/settings/buses/qup_fw/config/&lt;chipset&gt;/fw_devcfg.c</span></li><br><br>                                    <li class="li"><span class="ph filepath">/firmware/qualcomm-linux-spf-1-0_ap_standard_oem_nomodem/ADSP.HT.5.5.c8/adsp_proc/core/settings/buses/qup_fw/config/&lt;chipset&gt;/fw_devcfg.xml</span></li><br><br>                                </ul> |

Table : SPI interface: Qualcomm TEE

| File type | Description |
| --- | --- |
| QUP v3 serial engine configuration | <ul class="ul" id="spi_interface__ul_xr2_vvn_rzb"><br>                                    <li class="li"><span class="ph filepath">/firmware/qualcomm-linux-spf-1-0_ap_standard_oem_nomodem/TZ.XF.5.0/trustzone_images/core/settings/buses/spi/qupv3/config/&lt;chipset&gt;/tz/spi_devcfg_user.c</span></li><br><br>                                    <li class="li"><span class="ph filepath">/firmware/qualcomm-linux-spf-1-0_ap_standard_oem_nomodem/TZ.XF.5.0/trustzone_images/core/settings/buses/spi/qupv3/config/&lt;chipset&gt;/tz/spi_devcfg_user.h</span></li><br><br>                                    <li class="li"><span class="ph filepath">/firmware/qualcomm-linux-spf-1-0_ap_standard_oem_nomodem/TZ.XF.5.0/trustzone_images/core/settings/buses/spi/qupv3/config/&lt;chipset&gt;/tz/spi_devcfg.xml</span></li><br><br>                                </ul> |
| Qualcomm TEE settings | <ul class="ul" id="spi_interface__ul_ekb_vp3_vdc"><br>                                    <li class="li"><span class="ph filepath">/firmware/qualcomm-linux-spf-1-0_ap_standard_oem_nomodem/TZ.XF.5.0/trustzone_images/core/settings/buses/qup_accesscontrol/qupv3/config/&lt;chipset&gt;/QUPAC_Access.c</span></li><br><br>                                </ul> |

### SPI APIs

Source: [https://docs.qualcomm.com/doc/80-70018-8/topic/spi.html](https://docs.qualcomm.com/doc/80-70018-8/topic/spi.html)

SPI APIs for the following subsystems are listed in this section.
- Linux:
    - [https://github.com/torvalds/linux/blob/master/include/uapi/linux/spi/spidev.h](https://github.com/torvalds/linux/blob/master/include/uapi/linux/spi/spidev.h).
    - [https://github.com/torvalds/linux/blob/master/include/linux/spi/spi.h](https://github.com/torvalds/linux/blob/master/include/linux/spi/spi.h).
- Boot: boot\_images/boot/QcomPkg/Include/SpiApi.h
- aDSP/SDC: adsp\_proc/core/api/buses/spi\_api.h

## SPI software

Source: [https://docs.qualcomm.com/doc/80-70018-8/topic/spi.html](https://docs.qualcomm.com/doc/80-70018-8/topic/spi.html)

This section provides information on the SPI device tree configuration and documentation
            for the device nodes.

### Linux

For device SPI details, see the following DTSI files.
- QCS6490 and QCS5430: [https://git.linaro.org/kernel-org/linux-next.git/tree/arch/arm64/boot/dts/qcom/sc7280.dtsi](https://git.linaro.org/kernel-org/linux-next.git/tree/arch/arm64/boot/dts/qcom/sc7280.dtsi)
- QCS9075: [https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/qcom/sa8775p.dtsi](https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/qcom/sa8775p.dtsi)

For more information about kernel documentation specific to the SPI device nodes,
                    see [https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/spi/qcom%2Cspi-geni-qcom.yaml](https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/spi/qcom%2Cspi-geni-qcom.yaml), and SPI driver file at [https://github.com/torvalds/linux/blob/master/drivers/spi/spi-geni-qcom.c](https://github.com/torvalds/linux/blob/master/drivers/spi/spi-geni-qcom.c).

    spi@a98000 {
    compatible = "qcom,geni-spi";
    reg = <0 0x00a98000 0 0x4000>;
    clocks = <&gcc GCC_QUPV3_WRAP1_S6_CLK>;
    clock-names = "se";
    pinctrl-names = "default";
    pinctrl-0 = <&qup_spi14_data_clk>, <&qup_spi14_cs>;
    interrupts = <GIC_SPI 368 IRQ_TYPE_LEVEL_HIGH>;
    #address-cells = <1>;
    #size-cells = <0>;
    power-domains = <&rpmhpd SC7280_CX>;
    operating-points-v2 = <&qup_opp_table>;
    interconnects = <&clk_virt MASTER_QUP_CORE_1 0 &clk_virt SLAVE_QUP_CORE_1 0>,	<&gem_noc MASTER_APPSS_PROC 0 &cnoc2 SLAVE_QUP_1 0>;
    interconnect-names = "qup-core", "qup-config";	dmas = <&gpi_dma1 0 6 QCOM_GPI_SPI>,       <&gpi_dma1 1 6 QCOM_GPI_SPI>;
    dma-names = "tx", "rx";
    status = "disabled";
    };Copy to clipboard

For kernel documentation specific to the GPIO `pinctrl`configuration,
                see the following files.
- QCS6490 and QCS5430: [https://git.linaro.org/kernel-org/linux-next.git/tree/arch/arm64/boot/dts/qcom/sc7280.dtsi](https://git.linaro.org/kernel-org/linux-next.git/tree/arch/arm64/boot/dts/qcom/sc7280.dtsi)
- QCS9075: [https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/qcom/sa8775p.dtsi](https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/qcom/sa8775p.dtsi)
- Documentation/devicetree/bindings/pinctrl/qcom,&lt;chipset&gt;-tlmm.yaml

The corresponding configurations of the QUP v3 serial engine GPIOs are present
                and mapped in the pinctrl.dtsi.

For example:

    qup_spi14_data_clk: qup-spi14-data-clk-state {			pins = "gpio56", "gpio57", "gpio58";			function = "qup16";		};
    		qup_spi14_cs: qup-spi14-cs-state {			pins = "gpio59";			function = "qup16";		};
    		qup_spi14_cs_gpio: qup-spi14-cs-gpio-state {			pins = "gpio59";			function = "gpio";		};
    		qup_spi15_data_clk: qup-spi15-data-clk-state {			pins = "gpio60", "gpio61", "gpio62";			function = "qup17";		};Copy to clipboard

Ensure that the protocol configuration for a particular serial
                engine uses the SPI protocol in the file
                    at /firmware/qualcomm-linux-spf-1-0\_ap\_standard\_oem\_nomodem/TZ.XF.5.0/trustzone\_images/core/settings/buses/qup\_accesscontrol/qupv3/config/&lt;chipset&gt;/QUPAC\_Access.c.
                Modify the required settings if needed or see the default settings assigned for QUP
                v3 serial engine instances.

Following is the sample configuration for enabling the
                SPI.

    { QUPV3_0_SE3, QUPV3_PROTOCOL_SPI,     QUPV3_MODE_FIFO, AC_HLOS,            TRUE,  TRUE,  FALSE }, // CAN SPI
    { QUPV3_1_SE3, QUPV3_PROTOCOL_SPI,     QUPV3_MODE_FIFO, AC_HLOS,            FALSE, TRUE,  TRUE }, // LS1 SPI
    { QUPV3_1_SE4, QUPV3_PROTOCOL_SPI,     QUPV3_MODE_GSI,  AC_TZ,              FALSE, TRUE,  TRUE }, // SPI -NFC ESE
    { QUPV3_1_SE6, QUPV3_PROTOCOL_SPI,     QUPV3_MODE_GSI,  AC_HLOS,            FALSE, TRUE,  FALSE}, // FP
    { QUPV3_SSC_SE2, QUPV3_PROTOCOL_SPI,     QUPV3_MODE_GSI, AC_ADSP_Q6_ELF,  FALSE,      FALSE, FALSE }, // IMU_SPICopy to clipboard

### Boot

Configure the QUP v3 settings according to the Qualcomm Linux chip product
                requirements in
                    the /firmware/qualcomm-linux-spf-1-0\_ap\_standard\_oem\_nomodem/BOOT.MXF.1.0.c1/boot\_images/boot/Settings/Soc/&lt;chipset&gt;/Core/Buses/qup\_common/&lt;chipset&gt;-qupv3.dtsi file.

Note: To enable the required QUP v3 serial engine, update the QUP
                v3 wrapper node status to `okay`, and the respective serial engine
                node to `disabled` state.

The following sample nodes help to configure the QUP v3 serial engine in boot.

**QUP wrapper node                sample**

           /* QUPV3_0  wrapper  instance */
        TOP_QUP_0{ 
            compatible = "qcom,qup-controller";
            qup_id                      = /bits/  8 <(QUP_0)>;
            core_base_addr              = <QUPV3_0_CORE_BASE_ADDRESS>;
            common_base_addr            = <(QUPV3_0_CORE_COMMON_BASE_ADDRESS)>;
            se_wrapper_base_addr        = <(QUPV3_0_CORE_SE_BASE_ADDRESS)>;
            core_frequency              = <100000000>;
            qup_flags                   = <(QUP_FLAGS_UNUSED)>;
            num_se                      = /bits/ 8 <8>;
            status                      = "okay"; 
    Copy to clipboard

**Sample node of serial engine                instance**

    /*TOP_QUP_0_SE_0  Instance */ 
            TOP_QUP_0_SE_0{
              status                      = "disabled";  (updated to okay if you need the instance to be enabled)
                core_offset                 = <0x00000000>;
                se_flags                    = <(USES_DDR_BUFFER | USES_INTERNAL_DDR_MEM | ENABLE_FATAL_ON_TIMEOUT | POLLED_MODE)>;
                se_index                    = /bits/  8 <0>;
                FIFO_MODE                   = /bits/  8 <1>;
                protocol_supported          = <(I2C_SUPPORTED | UART_SUPPORTED | SPI_SUPPORTED)>;
                interface_supported         = <CORE_IRQ>;
               * gpi_index                   = /bits/ 8 <0xFF>;
                core_irq                    = /bits/ 16 <0>;
                pdc_irq                     = /bits/ 16 <0>;
                gpio_int_num                = /bits/ 16 <0>;
                i2c_hub                     = /bits/ 8  <0>;
                i2c_mm                      = /bits/ 16 <0>;
                SE_EXCLUSIVE                = /bits/  8 <1>;
                pinctrl-names               = "i2c-default", "i2c-sleep","spi-default", "spi-sleep","uart-default", "uart-sleep";
                pinctrl-0                   = <&top_qup0_se0_i2c_active>;
                pinctrl-1                   = <&top_qup0_se0_i2c_sleep>;
                pinctrl-2                   = <&top_qup0_se0_spi_active>;
                pinctrl-3                   = <&top_qup0_se0_spi_sleep>;
                pinctrl-4                   = <&top_qup0_se0_uart_active>;
                pinctrl-5                   = <&top_qup0_se0_uart_sleep>;
    
                se_clock                    = "gcc_qupv3_wrap0_s0_clk";
            };
    Copy to clipboard

For `pinctrl` definitions, see the GPIO configuration file at /firmware/qualcomm-linux-spf-1-0\_ap\_standard\_oem\_nomodem/BOOT.MXF.1.0.c1/boot\_images/boot/Settings/Soc/&lt;chipset&gt;/Core/Buses/qup\_common/&lt;chipset&gt;-qupv3-pinctrl.dtsi.

Sample GPIO configuration:

    #define top_qup0_se1_i2c_active_cfg  GPIO_CFG(GPIO_INPUT,GPIO_PULL_UP,GPIO_DRIVE_STRENGTH(200),GPIO_STRONG_PULL)Copy to clipboard

- In `<chipset>-qupv3-pinctrl.dtsi` modify the macro with the
                    GPIO configuration when the requirements are different from the default
                    configuration.
- For the macro definition, see the header file path
                        at Settings/Include/gpio-dt.h.

Replace macro in sample TLMM
                node.

      /*TOP_QUP0_se1_pinctrl*/
        top_qup0_se1_i2c_active: top_qup0_se1_i2c_active{
        --    config = <&qup0_l0_1 top_qup_i2c_active_cfg>,
                     <&qup0_l1_1 top_qup_i2c_active_cfg>;
       ++  config = <&qup0_l0_1 top_qup0_se1_i2c_active_cfg>,
                     <&qup0_l1_1 top_qup0_se1_i2c_active_cfg>;
        };
    Copy to clipboard

Note: Verify Qualcomm TEE settings before changing the unified
                extensible firmware interface (UEFI) configuration. Ensure that the serial engine
                node is in FIFO\_MODE and accessible from the application processor. Verify that the
                loaded protocol is according to the requirement.

### aDSP/SDC

Firmware loading with SSC QUP is performed during the bootup sequence of the aDSP
                subsystem. The configuration file is present in the aDSP build at /firmware/qualcomm-linux-spf-1-0\_ap\_standard\_oem\_nomodem/ADSP.HT.5.5.c8/adsp\_proc/core/settings/buses/qup\_fw/config/&lt;chipset&gt;/fw\_devcfg.c
                and /firmware/qualcomm-linux-spf-1-0\_ap\_standard\_oem\_nomodem/ADSP.HT.5.5.c8/adsp\_proc/core/settings/buses/qup\_fw/config/&lt;chipset&gt;/fw\_devcfg.xml.

The following configuration is a sample of the SSC QUP SE4 loaded with the SPI
                firmware.

    se_cfg se4_cfg = { 0x90000, SE_PROTOCOL_SPI,   	GSI,     TRUE, TRUE };Copy to clipboard

**GPIO configuration**: Each serial engine in the QUP common driver is configured
                with the default GPIO configuration. The GPIO configuration is picked up by the QUP
                common driver according to the protocol loaded for the serial engine
                    at /firmware/qualcomm-linux-spf-1-0\_ap\_standard\_oem\_nomodem/ADSP.HT.5.5.c8/adsp\_proc/core/settings/buses/qup\_common/config/&lt;chipset&gt;/adsp/ssc/qup\_instance\_mapping.c.

The default GPIO configuration can be overwritten as follows.

    {      .instance_id          =  5 ,         //Instance ID
            .qup              =  QUP_SSC,    //QUP Type
            .se_index         =  4,          //SE ID
            .se_data          =  NULL,       //devcfg_map
            .protocol_io_cfg  =  {
                                    TLMM_MAP(TLMM_GPIO_KEEPER ,TLMM_GPIO_2MA,TLMM_GPIO_KEEPER ),              //SLEEP CFG
                                    TLMM_MAP(TLMM_GPIO_NO_PULL,TLMM_GPIO_6MA,TLMM_GPIO_KEEPER ),              //SPI CFG
                                    TLMM_MAP(TLMM_GPIO_NO_PULL,TLMM_GPIO_2MA,TLMM_GPIO_NO_PULL),              //UART CFG
                                    TLMM_MAP(TLMM_GPIO_PULL_UP,TLMM_GPIO_2MA,TLMM_GPIO_NO_PULL),              //I2C CFG
                                    TLMM_MAP(TLMM_GPIO_PULL_UP,TLMM_GPIO_2MA,TLMM_GPIO_KEEPER )               //I3C CFG
                                 },
            .se_exclusive     =  TRUE,
    }
    Copy to clipboard

TLMM\_MAP is a macro to initialize the active and sleep state GPIO configurations. For
                example, sample usage of the TLMM\_MAP macro.

    TLMM_MAP (active state pull type, drive strength, sleep state pull type)Copy to clipboard

### Qualcomm TEE

The QUP v3 access configuration settings are
                    at /firmware/qualcomm-linux-spf-1-0\_ap\_standard\_oem\_nomodem/TZ.XF.5.0/trustzone\_images/core/settings/buses/spi/qupv3/interface/spi\_devcfg.h.

To enable the QUP v3 serial engine for SPI
                    in /firmware/qualcomm-linux-spf-1-0\_ap\_standard\_oem\_nomodem/TZ.XF.5.0/trustzone\_images/core/settings/buses/spi/qupv3/config/&lt;chipset&gt;/tz/spi\_devcfg\_user.h,
                add `#define TZ_USE_SPI_X` (<var class="keyword varname">X</var> is the SPI serial
                engine number) as
                follows.

    #define TZ_USE_SPI_13 //NFC-eseCopy to clipboard

    #define TZ_USE_SPI_14 //Touch-SPICopy to clipboard

    #define TZ_USE_SPI_15 //FP sensorCopy to clipboard

The
                    `TZ_USE_SPI_<num>` number is based on the serial number of the
                serial engine (starting from one). For example, if there are two QUPs: QUPV3\_0 with
                seven serial engines and QUPV3\_1 with eight serial engines, the user must enable
                QUPV3\_2\_SE2. The macro should be TZ\_USE\_SPI\_9.

**GPIO configuration**: In the following example, drive strength and pull are
                configured according to the PIN starting index from MISO
                    at settings/buses/spi/qupv3/config/&lt;chipset&gt;/tz/spi\_devcfg\_user.c.

    spi_plat_device_config_user spi_device_user_config_0 =
     
        {2,2,2,2,-1,-1,-1},    //.drive_strength index: 0 - MISO, 1 - MOSI, 2 - SCLK, 3 - CS_0, 4- CS_1, 5- CS_2, 6- CS_3
                                    	                 value: 0 - 2MA, 1 - 4MA, 2 - 6MA
        {1,1,0,1,-1,-1,-1},    //.pull index: 0 - MISO, 1 - MOSI, 2 - SCLK, 3 - CS_0, 4- CS_1, 5- CS_2, 6- CS_3
                                    value: 0 - NO_PULL, 1 = PULL_DOWN, 2 = KEEPER, 3 = PULL_UP
        0xFF,                 //.gpii_idx 
        0,                   //.mode_select  not supported for TZ
        0,                   //.flags not supported for TZ
    };
    Copy to clipboard

Access control permission to the Qualcomm TEE subsystem is configured in the QUPAC
                policy
                    at /firmware/qualcomm-linux-spf-1-0\_ap\_standard\_oem\_nomodem/TZ.XF.5.0/trustzone\_images/core/settings/buses/qup\_accesscontrol/qupv3/config/&lt;chipset&gt;/QUPAC\_Access.c.

    const QUPv3_se_security_permissions_type qupv3_perms_iot_rb3[] =
    {
      /*   PeriphID,         ProtocolID,               Mode,  NsOwner,       bAllowFifo, bLoad, bModExcl  */
      { QUPV3_0_SE0, QUPV3_PROTOCOL_I2C,     QUPV3_MODE_FIFO, AC_HLOS,            TRUE,  TRUE,  FALSE }, // LT9611 and QPS615 I2C
      { QUPV3_0_SE1, QUPV3_PROTOCOL_I2C,     QUPV3_MODE_FIFO, AC_HLOS,            TRUE,  TRUE,  FALSE }, // APPS I2C - PCIE/ USB Type C
      { QUPV3_0_SE2, QUPV3_PROTOCOL_I2C,     QUPV3_MODE_FIFO, AC_HLOS,            TRUE,  TRUE,  FALSE }, // SMB / LS1 I2C
      { QUPV3_0_SE3, QUPV3_PROTOCOL_SPI,     QUPV3_MODE_FIFO, AC_HLOS,            TRUE,  TRUE,  FALSE }, // CAN SPI
      { QUPV3_0_SE4, QUPV3_PROTOCOL_UART_4W, QUPV3_MODE_FIFO, AC_HLOS,            TRUE,  TRUE,  FALSE }, // LS1 UART
      { QUPV3_0_SE5, QUPV3_PROTOCOL_UART_2W, QUPV3_MODE_FIFO, AC_HLOS,            TRUE,  FALSE, FALSE }, // Debug UART
      { QUPV3_0_SE6, QUPV3_PROTOCOL_UART_2W, QUPV3_MODE_FIFO, AC_HLOS,            TRUE,  TRUE,  FALSE }, // WLAN UART
      { QUPV3_0_SE7, QUPV3_PROTOCOL_UART_4W, QUPV3_MODE_FIFO, AC_HLOS,            TRUE,  TRUE,  FALSE }, // Hastings BT
      { QUPV3_1_SE0, QUPV3_PROTOCOL_SPMI,    QUPV3_MODE_FIFO, AC_ADSP_Q6_ELF,     TRUE,  TRUE,  FALSE }, // QuP SPMI
      { QUPV3_1_SE1, QUPV3_PROTOCOL_I2C,     QUPV3_MODE_FIFO, AC_HLOS,            TRUE,  TRUE,  FALSE }, // NFC I2C
      { QUPV3_1_SE2, QUPV3_PROTOCOL_I2C,     QUPV3_MODE_FIFO, AC_HLOS,            TRUE,  TRUE,  FALSE }, // HDMI OUT for VIDEOIOBoard
      { QUPV3_1_SE3, QUPV3_PROTOCOL_SPI,     QUPV3_MODE_FIFO, AC_HLOS,            FALSE, TRUE,  TRUE }, // LS1 SPI
      { QUPV3_1_SE4, QUPV3_PROTOCOL_SPI,     QUPV3_MODE_GSI,  AC_TZ,              FALSE, TRUE,  TRUE }, // SPI -NFC ESE
      { QUPV3_1_SE5, QUPV3_PROTOCOL_I2C,     QUPV3_MODE_GSI,  AC_HLOS,            FALSE, TRUE,  FALSE}, // Legacy Touch
      { QUPV3_1_SE6, QUPV3_PROTOCOL_SPI,     QUPV3_MODE_GSI,  AC_HLOS,            FALSE, TRUE,  FALSE}, // FP
      /*QUPV3_1_SE7*/
    };Copy to clipboard

## SPI bringup

Source: [https://docs.qualcomm.com/doc/80-70018-8/topic/spi.html](https://docs.qualcomm.com/doc/80-70018-8/topic/spi.html)

This section describes how to enable the Qualcomm Linux SPI drivers.

### Linux

To verify SPI communication with the device, kernel configuration must be enabled.
                The `CONFIG_SPI_SPIDEV=m` setting is enabled in the corresponding
                    `<chipset> defconfig` file. Enable the specific QUP v3 SPI
                serial engine instance in the kernel device tree.

## SPI configuration

Source: [https://docs.qualcomm.com/doc/80-70018-8/topic/spi.html](https://docs.qualcomm.com/doc/80-70018-8/topic/spi.html)

This section provides information about the SPI software driver kernel configuration and
            device tree node changes.

### Linux

The following driver kernel configurations are required to support the SPI
                    interface.
- Driver source file at [https://github.com/torvalds/linux/blob/master/drivers/spi/spi-geni-qcom.c](https://github.com/torvalds/linux/blob/master/drivers/spi/spi-geni-qcom.c)
- Kernel `defconfig` file
                            at &lt;workspace\_path\_of\_LINUX\_kernel\_image&gt;/sources/kernel
                            /kernel\_platform/kernel/arch/arm64/configs/qcom\_defconfig

The following kernel configurations must be enabled.
- `CONFIG_QCOM_GENI_SE=y`
- `CONFIG_SPI_QCOM_GENI=m`
- `CONFIG_SPI_SPIDEV=m` to configure user space
                        applications
- `CONFIG_QCOM_GPI_DMA=m` to enable GSI support

To enable the SPI node for the loopback validation, apply the following patch to the /arch/arm64/boot/dts/qcom/&lt;chipset&gt;.dtsi
                file.

    diff --git a/arch/arm64/boot/dts/qcom/<chipset>.dtsi b/arch/arm64/boot/dts/qcom/<chipset>.dtsi
    index 82dfa3e..344e99a 100644
    --- a/arch/arm64/boot/dts/qcom/<chipset>.dtsi
    +++ b/arch/arm64/boot/dts/qcom/<chipset>.dtsi
    @@ -6760,3 +6760,12 @@
    <GIC_PPI 10 IRQ_TYPE_LEVEL_LOW>;
     };
     };
    +
    +&spi14 {
    +        status = "ok";
    +        spidev@0 {
    +                compatible = "spidev";
    +                spi-max-frequency = <50000000>;
    +                reg = <0>;
    +        };
    +};
    
    diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
    index d13dc15..36d7914 100644
    --- a/drivers/spi/spidev.c
    +++ b/drivers/spi/spidev.c
    @@ -84,7 +84,7 @@
    static LIST_HEAD(device_list);
    static DEFINE_MUTEX(device_list_lock);
     
    -static unsigned bufsiz = 4096;
    +static unsigned bufsiz = 35000;
    module_param(bufsiz, uint, S_IRUGO);
    MODULE_PARM_DESC(bufsiz, "data bytes in biggest supported SPI message");
     
    @@ -742,6 +742,7 @@
     	{ .compatible = "semtech,sx1301", .data = &spidev_of_check },
     	{ .compatible = "silabs,em3581", .data = &spidev_of_check },
     	{ .compatible = "silabs,si3210", .data = &spidev_of_check },
    +	{ .compatible = "spidev"},
    {},
     };
     MODULE_DEVICE_TABLE(of, spidev_dt_ids);
    Copy to clipboard

Note: You should compile the kernel configuration and device tree
                changes. After the kernel is compiled, you can load the images to the device to
                verify the interface. For information about interface verification, see the [SPI verification](https://docs.qualcomm.com/doc/80-70018-8/topic/spi.html#spi_verification) section.

## SPI verification

Source: [https://docs.qualcomm.com/doc/80-70018-8/topic/spi.html](https://docs.qualcomm.com/doc/80-70018-8/topic/spi.html)

This section describes the validation procedure and test results for the SPI drivers.

### Linux

To cross-compile the SPI tools, do the following.
1. Access the SPI tool
                            from yocto/build-qcom-wayland/tmp-glibc/work-shared/&lt;chipset&gt;/kernel-source/tools/spi.
                        For more details about the SPI tool, see [https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/tools/spi](https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/tools/spi).
2. Install cross
                        compiler.

        sudo apt-get install gcc-aarch64-linux-gnuCopy to clipboard
3. Set up the environment for cross-compilation by running the following
                        command.

        export ARCH=arm64export CROSS_COMPILE=aarch64-linux-gnu-Copy to clipboard
4. Compile the tool by running the following
                        command.

        makeCopy to clipboard

### Verify SPI device

Verify the driver by checking for `dev` node
                    (`/dev/spidev1.0`) in the SSH shell or use the ADB shell. For
                more information about how to run SSH, see the [Use SSH](https://docs.qualcomm.com/bundle/publicresource/topics/80-70018-254/how_to.html) section.

1. To verify the SPI driver, do the following:
    1. Open the SSH shell in permissive mode or use the ADB shell.
    2. Mount the file
                            system.

            mount -o remount,rw /usrCopy to clipboard
    3. Transfer files using SCP or similar tools. 
        For example, `scp
                                    spidev_test root@10.92.175.138:/bin`.
    4. Assign permission to
                            execute.

            chmod 777 spidev_testCopy to clipboard
2. Verify an SPI device. Command format `./spidev_test -D
                        /dev/<spidev_node>`.

        ./spidev_test -D /dev/spidev1.0
        ./spidev_test -D /dev/spidev3.0
        Copy to clipboard

The following output is
                        displayed.

        spi mode: 0x0
        bits per word: 8
        max speed: 500000 Hz (500 KHz)Copy to clipboard

Run the following command for information about
                usage.

    ./spidev_test -helpCopy to clipboard

The
                following output is displayed.

    -D --device   device to use (default /dev/spidev1.1)
    -s --speed    max speed (Hz)
    -d --delay    delay (usec)
    -b --bpw      bits per word
    -i --input    input data from a file (e.g. "test.bin")
    -o --output   output data to a file (e.g. "results.bin")
    -l --loop     loopback
    -H --cpha     clock phase
    -O --cpol     clock polarity
    -L --lsb      least significant bit first
    -C --cs-high  chip select active high
    -3 --3wire    SI/SO signals shared
    -v --verbose  Verbose (show tx buffer)
    -p  Send data (e.g. "1234\xde\xad")
    -N --no-cs    no chip select
      -R --ready    slave pulls low to pause
      -2 --dual     dual transfer
      -4 --quad     quad transfer
      -8 --octal    octal transfer
      -S --size     transfer size
      -I --iter     iterationsCopy to clipboard

## SPI debugging

Source: [https://docs.qualcomm.com/doc/80-70018-8/topic/spi.html](https://docs.qualcomm.com/doc/80-70018-8/topic/spi.html)

This section describes the default logging method of the SPI software driver to enable
            logging the SPI transfer failures.

### Linux

The SPI driver logs are enabled through a dynamic debugging method. Enable
                    `CONFIG_DYNAMIC_DEBUG`
                    in &lt;workspace\_path\_of\_LINUX\_kernel\_image&gt;/sources/kernel/kernel\_platform/kernel/arch/arm64/configs/qcom\_defconfig
                to support the dynamic debugging of the kernel drivers.

To enable and view the SPI driver logs in the kernel logs (`dmesg`),
                run the following
                command.

    mount -t debugfs none /sys/kernel/debug
    echo -n "file spi-geni-qcom.c +p" > /sys/kernel/debug/dynamic_debug/control
    echo -n "file qcom-geni-se.c  +p" > /sys/kernel/debug/dynamic_debug/control
    echo -n "file spidev.c +p" > /sys/kernel/debug/dynamic_debug/control
    echo -n "file gpi.c +p" > /sys/kernel/debug/dynamic_debug/controlCopy to clipboard

## SPI examples

Source: [https://docs.qualcomm.com/doc/80-70018-8/topic/spi.html](https://docs.qualcomm.com/doc/80-70018-8/topic/spi.html)

For information about the upstream device tree reference, see the following DTSI
                files.
- QCS6490 and QCS5430: [https://git.linaro.org/kernel-org/linux-next.git/tree/arch/arm64/boot/dts/qcom/sc7280.dtsi](https://git.linaro.org/kernel-org/linux-next.git/tree/arch/arm64/boot/dts/qcom/sc7280.dtsi)
- QCS9075: [https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/qcom/sa8775p.dtsi](https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/qcom/sa8775p.dtsi)

For information about device-tree node for the Qualcomm Linux hardware SoCs, see the
            following DTSI files.
- QCS6490 and QCS5430: [https://git.linaro.org/kernel-org/linux-next.git/tree/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts](https://git.linaro.org/kernel-org/linux-next.git/tree/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts)
- QCS9075: [https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/qcom/sa8775p.dtsi](https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/qcom/sa8775p.dtsi)

Last Published: Mar 26, 2025

[Previous Topic
UART](https://docs.qualcomm.com/bundle/publicresource/80-70018-8/topics/uart.md) [Next Topic
I2C](https://docs.qualcomm.com/bundle/publicresource/80-70018-8/topics/i2c.md)