1 /* 2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without modification, 5 * are permitted provided that the following conditions are met: 6 * 7 * 1. Redistributions of source code must retain the above copyright notice, this list of 8 * conditions and the following disclaimer. 9 * 10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 * of conditions and the following disclaimer in the documentation and/or other materials 12 * provided with the distribution. 13 * 14 * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 * to endorse or promote products derived from this software without specific prior written 16 * permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #ifndef I2C_USER_H 32 #define I2C_USER_H 33 34 #include "hdf_base.h" 35 36 enum I2cIoctlCmd { 37 IOCTL_RETRIES = 0x0701, 38 IOCTL_TIMEOUT = 0x0702, 39 IOCTL_CLIENT = 0x0703, 40 IOCTL_CLIENT_FORCE = 0x0706, 41 IOCTL_TENBIT = 0x0704, 42 IOCTL_FUNCS = 0x0705, 43 IOCTL_RDWR = 0x0707, 44 IOCTL_PEC = 0x0708, 45 IOCTL_SMBUS = 0x0720, 46 IOCTL_16BIT_REG = 0x0709, /* 16BIT REG WIDTH */ 47 IOCTL_16BIT_DATA = 0x070a, /* 16BIT DATA WIDTH */ 48 }; 49 50 enum I2cMsgFlag { 51 I2C_M_RD = 0x0001, 52 I2C_M_TEN = 0x0010, 53 I2C_M_RECV_LEN = 0x0400, 54 I2C_M_NO_RD_ACK = 0x0800, 55 I2C_M_IGNORE_NAK = 0x1000, 56 I2C_M_REV_DIR_ADDR = 0x2000, 57 I2C_M_NOSTART = 0x4000, 58 I2C_M_STOP = 0x8000, 59 #ifdef __LITEOS__ 60 I2C_M_16BIT_DATA = 0x0008, 61 I2C_M_16BIT_REG = 0x0002, 62 #endif 63 }; 64 65 typedef struct i2c_msg { 66 uint16_t addr; 67 uint16_t flags; 68 uint16_t len; 69 uint8_t *buf; 70 } I2cMsgUser; 71 72 typedef struct i2c_rdwr_ioctl_data { 73 struct i2c_msg *msgs; 74 unsigned int nmsgs; 75 } I2cIoctlWrap; 76 77 int32_t I2cAddVfsById(int16_t id); 78 79 void I2cRemoveVfsById(int16_t id); 80 81 #endif /* I2C_USER_H */ 82