/* vxbSMBus.h: vxbus definitions for SMBus controllers 
 * References: Software specification for Kontron EAPI Version 1.2
 */

/*
 * Copyright 2011 Kontron KGSC.
 */

/*
modification history
--------------------
01b,15mar11,edv remove specific method (will use generic driverControl), 
                rename functionality to smbusDriverControl,
		remove KEAPI staff declarations (will be BSP local)
01a,15feb11,edv initial version
*/

#ifndef __INvxbSMBush
#define __INvxbSMBush

#include <vxWorks.h>
#include <vxBusLib.h>
#include <hwif/vxbus/vxBus.h>

#ifdef __cplusplus
extern "C" {
#endif

/* read or write markers */
#define SMBUS_READ	(1)
#define SMBUS_WRITE	(0)

/* typedefs */

struct smbusDriverControl
    {
    /* backward reference to the device instance */	    
    VXB_DEVICE_ID pInst;
	    
    /* Quick command read/write may be used to simply turn a device on/off 
     * or to enable/disable low-power standby mode etc. 
     * There is no data received. */
    STATUS (*smbusQuickCommand)
        (
        VXB_DEVICE_ID	pInst,
        UINT8 addr,
	UINT8 operation /* SMBUS_WRITE / SMBUS_READ */
        );
    
    /* A simple device may accept up to 256 possible encoded 
     * commands in a form of a byte. */
    STATUS (*smbusSendByte)
        (
        VXB_DEVICE_ID	pInst,
        UINT8 addr,
        UINT8 command
        );
    
    /* A simple device may have information that the host needs. 
     * It can do so with Receive byte protocol. */
    STATUS (*smbusReceiveByte)
        (
        VXB_DEVICE_ID	pInst,
        UINT8 addr,
	UINT8 *pByte
        );

    /* This function writes data of size of byte to a device. */
    STATUS (*smbusWriteByte)
        (
        VXB_DEVICE_ID	pInst,
        UINT8 addr,
        UINT8 command,
	UINT8 byte
        );

    /* This function reads data of size of byte from a device. */
    STATUS (*smbusReadByte)
        (
        VXB_DEVICE_ID	pInst,
        UINT8 addr,
        UINT8 command,
	UINT8 *pByte
        );
    
    /* This function writes data of size of word to a device. */
    STATUS (*smbusWriteWord)
        (
        VXB_DEVICE_ID	pInst,
        UINT8 addr,
        UINT8 command,
	UINT16 word
        );

    /* This function reads data of size of word from a device. */
    STATUS (*smbusReadWord)
        (
        VXB_DEVICE_ID	pInst,
        UINT8 addr,
        UINT8 command,
	UINT16 *pWord
        );    
    
    /* This function writes up to 32 bytes to the device. */
    STATUS (*smbusWriteBlock)
        (
        VXB_DEVICE_ID	pInst,
        UINT8 addr,
        UINT8 command,
	UINT8 *pData,
        UINT8 dataLength
        );
    
    /* This function reads up to 32 byte from the device. */
    STATUS (*smbusReadBlock)
        (
        VXB_DEVICE_ID	pInst,
        UINT8 addr,
        UINT8 command,
	UINT8 *pData,
        UINT8 *pDataLength /* This is also the "out" parameter. 
			      It is a pointer to the length of data to read. 
			      After completing the function, this parameter 
			      contains real value of the data length. */
        );
    
     };

#ifdef __cplusplus
}
#endif

#endif /* __INvxbSMBush */
