1<?xml version="1.0" encoding="utf-8"?>
2
3
4<!--****************************************************************************
5* \file hfclk.cypersonality
6* \version 3.0
7*
8* \brief
9* CLK_HF personality description file. It Supports CAT1A, CAT1B and CAT1C family of devices.
10*
11********************************************************************************
12* \copyright
13* Copyright 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="hfclk" name="CLK_HF" version="3.0" xmlns="http://cypress.com/xsd/cyhwpersonality_v7">
30  <Dependencies>
31    <IpBlock name="mxs40srss,mxs40ssrss,mxs40srss_ver3,mxs40srss_ver2" />
32    <Resource name="srss\.clock\.hfclk" />
33  </Dependencies>
34  <ExposedMembers>
35    <ExposedMember key="frequency" paramId="frequency" />
36    <ExposedMember key="accuracy"  paramId="accuracy" />
37    <ExposedMember key="error"     paramId="error" />
38    <ExposedMember key="clockInst" paramId="clockInst" />
39    <ExposedMember key="sourceClockDisplayName" paramId="sourceClockDisplayName" />
40    <ExposedMember key="number"    paramId="number" />
41    <ExposedMember key="hal_block" paramId="hal_block" />
42  </ExposedMembers>
43  <Parameters>
44    <!-- PDL documentation -->
45    <ParamDoc id="pdlDoc" name="Configuration Help" group="Overview" default="file:///`${cy_libs_path()}`/docs/pdl_api_reference_manual/html/group__group__sysclk__clk__hf.html" linkText="Open High-Frequency Clocks Documentation" visible="true" desc="Opens the Peripheral Driver Library Documentation" />
46
47    <ParamRange id="clockInst" name="clockInst" group="Internal" default="`${getInstNumber(&quot;hfclk&quot;)}`" min="0" max="`${NUM_HFROOT-1}`" resolution="1" visible="false" editable="false" desc="" />
48    <ParamChoice id="sourceClockNumber" name="Source Clock" group="General" default="0" visible="true" editable="true" desc="The clock source for CLK_HF`${clockInst}`">
49      <Entry name="CLK_PATH0"  value="0"  visible="`${NUM_CLKPATH >= 1}`"/>
50      <Entry name="CLK_PATH1"  value="1"  visible="`${NUM_CLKPATH >= 2}`"/>
51      <Entry name="CLK_PATH2"  value="2"  visible="`${NUM_CLKPATH >= 3}`"/>
52      <Entry name="CLK_PATH3"  value="3"  visible="`${NUM_CLKPATH >= 4}`"/>
53      <Entry name="CLK_PATH4"  value="4"  visible="`${NUM_CLKPATH >= 5}`"/>
54      <Entry name="CLK_PATH5"  value="5"  visible="`${NUM_CLKPATH >= 6}`"/>
55      <Entry name="CLK_PATH6"  value="6"  visible="`${NUM_CLKPATH >= 7}`"/>
56      <Entry name="CLK_PATH7"  value="7"  visible="`${NUM_CLKPATH >= 8}`"/>
57      <Entry name="CLK_PATH8"  value="8"  visible="`${NUM_CLKPATH >= 9}`"/>
58      <Entry name="CLK_PATH9"  value="9"  visible="`${NUM_CLKPATH >= 10}`"/>
59      <Entry name="CLK_PATH10" value="10" visible="`${NUM_CLKPATH >= 11}`"/>
60      <Entry name="CLK_PATH11" value="11" visible="`${NUM_CLKPATH >= 12}`"/>
61      <Entry name="CLK_PATH12" value="12" visible="`${NUM_CLKPATH >= 13}`"/>
62      <Entry name="CLK_PATH13" value="13" visible="`${NUM_CLKPATH >= 14}`"/>
63      <Entry name="CLK_PATH14" value="14" visible="`${NUM_CLKPATH >= 15}`"/>
64      <Entry name="CLK_PATH15" value="15" visible="`${NUM_CLKPATH >= 16}`"/>
65    </ParamChoice>
66
67    <!-- If the FLL/PLL are enabled, their output drive the corresponding clock path -->
68
69    <ParamBool id="is40srss_ver3Available" name="is40srss_ver3Available" group="" default="`${(&quot;mxs40srss_ver3&quot; eq getIpBlockName())}`" visible="false" editable="false" desc="" />
70
71    <ParamBool id="is40srss_ver2or3Available" name="is40srss_ver2or3Available" group="" default="`${((&quot;mxs40srss_ver2&quot; eq getIpBlockName()) || (&quot;mxs40srss_ver3&quot; eq getIpBlockName()))}`" visible="false" editable="false" desc="" />
72
73    <ParamRange id="numPll400M" name="NUM_PLL400M_ALL" group="Internal" desc="Variable that can be used for all categories" editable="false"
74        default="`${lookupExpression(&quot;NUM_PLL400M&quot;, 0)}`" min="0" max="14" resolution="1" visible="false" />
75
76    <ParamRange id="numTotalPll" name="NUM_TOTAL_PLL_ALL" group="Internal" desc="Variable that can be used for all categories" editable="false"
77        default="`${lookupExpression(&quot;NUM_TOTAL_PLL&quot;, lookupExpression(&quot;NUM_PLL&quot;) + numPll400M)}`" min="0" max="29" resolution="1" visible="false" />
78
79    <ParamBool id="isFllUsed" name="Is FLL Used" group="Internal" default="`${(sourceClockNumber eq 0) &amp;&amp; isBlockUsed(&quot;srss[0].clock[0].fll[0]&quot;)}`" visible="false" editable="false" desc="" />
80
81    <ParamBool id="isPll400mUsed" name="Is PLL-400MHz Used" group="Internal"
82        default="`${((&quot;mxs40srss_ver3&quot; eq getIpBlockName())) &amp;&amp; ((sourceClockNumber &gt; 0) &amp;&amp; (sourceClockNumber &lt;= NUM_PLL400M) &amp;&amp;
83            isBlockUsed(&quot;srss[0].clock[0].pll400m[&quot; . (sourceClockNumber-1) . &quot;]&quot;))}`" visible="false" editable="false" desc="" />
84
85    <ParamBool id="isPllUsed" name="Is PLL Used" group="Internal"
86        default="`${ (&quot;mxs40ssrss&quot; eq getIpBlockName()) ? 0 :
87          (sourceClockNumber &gt; numPll400M) &amp;&amp; (sourceClockNumber &lt;= numTotalPll) &amp;&amp;
88          isBlockUsed(&quot;srss[0].clock[0].pll[&quot; . (sourceClockNumber - 1 - numPll400M) . &quot;]&quot;) }`"
89        visible="false" editable="false" desc="" />
90
91    <ParamBool id="isPll250mUsed" name="Is PLL-250MHz Used" group="Internal" default="`${(&quot;mxs40ssrss&quot; eq getIpBlockName()) ? (NUM_TOTAL_PLL ne 0 ? ((sourceClockNumber ne 0 &amp;&amp; sourceClockNumber &lt;= NUM_DPLL250) &amp;&amp; isBlockUsed(&quot;srss[0].clock[0].dpll250[&quot; . (sourceClockNumber - 1 ) . &quot;]&quot;)) : false) : false}`" visible="false" editable="false" desc="" />
92
93    <!--
94    The clock paths are always arranged in this order: [FLL] [PLL400s/DPLL250s] [PLLs]
95      - FLL clock path indexing will always be just the sourceClockNumber, which will always be zero. Only one FLL is supported here.
96      - PLL400 indexing always comes after FLL, so just needs to subtract 1 for the FLL.
97      - PLL indexing needs to subtract 1 for FLL, and then also subtract the number of PLL400s that may be in front of the PLL clock paths (for devices with PLL but no PLL400, this will subtract zero.)
98      - PLL250 indexing always comes after the FLL, so just needs to subtract 1 for the FLL.
99    As written, sourceClock indexing does not support the combination of PLL250 and PLL400. Update indexing below if a new device requires this combination.
100    -->
101    <ParamString id="sourceClock" name="Source clock resource" group="Internal" default="`${isFllUsed ? &quot;fll[0]&quot; :
102                                                                                            isPll400mUsed ? &quot;pll400m[&quot; . (sourceClockNumber-1) . &quot;]&quot; :
103                                                                                            isPllUsed ? &quot;pll[&quot; . (sourceClockNumber - 1 - numPll400M) . &quot;]&quot; :
104                                                                                            isPll250mUsed &amp;&amp; (&quot;mxs40ssrss&quot; eq getIpBlockName()) ? &quot;dpll250[&quot; . (sourceClockNumber-1) . &quot;]&quot; :
105                                                                                                        &quot;pathmux[&quot; . sourceClockNumber . &quot;]&quot;}`" visible="false" editable="false" desc="" />
106    <ParamString id="sourceClockDisplayName" name="Source Clock Display Name" group="Internal" default="`${getParamValueDisplay(&quot;sourceClock&quot;)}`" visible="false" editable="false" desc="" />
107    <ParamString id="sourceClockRsc" name="Source Clock" group="Internal" default="srss[0].clock[0].`${sourceClock}`" visible="false" editable="false" desc="" />
108
109    <!-- Set an error if the source clock is not enabled or contains an error -->
110    <ParamBool id="srcNotUsed" name="Clock Source Enabled" group="Internal" default="`${!isBlockUsed(sourceClockRsc)}`" visible="false" editable="false" desc="" />
111    <ParamBool id="error" name="Clock Error" group="Internal" default="`${srcNotUsed || getExposedMember(sourceClockRsc, &quot;error&quot;)}`" visible="false" editable="false" desc="" />
112    <ParamRange id="sourceFreq" name="sourceFrequency" group="Internal" default="`${!error ? getExposedMember(sourceClockRsc, &quot;frequency&quot;) : 0}`" min="0" max="400000000" resolution="0.001" visible="false" editable="false" desc="" />
113    <ParamString id="accuracy" name="accuracy" group="Internal" default="`${!error ? getExposedMember(sourceClockRsc, &quot;accuracy&quot;) : 0}`" visible="false" editable="false" desc="" />
114    <ParamString id="sourceFrequencyInfo" name="Source Frequency" group="General" default="`${formatFrequency(sourceFreq,accuracy)}`" visible="true" editable="false" desc="Source clock frequency" />
115
116
117    <ParamChoice id="divider" name="Divider" group="General" default="1" visible="true" editable="true" desc="The source clock frequency divider">
118      <Entry name="1" value="1" visible="true"/>
119      <Entry name="2" value="2" visible="true"/>
120      <Entry name="3" value="3" visible="`${(&quot;mxs40ssrss&quot; eq getIpBlockName()) ? (NUM_TOTAL_PLL ne 0 ? true : false) : false}`"/>
121      <Entry name="4" value="4" visible="true"/>
122      <Entry name="5" value="5" visible="`${(&quot;mxs40ssrss&quot; eq getIpBlockName()) ? (NUM_TOTAL_PLL ne 0 ? true : false) : false}`"/>
123      <Entry name="6" value="6" visible="`${(&quot;mxs40ssrss&quot; eq getIpBlockName()) ? (NUM_TOTAL_PLL ne 0 ? true : false) : false}`"/>
124      <Entry name="7" value="7" visible="`${(&quot;mxs40ssrss&quot; eq getIpBlockName()) ? (NUM_TOTAL_PLL ne 0 ? true : false) : false}`"/>
125      <Entry name="8" value="8" visible="true"/>
126      <Entry name="9" value="9" visible="`${(&quot;mxs40ssrss&quot; eq getIpBlockName()) ? (NUM_TOTAL_PLL ne 0 ? true : false) : false}`"/>
127      <Entry name="10" value="10" visible="`${(&quot;mxs40ssrss&quot; eq getIpBlockName()) ? (NUM_TOTAL_PLL ne 0 ? true : false) : false}`"/>
128      <Entry name="11" value="11" visible="`${(&quot;mxs40ssrss&quot; eq getIpBlockName()) ? (NUM_TOTAL_PLL ne 0 ? true : false) : false}`"/>
129      <Entry name="12" value="12" visible="`${(&quot;mxs40ssrss&quot; eq getIpBlockName()) ? (NUM_TOTAL_PLL ne 0 ? true : false) : false}`"/>
130      <Entry name="13" value="13" visible="`${(&quot;mxs40ssrss&quot; eq getIpBlockName()) ? (NUM_TOTAL_PLL ne 0 ? true : false) : false}`"/>
131      <Entry name="14" value="14" visible="`${(&quot;mxs40ssrss&quot; eq getIpBlockName()) ? (NUM_TOTAL_PLL ne 0 ? true : false) : false}`"/>
132      <Entry name="15" value="15" visible="`${(&quot;mxs40ssrss&quot; eq getIpBlockName()) ? (NUM_TOTAL_PLL ne 0 ? true : false) : false}`"/>
133      <Entry name="16" value="16" visible="`${(&quot;mxs40ssrss&quot; eq getIpBlockName()) ? (NUM_TOTAL_PLL ne 0 ? true : false) : false}`"/>
134    </ParamChoice>
135    <ParamRange id="frequency" name="Frequency" group="Internal" default="`${sourceFreq / divider}`" min="0" max="400000000" resolution="1" visible="false" editable="false" desc="" />
136    <!-- If the frequency is less than one MHz, display its value in kHz -->
137    <ParamString id="frequencyInfo" name="Frequency" group="General" default="`${formatFrequency(frequency,accuracy)}`" visible="true" editable="false" desc="The resulting CLK_HF`${clockInst}` output clock frequency" />
138    <ParamSignal port="root_clk[0]" name="Clock Output" group="General" visible="`${hasVisibleOption(&quot;root_clk[0]&quot;)}`" desc="A high-frequency clock output driving specific peripherals" canBeEmpty="true" >
139      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
140        <Parameter id="DriveModes" severity="DEFAULT" reason="">
141          <Fixed value="CY_GPIO_DM_STRONG_IN_OFF" />
142        </Parameter>
143      </Constraint>
144      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
145        <Parameter id="DriveModes" severity="WARNING" reason="">
146          <Choice>
147            <Option value="CY_GPIO_DM_STRONG_IN_OFF"/>
148            <Option value="CY_GPIO_DM_STRONG"/>
149            <Option value="CY_GPIO_DM_OD_DRIVESLOW_IN_OFF"/>
150            <Option value="CY_GPIO_DM_OD_DRIVESHIGH_IN_OFF"/>
151            <Option value="CY_GPIO_DM_OD_DRIVESLOW"/>
152            <Option value="CY_GPIO_DM_OD_DRIVESHIGH"/>
153            <Option value="CY_GPIO_DM_PULLUP_IN_OFF"/>
154            <Option value="CY_GPIO_DM_PULLDOWN_IN_OFF"/>
155            <Option value="CY_GPIO_DM_PULLUP_DOWN_IN_OFF"/>
156            <Option value="CY_GPIO_DM_PULLUP"/>
157            <Option value="CY_GPIO_DM_PULLDOWN"/>
158            <Option value="CY_GPIO_DM_PULLUP_DOWN"/>
159          </Choice>
160        </Parameter>
161      </Constraint>
162      <!--Constraint type="REQUIRE" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
163        <Parameter id="DriveModes" severity="ERROR" reason="">
164          <Fixed value="CY_GPIO_DM_STRONG_IN_OFF" />
165        </Parameter>
166      </Constraint-->
167      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
168    </ParamSignal>
169    <ParamRange id="number" name="HFCLK number" group="Internal" default="`${getInstNumber(&quot;hfclk&quot;)}`" min="0" max="`${NUM_HFROOT-1}`" resolution="1" visible="false" editable="false" desc="" />
170    <ParamString id="hal_block" name="hal_block" group="Internal" default="CYHAL_CLOCK_BLOCK_HF[`${number}`]" visible="false" editable="false" desc="" />
171  </Parameters>
172  <DRCs>
173    <DRC type="ERROR" text="Source clock for CLK_HF`${clockInst}` is not enabled" condition="`${srcNotUsed}`" >
174      <FixIt action="ENABLE_BLOCK" target="`${sourceClockRsc}`" value="" valid="true" />
175    </DRC>
176    <DRC type="ERROR" text="CLK_HF0 is slower than legal min 200 kHz." condition="`${!error &amp;&amp; ((clockInst == 0) &amp;&amp; (sourceFreq &lt; 200000))}`" />
177    <DRC type="INFO" text="The top-level System Clocks must be enabled to generate the clock initialization code" condition="`${!isBlockUsed(&quot;srss[0].clock[0]&quot;) &amp;&amp; clockInst == 0}`" location="srss[0].clock[0]" >
178      <FixIt action="ENABLE_BLOCK" target="srss[0].clock[0]" value="" valid="true" />
179    </DRC>
180    <!-- Generate a DRC from HFCLK0 that prevents IMO from being disabled -->
181    <DRC type="ERROR" text="The IMO cannot be disabled." condition="`${(clockInst eq 0) &amp;&amp; !isBlockUsed(&quot;srss[0].clock[0].imo[0]&quot;)}`" location="srss[0].clock[0]">
182      <FixIt action="ENABLE_BLOCK" target="srss[0].clock[0].imo[0]" value="" valid="true" />
183    </DRC>
184	<DRC type="ERROR" text="CLK_HF2 should be equal to 48MHz." condition="`${((clockInst == 2) &amp;&amp; (frequency ne 48000000) &amp;&amp; (&quot;mxs40ssrss&quot; eq getIpBlockName()) &amp;&amp; NUM_TOTAL_PLL eq 0)}`" />
185	<DRC type="ERROR" text="CLK_HF3 should be less than 24MHz." condition="`${((clockInst == 3) &amp;&amp; (frequency &gt; 24000000) &amp;&amp; (&quot;mxs40ssrss&quot; eq getIpBlockName()))}`" />
186    <!--DRC type="ERROR" text="Only one connection between the clock system and GPIO pins is possible, either EXTCLK or CLK_HF4." condition="`${hasConnection(&quot;root_clk&quot;, 0) &amp;&amp; isBlockUsed(&quot;srss[0].clock[0].ext[0]&quot;)}`" /-->
187  </DRCs>
188  <ConfigFirmware>
189    <ConfigInclude value="cy_sysclk.h" include="true" />
190    <ConfigDefine name="CY_CFG_SYSCLK_CLKHF`${clockInst}`_ENABLED" public="false" value="1" include="true" />
191    <ConfigDefine name="CY_CFG_SYSCLK_CLKHF`${clockInst}`_DIVIDER" public="false" value="CY_SYSCLK_CLKHF_`${divider == 1 ? &quot;NO_DIVIDE&quot; : ((&quot;DIVIDE_BY_&quot;) . divider)}`" include="true" />
192    <ConfigDefine name="CY_CFG_SYSCLK_CLKHF`${clockInst}`" public="true" value="`${clockInst}`UL" include="true" />
193    <ConfigDefine name="CY_CFG_SYSCLK_CLKHF`${clockInst}`_FREQ_MHZ" public="false" value="`${frequency / 1000000}`UL" include="true" />
194    <ConfigDefine name="CY_CFG_SYSCLK_CLKHF`${clockInst}`_CLKPATH" public="false" value="CY_SYSCLK_CLKHF_IN_CLKPATH`${sourceClockNumber}`" include="true" />
195    <ConfigDefine name="CY_CFG_SYSCLK_CLKHF`${clockInst}`_CLKPATH_NUM" public="true" value="`${sourceClockNumber}`UL" include="true" />
196
197    <ConfigFunction signature="__STATIC_INLINE void Cy_SysClk_ClkHf`${clockInst}`Init()" body="    Cy_SysClk_ClkHfSetSource(`${clockInst}`U, CY_CFG_SYSCLK_CLKHF`${clockInst}`_CLKPATH);&#xA;    Cy_SysClk_ClkHfSetDivider(`${clockInst}`U, CY_SYSCLK_CLKHF_`${divider == 1 ? &quot;NO_DIVIDE&quot; : ((&quot;DIVIDE_BY_&quot;) . divider)}`);&#xA;    Cy_SysClk_ClkHfDirectSel(CY_CFG_SYSCLK_CLKHF`${clockInst}`, false);" public="false" include="`${(is40srss_ver3Available) &amp;&amp; (clockInst eq 0)}`"  />
198
199    <ConfigFunction signature="__STATIC_INLINE void Cy_SysClk_ClkHf`${clockInst}`Init()" body="    Cy_SysClk_ClkHfSetSource(CY_CFG_SYSCLK_CLKHF`${clockInst}`, CY_CFG_SYSCLK_CLKHF`${clockInst}`_CLKPATH);&#xA;    Cy_SysClk_ClkHfSetDivider(CY_CFG_SYSCLK_CLKHF`${clockInst}`, CY_SYSCLK_CLKHF_`${divider == 1 ? &quot;NO_DIVIDE&quot; : ((&quot;DIVIDE_BY_&quot;) . divider)}`);&#xA;    Cy_SysClk_ClkHfDirectSel(CY_CFG_SYSCLK_CLKHF`${clockInst}`, false);&#xA;    Cy_SysClk_ClkHfEnable(CY_CFG_SYSCLK_CLKHF`${clockInst}`);" public="false" include="`${(is40srss_ver3Available) &amp;&amp; (clockInst gt 0)}`"  />
200
201    <ConfigFunction signature="__STATIC_INLINE void Cy_SysClk_ClkHf`${clockInst}`Init()" body="    Cy_SysClk_ClkHfSetSource(`${clockInst}`U, CY_CFG_SYSCLK_CLKHF`${clockInst}`_CLKPATH);&#xA;    Cy_SysClk_ClkHfSetDivider(`${clockInst}`U, CY_SYSCLK_CLKHF_`${divider == 1 ? &quot;NO_DIVIDE&quot; : ((&quot;DIVIDE_BY_&quot;) . divider)}`);" public="false" include="`${!(is40srss_ver3Available) &amp;&amp; (clockInst eq 0)}`" guard="(!defined(CY_DEVICE_SECURE))"/>
202
203    <ConfigFunction signature="__STATIC_INLINE void Cy_SysClk_ClkHf`${clockInst}`Init()" body="    Cy_SysClk_ClkHfSetSource(CY_CFG_SYSCLK_CLKHF`${clockInst}`, CY_CFG_SYSCLK_CLKHF`${clockInst}`_CLKPATH);&#xA;    Cy_SysClk_ClkHfSetDivider(CY_CFG_SYSCLK_CLKHF`${clockInst}`, CY_SYSCLK_CLKHF_`${divider == 1 ? &quot;NO_DIVIDE&quot; : ((&quot;DIVIDE_BY_&quot;) . divider)}`);&#xA;    Cy_SysClk_ClkHfEnable(CY_CFG_SYSCLK_CLKHF`${clockInst}`);" public="false" include="`${!(is40srss_ver3Available) &amp;&amp; (clockInst gt 0)}`" guard="(!defined(CY_DEVICE_SECURE))"/>
204
205  </ConfigFirmware>
206</Personality>
207