1 /******************************************************************************
3 * Copyright (C) 2016-2017 Xilinx, Inc. All rights reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
31 ******************************************************************************/
32 /*****************************************************************************/
36 * The XSysMon driver supports the Xilinx System Monitor device.
38 * The System Monitor device has the following features:
39 * - PL Sysmon instance has 10-bit, 200-KSPS (kilo samples per second)
40 * Analog-to-Digital Converter (ADC)
41 * - PS Sysmon instance has 10-bit, 1000-KSPS ADC.
42 * - Monitoring of on-chip supply voltages and temperature
43 * - 1 dedicated differential analog-input pair and
44 * 16 auxiliary differential analog-input pairs
45 * - Automatic alarms based on user defined limits for the on-chip
46 * supply voltages and temperature
47 * - Automatic Channel Sequencer, programmable averaging, programmable
48 * acquisition time for the external inputs, unipolar or differential
49 * input selection for the external inputs
50 * - Inbuilt Calibration
51 * - Optional interrupt request generation
55 * The user should refer to the hardware device specification for detailed
56 * information about the device.
58 * This header file contains the prototypes of driver functions that can
59 * be used to access the System Monitor device.
62 * <b> System Monitor Channel Sequencer Modes </b>
64 * The System Monitor Channel Sequencer supports the following operating modes:
66 * - <b> Default </b>: This is the default mode after power up.
67 * In this mode of operation the System Monitor operates in
68 * a sequence mode, monitoring the on chip sensors:
69 * Temperature, VCCINT, and VCCAUX.
70 * - <b> One pass through sequence </b>: In this mode the System Monitor
71 * converts the channels enabled in the Sequencer Channel Enable
72 * registers for a single pass and then stops.
73 * - <b> Continuous cycling of sequence </b>: In this mode the System Monitor
74 * converts the channels enabled in the Sequencer Channel Enable
75 * registers continuously.
76 * - <b> Single channel mode</b>: In this mode the System Monitor Channel
77 * Sequencer is disabled and the System Monitor operates in a
78 * Single Channel Mode.
79 * The System Monitor can operate either in a Continuous or Event
80 * driven sampling mode in the single channel mode.
83 * <b> Initialization and Configuration </b>
85 * The device driver enables higher layer software (e.g., an application) to
86 * communicate to the System Monitor device.
88 * XSysMonPsu_CfgInitialize() API is used to initialize the System Monitor
89 * device. The user needs to first call the XSysMonPsu_LookupConfig() API which
90 * returns the Configuration structure pointer which is passed as a parameter to
91 * the XSysMonPsu_CfgInitialize() API.
96 * The System Monitor device supports interrupt driven mode and the default
97 * operation mode is polling mode.
99 * This driver does not provide a Interrupt Service Routine (ISR) for the device.
100 * It is the responsibility of the application to provide one if needed. Refer to
101 * the interrupt example provided with this driver for details on using the
102 * device in interrupt mode.
105 * <b> Virtual Memory </b>
107 * This driver supports Virtual Memory. The RTOS is responsible for calculating
108 * the correct device base address in Virtual Memory space.
113 * This driver is not thread safe. Any needs for threads or thread mutual
114 * exclusion must be satisfied by the layer above this driver.
119 * Asserts are used within all Xilinx drivers to enforce constraints on argument
120 * values. Asserts can be turned off on a system-wide basis by defining, at
121 * compile time, the NDEBUG identifier. By default, asserts are turned on and it
122 * is recommended that users leave asserts on during development.
125 * <b> Building the driver </b>
127 * The XSysMonPsu driver is composed of several source files. This allows the user
128 * to build and link only those parts of the driver that are necessary.
131 * <b> Limitations of the driver </b>
133 * System Monitor device can be accessed through the JTAG port and the AXI
134 * interface. The driver implementation does not support the simultaneous access
135 * of the device by both these interfaces. The user has to take care of this
136 * situation in the user application code.
144 * MODIFICATION HISTORY:
146 * Ver Who Date Changes
147 * ----- ----- -------- -----------------------------------------------
148 * 1.00 kvn 12/15/15 First release
149 * 02/15/16 Corrected Assert function call in
150 * XSysMonPsu_GetMonitorStatus API.
151 * 03/03/16 Added Temperature remote channel for Setsingle
152 * channel API. Also corrected external mux channel
154 * 1.1 kvn 05/05/16 Modified code for MISRA-C:2012 Compliance.
155 * 2.0 vns 08/14/16 Fixed CR #956780, added support for enabling/disabling
156 * SEQ_CH2 and SEQ_AVG2 registers, modified function
157 * prototypes of XSysMonPsu_GetSeqAvgEnables,
158 * XSysMonPsu_SetSeqAvgEnables, XSysMonPsu_SetSeqChEnables,
159 * XSysMonPsu_GetSeqChEnables,
160 * XSysMonPsu_SetSeqInputMode, XSysMonPsu_GetSeqInputMode,
161 * XSysMonPsu_SetSeqAcqTime
162 * and XSysMonPsu_GetSeqAcqTime to provide support for
163 * set/get 64 bit value.
164 * Added constants XSM_CFR_ALM_SUPPLY*(8-31)_MASKs to
165 * provide support for enabling extra PS alarams.
166 * 2.1 sk 03/03/16 Check for PL reset before doing PL Sysmon reset.
167 * ms 03/17/17 Added readme.txt file in examples folder for doxygen
169 * ms 04/05/17 Modified Comment lines in functions of sysmonpsu
170 * examples to recognize it as documentation block
171 * for doxygen generation.
172 * 2.2 sk 04/14/17 Corrected temperature conversion formulas.
173 * 2.3 mn 12/11/17 Added missing closing bracket error when C++ is used
174 * mn 12/12/17 Added Conversion Support for voltages having Range of
176 * mn 12/13/17 Correct the AMS block channel numbers
177 * ms 12/15/17 Added peripheral test support.
178 * ms 01/04/18 Provided conditional checks for interrupt example
179 * in sysmonpsu_header.h
180 * mn 03/08/18 Update Clock Divisor to the proper value
184 ******************************************************************************/
187 #ifndef XSYSMONPSU_H_ /* prevent circular inclusions */
188 #define XSYSMONPSU_H_ /* by using protection macros */
194 /***************************** Include Files *********************************/
197 #include "xil_assert.h"
199 #include "xsysmonpsu_hw.h"
200 #include "xil_types.h"
202 /************************** Constant Definitions *****************************/
205 * @name Indexes for the different channels.
208 #define XSM_CH_TEMP 0x0U /**< On Chip Temperature */
209 #define XSM_CH_SUPPLY1 0x1U /**< SUPPLY1 VCC_PSINTLP */
210 #define XSM_CH_SUPPLY2 0x2U /**< SUPPLY2 VCC_PSINTFP */
211 #define XSM_CH_VPVN 0x3U /**< VP/VN Dedicated analog inputs */
212 #define XSM_CH_VREFP 0x4U /**< VREFP */
213 #define XSM_CH_VREFN 0x5U /**< VREFN */
214 #define XSM_CH_SUPPLY3 0x6U /**< SUPPLY3 VCC_PSAUX */
215 #define XSM_CH_SUPPLY_CALIB 0x08U /**< Supply Calib Data Reg */
216 #define XSM_CH_ADC_CALIB 0x09U /**< ADC Offset Channel Reg */
217 #define XSM_CH_GAINERR_CALIB 0x0AU /**< Gain Error Channel Reg */
218 #define XSM_CH_SUPPLY4 0x0DU /**< SUPPLY4 VCC_PSDDR_504 */
219 #define XSM_CH_SUPPLY5 0x0EU /**< SUPPLY5 VCC_PSIO3_503 */
220 #define XSM_CH_SUPPLY6 0x0FU /**< SUPPLY6 VCC_PSIO0_500 */
221 #define XSM_CH_AUX_MIN 16U /**< Channel number for 1st Aux Channel */
222 #define XSM_CH_AUX_MAX 31U /**< Channel number for Last Aux channel */
223 #define XSM_CH_SUPPLY7 32U /**< SUPPLY7 VCC_PSIO1_501 */
224 #define XSM_CH_SUPPLY8 33U /**< SUPPLY8 VCC_PSIO2_502 */
225 #define XSM_CH_SUPPLY9 34U /**< SUPPLY9 PS_MGTRAVCC */
226 #define XSM_CH_SUPPLY10 35U /**< SUPPLY10 PS_MGTRAVTT */
227 #define XSM_CH_VCCAMS 36U /**< VCCAMS */
228 #define XSM_CH_TEMP_REMTE 37U /**< Temperature Remote */
229 #define XSM_CH_VCC_PSLL0 48U /**< VCC_PSLL0 */
230 #define XSM_CH_VCC_PSLL3 51U /**< VCC_PSLL3 */
231 #define XSM_CH_VCCINT 54U /**< VCCINT */
232 #define XSM_CH_VCCBRAM 55U /**< VCCBRAM */
233 #define XSM_CH_VCCAUX 56U /**< VCCAUX */
234 #define XSM_CH_VCC_PSDDRPLL 57U /**< VCC_PSDDRPLL */
235 #define XSM_CH_DDRPHY_VREF 58U /**< DDRPHY_VREF */
236 #define XSM_CH_RESERVE1 63U /**< PSGT_AT0 */
241 * @name Indexes for reading the Calibration Coefficient Data.
244 #define XSM_CALIB_SUPPLY_OFFSET_COEFF 0U /**< Supply Offset Calib Coefficient */
245 #define XSM_CALIB_ADC_OFFSET_COEFF 1U /**< ADC Offset Calib Coefficient */
246 #define XSM_CALIB_GAIN_ERROR_COEFF 2U /**< Gain Error Calib Coefficient*/
251 * @name Indexes for reading the Minimum/Maximum Measurement Data.
254 #define XSM_MAX_TEMP 0U /**< Maximum Temperature Data */
255 #define XSM_MAX_SUPPLY1 1U /**< Maximum SUPPLY1 Data */
256 #define XSM_MAX_SUPPLY2 2U /**< Maximum SUPPLY2 Data */
257 #define XSM_MAX_SUPPLY3 3U /**< Maximum SUPPLY3 Data */
258 #define XSM_MIN_TEMP 4U /**< Minimum Temperature Data */
259 #define XSM_MIN_SUPPLY1 5U /**< Minimum SUPPLY1 Data */
260 #define XSM_MIN_SUPPLY2 6U /**< Minimum SUPPLY2 Data */
261 #define XSM_MIN_SUPPLY3 7U /**< Minimum SUPPLY3 Data */
262 #define XSM_MAX_SUPPLY4 8U /**< Maximum SUPPLY4 Data */
263 #define XSM_MAX_SUPPLY5 9U /**< Maximum SUPPLY5 Data */
264 #define XSM_MAX_SUPPLY6 0xAU /**< Maximum SUPPLY6 Data */
265 #define XSM_MIN_SUPPLY4 0xCU /**< Minimum SUPPLY4 Data */
266 #define XSM_MIN_SUPPLY5 0xDU /**< Minimum SUPPLY5 Data */
267 #define XSM_MIN_SUPPLY6 0xEU /**< Minimum SUPPLY6 Data */
268 #define XSM_MAX_SUPPLY7 0x80U /**< Maximum SUPPLY7 Data */
269 #define XSM_MAX_SUPPLY8 0x81U /**< Maximum SUPPLY8 Data */
270 #define XSM_MAX_SUPPLY9 0x82U /**< Maximum SUPPLY9 Data */
271 #define XSM_MAX_SUPPLY10 0x83U /**< Maximum SUPPLY10 Data */
272 #define XSM_MAX_VCCAMS 0x84U /**< Maximum VCCAMS Data */
273 #define XSM_MAX_TEMP_REMOTE 0x85U /**< Maximum Remote Temperature Data */
274 #define XSM_MIN_SUPPLY7 0x88U /**< Minimum SUPPLY7 Data */
275 #define XSM_MIN_SUPPLY8 0x89U /**< Minimum SUPPLY8 Data */
276 #define XSM_MIN_SUPPLY9 0x8AU /**< Minimum SUPPLY9 Data */
277 #define XSM_MIN_SUPPLY10 0x8BU /**< Minimum SUPPLY10 Data */
278 #define XSM_MIN_VCCAMS 0x8CU /**< Minimum VCCAMS Data */
279 #define XSM_MIN_TEMP_REMOTE 0x8DU /**< Minimum Remote Temperature Data */
284 * @name Averaging to be done for the channels.
287 #define XSM_AVG_0_SAMPLES 0U /**< No Averaging */
288 #define XSM_AVG_16_SAMPLES 1U /**< Average 16 samples */
289 #define XSM_AVG_64_SAMPLES 2U /**< Average 64 samples */
290 #define XSM_AVG_256_SAMPLES 3U /**< Average 256 samples */
295 * @name Channel Sequencer Modes of operation.
298 #define XSM_SEQ_MODE_SAFE 0U /**< Default Safe Mode */
299 #define XSM_SEQ_MODE_ONEPASS 1U /**< Onepass through Sequencer */
300 #define XSM_SEQ_MODE_CONTINPASS 2U /**< Continuous Cycling Seqquencer */
301 #define XSM_SEQ_MODE_SINGCHAN 3U /**< Single channel - No Sequencing */
302 #define XSM_SEQ_MODE_OYLMPUS 6U /**< Olympus mode */
307 * @name Clock Divisor values range.
310 #define XSM_CLK_DIV_MIN 0U /**< Minimum Clock Divisor value */
311 #define XSM_CLK_DIV_MAX 255U /**< Maximum Clock Divisor value */
316 * @name Alarm Threshold(Limit) Register (ATR) indexes.
319 #define XSM_ATR_TEMP_UPPER 0U /**< High user Temperature limit */
320 #define XSM_ATR_SUP1_UPPER 1U /**< Supply1 high voltage limit */
321 #define XSM_ATR_SUP2_UPPER 2U /**< Supply2 high voltage limit */
322 #define XSM_ATR_OT_UPPER 3U /**< Upper Over Temperature limit */
323 #define XSM_ATR_TEMP_LOWER 4U /**< Low user Temperature */
324 #define XSM_ATR_SUP1_LOWER 5U /**< Suuply1 low voltage limit */
325 #define XSM_ATR_SUP2_LOWER 6U /**< Supply2 low voltage limit */
326 #define XSM_ATR_OT_LOWER 7U /**< Lower Over Temperature limit */
327 #define XSM_ATR_SUP3_UPPER 8U /**< Supply3 high voltage limit */
328 #define XSM_ATR_SUP4_UPPER 9U /**< Supply4 high voltage limit */
329 #define XSM_ATR_SUP5_UPPER 0xAU /**< Supply5 high voltage limit */
330 #define XSM_ATR_SUP6_UPPER 0xBU /**< Supply6 high voltage limit */
331 #define XSM_ATR_SUP3_LOWER 0xCU /**< Supply3 low voltage limit */
332 #define XSM_ATR_SUP4_LOWER 0xDU /**< Supply4 low voltage limit */
333 #define XSM_ATR_SUP5_LOWER 0xEU /**< Supply5 low voltage limit */
334 #define XSM_ATR_SUP6_LOWER 0xFU /**< Supply6 low voltage limit */
335 #define XSM_ATR_SUP7_UPPER 0x10U /**< Supply7 high voltage limit */
336 #define XSM_ATR_SUP8_UPPER 0x11U /**< Supply8 high voltage limit */
337 #define XSM_ATR_SUP9_UPPER 0x12U /**< Supply9 high voltage limit */
338 #define XSM_ATR_SUP10_UPPER 0x13U /**< Supply10 high voltage limit */
339 #define XSM_ATR_VCCAMS_UPPER 0x14U /**< VCCAMS high voltage limit */
340 #define XSM_ATR_TEMP_RMTE_UPPER 0x15U /**< High remote Temperature limit */
341 #define XSM_ATR_SUP7_LOWER 0x18U /**< Supply7 low voltage limit */
342 #define XSM_ATR_SUP8_LOWER 0x19U /**< Supply8 low voltage limit */
343 #define XSM_ATR_SUP9_LOWER 0x1AU /**< Supply9 low voltage limit */
344 #define XSM_ATR_SUP10_LOWER 0x1BU /**< Supply10 low voltage limit */
345 #define XSM_ATR_VCCAMS_LOWER 0x1CU /**< VCCAMS low voltage limit */
346 #define XSM_ATR_TEMP_RMTE_LOWER 0x1DU /**< Low remote Temperature limit */
351 * @name Alarm masks for channels in Configuration registers 1
354 #define XSM_CFR_ALM_SUPPLY13_MASK 0x200000 /**< Alarm 6 - SUPPLY6 */
355 #define XSM_CFR_ALM_SUPPLY12_MASK 0x100000 /**< Alarm 6 - SUPPLY6 */
356 #define XSM_CFR_ALM_SUPPLY11_MASK 0x080000 /**< Alarm 6 - SUPPLY6 */
357 #define XSM_CFR_ALM_SUPPLY10_MASK 0x040000 /**< Alarm 6 - SUPPLY6 */
358 #define XSM_CFR_ALM_SUPPLY9_MASK 0x020000 /**< Alarm 6 - SUPPLY6 */
359 #define XSM_CFR_ALM_SUPPLY8_MASK 0x010000 /**< Alarm 6 - SUPPLY6 */
360 #define XSM_CFR_ALM_SUPPLY6_MASK 0x0800 /**< Alarm 6 - SUPPLY6 */
361 #define XSM_CFR_ALM_SUPPLY5_MASK 0x0400 /**< Alarm 5 - SUPPLY5 */
362 #define XSM_CFR_ALM_SUPPLY4_MASK 0x0200 /**< Alarm 4 - SUPPLY4 */
363 #define XSM_CFR_ALM_SUPPLY3_MASK 0x0100 /**< Alarm 3 - SUPPLY3 */
364 #define XSM_CFR_ALM_SUPPLY2_MASK 0x0008 /**< Alarm 2 - SUPPLY2 */
365 #define XSM_CFR_ALM_SUPPLY1_MASK 0x0004 /**< Alarm 1 - SUPPLY1 */
366 #define XSM_CFR_ALM_TEMP_MASK 0x0002 /**< Alarm 0 - Temperature */
367 #define XSM_CFR_ALM_OT_MASK 0x0001 /**< Over Temperature Alarm */
371 /**************************** Type Definitions *******************************/
373 /******************************************************************************/
375 * This data type defines a handler that an application defines to communicate
376 * with interrupt system to retrieve state information about an application.
378 * @param CallBackRef is a callback reference passed in by the upper layer
379 * when setting the handler, and is passed back to the upper layer
380 * when the handler is called. It is used to find the device driver
383 ******************************************************************************/
384 typedef void (*XSysMonPsu_Handler) (void *CallBackRef);
387 * This typedef contains configuration information for a device.
390 u16 DeviceId; /**< Unique ID of device */
391 u32 BaseAddress; /**< Register base address */
392 u16 InputClockMHz; /**< Input clock frequency */
396 * The XSysmonPsu driver instance data. The user is required to allocate a
397 * variable of this type for the SYSMON device in the system. A pointer
398 * to a variable of this type is then passed to the driver API functions.
401 XSysMonPsu_Config Config; /**< Device configuration */
402 u32 IsReady; /**< Device is initialized and ready */
403 XSysMonPsu_Handler Handler;
404 void *CallBackRef; /**< Callback reference for event handler */
407 /* BaseAddress Offsets */
408 #define XSYSMON_PS 1U
409 #define XSYSMON_PL 2U
410 #define XSYSMON_AMS 3U
411 #define XPS_BA_OFFSET 0x00000800U
412 #define XPL_BA_OFFSET 0x00000C00U
413 #define XSM_ADC_CH_OFFSET 0x00000200U
414 #define XSM_AMS_CH_OFFSET 0x00000060U
415 #define XSM_MIN_MAX_CH_OFFSET 0x00000080U
417 /************************* Variable Definitions ******************************/
419 /***************** Macros (Inline Functions) Definitions *********************/
421 /****************************************************************************/
424 * This macro converts System Monitor Raw Data to Temperature(centigrades)
425 * for On-Chip Sensors.
427 * @param AdcData is the SysMon Raw ADC Data.
429 * @return The Temperature in centigrades.
431 * @note C-Style signature:
432 * float XSysMon_RawToTemperature_OnChip(u32 AdcData)
434 *****************************************************************************/
435 #define XSysMonPsu_RawToTemperature_OnChip(AdcData) \
436 ((((float)(AdcData)/65536.0f)/0.00196342531f ) - 280.2309f)
438 /****************************************************************************/
441 * This macro converts System Monitor Raw Data to Temperature(centigrades)
442 * for external reference.
444 * @param AdcData is the SysMon Raw ADC Data.
446 * @return The Temperature in centigrades.
448 * @note C-Style signature:
449 * float XSysMon_RawToTemperature_ExternalRef(u32 AdcData)
451 *****************************************************************************/
452 #define XSysMonPsu_RawToTemperature_ExternalRef(AdcData) \
453 ((((float)(AdcData)/65536.0f)/0.00197008621f ) - 279.4266f)
455 /****************************************************************************/
458 * This macro converts System Monitor Raw Data to Voltage(volts) for VpVn
461 * @param AdcData is the System Monitor ADC Raw Data.
463 * @return The Voltage in volts.
465 * @note C-Style signature:
466 * float XSysMon_VpVnRawToVoltage(u32 AdcData)
468 *****************************************************************************/
469 #define XSysMonPsu_VpVnRawToVoltage(AdcData) \
470 ((((float)(AdcData))* (1.0f))/65536.0f)
472 /****************************************************************************/
475 * This macro converts System Monitor Raw Data to Voltage(volts) other than
478 * @param AdcData is the System Monitor ADC Raw Data.
480 * @return The Voltage in volts.
482 * @note C-Style signature:
483 * float XSysMon_RawToVoltage(u32 AdcData)
485 *****************************************************************************/
486 #define XSysMonPsu_RawToVoltage(AdcData) \
487 ((((float)(AdcData))* (3.0f))/65536.0f)
489 /****************************************************************************/
492 * This macro converts System Monitor Raw Data to Voltage(volts) for
495 * @param AdcData is the System Monitor ADC Raw Data.
497 * @return The Voltage in volts.
499 * @note C-Style signature:
500 * float XSysMon_RawToVoltage(u32 AdcData)
502 *****************************************************************************/
503 #define XSysMonPsu_VccopsioRawToVoltage(AdcData) \
504 ((((float)(AdcData))* (6.0f))/65536.0f)
506 /****************************************************************************/
509 * This macro converts Temperature in centigrades to System Monitor Raw Data
510 * for On-Chip Sensors.
512 * @param Temperature is the Temperature in centigrades to be
513 * converted to System Monitor ADC Raw Data.
515 * @return The System Monitor ADC Raw Data.
517 * @note C-Style signature:
518 * int XSysMon_TemperatureToRaw_OnChip(float Temperature)
520 *****************************************************************************/
521 #define XSysMonPsu_TemperatureToRaw_OnChip(Temperature) \
522 ((s32)(((Temperature) + 280.2309f)*65536.0f*0.00196342531f))
524 /****************************************************************************/
527 * This macro converts Temperature in centigrades to System Monitor Raw Data
528 * for external reference.
530 * @param Temperature is the Temperature in centigrades to be
531 * converted to System Monitor ADC Raw Data.
533 * @return The System Monitor ADC Raw Data.
535 * @note C-Style signature:
536 * int XSysMon_TemperatureToRaw_ExternalRef(float Temperature)
538 *****************************************************************************/
539 #define XSysMonPsu_TemperatureToRaw_ExternalRef(Temperature) \
540 ((s32)(((Temperature) + 279.4266f)*65536.0f*0.00197008621f))
542 /****************************************************************************/
545 * This macro converts Voltage in Volts to System Monitor Raw Data other than
548 * @param Voltage is the Voltage in volts to be converted to
549 * System Monitor/ADC Raw Data.
551 * @return The System Monitor ADC Raw Data.
553 * @note C-Style signature:
554 * int XSysMon_VoltageToRaw(float Voltage)
556 *****************************************************************************/
557 #define XSysMonPsu_VoltageToRaw(Voltage) \
558 ((s32)((Voltage)*65536.0f/3.0f))
560 /****************************************************************************/
563 * This macro converts Voltage in Volts to System Monitor Raw Data for
566 * @param Voltage is the Voltage in volts to be converted to
567 * System Monitor/ADC Raw Data.
569 * @return The System Monitor ADC Raw Data.
571 * @note C-Style signature:
572 * int XSysMon_VoltageToRaw(float Voltage)
574 *****************************************************************************/
575 #define XSysMonPsu_VccopsioVoltageToRaw(Voltage) \
576 ((s32)((Voltage)*65536.0f/6.0f))
578 /****************************************************************************/
581 * This static inline macro calculates the effective baseaddress based on the
582 * Sysmon instance. For PS Sysmon, use additional offset XPS_BA_OFFSET and For
583 * PL Sysmon, use additional offset XPL_BA_OFFSET.
585 * @param BaseAddress is the starting address of the SysMon block in
587 * @param SysmonBlk is the value that tells whether it is for PS Sysmon block
588 * or PL Sysmon block or the AMS controller register region.
590 * @return Returns the effective baseaddress of the sysmon instance.
592 *****************************************************************************/
593 static inline u32 XSysMonPsu_GetEffBaseAddress(u32 BaseAddress, u32 SysmonBlk)
597 if (SysmonBlk == XSYSMON_PS) {
598 EffBaseAddr = BaseAddress + XPS_BA_OFFSET;
599 } else if(SysmonBlk == XSYSMON_PL) {
600 EffBaseAddr = BaseAddress + XPL_BA_OFFSET;
602 EffBaseAddr = BaseAddress;
608 /************************** Function Prototypes ******************************/
610 /* Functions in xsysmonpsu.c */
611 s32 XSysMonPsu_CfgInitialize(XSysMonPsu *InstancePtr, XSysMonPsu_Config *ConfigPtr,
613 void XSysMonPsu_Reset(XSysMonPsu *InstancePtr);
614 void XSysMonPsu_Reset_FromLPD(XSysMonPsu *InstancePtr);
615 u32 XSysMonPsu_GetStatus(XSysMonPsu *InstancePtr, u32 SysmonBlk);
616 void XSysMonPsu_StartAdcConversion(XSysMonPsu *InstancePtr);
617 u16 XSysMonPsu_GetAdcData(XSysMonPsu *InstancePtr, u8 Channel, u32 Block);
618 u16 XSysMonPsu_GetCalibCoefficient(XSysMonPsu *InstancePtr, u8 CoeffType, u32 SysmonBlk);
619 u16 XSysMonPsu_GetMinMaxMeasurement(XSysMonPsu *InstancePtr, u8 MeasurementType,
621 void XSysMonPsu_SetAvg(XSysMonPsu *InstancePtr, u8 Average, u32 SysmonBlk);
622 u8 XSysMonPsu_GetAvg(XSysMonPsu *InstancePtr, u32 SysmonBlk);
623 s32 XSysMonPsu_SetSingleChParams(XSysMonPsu *InstancePtr, u8 Channel,
624 u32 IncreaseAcqCycles, u32 IsEventMode,
625 u32 IsDifferentialMode, u32 SysmonBlk);
626 void XSysMonPsu_SetAlarmEnables(XSysMonPsu *InstancePtr, u32 AlmEnableMask,
628 u32 XSysMonPsu_GetAlarmEnables(XSysMonPsu *InstancePtr, u32 SysmonBlk);
629 void XSysMonPsu_SetSequencerMode(XSysMonPsu *InstancePtr, u8 SequencerMode,
631 u8 XSysMonPsu_GetSequencerMode(XSysMonPsu *InstancePtr, u32 SysmonBlk);
632 void XSysMonPsu_SetSequencerEvent(XSysMonPsu *InstancePtr, u32 IsEventMode,
634 s32 XSysMonPsu_GetSequencerEvent(XSysMonPsu *InstancePtr, u32 SysmonBlk);
635 void XSysMonPsu_SetExtenalMux(XSysMonPsu *InstancePtr, u8 Channel, u32 SysmonBlk);
636 u32 XSysMonPsu_GetExtenalMux(XSysMonPsu *InstancePtr, u32 SysmonBlk);
637 void XSysMonPsu_SetAdcClkDivisor(XSysMonPsu *InstancePtr, u8 Divisor, u32 SysmonBlk);
638 u8 XSysMonPsu_GetAdcClkDivisor(XSysMonPsu *InstancePtr, u32 SysmonBlk);
639 u8 XSysMonPsu_UpdateAdcClkDivisor(XSysMonPsu *InstancePtr, u32 SysmonBlk);
640 s32 XSysMonPsu_SetSeqChEnables(XSysMonPsu *InstancePtr, u64 ChEnableMask,
642 u64 XSysMonPsu_GetSeqAvgEnables(XSysMonPsu *InstancePtr, u32 SysmonBlk);
643 u64 XSysMonPsu_GetSeqChEnables(XSysMonPsu *InstancePtr, u32 SysmonBlk);
644 s32 XSysMonPsu_SetSeqAvgEnables(XSysMonPsu *InstancePtr, u64 AvgEnableChMask,
646 s32 XSysMonPsu_SetSeqInputMode(XSysMonPsu *InstancePtr, u64 InputModeChMask,
648 u64 XSysMonPsu_GetSeqInputMode(XSysMonPsu *InstancePtr, u32 SysmonBlk);
649 s32 XSysMonPsu_SetSeqAcqTime(XSysMonPsu *InstancePtr, u64 AcqCyclesChMask,
651 u64 XSysMonPsu_GetSeqAcqTime(XSysMonPsu *InstancePtr, u32 SysmonBlk);
652 void XSysMonPsu_SetAlarmThreshold(XSysMonPsu *InstancePtr, u8 AlarmThrReg,
653 u16 Value, u32 SysmonBlk);
654 u16 XSysMonPsu_GetAlarmThreshold(XSysMonPsu *InstancePtr, u8 AlarmThrReg,
656 void XSysMonPsu_SetPSAutoConversion(XSysMonPsu *InstancePtr);
657 u32 XSysMonPsu_GetMonitorStatus(XSysMonPsu *InstancePtr);
659 /* interrupt functions in xsysmonpsu_intr.c */
660 void XSysMonPsu_IntrEnable(XSysMonPsu *InstancePtr, u64 Mask);
661 void XSysMonPsu_IntrDisable(XSysMonPsu *InstancePtr, u64 Mask);
662 u64 XSysMonPsu_IntrGetEnabled(XSysMonPsu *InstancePtr);
663 u64 XSysMonPsu_IntrGetStatus(XSysMonPsu *InstancePtr);
664 void XSysMonPsu_IntrClear(XSysMonPsu *InstancePtr, u64 Mask);
666 /* Functions in xsysmonpsu_selftest.c */
667 s32 XSysMonPsu_SelfTest(XSysMonPsu *InstancePtr);
669 /* Functions in xsysmonpsu_sinit.c */
670 XSysMonPsu_Config *XSysMonPsu_LookupConfig(u16 DeviceId);
677 #endif /* XSYSMONPSU_H_ */