XilinxProcessorIPLib/drivers/board_common/src/rfclk/src/xrfclk.c
u32 XRFClk_ReadReg(u32 ChipId, u32 *d)
{
	Xil_AssertNonvoid(ChipId < RFCLK_CHIP_NUM);
	Xil_AssertNonvoid(d != NULL);

	u8 data[3] = { 0xff & (*d >> 16), 0xff & (*d >> 8), 0xff & (*d) };
	u8 tx[4] = { SELECT_SPI_SDO(ChipId), data[0], data[1], data[2] };

#ifdef XPS_BOARD_ZCU111
	if (ChipId == RFCLK_LMK) {
		LOG("read LMK not supported");
		return XST_FAILURE;
	}
#endif

	/* Setup environment for read */
	if (XRFClk_MuxSPISDO(ChipId) == XST_FAILURE) {
		LOG("Setup SPISDO for read");
		return XST_FAILURE;
	}
	/* Read register */
	tx[1] = data[0] | RF_DATA_READ_BIT;
	if (XST_FAILURE ==
	    XRFClk_I2CWrData(FD_BRIDGE, I2C_ADDR_I2C2SPI_BRIDGE, tx, 4)) {
		LOG("set bridge for read");
		return XST_FAILURE;
	}
	if (XST_FAILURE ==
	    XRFClk_I2CRdData(FD_BRIDGE, I2C_ADDR_I2C2SPI_BRIDGE, data, 3)) {
		LOG("read register");
		return XST_FAILURE;
	}
	/* Revert the environment */
	if (XRFClk_MuxSPISDORevert(ChipId) == XST_FAILURE) {
		LOG("revert the environment");
		return XST_FAILURE;
	}
	*d = (data[0] << 16) + (data[1] << 8) + data[2];
	return XST_SUCCESS;
}
/****************************************************************************/
/**
*
* This function is used to read a register from one of LMX2594 or LMX04828.
*
* @param	ChipId indicates the RF clock chip Id.
* @param	d = {D2, D1, D0}
*	Where [D0,D1,D2] bits are:
*		LMK04282:
*			bit [23] - 1-bit command field (R/W)
*			bits [22:21] - 2-bit multi-byte field (W1, W0)
*			bits [20:8] - 13-bit address field (A12 to A0)
*			bits [7-0]- 8-bit data field (D7 to D0).
*		LMX2594:
*			bit [23] - 1-bit command field (R/W)
*			bits [22:16] - 7-bit address field (A6 to A0)
*			bits [15-0]- 16-bit data field (D15 to D0).
*
* @return
*	- XST_SUCCESS if successful.
*	- XST_FAILURE if failed.
*
* @note		None
*
****************************************************************************/
This function is used to read a register from one of LMX2594 or LMX04828.
This function is used to read a register from one of LMX2594 or LMX04828 .
u32 XRFClk_ReadReg(u32 ChipId, u32 *d)
{
	Xil_AssertNonvoid(ChipId < RFCLK_CHIP_NUM);
	Xil_AssertNonvoid(d != NULL);
	u8 data[3] = { 0xff & (*d >> 16), 0xff & (*d >> 8), 0xff & (*d) };
	u8 tx[4] = { SELECT_SPI_SDO(ChipId), data[0], data[1], data[2] };
#ifdef XPS_BOARD_ZCU111
	if (ChipId == RFCLK_LMK) {
		LOG("read LMK not supported");
		return XST_FAILURE;
	}
#endif
	if (XRFClk_MuxSPISDO(ChipId) == XST_FAILURE) {
		LOG("Setup SPISDO for read");
		return XST_FAILURE;
	}
	tx[1] = data[0] | RF_DATA_READ_BIT;
	if (XST_FAILURE ==
	    XRFClk_I2CWrData(FD_BRIDGE, I2C_ADDR_I2C2SPI_BRIDGE, tx, 4)) {
		LOG("set bridge for read");
		return XST_FAILURE;
	}
	if (XST_FAILURE ==
	    XRFClk_I2CRdData(FD_BRIDGE, I2C_ADDR_I2C2SPI_BRIDGE, data, 3)) {
		LOG("read register");
		return XST_FAILURE;
	}
	if (XRFClk_MuxSPISDORevert(ChipId) == XST_FAILURE) {
		LOG("revert the environment");
		return XST_FAILURE;
	}
	*d = (data[0] << 16) + (data[1] << 8) + data[2];
	return XST_SUCCESS;
}
u32 XRFClk_ReadReg ( u32 ChipId , u32 * d ) { Xil_AssertNonvoid ( ChipId < RFCLK_CHIP_NUM ) ; Xil_AssertNonvoid ( d != NULL ) ; u8 data [ 3 ] = { 0xff & ( * d >> 16 ) , 0xff & ( * d >> 8 ) , 0xff & ( * d ) } ; u8 tx [ 4 ] = { SELECT_SPI_SDO ( ChipId ) , data [ 0 ] , data [ 1 ] , data [ 2 ] } ; #ifdef XPS_BOARD_ZCU111 if ( ChipId == RFCLK_LMK ) { LOG ( " " ) ; return XST_FAILURE ; } #endif if ( XRFClk_MuxSPISDO ( ChipId ) == XST_FAILURE ) { LOG ( " " ) ; return XST_FAILURE ; } tx [ 1 ] = data [ 0 ] | RF_DATA_READ_BIT ; if ( XST_FAILURE == XRFClk_I2CWrData ( FD_BRIDGE , I2C_ADDR_I2C2SPI_BRIDGE , tx , 4 ) ) { LOG ( " " ) ; return XST_FAILURE ; } if ( XST_FAILURE == XRFClk_I2CRdData ( FD_BRIDGE , I2C_ADDR_I2C2SPI_BRIDGE , data , 3 ) ) { LOG ( " " ) ; return XST_FAILURE ; } if ( XRFClk_MuxSPISDORevert ( ChipId ) == XST_FAILURE ) { LOG ( " " ) ; return XST_FAILURE ; } * d = ( data [ 0 ] << 16 ) + ( data [ 1 ] << 8 ) + data [ 2 ] ; return XST_SUCCESS ; }
This function is used to read a register from one of LMX2594 or LMX04828.
This function is used to read a register from one of LMX2594 or LMX04828 .
/* Setup environment for read */ /* Read register */ /* Revert the environment */