+++ /dev/null
-/*++\r
-\r
- Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
- \r\r
- SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
- \r\r
-\r
-\r
-**/\r
-\r
-#ifndef __I2C_SLAVE_H__\r
-#define __I2C_SLAVE_H__\r
-\r
-#include <Protocol/I2cHostMcg.h>\r
-\r
-/**\r
- Declare the forward references\r
-\r
-**/\r
-typedef struct _EFI_I2C_SLAVE_PROTOCOL EFI_I2C_SLAVE_PROTOCOL; ///< I2C slave protocol\r
-\r
-/**\r
- The I2C controller received a data byte from the\r
- I2C msster.\r
-\r
- @param[in] Context The value passed to the slave enable routine.\r
- @param[in] NumberOfBytes Number of data bytes received\r
- @param[in] Data Buffer containing the received data bytes\r
-\r
- @retval EFI_SUCCESS ACK the data byte\r
- @retval EFI_UNSUPPORTED NACK the data byte\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_I2C_SLAVE_RECEIVE_DATA) (\r
- IN VOID *Context,\r
- IN UINTN NumberOfBytes,\r
- IN CONST UINT8 *Data\r
- );\r
-\r
-/**\r
- The I2C controller received the start bit from the\r
- I2C master.\r
-\r
- @param[in] Context The value passed to the slave enable routine.\r
-\r
-**/\r
-typedef\r
-VOID\r
-(EFIAPI *EFI_I2C_SLAVE_RECEIVE_START) (\r
- IN VOID *Context,\r
- IN UINTN BytesSent,\r
- IN EFI_STATUS Status\r
- );\r
-\r
-/**\r
- The I2C controller received the stop bit from the\r
- I2C master.\r
-\r
- @param[in] Context The value passed to the slave enable routine.\r
- @param[in] BytesSent Number of bytes successfully ACKed by the\r
- I2C master. This is a hint, not all I2C\r
- controllers support the ability to return\r
- the number of bytes sent. When it is not\r
- possible, the port driver returns zero.\r
- @param[in] Status <ul>\r
- <li>EFI_SUCCESS - All of the data was successfully sent</li>\r
- <li>EFI_ABORTED - The controller was reset</li>\r
- <li>EFI_DEVICE_ERROR - A NACK was received when sending the data.</li>\r
- <li>EFI_END_OF_FILE - The stop bit was received before all of\r
- the data was sent.</li>\r
- </ul>\r
-\r
-**/\r
-typedef\r
-VOID\r
-(EFIAPI *EFI_I2C_SLAVE_RECEIVE_STOP) (\r
- IN VOID *Context,\r
- IN UINTN BytesSent,\r
- IN EFI_STATUS Status\r
- );\r
-\r
-/**\r
- Enable or disable I2C slave operation.\r
-\r
- The ReceiveData callback allows the port driver to return data\r
- to the driver or application handling slave mode operations. This\r
- is data that a remote master has sent to the local I2C controller.\r
- The data may be returned one byte at a time if the controller supports\r
- the ability to ACK/NACK on each receive byte. If not, a block of\r
- data may be returned by the I2C port driver and the ACK/NACK status\r
- is used only as a hint for the port driver.\r
-\r
- The slave mode driver or application should buffer the data until\r
- either ReceiveStart or ReceiveStop is called. At that time all of\r
- the data is received and the command may be processed.\r
-\r
- ReceiveStart is called when the I2C master is expecting a response.\r
- After processing the command, but before sending the response the\r
- slave driver or application should mark the command as processed to\r
- avoid processing it a second time when ReceiveStop is called. The\r
- slave driver or application then calls SendData to send to queue the\r
- response data for transmission. The data must remain valid in the\r
- WriteBuffer until ReceiveStop is called.\r
-\r
- ReceiveStop is called when the stop bit is received on the I2C bus.\r
- The slave driver or application starts processing the command if an\r
- command data is pending in the slave driver's or application's buffer.\r
- The BytesSent value is a hint to the slave driver or application as\r
- to how much data was returned to the I2C master. If the controller\r
- does not provide this level of support then this value is set to zero.\r
-\r
- @param[in] This Address of an EFI_I2C_SLAVE_PROTOCOL\r
- structure\r
- @param[in] SlaveAddress Slave address for the I2C controller\r
- @param[in] Context Address of a context structure for use when\r
- calling ReceiveData or ReceiveStop\r
- @param[in] ReceiveData Called by the I2C port driver as data bytes\r
- are received from the master. Response status\r
- indicates if the byte is ACKed or NACKed. When\r
- data is passed back a byte at a time, the port\r
- driver must hold the clock until this callback\r
- returns.\r
- @param[in] ReceiveStart Called when the I2C controller receives a start bit.\r
- @param[in] ReceiveStop Called after all of the data bytes are\r
- received.\r
-\r
- @retval EFI_SUCCESS Slave operation is enabled on the controller.\r
- @retval EFI_UNSUPPORTED The controller does not support this frequency.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_I2C_SLAVE_ENABLE) (\r
- IN CONST EFI_I2C_SLAVE_PROTOCOL *This,\r
- IN UINT32 SlaveAddress,\r
- IN VOID *Context,\r
- IN EFI_I2C_SLAVE_RECEIVE_DATA ReceiveData,\r
- IN EFI_I2C_SLAVE_RECEIVE_START ReceiveStart,\r
- IN EFI_I2C_SLAVE_RECEIVE_STOP ReceiveStop\r
- );\r
-\r
-/**\r
- Send data to the I2C master.\r
-\r
- Port drivers may implement this as a blocking or non-blocking call.\r
- The data in the write buffer must remain valid until ReceiveStop or\r
- ReceiveStart is called indicating that the I2C master has terminated\r
- the transfer.\r
-\r
- @param[in] This Address of an EFI_I2C_SLAVE_PROTOCOL\r
- structure\r
- @param[in] WriteBytes Number of bytes to write\r
- @param[in] WriteBuffer Buffer containing the data to send\r
-\r
- @retval EFI_SUCCESS Data waiting for master access.\r
- @retval EFI_INVALID_PARAMETER WriteBuffer is NULL or WriteBytes\r
- is zero.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_I2C_SLAVE_SEND) (\r
- IN CONST EFI_I2C_SLAVE_PROTOCOL *This,\r
- IN UINTN WriteBytes,\r
- IN CONST UINT8 *WriteBuffer\r
- );\r
-\r
-///\r
-/// I2C slave protocol\r
-///\r
-/// The port driver publishes this protocol when slave mode is\r
-/// supported by the controller.\r
-///\r
-struct _EFI_I2C_SLAVE_PROTOCOL {\r
- ///\r
- /// Enable or disable I2C slave operation\r
- ///\r
- EFI_I2C_SLAVE_ENABLE SlaveEnable;\r
-\r
- ///\r
- /// Send data to the I2C master\r
- ///\r
- EFI_I2C_SLAVE_SEND SendData;\r
-};\r
-\r
-///\r
-/// GUID for the EFI_I2C_SLAVE_PROTOCOL\r
-///\r
-extern EFI_GUID gEfiI2cSlaveProtocolGuid;\r
-\r
-#endif // __I2C_SLAVE_H__\r