1<?xml version="1.0" encoding="utf-8"?> 2 3<!--**************************************************************************** 4* \file emusb.cypersonality 5* \version 1.0 6* 7* \brief 8* emusb personality description file. 9* 10******************************************************************************** 11* \copyright 12* Copyright 2022 Cypress Semiconductor Corporation 13* SPDX-License-Identifier: Apache-2.0 14* 15* Licensed under the Apache License, Version 2.0 (the "License"); 16* you may not use this file except in compliance with the License. 17* You may obtain a copy of the License at 18* 19* http://www.apache.org/licenses/LICENSE-2.0 20* 21* Unless required by applicable law or agreed to in writing, software 22* distributed under the License is distributed on an "AS IS" BASIS, 23* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 24* See the License for the specific language governing permissions and 25* limitations under the License. 26*****************************************************************************--> 27 28<Personality id="mxs40emusb" name="emUSB-Host/Device" version="1.0" xmlns="http://cypress.com/xsd/cyhwpersonality_v7"> 29 <Dependencies> 30 <IpBlock name="mxusbfs" /> 31 <Resource name="usb" /> 32 </Dependencies> 33 <ExposedMembers /> 34 <Parameters> 35 36 <!-- Debug mode selection --> 37 <ParamBool id="debug" name="debug" group="Internal" default="false" visible="false" editable="false" desc="Enable/Disable debug mode" /> 38 39 <!-- Mode selection --> 40 <ParamChoice id="mode" name="USB mode" group="General" default="Host" visible="true" editable="true" desc="Select USB Mode"> 41 <Entry name="Host" value="Host" visible="true" /> 42 <Entry name="Device" value="Device" visible="true" /> 43 </ParamChoice> 44 <ParamBool id="modeIsDevice" name="modeIsDevice" group="Internal" default="`${mode eq Device}`" visible="false" editable="false" desc="USB mode is Device" /> 45 <ParamBool id="modeIsHost" name="modeIsHost" group="Internal" default="`${mode eq Host}`" visible="false" editable="false" desc="USB Mode is Host" /> 46 47 <!-- Documentation --> 48 <ParamDoc id="emUsbDoc" name="Configuration Help" group="Overview" default="`${modeIsHost ? "https://infineon.github.io/emusb-host/html/index.html" : "https://infineon.github.io/emusb-device/html/index.html"}`" linkText="`${modeIsHost ? "Open emUSB-Host Documentation" : "Open emUSB-Device Documentation"}`" visible="true" desc="Open the USB Documentation" /> 49 50 <!-- USB Hf clock configuration --> 51 <ParamSignal port="clk_usb_host[0]" name="Clock" group="Connections" visible="`${modeIsHost}`" desc="The clock to operate this block" canBeEmpty="true" /> 52 <ParamBool id="clkUsbHostIsConnected" name="clkUsbHostIsConnected" group="Internal" default="`${hasConnection("clk_usb_host", 0)}`" visible="`${debug}`" editable="false" desc="Check if clk_usb_host[0] is connected" /> 53 <ParamSignal port="clk_usb_dev[0]" name="Clock" group="Connections" visible="`${modeIsDevice}`" desc="The clock to operate this block" canBeEmpty="true" /> 54 <ParamBool id="clkUsbDeviceIsConnected" name="clkUsbDeviceIsConnected" group="Internal" default="`${hasConnection("clk_usb_dev", 0)}`" visible="`${debug}`" editable="false" desc="Check if clk_usb_dev[0] is connected" /> 55 56 <ParamString id="usbHfSource" name="usbHfSource" group="Internal" default="`${modeIsHost ? getBlockFromSignal("clk_usb_host[0]") : getBlockFromSignal("clk_usb_dev[0]")}`" visible="false" editable="false" desc="Select Hf clock source" /> 57 <ParamRange id="usbHfHz" name="usbHfHz" group="Internal" default="`${getExposedMember(usbHfSource, "frequency")}`" min="0" max="200000000" resolution="1" visible="false" editable="false" desc="USB HF clock frequency in Hz." /> 58 59 <ParamRange id="usbHfRealAccuracyPercent" name="usbHfRealAccuracy" group="Internal" default="`${getExposedMember(usbHfSource, "accuracy")}`" min="0" max="100" resolution="0.0001" visible="false" editable="false" desc="USB HF clock accuracy." /> 60 <ParamRange id="usbHfRealAccuracy" name="usbHfRealAccuracy" group="Internal" default="`${usbHfRealAccuracyPercent / 100}`" min="0" max="100" resolution="0.0001" visible="false" editable="false" desc="USB HF clock accuracy." /> 61 <ParamRange id="usbHfRealAccuracyUp" name="usbHfRealAccuracyUp" group="Internal" default="`${usbHfHz + (usbHfHz * usbHfRealAccuracy)}`" min="0" max="200000000" resolution="0.0001" visible="false" editable="false" desc="USB HF clock accuracy." /> 62 <ParamRange id="usbHfRealAccuracyLower" name="usbHfRealAccuracyLower" group="Internal" default="`${usbHfHz - (usbHfHz * usbHfRealAccuracy)}`" min="0" max="200000000" resolution="0.0001" visible="false" editable="false" desc="USB HF clock accuracy." /> 63 64 <ParamRange id="usbHfAccuracy" name="usbHfClockAccuracy" group="Internal" default="`${modeIsHost ? 0.0005 : 0.0025}`" min="0" max="100" resolution="0.0001" visible="false" editable="false" desc="Hf Clock accuracy, the accuracy is in percent" /> 65 <ParamRange id="usbHfAccuracyUp" name="usbHfClockAccuracyUp" group="Internal" default="`${48000000 + (48000000 * usbHfAccuracy)}`" min="0" max="200000000" resolution="1" visible="false" editable="false" desc="Hf Clock accuracy, the accuracy is in percent" /> 66 <ParamRange id="usbHfAccuracyLower" name="usbHfClockAccuracyLower" group="Internal" default="`${48000000 - (48000000 * usbHfAccuracy)}`" min="0" max="200000000" resolution="1" visible="false" editable="false" desc="Hf Clock accuracy, the accuracy is in percent" /> 67 68 <ParamString id="usbHfClockFreq" name="Clock real frequency" group="Connections" default="`${usbHfHz . "Hz +/-" . usbHfRealAccuracy * 100 . "%"}`" visible="`${debug}`" editable="false" desc="Real frequency of the connected clock" /> 69 70 <!-- USB Reset clock configuration, only for Device --> 71 <ParamBool id="checkPeri" name="Check periclk" group="Internal" default="`${hasExposedMember("srss[0].clock[0].periclk[0]", "frequency")}`" visible="false" editable="false" desc="Check if peri clk could be used." /> 72 <ParamRange id="clkPeriHz" name="clkPeriHz" group="Internal" default="`${checkPeri ? getExposedMember("srss[0].clock[0].periclk[0]", "frequency") : 0}`" min="0" max="400000000" resolution="1" visible="false" editable="false" desc="Clk_Peri frequency." /> 73 <ParamRange id="clkPeriAccuracyPercent" name="clkPeriAccuracyPercent" group="Internal" default="`${checkPeri ? getExposedMember("srss[0].clock[0].periclk[0]", "accuracy") : 0}`" min="0" max="100" resolution="0.0001" visible="false" editable="false" desc="Clk_Peri accuracy." /> 74 <ParamRange id="clkPeriAccuracy" name="clkPeriAccuracy" group="Internal" default="`${checkPeri ? clkPeriAccuracyPercent / 100 : 0}`" min="0" max="100" resolution="0.0001" visible="false" editable="false" desc="Clk_Peri accuracy." /> 75 76 <ParamString id="emusb_solver" name="emusb_solver" group="Internal" default="`${runTcl("emusb_solver-1.0.tcl", clkPeriHz, clkPeriAccuracy)}`" visible="`${debug}`" editable="false" desc="Calculate the range of divider value" /> 77 <ParamRange id="divCalcResult" name="divCalcResult" group="Internal" default="`${modeIsDevice ? getTclVar("result", emusb_solver) : 0}`" min="0" max="2" resolution="1" visible="`${debug}`" editable="false" desc="Returned result" /> 78 <ParamRange id="divUpperLimit" name="divUpperLimit" group="Internal" default="`${modeIsDevice ? getTclVar("upperDiv", emusb_solver) : 1}`" min="0" max="16777215" resolution="1" visible="`${debug}`" editable="false" desc="This parameter defines the maximum allowable divider value" /> 79 <ParamRange id="divLowerLimit" name="divLowerLimit" group="Internal" default="`${modeIsDevice ? getTclVar("lowerDiv", emusb_solver) : 1}`" min="0" max="16777215" resolution="1" visible="`${debug}`" editable="false" desc="This parameter defines the minimum allowable divider value" /> 80 <ParamRange id="divBestVal" name="divBestVal" group="Internal" default="`${modeIsDevice ? getTclVar("bestDiv", emusb_solver) : 1}`" min="0" max="16777215" resolution="1" visible="`${debug}`" editable="false" desc="This parameter defines the minimum allowable divider value" /> 81 82 <ParamBool id="usbRstDiv8" name="usbRstDiv8" group="Internal" default="`${modeIsDevice ? (divLowerLimit <= pow(2, 8)) : 0}`" visible="false" editable="false" desc="Checks whether 8-bit divider can be used for USBFS bus reset detection." /> 83 84 <ParamSignal port="clock_dev_brs[0]" name="Clock (Bus Reset)" group="Connections" visible="`${modeIsDevice}`" desc="The clock used to detect the USB Reset condition." canBeEmpty="`${modeIsHost}`" > 85 86 <Constraint type="ACCEPT" targetLocation="peri\[\d+\]\.div_8.*" valid="`${usbRstDiv8}`" > 87 <Parameter id="intDivider" severity="ERROR" reason="Clock frequency does not match desired 100 kHz."> 88 <Range min="`${divLowerLimit}`" max="`${divUpperLimit}`" preferred="`${divBestVal}`" /> 89 </Parameter> 90 </Constraint> 91 92 <Constraint type="ACCEPT" targetLocation="peri\[\d+\]\.div_(16|16.5|24.5).*" valid="true" > 93 <Parameter id="intDivider" severity="ERROR" reason="Clock frequency does not match desired 100 kHz."> 94 <Range min="`${divLowerLimit}`" max="`${divUpperLimit}`" preferred="`${divBestVal}`" /> 95 </Parameter> 96 </Constraint> 97 98 <Constraint type="ACCEPT" targetLocation="peri\[\d+\]\.div_(16.5|24.5).*" valid="true" > 99 <Parameter id="fracDivider" severity="ERROR" reason="Fractional divider must be 0."> 100 <Fixed value= "0" /> 101 </Parameter> 102 </Constraint> 103 </ParamSignal> 104 105 <ParamString id="usbDivSource" name="usbDivSource" group="Internal" default="`${modeIsDevice ? getBlockFromSignal("clock_dev_brs[0]") : 0}`" visible="false" editable="false" desc="Source divider of Clock (Bus Reset)" /> 106 <ParamBool id="usbDivOk" name="usbDivOk" group="Internal" default="`${hasConnection("clock_dev_brs", 0) && isBlockUsed(usbDivSource)}`" visible="false" editable="false" desc="Checks whether there is a divider connected and enabled." /> 107 <ParamString id="usbDivDst" name="usbDivDst" group="Internal" default="PCLK_USB_CLOCK_DEV_BRS" visible="false" editable="false" desc="Generates divider connection define." /> 108 <ParamRange id="checkDivFreq" name="Check periclk" group="Internal" default="`${modeIsDevice ? getExposedMember(usbDivSource, "frequency") : 0}`" min="0" max="400000000" resolution="1" visible="false" editable="false" desc="Divider value for Clock (Bus Reset)" /> 109 <ParamRange id="checkDivAccur" name="Check periclk" group="Internal" default="`${modeIsDevice ? getExposedMember(usbDivSource, "accuracy") : 0}`" min="0" max="100" resolution="0.01" visible="false" editable="false" desc="Divider accuracy of Clock (Bus Reset)" /> 110 111 <ParamString id="usbRstClkFreq" name="Clock (Bus Reset) real frequency" group="Connections" default="`${checkDivFreq . "Hz +/-" . checkDivAccur . "%"}`" visible="`${debug && modeIsDevice}`" editable="false" desc="Real frequency of the connected clock" /> 112 113 <!-- Pins configuration --> 114 <ParamSignal port="usb_dp_pad[0]" name="D+" group="Connections" visible="true" desc="USB Data plus signal (USBDP)." canBeEmpty="true" /> 115 <ParamBool id="usbDpIsConnected" name="usbDpIsConnected" group="Internal" default="`${hasConnection("usb_dp_pad", 0)}`" visible="`${debug}`" editable="false" desc="Check if D+ is connected" /> 116 <ParamSignal port="usb_dm_pad[0]" name="D-" group="Connections" visible="true" desc="USB Data minus signal (USBDM)." canBeEmpty="true" /> 117 <ParamBool id="usbDmIsConnected" name="usbDmIsConnected" group="Internal" default="`${hasConnection("usb_dm_pad", 0)}`" visible="`${debug}`" editable="false" desc="Check if D- is connected" /> 118 </Parameters> 119 120 <DRCs> 121 <DRC type="WARNING" text="`${"CLK_HF3 does not meet the requirements. The frequency must be in the range 48 MHz +/- " . usbHfAccuracy * 100 . " % or the maximum deviation in the range " . usbHfAccuracyLower . "-" . usbHfAccuracyUp . "] Hz"}`" condition="`${(usbHfRealAccuracyUp > usbHfAccuracyUp) || (usbHfRealAccuracyLower < usbHfAccuracyLower)}`" location="`${usbHfSource}`" paramId="frequencyInfo"> 122 </DRC> 123 <DRC type="ERROR" text="Clock (Bus Reset) does not meet the requirements. The clock accuracy must be +/- 0.25 %." condition="`${divCalcResult eq 2}`" paramId="frequencyInfo"> 124 </DRC> 125 <DRC type="ERROR" text="Clock (Bus Reset) does not meet the requirements. This frequency cannot be generated in the required range [99750-100250] Hz" condition="`${divCalcResult eq 1}`" paramId="frequencyInfo"> 126 </DRC> 127 <DRC type="ERROR" text="USB Data plus signal (USBDP) must be always connected" condition="`${!usbDpIsConnected}`" paramId="usb_dp_pad[0]"> 128 </DRC> 129 <DRC type="ERROR" text="USB Data minus signal (USBDM) must be always connected" condition="`${!usbDmIsConnected}`" paramId="usb_dm_pad[0]"> 130 </DRC> 131 <DRC type="ERROR" text="Clock for USB must be always connected" condition="`${modeIsDevice ? !clkUsbDeviceIsConnected : false}`" paramId="clk_usb_dev[0]"> 132 </DRC> 133 <DRC type="ERROR" text="Clock for USB must be always connected" condition="`${modeIsDevice ? false : !clkUsbHostIsConnected}`" paramId="clk_usb_host[0]"> 134 </DRC> 135 </DRCs> 136 137 <ConfigFirmware> 138 <ConfigInclude value="cy_sysclk.h" include="`${usbDivOk}`" /> 139 <ConfigInclude value="cyhal_hwmgr.h" include="true" guard="defined (CY_USING_HAL)" /> 140 141 <ConfigStruct name="`${INST_NAME}`_obj" type="cyhal_resource_inst_t" const="true" public="true" include="true" guard="defined (CY_USING_HAL)"> 142 <Member name="type" value="CYHAL_RSC_USB" /> 143 <Member name="block_num" value="`${getInstNumber("usb")}`U" /> 144 <Member name="channel_num" value="0U" /> 145 </ConfigStruct> 146 <ConfigInstruction value="cyhal_hwmgr_reserve(&`${INST_NAME}`_obj);" include="true" guard="defined (CY_USING_HAL)" /> 147 148 <ConfigInstruction value="Cy_SysClk_PeriphAssignDivider(`${usbDivDst}`, `${getExposedMember(usbDivSource, "clockSel")}`);" include="`${usbDivOk}`" /> 149 150 </ConfigFirmware> 151 152</Personality> 153