lib/sw_services/xilloader/src/xloader.c
static void XLoader_SetJtagTapToReset(void)
{
	u8 Index = 0U;
	u32 Flag = 0U;
	u32 Val = 0U;

	/*
	 * Based on Vivado property, check whether to apply MJTAG workaround
	 * or not. By default vivado property disables MJTAG workaround.
	 */
	Val = XPlmi_In32(XPLMI_RTCFG_PLM_MJTAG_WA);
	Flag = Val & XPLMI_RTCFG_PLM_MJTAG_WA_IS_ENABLED_MASK;
	if (Flag != XPLMI_RTCFG_PLM_MJTAG_WA_IS_ENABLED_MASK) {
		goto END;
	}

	/* Skip applying MJTAG workaround if already applied */
	Flag = ((Val & XPLMI_RTCFG_PLM_MJTAG_WA_STATUS_MASK) >>
			XPLMI_RTCFG_PLM_MJTAG_WA_STATUS_SHIFT);
	if (Flag != 0U) {
		goto END;
	}

	/* Check if End of PL Startup is asserted or not */
	Flag = ((XPlmi_In32(CFU_APB_CFU_FGCR) & CFU_APB_CFU_FGCR_EOS_MASK));
	if (Flag != CFU_APB_CFU_FGCR_EOS_MASK) {
		goto END;
	}

	/* Enable MJTAG */
	XPlmi_Out32(PMC_TAP_JTAG_TEST, 1U);

	/* Toggle MJTAG ISO to generate clock pulses, default 10 clock pulses */
	for (Index = 0U; Index < XPLMI_MJTAG_WA_GASKET_TOGGLE_CNT; Index++) {
		XPlmi_UtilRMW(PMC_GLOBAL_DOMAIN_ISO_CNTRL,
				PMC_GLOBAL_DOMAIN_ISO_CNTRL_PMC_PL_TEST_MASK,
				0U);
		XPlmi_UtilRMW(PMC_GLOBAL_DOMAIN_ISO_CNTRL,
				PMC_GLOBAL_DOMAIN_ISO_CNTRL_PMC_PL_TEST_MASK,
				0U);

		/* Delay in between low and high states of toggle */
		usleep(XPLMI_MJTAG_WA_DELAY_USED_IN_GASKET_TOGGLE);

		XPlmi_UtilRMW(PMC_GLOBAL_DOMAIN_ISO_CNTRL,
				PMC_GLOBAL_DOMAIN_ISO_CNTRL_PMC_PL_TEST_MASK,
				PMC_GLOBAL_DOMAIN_ISO_CNTRL_PMC_PL_TEST_MASK);
		XPlmi_UtilRMW(PMC_GLOBAL_DOMAIN_ISO_CNTRL,
				PMC_GLOBAL_DOMAIN_ISO_CNTRL_PMC_PL_TEST_MASK,
				PMC_GLOBAL_DOMAIN_ISO_CNTRL_PMC_PL_TEST_MASK);

		/* Delay in between high and low states of toggle */
		usleep(XPLMI_MJTAG_WA_DELAY_USED_IN_GASKET_TOGGLE);
	}

	/* Disable MJTAG */
	XPlmi_Out32(PMC_TAP_JTAG_TEST, 0U);

	XPlmi_UtilRMW(XPLMI_RTCFG_PLM_MJTAG_WA,
				XPLMI_RTCFG_PLM_MJTAG_WA_STATUS_MASK,
				XPLMI_RTCFG_PLM_MJTAG_WA_STATUS_MASK);
END:
	return;
}
/*****************************************************************************/
/**
 * @brief	This function is used to run MJTAG solution workaround in which
 * JTAG Tap state will be set to reset.
 *
 *
 * @return	None
 *
 *****************************************************************************/
@brief       This function is used to run MJTAG solution workaround in which
JTAG Tap state will be set to reset.

@return      None
@brief This function is used to run MJTAG solution workaround in which JTAG Tap state will be set to reset . @return None
static void XLoader_SetJtagTapToReset(void)
{
	u8 Index = 0U;
	u32 Flag = 0U;
	u32 Val = 0U;
	Val = XPlmi_In32(XPLMI_RTCFG_PLM_MJTAG_WA);
	Flag = Val & XPLMI_RTCFG_PLM_MJTAG_WA_IS_ENABLED_MASK;
	if (Flag != XPLMI_RTCFG_PLM_MJTAG_WA_IS_ENABLED_MASK) {
		goto END;
	}
	Flag = ((Val & XPLMI_RTCFG_PLM_MJTAG_WA_STATUS_MASK) >>
			XPLMI_RTCFG_PLM_MJTAG_WA_STATUS_SHIFT);
	if (Flag != 0U) {
		goto END;
	}
	Flag = ((XPlmi_In32(CFU_APB_CFU_FGCR) & CFU_APB_CFU_FGCR_EOS_MASK));
	if (Flag != CFU_APB_CFU_FGCR_EOS_MASK) {
		goto END;
	}
	XPlmi_Out32(PMC_TAP_JTAG_TEST, 1U);
	for (Index = 0U; Index < XPLMI_MJTAG_WA_GASKET_TOGGLE_CNT; Index++) {
		XPlmi_UtilRMW(PMC_GLOBAL_DOMAIN_ISO_CNTRL,
				PMC_GLOBAL_DOMAIN_ISO_CNTRL_PMC_PL_TEST_MASK,
				0U);
		XPlmi_UtilRMW(PMC_GLOBAL_DOMAIN_ISO_CNTRL,
				PMC_GLOBAL_DOMAIN_ISO_CNTRL_PMC_PL_TEST_MASK,
				0U);
		usleep(XPLMI_MJTAG_WA_DELAY_USED_IN_GASKET_TOGGLE);
		XPlmi_UtilRMW(PMC_GLOBAL_DOMAIN_ISO_CNTRL,
				PMC_GLOBAL_DOMAIN_ISO_CNTRL_PMC_PL_TEST_MASK,
				PMC_GLOBAL_DOMAIN_ISO_CNTRL_PMC_PL_TEST_MASK);
		XPlmi_UtilRMW(PMC_GLOBAL_DOMAIN_ISO_CNTRL,
				PMC_GLOBAL_DOMAIN_ISO_CNTRL_PMC_PL_TEST_MASK,
				PMC_GLOBAL_DOMAIN_ISO_CNTRL_PMC_PL_TEST_MASK);
		usleep(XPLMI_MJTAG_WA_DELAY_USED_IN_GASKET_TOGGLE);
	}
	XPlmi_Out32(PMC_TAP_JTAG_TEST, 0U);
	XPlmi_UtilRMW(XPLMI_RTCFG_PLM_MJTAG_WA,
				XPLMI_RTCFG_PLM_MJTAG_WA_STATUS_MASK,
				XPLMI_RTCFG_PLM_MJTAG_WA_STATUS_MASK);
END:
	return;
}
static void XLoader_SetJtagTapToReset ( void ) { u8 Index = 0U ; u32 Flag = 0U ; u32 Val = 0U ; Val = XPlmi_In32 ( XPLMI_RTCFG_PLM_MJTAG_WA ) ; Flag = Val & XPLMI_RTCFG_PLM_MJTAG_WA_IS_ENABLED_MASK ; if ( Flag != XPLMI_RTCFG_PLM_MJTAG_WA_IS_ENABLED_MASK ) { goto END ; } Flag = ( ( Val & XPLMI_RTCFG_PLM_MJTAG_WA_STATUS_MASK ) >> XPLMI_RTCFG_PLM_MJTAG_WA_STATUS_SHIFT ) ; if ( Flag != 0U ) { goto END ; } Flag = ( ( XPlmi_In32 ( CFU_APB_CFU_FGCR ) & CFU_APB_CFU_FGCR_EOS_MASK ) ) ; if ( Flag != CFU_APB_CFU_FGCR_EOS_MASK ) { goto END ; } XPlmi_Out32 ( PMC_TAP_JTAG_TEST , 1U ) ; for ( Index = 0U ; Index < XPLMI_MJTAG_WA_GASKET_TOGGLE_CNT ; Index ++ ) { XPlmi_UtilRMW ( PMC_GLOBAL_DOMAIN_ISO_CNTRL , PMC_GLOBAL_DOMAIN_ISO_CNTRL_PMC_PL_TEST_MASK , 0U ) ; XPlmi_UtilRMW ( PMC_GLOBAL_DOMAIN_ISO_CNTRL , PMC_GLOBAL_DOMAIN_ISO_CNTRL_PMC_PL_TEST_MASK , 0U ) ; usleep ( XPLMI_MJTAG_WA_DELAY_USED_IN_GASKET_TOGGLE ) ; XPlmi_UtilRMW ( PMC_GLOBAL_DOMAIN_ISO_CNTRL , PMC_GLOBAL_DOMAIN_ISO_CNTRL_PMC_PL_TEST_MASK , PMC_GLOBAL_DOMAIN_ISO_CNTRL_PMC_PL_TEST_MASK ) ; XPlmi_UtilRMW ( PMC_GLOBAL_DOMAIN_ISO_CNTRL , PMC_GLOBAL_DOMAIN_ISO_CNTRL_PMC_PL_TEST_MASK , PMC_GLOBAL_DOMAIN_ISO_CNTRL_PMC_PL_TEST_MASK ) ; usleep ( XPLMI_MJTAG_WA_DELAY_USED_IN_GASKET_TOGGLE ) ; } XPlmi_Out32 ( PMC_TAP_JTAG_TEST , 0U ) ; XPlmi_UtilRMW ( XPLMI_RTCFG_PLM_MJTAG_WA , XPLMI_RTCFG_PLM_MJTAG_WA_STATUS_MASK , XPLMI_RTCFG_PLM_MJTAG_WA_STATUS_MASK ) ; END : return ; }
@brief       This function is used to run MJTAG solution workaround in which
 JTAG Tap state will be set to reset.
@brief This function is used to run MJTAG solution workaround in which JTAG Tap state will be set to reset .
/*
	 * Based on Vivado property, check whether to apply MJTAG workaround
	 * or not. By default vivado property disables MJTAG workaround.
	 */ /* Skip applying MJTAG workaround if already applied */ /* Check if End of PL Startup is asserted or not */ /* Enable MJTAG */ /* Toggle MJTAG ISO to generate clock pulses, default 10 clock pulses */ /* Delay in between low and high states of toggle */ /* Delay in between high and low states of toggle */ /* Disable MJTAG */