lib/sw_apps/zynqmp_fsbl/src/xfsbl_misc_drivers.c
u32 XFsbl_InitWdt(void)
{
	s32 Status;
	u32 UStatus;
	XWdtPs_Config *ConfigPtr; 	/* Config structure of the WatchDog Timer */
	u32 CounterValue;
	u32 RegValue;


	/**
	 * Initialize the WDT timer
	 */
	ConfigPtr = XWdtPs_LookupConfig(XFSBL_WDT_DEVICE_ID);

	if (NULL==ConfigPtr) {
		UStatus = XFSBL_WDT_INIT_FAILED;
		goto END;
	}

	Status = XWdtPs_CfgInitialize(&Watchdog,
			ConfigPtr,
			ConfigPtr->BaseAddress);
	if (Status != XFSBL_SUCCESS) {
		if(Status == XST_DEVICE_IS_STARTED)
		{
			UStatus = XFSBL_SUCCESS;
			goto END;
		}
		XFsbl_Printf(DEBUG_INFO, "XFSBL_WDT_INIT_FAILED\n\r");
		UStatus = XFSBL_WDT_INIT_FAILED;
		goto END;
	}

	/**
	 * Setting the divider value
	 */
	XWdtPs_SetControlValue(&Watchdog,
			XWDTPS_CLK_PRESCALE,
			XWDTPS_CCR_PSCALE_4096);
	/**
	 * Convert time to  Watchdog counter reset value
	 */
	CounterValue = XFsbl_ConvertTime_WdtCounter(XFSBL_WDT_EXPIRE_TIME);

	/**
	 * Set the Watchdog counter reset value
	 */
	XWdtPs_SetControlValue(&Watchdog,
			XWDTPS_COUNTER_RESET,
			CounterValue);
	/**
	 * enable reset output, as we are only using this as a basic counter
	 */
	XWdtPs_EnableOutput(&Watchdog, XWDTPS_RESET_SIGNAL);

	/* Enable generation of system reset by PMU due to SWDT0/1 */
	RegValue = XFsbl_In32(PMU_GLOBAL_ERROR_SRST_EN_1);
	RegValue |= XFSBL_WDT_MASK;
	XFsbl_Out32(PMU_GLOBAL_ERROR_SRST_EN_1, RegValue);

	/* Enable SWDT0/1 System Watchdog Timer Error */
	RegValue = XFsbl_In32(PMU_GLOBAL_ERROR_EN_1);
	RegValue |= XFSBL_WDT_MASK;
	XFsbl_Out32(PMU_GLOBAL_ERROR_EN_1, RegValue);

	/**
	 * Start the Watchdog timer
	 */
	XWdtPs_Start(&Watchdog);

	XWdtPs_RestartWdt(&Watchdog);

	UStatus = XFSBL_SUCCESS;
END:
	return UStatus;
}
/*****************************************************************************/
/**
 * This function is used to initialize the system
 *
 * @param	None
 *
 * @return	None
 *
 *****************************************************************************/
This function is used to initialize the system
@param       None

@return      None
This function is used to initialize the system @param None @return None
u32 XFsbl_InitWdt(void)
{
	s32 Status;
	u32 UStatus;
	XWdtPs_Config *ConfigPtr; 	
	u32 CounterValue;
	u32 RegValue;
	ConfigPtr = XWdtPs_LookupConfig(XFSBL_WDT_DEVICE_ID);
	if (NULL==ConfigPtr) {
		UStatus = XFSBL_WDT_INIT_FAILED;
		goto END;
	}
	Status = XWdtPs_CfgInitialize(&Watchdog,
			ConfigPtr,
			ConfigPtr->BaseAddress);
	if (Status != XFSBL_SUCCESS) {
		if(Status == XST_DEVICE_IS_STARTED)
		{
			UStatus = XFSBL_SUCCESS;
			goto END;
		}
		XFsbl_Printf(DEBUG_INFO, "XFSBL_WDT_INIT_FAILED\n\r");
		UStatus = XFSBL_WDT_INIT_FAILED;
		goto END;
	}
	XWdtPs_SetControlValue(&Watchdog,
			XWDTPS_CLK_PRESCALE,
			XWDTPS_CCR_PSCALE_4096);
	CounterValue = XFsbl_ConvertTime_WdtCounter(XFSBL_WDT_EXPIRE_TIME);
	XWdtPs_SetControlValue(&Watchdog,
			XWDTPS_COUNTER_RESET,
			CounterValue);
	XWdtPs_EnableOutput(&Watchdog, XWDTPS_RESET_SIGNAL);
	RegValue = XFsbl_In32(PMU_GLOBAL_ERROR_SRST_EN_1);
	RegValue |= XFSBL_WDT_MASK;
	XFsbl_Out32(PMU_GLOBAL_ERROR_SRST_EN_1, RegValue);
	RegValue = XFsbl_In32(PMU_GLOBAL_ERROR_EN_1);
	RegValue |= XFSBL_WDT_MASK;
	XFsbl_Out32(PMU_GLOBAL_ERROR_EN_1, RegValue);
	XWdtPs_Start(&Watchdog);
	XWdtPs_RestartWdt(&Watchdog);
	UStatus = XFSBL_SUCCESS;
END:
	return UStatus;
}
u32 XFsbl_InitWdt ( void ) { s32 Status ; u32 UStatus ; XWdtPs_Config * ConfigPtr ; u32 CounterValue ; u32 RegValue ; ConfigPtr = XWdtPs_LookupConfig ( XFSBL_WDT_DEVICE_ID ) ; if ( NULL == ConfigPtr ) { UStatus = XFSBL_WDT_INIT_FAILED ; goto END ; } Status = XWdtPs_CfgInitialize ( & Watchdog , ConfigPtr , ConfigPtr -> BaseAddress ) ; if ( Status != XFSBL_SUCCESS ) { if ( Status == XST_DEVICE_IS_STARTED ) { UStatus = XFSBL_SUCCESS ; goto END ; } XFsbl_Printf ( DEBUG_INFO , " \n \r " ) ; UStatus = XFSBL_WDT_INIT_FAILED ; goto END ; } XWdtPs_SetControlValue ( & Watchdog , XWDTPS_CLK_PRESCALE , XWDTPS_CCR_PSCALE_4096 ) ; CounterValue = XFsbl_ConvertTime_WdtCounter ( XFSBL_WDT_EXPIRE_TIME ) ; XWdtPs_SetControlValue ( & Watchdog , XWDTPS_COUNTER_RESET , CounterValue ) ; XWdtPs_EnableOutput ( & Watchdog , XWDTPS_RESET_SIGNAL ) ; RegValue = XFsbl_In32 ( PMU_GLOBAL_ERROR_SRST_EN_1 ) ; RegValue |= XFSBL_WDT_MASK ; XFsbl_Out32 ( PMU_GLOBAL_ERROR_SRST_EN_1 , RegValue ) ; RegValue = XFsbl_In32 ( PMU_GLOBAL_ERROR_EN_1 ) ; RegValue |= XFSBL_WDT_MASK ; XFsbl_Out32 ( PMU_GLOBAL_ERROR_EN_1 , RegValue ) ; XWdtPs_Start ( & Watchdog ) ; XWdtPs_RestartWdt ( & Watchdog ) ; UStatus = XFSBL_SUCCESS ; END : return UStatus ; }
This function is used to initialize the system
 @param       None
This function is used to initialize the system @param None
/* Config structure of the WatchDog Timer */ /**
	 * Initialize the WDT timer
	 */ /**
	 * Setting the divider value
	 */ /**
	 * Convert time to  Watchdog counter reset value
	 */ /**
	 * Set the Watchdog counter reset value
	 */ /**
	 * enable reset output, as we are only using this as a basic counter
	 */ /* Enable generation of system reset by PMU due to SWDT0/1 */ /* Enable SWDT0/1 System Watchdog Timer Error */ /**
	 * Start the Watchdog timer
	 */