/* * Copyright (C) 2012 Realtek Semiconductor Corp. * All Rights Reserved. * * This program is the proprietary software of Realtek Semiconductor * Corporation and/or its licensors, and only be used, duplicated, * modified or distributed under the authorized license from Realtek. * * ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER * THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. * * $Revision: 86103 $ * $Date: 2018-02-08 17:08:36 +0800 (Thu, 08 Feb 2018) $ * * Purpose : Definition of I2C API * * Feature : The file includes the following modules and sub-modules * (1) I2C control * (2) I2C read/write */ #ifndef __DAL_APOLLOMP_I2C_H__ #define __DAL_APOLLOMP_I2C_H__ /* * Include Files */ #include #include /* * Symbol Definition */ /* * Data Declaration */ /* * Macro Declaration */ /* * Function Declaration */ /* Function Name: * dal_apollomp_i2c_init * Description: * Initialize i2c interface. * Input: * i2cPort - I2C port interface * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * Note: * Must initialize before calling any other APIs. */ int32 dal_apollomp_i2c_init(rtk_i2c_port_t i2cPort); /* Function Name: * dal_apollomp_i2c_enable_set * Description: * Enable/Disable I2C interface. * Input: * i2cPort - I2C port interface * enable - enable/disable state * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_INPUT * Note: * */ int32 dal_apollomp_i2c_enable_set(rtk_i2c_port_t i2cPort, rtk_enable_t enable); /* Function Name: * dal_apollomp_i2c_enable_get * Description: * Get I2C interface state. * Input: * i2cPort - I2C port interface * pEnable - the pointer of enable/disable state * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_NULL_POINTER * Note: * */ int32 dal_apollomp_i2c_enable_get(rtk_i2c_port_t i2cPort, rtk_enable_t *pEnable); /* Function Name: * dal_apollomp_i2c_width_set * Description: * Set the data and address width of I2C interface. * Input: * i2cPort - I2C port interface * width - 8-bit or 16-bit * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_INPUT * Note: * */ int32 dal_apollomp_i2c_width_set(rtk_i2c_port_t i2cPort, rtk_i2c_width_t width); /* Function Name: * dal_apollomp_i2c_width_get * Description: * Get the data and address width of I2C interface. * Input: * i2cPort - I2C port interface * pWidth - the pointer of width * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_NULL_POINTER * Note: * */ int32 dal_apollomp_i2c_width_get(rtk_i2c_port_t i2cPort, rtk_i2c_width_t *pWidth); /* Function Name: * dal_apollomp_i2c_write * Description: * I2c write data. * Input: * i2cPort - I2C port interface * devID - the device ID * regAddr - register address * data - data value * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_INPUT * Note: * */ int32 dal_apollomp_i2c_write(rtk_i2c_port_t i2cPort, uint32 devID, uint32 regAddr, uint32 data); /* Function Name: * dal_apollomp_i2c_read * Description: * I2c read data. * Input: * i2cPort - I2C port interface * devID - the device ID * regAddr - register address * pData - the pointer of returned data * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_INPUT * RT_ERR_NULL_POINTER * Note: * */ int32 dal_apollomp_i2c_read(rtk_i2c_port_t i2cPort, uint32 devID, uint32 regAddr, uint32 *pData); /* Function Name: * dal_apollmp_i2c_seq_read * Description: * I2c read data. * Input: * i2cPort - I2C port interface * devID - the device ID * regAddr - register address * pData - the pointer of returned data * count - number of sequential read * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_INPUT * RT_ERR_NULL_POINTER * RT_ERR_CHIP_NOT_SUPPORTED * Note: * The ASIC doesn't support sequential read opearation * Use multiple random read to simulate the behavior */ int32 dal_apollomp_i2c_seq_read(rtk_i2c_port_t i2cPort, uint32 devID, uint32 regAddr, uint32 *pData, uint32 count); /* Function Name: * dal_apollomp_i2c_clock_set * Description: * Set the clock of I2C interface. * Input: * i2cPort - I2C port interface * clock - KMHz, 10-bit value * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_INPUT * Note: * */ int32 dal_apollomp_i2c_clock_set(rtk_i2c_port_t i2cPort, uint32 clock); /* Function Name: * dal_apollomp_i2c_clock_get * Description: * Set the clock of I2C interface. * Input: * i2cPort - I2C port interface * clock - KMHz, 10-bit value * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_INPUT * Note: * */ int32 dal_apollomp_i2c_clock_get(rtk_i2c_port_t i2cPort, uint32 *pClock); /* Function Name: * dal_apollomp_i2c_dataWidth_set * Description: * Set the data width of I2C interface. * Input: * i2cPort - I2C port interface * width - 8-bit or 16-bit * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_INPUT * Note: * */ extern int32 dal_apollomp_i2c_dataWidth_set(rtk_i2c_port_t i2cPort, rtk_i2c_width_t width); /* Function Name: * dal_apollomp_i2c_dataWidth_get * Description: * Get the data width of I2C interface. * Input: * i2cPort - I2C port interface * pWidth - the pointer of width * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_NULL_POINTER * Note: * */ extern int32 dal_apollomp_i2c_dataWidth_get(rtk_i2c_port_t i2cPort, rtk_i2c_width_t *pWidth); /* Function Name: * dal_apollomp_i2c_addrWidth_set * Description: * Set the address width of I2C interface. * Input: * i2cPort - I2C port interface * width - 8-bit or 16-bit * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_INPUT * Note: * */ extern int32 dal_apollomp_i2c_addrWidth_set(rtk_i2c_port_t i2cPort, rtk_i2c_width_t width); /* Function Name: * dal_apollomp_i2c_addrWidth_get * Description: * Get the address width of I2C interface. * Input: * i2cPort - I2C port interface * pWidth - the pointer of width * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_NULL_POINTER * Note: * */ extern int32 dal_apollomp_i2c_addrWidth_get(rtk_i2c_port_t i2cPort, rtk_i2c_width_t *pWidth); #endif /*#ifndef __DAL_APOLLOMP_I2C_H__*/