XilinxProcessorIPLib/drivers/sysmonpsu/src/xsysmonpsu.c
s32 XSysMonPsu_CfgInitialize(XSysMonPsu *InstancePtr, XSysMonPsu_Config *ConfigPtr,
			  u32 EffectiveAddr)
{
	u32 PsSysmonControlStatus;
	u64 IntrStatus;

	/* Assert the input arguments. */
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(ConfigPtr != NULL);

	/* Set the values read from the device config and the base address. */
	InstancePtr->Config.DeviceId = ConfigPtr->DeviceId;
	InstancePtr->Config.BaseAddress = EffectiveAddr;
	InstancePtr->Config.InputClockMHz = ConfigPtr->InputClockMHz;

	/* Set all handlers to stub values, let user configure this data later. */
	InstancePtr->Handler = (XSysMonPsu_Handler)XSysMonPsu_StubHandler;

	(void)XSysMonPsu_UpdateAdcClkDivisor(InstancePtr, XSYSMON_PS);
	(void)XSysMonPsu_UpdateAdcClkDivisor(InstancePtr, XSYSMON_PL);

	/* Reset the device such that it is in a known state. */
	XSysMonPsu_Reset(InstancePtr);

	PsSysmonControlStatus = XSysmonPsu_ReadReg(InstancePtr->Config.BaseAddress +
			XSYSMONPSU_PS_SYSMON_CSTS_OFFSET);

	/* Check if the PS Sysmon is in Idle / ready state or not */
	while(PsSysmonControlStatus != XSYSMONPSU_PS_SYSMON_READY) {
		PsSysmonControlStatus = XSysmonPsu_ReadReg(InstancePtr->Config.BaseAddress +
					XSYSMONPSU_PS_SYSMON_CSTS_OFFSET);
	}

	InstancePtr->IsPlAccessibleByPs =
			XSysmonPsu_ReadReg(InstancePtr->Config.BaseAddress +
			XSYSMONPSU_PL_SYSMON_CSTS_OFFSET) &
			XSYSMONPSU_PL_SYSMON_CSTS_ACESBLE_MASK;

	/* Indicate the instance is now ready to use, initialized without error */
	InstancePtr->IsReady = XIL_COMPONENT_IS_READY;

	/* Clear any bits set in the Interrupt Status Register. */
	IntrStatus = XSysMonPsu_IntrGetStatus(InstancePtr);
	XSysMonPsu_IntrClear(InstancePtr, IntrStatus);

	return (s32)XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function initializes XSysMonPsu device/instance. This function
* must be called prior to using the System Monitor device.
*
* @param	InstancePtr is a pointer to the XSysMonPsu instance.
* @param	ConfigPtr points to the XSysMonPsu device configuration structure.
* @param	EffectiveAddr is the device base address in the virtual memory
*		address space. If the address translation is not used then the
*		physical address is passed.
*		Unexpected errors may occur if the address mapping is changed
*		after this function is invoked.
*
* @return
*		- XSYSMON_SUCCESS if successful.
*
* @note		The user needs to first call the XSysMonPsu_LookupConfig() API
*		which returns the Configuration structure pointer which is
*		passed as a parameter to the XSysMonPsu_CfgInitialize() API.
*
******************************************************************************/
This function initializes XSysMonPsu device/instance. This function
must be called prior to using the System Monitor device.
This function initializes XSysMonPsu device / instance . This function must be called prior to using the System Monitor device .
s32 XSysMonPsu_CfgInitialize(XSysMonPsu *InstancePtr, XSysMonPsu_Config *ConfigPtr,
			  u32 EffectiveAddr)
{
	u32 PsSysmonControlStatus;
	u64 IntrStatus;
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(ConfigPtr != NULL);
	InstancePtr->Config.DeviceId = ConfigPtr->DeviceId;
	InstancePtr->Config.BaseAddress = EffectiveAddr;
	InstancePtr->Config.InputClockMHz = ConfigPtr->InputClockMHz;
	InstancePtr->Handler = (XSysMonPsu_Handler)XSysMonPsu_StubHandler;
	(void)XSysMonPsu_UpdateAdcClkDivisor(InstancePtr, XSYSMON_PS);
	(void)XSysMonPsu_UpdateAdcClkDivisor(InstancePtr, XSYSMON_PL);
	XSysMonPsu_Reset(InstancePtr);
	PsSysmonControlStatus = XSysmonPsu_ReadReg(InstancePtr->Config.BaseAddress +
			XSYSMONPSU_PS_SYSMON_CSTS_OFFSET);
	while(PsSysmonControlStatus != XSYSMONPSU_PS_SYSMON_READY) {
		PsSysmonControlStatus = XSysmonPsu_ReadReg(InstancePtr->Config.BaseAddress +
					XSYSMONPSU_PS_SYSMON_CSTS_OFFSET);
	}
	InstancePtr->IsPlAccessibleByPs =
			XSysmonPsu_ReadReg(InstancePtr->Config.BaseAddress +
			XSYSMONPSU_PL_SYSMON_CSTS_OFFSET) &
			XSYSMONPSU_PL_SYSMON_CSTS_ACESBLE_MASK;
	InstancePtr->IsReady = XIL_COMPONENT_IS_READY;
	IntrStatus = XSysMonPsu_IntrGetStatus(InstancePtr);
	XSysMonPsu_IntrClear(InstancePtr, IntrStatus);
	return (s32)XST_SUCCESS;
}
s32 XSysMonPsu_CfgInitialize ( XSysMonPsu * InstancePtr , XSysMonPsu_Config * ConfigPtr , u32 EffectiveAddr ) { u32 PsSysmonControlStatus ; u64 IntrStatus ; Xil_AssertNonvoid ( InstancePtr != NULL ) ; Xil_AssertNonvoid ( ConfigPtr != NULL ) ; InstancePtr -> Config . DeviceId = ConfigPtr -> DeviceId ; InstancePtr -> Config . BaseAddress = EffectiveAddr ; InstancePtr -> Config . InputClockMHz = ConfigPtr -> InputClockMHz ; InstancePtr -> Handler = ( XSysMonPsu_Handler ) XSysMonPsu_StubHandler ; ( void ) XSysMonPsu_UpdateAdcClkDivisor ( InstancePtr , XSYSMON_PS ) ; ( void ) XSysMonPsu_UpdateAdcClkDivisor ( InstancePtr , XSYSMON_PL ) ; XSysMonPsu_Reset ( InstancePtr ) ; PsSysmonControlStatus = XSysmonPsu_ReadReg ( InstancePtr -> Config . BaseAddress + XSYSMONPSU_PS_SYSMON_CSTS_OFFSET ) ; while ( PsSysmonControlStatus != XSYSMONPSU_PS_SYSMON_READY ) { PsSysmonControlStatus = XSysmonPsu_ReadReg ( InstancePtr -> Config . BaseAddress + XSYSMONPSU_PS_SYSMON_CSTS_OFFSET ) ; } InstancePtr -> IsPlAccessibleByPs = XSysmonPsu_ReadReg ( InstancePtr -> Config . BaseAddress + XSYSMONPSU_PL_SYSMON_CSTS_OFFSET ) & XSYSMONPSU_PL_SYSMON_CSTS_ACESBLE_MASK ; InstancePtr -> IsReady = XIL_COMPONENT_IS_READY ; IntrStatus = XSysMonPsu_IntrGetStatus ( InstancePtr ) ; XSysMonPsu_IntrClear ( InstancePtr , IntrStatus ) ; return ( s32 ) XST_SUCCESS ; }
This function initializes XSysMonPsu device/instance.
This function initializes XSysMonPsu device / instance .
/* Assert the input arguments. */ /* Set the values read from the device config and the base address. */ /* Set all handlers to stub values, let user configure this data later. */ /* Reset the device such that it is in a known state. */ /* Check if the PS Sysmon is in Idle / ready state or not */ /* Indicate the instance is now ready to use, initialized without error */ /* Clear any bits set in the Interrupt Status Register. */