1<?xml version="1.0" encoding="utf-8"?>
2
3
4<!--****************************************************************************
5* \file smif.cypersonality
6* \version 1.2
7*
8* \brief
9* Quad Serial Peripheral Interface (QSPI) personality description file.
10*
11********************************************************************************
12* \copyright
13* Copyright 2018-2022 Cypress Semiconductor Corporation
14* SPDX-License-Identifier: Apache-2.0
15*
16* Licensed under the Apache License, Version 2.0 (the "License");
17* you may not use this file except in compliance with the License.
18* You may obtain a copy of the License at
19*
20*     http://www.apache.org/licenses/LICENSE-2.0
21*
22* Unless required by applicable law or agreed to in writing, software
23* distributed under the License is distributed on an "AS IS" BASIS,
24* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25* See the License for the specific language governing permissions and
26* limitations under the License.
27*****************************************************************************-->
28
29<Personality id="mxs40smif" name="Quad Serial Peripheral Interface (QSPI)" version="1.2" xmlns="http://cypress.com/xsd/cyhwpersonality_v7">
30  <Dependencies>
31    <IpBlock name="mxsmif" >
32        <Version major="1" />
33    </IpBlock>
34    <Resource name="smif" />
35  </Dependencies>
36  <ExposedMembers />
37  <Parameters>
38    <!-- PDL documentation -->
39    <ParamDoc id="pdlDoc" name="Configuration Help" group="Overview" default="file:///`${cy_libs_path()}`/docs/pdl_api_reference_manual/html/group__group__smif.html" linkText="Open SMIF Documentation" visible="true" desc="Opens the Peripheral Driver Library Documentation" />
40
41    <!-- Clocks -->
42    <ParamSignal port="clk_hf[0]" name="HF Clock" group="Clocks" visible="true" desc="High frequency source clock" canBeEmpty="false" />
43    <ParamSignal port="clk_if[0]" name="Interface Clock" group="Clocks" visible="true" desc="Transmission interface clock" canBeEmpty="false" />
44    <ParamSignal port="spi_clk[0]" name="SPI Clock" group="Clocks" visible="true" desc="The Serial Clock (SCLK) to the slave devices" canBeEmpty="false">
45      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
46        <Parameter id="DriveModes" severity="ERROR" reason="Drive Mode must be set to 'Strong Drive. Input buffer off'.">
47          <Fixed value="CY_GPIO_DM_STRONG_IN_OFF" />
48        </Parameter>
49      </Constraint>
50      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
51    </ParamSignal>
52
53    <ParamString id="smifIfSource" name="smifIfSource" group="Internal" default="`${getBlockFromSignal(&quot;clk_if[0]&quot;)}`" visible="false" editable="false" desc="Interface Source Clock Resource" />
54    <ParamRange  id="smifIfClkHz" name="smifIfClkHz" group="Internal" default="`${getExposedMember(smifIfSource, &quot;frequency&quot;)}`" min="1" max="200000000" resolution="1" visible="false" editable="false" desc="SMIF IF clock frequency in Hz." />
55
56
57    <!-- External tools -->
58    <ParamString id="cfgFileName" name="cfgFileName" group="External Tools" default="design.cyqspi" visible="false" editable="false" desc="" />
59    <ParamString id="cfgFilePath" name="cfgFilePath" group="External Tools" default="`${cy_design_path() . &quot;/&quot; . cfgFileName}`" visible="false" editable="false" desc="" />
60
61    <ParamCustom id="configurator" name="QSPI Configurator" group="External Tools" default="0" path="`${cy_tools_path(&quot;qspi-configurator&quot;) . &quot;/qspi-configurator&quot;}`" modal="false" visible="true" editable="true" desc="Launch QSPI Configurator tool">
62      <Arg value="`${&quot;--config=&quot; . cfgFilePath}`" />
63      <Arg value="`${&quot;--output-dir=&quot; . cy_codegen_path()}`" />
64      <Arg value="`${&quot;--library=&quot; . cy_libs_file()}`" />
65    </ParamCustom>
66
67    <!-- Data -->
68    <ParamSignal port="spi_data0[0]" name="SPI Data[0]" group="Data" visible="`${hasVisibleOption(&quot;spi_data0[0]&quot;)}`" desc="Data line 0 to be used by the QSPI block, must be used in conjunction with Data line 1" canBeEmpty="true">
69      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
70        <Parameter id="DriveModes" severity="ERROR" reason="Drive Mode must be set to 'Strong Drive. Input buffer on'.">
71          <Fixed value="CY_GPIO_DM_STRONG" />
72        </Parameter>
73      </Constraint>
74      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
75    </ParamSignal>
76    <ParamSignal port="spi_data1[0]" name="SPI Data[1]" group="Data" visible="`${hasVisibleOption(&quot;spi_data1[0]&quot;)}`" desc="Data line 1 to be used by the QSPI block, must be used in conjunction with Data line 0" canBeEmpty="true">
77      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
78        <Parameter id="DriveModes" severity="ERROR" reason="Drive Mode must be set to 'Strong Drive. Input buffer on'.">
79          <Fixed value="CY_GPIO_DM_STRONG" />
80        </Parameter>
81      </Constraint>
82      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
83    </ParamSignal>
84    <ParamSignal port="spi_data2[0]" name="SPI Data[2]" group="Data" visible="`${hasVisibleOption(&quot;spi_data2[0]&quot;)}`" desc="Data line 2 to be used by the QSPI block, must be used in conjunction with Data line 3" canBeEmpty="true">
85      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
86        <Parameter id="DriveModes" severity="ERROR" reason="Drive Mode must be set to 'Strong Drive. Input buffer on'.">
87          <Fixed value="CY_GPIO_DM_STRONG" />
88        </Parameter>
89      </Constraint>
90      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
91    </ParamSignal>
92    <ParamSignal port="spi_data3[0]" name="SPI Data[3]" group="Data" visible="`${hasVisibleOption(&quot;spi_data3[0]&quot;)}`" desc="Data line 3 to be used by the QSPI block, must be used in conjunction with Data line 2" canBeEmpty="true">
93      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
94        <Parameter id="DriveModes" severity="ERROR" reason="Drive Mode must be set to 'Strong Drive. Input buffer on'.">
95          <Fixed value="CY_GPIO_DM_STRONG" />
96        </Parameter>
97      </Constraint>
98      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
99    </ParamSignal>
100    <ParamSignal port="spi_data4[0]" name="SPI Data[4]" group="Data" visible="`${(CHIP_TOP.DATA8_PRESENT == 1) &amp;&amp; hasVisibleOption(&quot;spi_data4[0]&quot;)}`" desc="Data line 4 to be used by the QSPI block, must be used in conjunction with Data line 5" canBeEmpty="true">
101      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
102        <Parameter id="DriveModes" severity="ERROR" reason="Drive Mode must be set to 'Strong Drive. Input buffer on'.">
103          <Fixed value="CY_GPIO_DM_STRONG" />
104        </Parameter>
105      </Constraint>
106      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
107    </ParamSignal>
108    <ParamSignal port="spi_data5[0]" name="SPI Data[5]" group="Data" visible="`${(CHIP_TOP.DATA8_PRESENT == 1) &amp;&amp; hasVisibleOption(&quot;spi_data5[0]&quot;)}`" desc="Data line 5 to be used by the QSPI block, must be used in conjunction with Data line 4" canBeEmpty="true">
109      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
110        <Parameter id="DriveModes" severity="ERROR" reason="Drive Mode must be set to 'Strong Drive. Input buffer on'.">
111          <Fixed value="CY_GPIO_DM_STRONG" />
112        </Parameter>
113      </Constraint>
114      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
115    </ParamSignal>
116    <ParamSignal port="spi_data6[0]" name="SPI Data[6]" group="Data" visible="`${(CHIP_TOP.DATA8_PRESENT == 1) &amp;&amp; hasVisibleOption(&quot;spi_data6[0]&quot;)}`" desc="Data line 6 to be used by the QSPI block, must be used in conjunction with Data line 7" canBeEmpty="true">
117      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
118        <Parameter id="DriveModes" severity="ERROR" reason="Drive Mode must be set to 'Strong Drive. Input buffer on'.">
119          <Fixed value="CY_GPIO_DM_STRONG" />
120        </Parameter>
121      </Constraint>
122      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
123    </ParamSignal>
124    <ParamSignal port="spi_data7[0]" name="SPI Data[7]" group="Data" visible="`${(CHIP_TOP.DATA8_PRESENT == 1) &amp;&amp; hasVisibleOption(&quot;spi_data7[0]&quot;)}`" desc="Data line 7 to be used by the QSPI block, must be used in conjunction with Data line 6" canBeEmpty="true">
125      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
126        <Parameter id="DriveModes" severity="ERROR" reason="Drive Mode must be set to 'Strong Drive. Input buffer on'.">
127          <Fixed value="CY_GPIO_DM_STRONG" />
128        </Parameter>
129      </Constraint>
130      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
131    </ParamSignal>
132
133    <!-- Select -->
134    <ParamSignal port="spi_select0[0]" name="SPI Slave Select 0" group="Slave Select" visible="`${hasVisibleOption(&quot;spi_select0[0]&quot;)}`" desc="Select signal 0 to specifiy which memory device to communicate with" canBeEmpty="true">
135      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
136        <Parameter id="DriveModes" severity="ERROR" reason="Drive Mode must be set to 'Strong Drive. Input buffer off'.">
137          <Fixed value="CY_GPIO_DM_STRONG_IN_OFF" />
138        </Parameter>
139      </Constraint>
140      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
141    </ParamSignal>
142    <ParamSignal port="spi_select1[0]" name="SPI Slave Select 1" group="Slave Select" visible="`${hasVisibleOption(&quot;spi_select1[0]&quot;)}`" desc="Select signal 1 to specifiy which memory device to communicate with" canBeEmpty="true">
143      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
144        <Parameter id="DriveModes" severity="ERROR" reason="Drive Mode must be set to 'Strong Drive. Input buffer off'.">
145          <Fixed value="CY_GPIO_DM_STRONG_IN_OFF" />
146        </Parameter>
147      </Constraint>
148      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
149    </ParamSignal>
150    <ParamSignal port="spi_select2[0]" name="SPI Slave Select 2" group="Slave Select" visible="`${hasVisibleOption(&quot;spi_select2[0]&quot;)}`" desc="Select signal 2 to specifiy which memory device to communicate with" canBeEmpty="true">
151      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
152        <Parameter id="DriveModes" severity="ERROR" reason="Drive Mode must be set to 'Strong Drive. Input buffer off'.">
153          <Fixed value="CY_GPIO_DM_STRONG_IN_OFF" />
154        </Parameter>
155      </Constraint>
156      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
157    </ParamSignal>
158    <ParamSignal port="spi_select3[0]" name="SPI Slave Select 3" group="Slave Select" visible="`${hasVisibleOption(&quot;spi_select3[0]&quot;)}`" desc="Select signal 3 to specifiy which memory device to communicate with" canBeEmpty="true">
159      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
160        <Parameter id="DriveModes" severity="ERROR" reason="Drive Mode must be set to 'Strong Drive. Input buffer off'.">
161          <Fixed value="CY_GPIO_DM_STRONG_IN_OFF" />
162        </Parameter>
163      </Constraint>
164      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
165    </ParamSignal>
166
167    <!-- Interrupt -->
168    <ParamBool id="isrAlignment" name="Memory Mode Alignment Error" group="Interrupt" default="false" visible="true" editable="true" desc="An alignment error in the memory mode (XIP mode) is set as an interrupt cause" />
169    <ParamBool id="isrUnderflow" name="RX Data FIFO Underflow" group="Interrupt" default="false" visible="true" editable="true" desc="The Rx Data FIFO underflow condition is set as an interrupt cause" />
170    <ParamBool id="isrCmdOverflow" name="TX Command FIFO Overflow" group="Interrupt" default="false" visible="true" editable="true" desc="The TX command FIFO overflow condition is set as an interrupt cause" />
171    <ParamBool id="isrDataOverflow" name="TX Data FIFO Overflow" group="Interrupt" default="false" visible="true" editable="true" desc="The TX data FIFO overflow condition is set as an interrupt cause" />
172
173    <!-- DMA -->
174    <ParamSignal port="tr_rx_req[0]" name="RX Trigger Output" group="DMA Triggers" visible="true" desc="Enables the RX trigger output terminal (tr_rx_req)" canBeEmpty="true" />
175    <ParamRange id="rxTriggerLevel" name="RX FIFO Trigger Level" group="DMA Triggers" default="0" min="0" max="7" resolution="1" visible="true" editable="true" desc="The level that can trigger the RX FIFO to trigger an interrupt or a DMA request" />
176    <ParamSignal port="tr_tx_req[0]" name="TX Trigger Output" group="DMA Triggers" visible="true" desc="enables the TX trigger output terminal (tr_tx_req)" canBeEmpty="true" />
177    <ParamRange id="txTriggerLevel" name="TX FIFO Trigger Level" group="DMA Triggers" default="0" min="0" max="7" resolution="1" visible="true" editable="true" desc="The level that can trigger the TX FIFO to trigger an interrupt or a DMA request" />
178
179    <!-- SMIF instance number -->
180    <ParamString id="InstNumber" name="InstNumber" group="Internal" default="`${getInstNumber(&quot;smif&quot;)}`" visible="false" editable="false" desc="SMIF Instance name number." />
181
182    <!-- Other -->
183    <ParamBool id="inFlash" name="Store Config in Flash" group="Advanced" default="true" visible="true" editable="true" desc="Controls whether the configuration structure is stored in flash (const, true) or SRAM (not const, false)." />
184
185    <!-- Helpers -->
186    <Repeat count="8">
187      <ParamBool id="hasConnection$idx" name="" group="Hidden" default="`${hasConnection(&quot;spi_data$idx&quot;, 0)}`" visible="false" editable="false" desc="" />
188	</Repeat>
189    <Repeat count="4">
190      <ParamBool id="hasSelect$idx" name="" group="Hidden" default="`${hasConnection(&quot;spi_select$idx&quot;, 0)}`" visible="false" editable="false" desc="" />
191	</Repeat>
192    <ParamBool id="allDataConnected" name="" group="Hidden" default="`${hasConnection0 &amp;&amp; hasConnection2 &amp;&amp; hasConnection4 &amp;&amp; hasConnection6}`" visible="false" editable="false" desc="" />
193    <ParamBool id="requireMultipleSelects" name="" group="Hidden" default="`${!allDataConnected &amp;&amp; ((hasConnection0 &amp;&amp; hasConnection4) || (hasConnection0 &amp;&amp; hasConnection6) || (hasConnection2 &amp;&amp; hasConnection4) || (hasConnection2 &amp;&amp; hasConnection6))}`" visible="false" editable="false" desc="" />
194  </Parameters>
195
196  <DRCs>
197    <DRC type="ERROR" text="SPI Data[0] and SPI Data[1] must be used together" condition="`${hasConnection0 != hasConnection1}`" paramId="spi_data0[0]" />
198    <DRC type="ERROR" text="SPI Data[2] and SPI Data[3] must be used together" condition="`${hasConnection2 != hasConnection3}`" paramId="spi_data2[0]" />
199    <DRC type="ERROR" text="SPI Data[4] and SPI Data[5] must be used together" condition="`${hasConnection4 != hasConnection5}`" paramId="spi_data4[0]" />
200    <DRC type="ERROR" text="SPI Data[6] and SPI Data[7] must be used together" condition="`${hasConnection6 != hasConnection7}`" paramId="spi_data6[0]" />
201    <DRC type="ERROR" text="At least two SPI Data signal must be connected" condition="`${!(hasConnection0 || hasConnection2 || hasConnection4 || hasConnection6)}`" paramId="spi_data0[0]" />
202    <DRC type="ERROR" text="At least one SPI Select signal must be connected" condition="`${!(requireMultipleSelects || hasSelect0 || hasSelect1 || hasSelect2 || hasSelect3)}`" paramId="spi_select0[0]" />
203    <DRC type="ERROR" text="At least two SPI Select signal must be connected" condition="`${requireMultipleSelects &amp;&amp; !((hasSelect0 &amp;&amp; hasSelect1) || (hasSelect0 &amp;&amp; hasSelect2) || (hasSelect0 &amp;&amp; hasSelect3) || (hasSelect1 &amp;&amp; hasSelect2) || (hasSelect1 &amp;&amp; hasSelect3) || (hasSelect2 &amp;&amp; hasSelect3))}`" paramId="spi_select0[0]"/>
204    <DRC type="ERROR" text="Interface Clock must not be greater than 80 Mhz" condition="`${smifIfClkHz > 80000000}`" location="`${smifIfSource}`" />
205  </DRCs>
206
207  <ConfigFirmware>
208    <!-- External tools -->
209    <ConfigTool value="`${cy_tools_path(&quot;qspi-configurator&quot;) . &quot;/qspi-configurator-cli&quot;}`" include="true">
210      <Arg value="`${&quot;--config=&quot; . cfgFilePath}`" />
211      <Arg value="`${&quot;--output-dir=&quot; . cy_codegen_path()}`" />
212    </ConfigTool>
213
214    <ConfigInclude value="cy_smif.h" include="true" />
215    <ConfigInclude value="cycfg_qspi_memslot.h" include="true" />
216    <ConfigInclude value="cyhal_hwmgr.h" include="true" guard="defined (CY_USING_HAL)" />
217
218    <ConfigDefine name="`${INST_NAME}`_HW" value="SMIF`${InstNumber}`" public="true" include="true" />
219    <ConfigDefine name="`${INST_NAME}`_IRQ" value="smif_interrupt_IRQn" public="true" include="true" />
220    <ConfigDefine name="`${INST_NAME}`_MEMORY_MODE_ALIGMENT_ERROR" value="`${isrAlignment ? &quot;(1UL)&quot; : &quot;(0UL)&quot;}`" public="true" include="true" />
221    <ConfigDefine name="`${INST_NAME}`_RX_DATA_FIFO_UNDERFLOW" value="`${isrUnderflow ? &quot;(1UL)&quot; : &quot;(0UL)&quot;}`" public="true" include="true" />
222    <ConfigDefine name="`${INST_NAME}`_TX_COMMAND_FIFO_OVERFLOW" value="`${isrCmdOverflow ? &quot;(1UL)&quot; : &quot;(0UL)&quot;}`" public="true" include="true" />
223    <ConfigDefine name="`${INST_NAME}`_TX_DATA_FIFO_OVERFLOW" value="`${isrDataOverflow ? &quot;(1UL)&quot; : &quot;(0UL)&quot;}`" public="true" include="true" />
224
225    <ConfigDefine name="`${INST_NAME}`_RX_FIFO_TRIGEER_LEVEL" value="(`${rxTriggerLevel}`UL)" public="true" include="true" />
226    <ConfigDefine name="`${INST_NAME}`_TX_FIFO_TRIGEER_LEVEL" value="(`${txTriggerLevel}`UL)" public="true" include="true" />
227
228    <ConfigDefine name="`${INST_NAME}`_DATALINES0_1" value="`${hasConnection0 ? &quot;(1UL)&quot; : &quot;(0UL)&quot;}`" public="true" include="true" />
229    <ConfigDefine name="`${INST_NAME}`_DATALINES2_3" value="`${hasConnection2 ? &quot;(1UL)&quot; : &quot;(0UL)&quot;}`" public="true" include="true" />
230    <ConfigDefine name="`${INST_NAME}`_DATALINES4_5" value="`${hasConnection4 ? &quot;(1UL)&quot; : &quot;(0UL)&quot;}`" public="true" include="true" />
231    <ConfigDefine name="`${INST_NAME}`_DATALINES6_7" value="`${hasConnection6 ? &quot;(1UL)&quot; : &quot;(0UL)&quot;}`" public="true" include="true" />
232
233    <ConfigDefine name="`${INST_NAME}`_SS0" value="`${hasSelect0 ? &quot;(1UL)&quot; : &quot;(0UL)&quot;}`" public="true" include="true" />
234    <ConfigDefine name="`${INST_NAME}`_SS1" value="`${hasSelect1 ? &quot;(1UL)&quot; : &quot;(0UL)&quot;}`" public="true" include="true" />
235    <ConfigDefine name="`${INST_NAME}`_SS2" value="`${hasSelect2 ? &quot;(1UL)&quot; : &quot;(0UL)&quot;}`" public="true" include="true" />
236    <ConfigDefine name="`${INST_NAME}`_SS3" value="`${hasSelect3 ? &quot;(1UL)&quot; : &quot;(0UL)&quot;}`" public="true" include="true" />
237
238    <ConfigDefine name="`${INST_NAME}`_DESELECT_DELAY" value="7" public="true" include="true" />
239
240    <ConfigStruct name="`${INST_NAME . &quot;_config&quot;}`" type="cy_stc_smif_config_t" const="`${inFlash}`" public="true" include="true" >
241      <Member name="mode" value="(uint32_t)CY_SMIF_NORMAL" />
242      <Member name="deselectDelay" value="`${INST_NAME}`_DESELECT_DELAY" />
243      <Member name="rxClockSel" value="(uint32_t)CY_SMIF_SEL_INV_INTERNAL_CLK" />
244      <Member name="blockEvent" value="(uint32_t)CY_SMIF_BUS_ERROR" />
245    </ConfigStruct>
246
247    <ConfigStruct name="`${INST_NAME}`_obj" type="cyhal_resource_inst_t" const="true" public="true" include="true" guard="defined (CY_USING_HAL)">
248      <Member name="type" value="CYHAL_RSC_SMIF" />
249      <Member name="block_num" value="`${getInstNumber(&quot;smif&quot;)}`U" />
250      <Member name="channel_num" value="0U" />
251    </ConfigStruct>
252
253    <ConfigInstruction value="cyhal_hwmgr_reserve(&amp;`${INST_NAME}`_obj);" include="true" guard="defined (CY_USING_HAL)" />
254  </ConfigFirmware>
255</Personality>
256