XilinxProcessorIPLib/drivers/board_common/src/rfclk/src/xrfclk.c
static int XRFClk_InitI2C(void)
{
#ifdef __BAREMETAL__
	XIicPs_Config *Config_iic;
	int Status;
	u32 ClkRate = 100000;

#ifdef XPS_BOARD_ZCU111
	/* i2c0 */
	Config_iic = XIicPs_LookupConfig(0);
	if (NULL == Config_iic) {
		return XST_FAILURE;
	}

	Status = XIicPs_CfgInitialize(&Iic0, Config_iic,
				      Config_iic->BaseAddress);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	Status = XIicPs_SetSClk(&Iic0, ClkRate);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
#endif

	/* i2c1 */
	Config_iic = XIicPs_LookupConfig(1);
	if (NULL == Config_iic) {
		return XST_FAILURE;
	}

	Status = XIicPs_CfgInitialize(&Iic1, Config_iic,
				      Config_iic->BaseAddress);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	Status = XIicPs_SetSClk(&Iic1, ClkRate);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
#else
#ifdef XPS_BOARD_ZCU111
	/* i2c0 */
	fd_i2c0 = open(RFCLK_I2C0_DEVICE_PATH, O_RDWR);
	if (fd_i2c0 < 0) {
		LOG("i2c0 open");
		return XST_FAILURE;
	}
#endif

	/* i2c1 */
	fd_i2c1 = open(RFCLK_I2C1_DEVICE_PATH, O_RDWR);
	if (fd_i2c1 < 0) {
		LOG("i2c1 open");
		return XST_FAILURE;
	}
	fd_bridge = open(RFCLK_I2C_I2C2SPI_BRIDGE_DEVICE_PATH, O_RDWR);
	if (fd_bridge < 0) {
		LOG("i2c2spi bridge open");
		return XST_FAILURE;
	}
#endif
	return XST_SUCCESS;
}
/****************************************************************************/
/**
*
* This function is used to open and configure i2c drivers.
*
* @param	None
*
* @return
*	- XST_SUCCESS if successful.
*	- XST_FAILURE if failed.
*
* @note		None
*
****************************************************************************/
This function is used to open and configure i2c drivers.
This function is used to open and configure i2c drivers .
static int XRFClk_InitI2C(void)
{
#ifdef __BAREMETAL__
	XIicPs_Config *Config_iic;
	int Status;
	u32 ClkRate = 100000;
#ifdef XPS_BOARD_ZCU111
	Config_iic = XIicPs_LookupConfig(0);
	if (NULL == Config_iic) {
		return XST_FAILURE;
	}
	Status = XIicPs_CfgInitialize(&Iic0, Config_iic,
				      Config_iic->BaseAddress);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = XIicPs_SetSClk(&Iic0, ClkRate);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
#endif
	Config_iic = XIicPs_LookupConfig(1);
	if (NULL == Config_iic) {
		return XST_FAILURE;
	}
	Status = XIicPs_CfgInitialize(&Iic1, Config_iic,
				      Config_iic->BaseAddress);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = XIicPs_SetSClk(&Iic1, ClkRate);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
#else
#ifdef XPS_BOARD_ZCU111
	fd_i2c0 = open(RFCLK_I2C0_DEVICE_PATH, O_RDWR);
	if (fd_i2c0 < 0) {
		LOG("i2c0 open");
		return XST_FAILURE;
	}
#endif
	fd_i2c1 = open(RFCLK_I2C1_DEVICE_PATH, O_RDWR);
	if (fd_i2c1 < 0) {
		LOG("i2c1 open");
		return XST_FAILURE;
	}
	fd_bridge = open(RFCLK_I2C_I2C2SPI_BRIDGE_DEVICE_PATH, O_RDWR);
	if (fd_bridge < 0) {
		LOG("i2c2spi bridge open");
		return XST_FAILURE;
	}
#endif
	return XST_SUCCESS;
}
static int XRFClk_InitI2C ( void ) { #ifdef __BAREMETAL__ XIicPs_Config * Config_iic ; int Status ; u32 ClkRate = 100000 ; #ifdef XPS_BOARD_ZCU111 Config_iic = XIicPs_LookupConfig ( 0 ) ; if ( NULL == Config_iic ) { return XST_FAILURE ; } Status = XIicPs_CfgInitialize ( & Iic0 , Config_iic , Config_iic -> BaseAddress ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = XIicPs_SetSClk ( & Iic0 , ClkRate ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } #endif Config_iic = XIicPs_LookupConfig ( 1 ) ; if ( NULL == Config_iic ) { return XST_FAILURE ; } Status = XIicPs_CfgInitialize ( & Iic1 , Config_iic , Config_iic -> BaseAddress ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = XIicPs_SetSClk ( & Iic1 , ClkRate ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } #else #ifdef XPS_BOARD_ZCU111 fd_i2c0 = open ( RFCLK_I2C0_DEVICE_PATH , O_RDWR ) ; if ( fd_i2c0 < 0 ) { LOG ( " " ) ; return XST_FAILURE ; } #endif fd_i2c1 = open ( RFCLK_I2C1_DEVICE_PATH , O_RDWR ) ; if ( fd_i2c1 < 0 ) { LOG ( " " ) ; return XST_FAILURE ; } fd_bridge = open ( RFCLK_I2C_I2C2SPI_BRIDGE_DEVICE_PATH , O_RDWR ) ; if ( fd_bridge < 0 ) { LOG ( " " ) ; return XST_FAILURE ; } #endif return XST_SUCCESS ; }
This function is used to open and configure i2c drivers.
This function is used to open and configure i2c drivers .
/* i2c0 */ /* i2c1 */ /* i2c0 */ /* i2c1 */