1 /* 2 * Arm SCP/MCP Software 3 * Copyright (c) 2018-2022, Arm Limited and Contributors. All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 #ifndef MOD_F_I2C_H 9 #define MOD_F_I2C_H 10 11 #include <i2c_api.h> 12 13 #include <internal/i2c_depend.h> 14 #include <internal/i2c_driver.h> 15 16 #include <fwk_id.h> 17 18 #include <stdint.h> 19 20 /*! 21 * \addtogroup GroupSYNQUACERModule SYNQUACER Product Modules 22 * \{ 23 */ 24 25 /*! 26 * \defgroup GroupF_I2C F_I2C Driver 27 * 28 * \brief SynQuacer F_I2C device driver. 29 * 30 * \details This module implements a device driver for the F_I2C 31 * 32 * \{ 33 */ 34 35 /*! 36 * \brief APIs to access the i2c device. 37 */ 38 struct mod_f_i2c_api { 39 /*! 40 * \brief APIs to access the i2c device. 41 * 42 * \param id Module identifier. 43 * \param count Pointer to storage for the descriptor table. 44 * 45 * \retval I2C_ERR_OK Operation succeeded. 46 * \return One of the I2C_ERR_t codes described by f_i2c module. 47 */ 48 void (*init)(void); 49 50 /*! 51 * \brief receive data from i2c device 52 * 53 * \param ch channel 54 * \param target_address target address 55 * \param address target address 56 * \param data buffer to receive the data 57 * \param length length to read 58 * 59 * \retval I2C_ERR_OK Operation succeeded. 60 * \retval I2C_ERR_PARAM Invalid parameter. 61 * \retval I2C_ERR_BUSY I2C controller is busy. 62 * \retval I2C_ERR_BER Bus error. 63 * \return One of the other specific error codes. 64 */ 65 I2C_ERR_t (*recv_data)( 66 I2C_EN_CH_t ch, 67 uint32_t target_address, 68 uint32_t address, 69 uint8_t *data, 70 int length); 71 72 /*! 73 * \brief send data to i2c device 74 * 75 * \param ch channel 76 * \param target_address target address 77 * \param address target address 78 * \param data buffer to be sent 79 * \param length length to be sent 80 * 81 * \retval I2C_ERR_OK Operation succeeded. 82 * \retval I2C_ERR_PARAM Invalid parameter. 83 * \retval I2C_ERR_BUSY I2C controller is busy. 84 * \retval I2C_ERR_BER Bus error. 85 * \return One of the other specific error codes. 86 */ 87 I2C_ERR_t (*send_data)( 88 I2C_EN_CH_t ch, 89 uint32_t target_address, 90 uint32_t address, 91 const uint8_t *data, 92 int length); 93 }; 94 95 /*! 96 * \brief F_I2C device configuration data. 97 */ 98 struct mod_f_i2c_config { 99 /*! Base address of the device registers */ 100 uintptr_t reg_base; 101 }; 102 103 /*! 104 * \} 105 */ 106 107 /*! 108 * \} 109 */ 110 111 #endif /* MOD_F_I2C_H */ 112