1/*
2 * Copyright (c) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef _HI_I2C_H
17#define _HI_I2C_H
18
19/* /dev/i2c-X ioctl commands.  The ioctl's parameter is always an
20 * unsigned long, except for:
21 *      - I2C_FUNCS, takes pointer to an unsigned long
22 *      - I2C_RDWR, takes pointer to struct i2c_rdwr_ioctl_data
23 *      - I2C_SMBUS, takes pointer to struct i2c_smbus_ioctl_data
24 */
25#define I2C_RETRIES     0x0701  /* number of times a device address should
26                   be polled when not acknowledging */
27#define I2C_TIMEOUT     0x0702  /* set timeout in units of 10 ms */
28
29/* NOTE: Slave address is 7 or 10 bits, but 10-bit addresses
30 * are NOT supported! (due to code brokenness)
31 */
32#define I2C_SLAVE       0x0703  /* Use this slave address */
33#define I2C_SLAVE_FORCE 0x0706  /* Use this slave address, even if it
34                   is already in use by a driver! */
35#define I2C_TENBIT      0x0704  /* 0 for 7 bit addrs, != 0 for 10 bit */
36
37#define I2C_FUNCS       0x0705  /* Get the adapter functionality mask */
38
39#define I2C_RDWR        0x0707  /* Combined R/W transfer (one STOP only) */
40
41#define I2C_PEC         0x0708  /* != 0 to use PEC with SMBus */
42#define I2C_SMBUS       0x0720  /* SMBus transfer */
43#define I2C_16BIT_REG   0x0709  /* 16BIT REG WIDTH */
44#define I2C_16BIT_DATA  0x070a  /* 16BIT DATA WIDTH */
45
46typedef struct hiI2C_DATA_S {
47    unsigned char dev_addr;
48    unsigned int reg_addr;
49    unsigned int addr_byte_num;
50    unsigned int data;
51    unsigned int data_byte_num;
52} I2C_DATA_S;
53
54typedef I2C_DATA_S i2c_data;
55
56#endif
57
58