dp: rx: mst: Added ability to set an I2C map for each port.
The "I2C map" terminology is used to refer to a set of I2C entries for a given port. Each I2C entry contains an I2C address associated with that entry, alongside a user-defined data structure which is to be pointed to. This is the mechanism for which the driver allows the RX application to control what data to be sent for a given I2C address when a REMOTE_I2C_READ is issued by an upstream device. Signed-off-by: Andrei-Liviu Simion <andrei.simion@xilinx.com>
This commit is contained in:
parent
745530d3e2
commit
0fd3fc6d54
3 changed files with 99 additions and 8 deletions
|
@ -598,14 +598,14 @@ typedef struct {
|
|||
* duplicated here.
|
||||
*/
|
||||
typedef struct {
|
||||
XDp_RxIicMapEntry IicMap[3]; /**< The I2C map of the internal sinks.
|
||||
When the RX replies to a
|
||||
REMOTE_I2C_READ sideband
|
||||
message, it responds with the
|
||||
associated I2C map for the
|
||||
requested port. The driver
|
||||
allows up to 3 I2C addresses per
|
||||
port to be user-defined. */
|
||||
XDp_RxIicMapEntry IicMap[XDP_RX_NUM_I2C_ENTRIES_PER_PORT]; /**< When the
|
||||
RX replies to a REMOTE_I2C_READ
|
||||
sideband message, it responds
|
||||
with the associated I2C map for
|
||||
the requested port. The driver
|
||||
allows the user to define up to
|
||||
XDP_RX_NUM_I2C_ENTRIES_PER_PORT
|
||||
I2C addresses per port. */
|
||||
u8 Exposed; /**< When set to 1, the RX branch device
|
||||
will expose the port in the
|
||||
LINK_ADDRESS reply. */
|
||||
|
@ -1022,6 +1022,10 @@ void XDp_TxWriteGuid(XDp *InstancePtr, u8 LinkCountTotal, u8 *RelativeAddress,
|
|||
u32 Guid[4]);
|
||||
void XDp_TxGetGuid(XDp *InstancePtr, u8 LinkCountTotal, u8 *RelativeAddress,
|
||||
u32 *Guid);
|
||||
XDp_RxIicMapEntry *XDp_RxGetIicMapEntry(XDp *InstancePtr, u8 PortNum,
|
||||
u8 IicAddress);
|
||||
u32 XDp_RxSetIicMapEntry(XDp *InstancePtr, u8 PortNum, u8 IicAddress,
|
||||
u8 ReadNumBytes, u8 *ReadData);
|
||||
void XDp_RxMstExposePort(XDp *InstancePtr, u8 PortNum, u8 Expose);
|
||||
void XDp_RxMstSetPort(XDp *InstancePtr, u8 PortNum,
|
||||
XDp_SbMsgLinkAddressReplyPortDetail *PortDetails);
|
||||
|
|
|
@ -2291,6 +2291,10 @@
|
|||
#define XDP_TX_SBMSG_REMOTE_I2C_WRITE 0x23
|
||||
/* @} */
|
||||
|
||||
#define XDP_RX_NUM_I2C_ENTRIES_PER_PORT 3 /**< The number of I2C user-
|
||||
defined entries in the
|
||||
I2C map of each port. */
|
||||
|
||||
/******************* Macros (Inline Functions) Definitions ********************/
|
||||
|
||||
/** @name Register access macro definitions.
|
||||
|
|
|
@ -2295,6 +2295,89 @@ void XDp_TxGetGuid(XDp *InstancePtr, u8 LinkCountTotal, u8 *RelativeAddress,
|
|||
}
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/**
|
||||
* This function returns a pointer to the I2C map entry at the supplied I2C
|
||||
* address for the specified port.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDp instance.
|
||||
* @param PortNum is the port number for which to obtain the I2C map entry
|
||||
* for.
|
||||
* @param IicAddress is the I2C address of the map entry.
|
||||
*
|
||||
* @return
|
||||
* - NULL if no entry exists in the I2C map corresponding to the
|
||||
* supplied I2C address for the given port.
|
||||
* - Otherwise, a pointer to the I2C map entry with the specified
|
||||
* I2C address.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*******************************************************************************/
|
||||
XDp_RxIicMapEntry *XDp_RxGetIicMapEntry(XDp *InstancePtr, u8 PortNum,
|
||||
u8 IicAddress)
|
||||
{
|
||||
u8 Index;
|
||||
XDp_RxIicMapEntry *IicMap;
|
||||
|
||||
IicMap = InstancePtr->RxInstance.Topology.Ports[PortNum].IicMap;
|
||||
|
||||
for (Index = 0; Index < XDP_RX_NUM_I2C_ENTRIES_PER_PORT; Index++) {
|
||||
/* Return a pointer to the specified I2C address, or the first
|
||||
* empty slot. */
|
||||
if ((IicMap[Index].IicAddress == IicAddress) ||
|
||||
(IicMap[Index].IicAddress == 0)) {
|
||||
return &IicMap[Index];
|
||||
}
|
||||
}
|
||||
|
||||
/* No entry with the specified I2C address has been found and there are
|
||||
* no empty slots. */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/**
|
||||
* This function adds an entry into the I2C map for a given port. The user
|
||||
* provides a pointer to the data to be used for the specified I2C address.
|
||||
* When an upstream device issues a REMOTE_I2C_READ sideband message, this I2C
|
||||
* map will be searched for an entry matching the requested I2C address read.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDp instance.
|
||||
* @param PortNum is the port number for which to set the I2C map entry.
|
||||
* @param IicAddress is the I2C address for which to set the data.
|
||||
* @param ReadNumBytes is number of bytes available for reading from the
|
||||
* associated IicAddress.
|
||||
* @param ReadData is a pointer to a user-defined data structure that will
|
||||
* be used as read data when an upstream device issues an I2C read.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if there is an available slot in the I2C map for a
|
||||
* new entry and the I2C address isn't taken.
|
||||
* - XST_FAILURE, otherwise.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*******************************************************************************/
|
||||
u32 XDp_RxSetIicMapEntry(XDp *InstancePtr, u8 PortNum, u8 IicAddress,
|
||||
u8 ReadNumBytes, u8 *ReadData)
|
||||
{
|
||||
XDp_RxIicMapEntry *IicMapEntry;
|
||||
|
||||
IicMapEntry = XDp_RxGetIicMapEntry(InstancePtr, PortNum, IicAddress);
|
||||
if (!IicMapEntry) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/* Definition at specified IicAddress exists. */
|
||||
IicMapEntry->IicAddress = IicAddress;
|
||||
IicMapEntry->WriteVal = 0;
|
||||
IicMapEntry->ReadNumBytes = ReadNumBytes;
|
||||
IicMapEntry->ReadData = ReadData;
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/**
|
||||
* This function allows the user to select which ports will be exposed when
|
||||
|
|
Loading…
Add table
Reference in a new issue