11bd4fe43Sopenharmony_ci/* 21bd4fe43Sopenharmony_ci * Copyright (c) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED. 31bd4fe43Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 41bd4fe43Sopenharmony_ci * you may not use this file except in compliance with the License. 51bd4fe43Sopenharmony_ci * You may obtain a copy of the License at 61bd4fe43Sopenharmony_ci * 71bd4fe43Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 81bd4fe43Sopenharmony_ci * 91bd4fe43Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 101bd4fe43Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 111bd4fe43Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 121bd4fe43Sopenharmony_ci * See the License for the specific language governing permissions and 131bd4fe43Sopenharmony_ci * limitations under the License. 141bd4fe43Sopenharmony_ci */ 151bd4fe43Sopenharmony_ci 161bd4fe43Sopenharmony_ci#ifndef _HI_I2C_H 171bd4fe43Sopenharmony_ci#define _HI_I2C_H 181bd4fe43Sopenharmony_ci 191bd4fe43Sopenharmony_ci/* /dev/i2c-X ioctl commands. The ioctl's parameter is always an 201bd4fe43Sopenharmony_ci * unsigned long, except for: 211bd4fe43Sopenharmony_ci * - I2C_FUNCS, takes pointer to an unsigned long 221bd4fe43Sopenharmony_ci * - I2C_RDWR, takes pointer to struct i2c_rdwr_ioctl_data 231bd4fe43Sopenharmony_ci * - I2C_SMBUS, takes pointer to struct i2c_smbus_ioctl_data 241bd4fe43Sopenharmony_ci */ 251bd4fe43Sopenharmony_ci#define I2C_RETRIES 0x0701 /* number of times a device address should 261bd4fe43Sopenharmony_ci be polled when not acknowledging */ 271bd4fe43Sopenharmony_ci#define I2C_TIMEOUT 0x0702 /* set timeout in units of 10 ms */ 281bd4fe43Sopenharmony_ci 291bd4fe43Sopenharmony_ci/* NOTE: Slave address is 7 or 10 bits, but 10-bit addresses 301bd4fe43Sopenharmony_ci * are NOT supported! (due to code brokenness) 311bd4fe43Sopenharmony_ci */ 321bd4fe43Sopenharmony_ci#define I2C_SLAVE 0x0703 /* Use this slave address */ 331bd4fe43Sopenharmony_ci#define I2C_SLAVE_FORCE 0x0706 /* Use this slave address, even if it 341bd4fe43Sopenharmony_ci is already in use by a driver! */ 351bd4fe43Sopenharmony_ci#define I2C_TENBIT 0x0704 /* 0 for 7 bit addrs, != 0 for 10 bit */ 361bd4fe43Sopenharmony_ci 371bd4fe43Sopenharmony_ci#define I2C_FUNCS 0x0705 /* Get the adapter functionality mask */ 381bd4fe43Sopenharmony_ci 391bd4fe43Sopenharmony_ci#define I2C_RDWR 0x0707 /* Combined R/W transfer (one STOP only) */ 401bd4fe43Sopenharmony_ci 411bd4fe43Sopenharmony_ci#define I2C_PEC 0x0708 /* != 0 to use PEC with SMBus */ 421bd4fe43Sopenharmony_ci#define I2C_SMBUS 0x0720 /* SMBus transfer */ 431bd4fe43Sopenharmony_ci#define I2C_16BIT_REG 0x0709 /* 16BIT REG WIDTH */ 441bd4fe43Sopenharmony_ci#define I2C_16BIT_DATA 0x070a /* 16BIT DATA WIDTH */ 451bd4fe43Sopenharmony_ci 461bd4fe43Sopenharmony_citypedef struct hiI2C_DATA_S { 471bd4fe43Sopenharmony_ci unsigned char dev_addr; 481bd4fe43Sopenharmony_ci unsigned int reg_addr; 491bd4fe43Sopenharmony_ci unsigned int addr_byte_num; 501bd4fe43Sopenharmony_ci unsigned int data; 511bd4fe43Sopenharmony_ci unsigned int data_byte_num; 521bd4fe43Sopenharmony_ci} I2C_DATA_S; 531bd4fe43Sopenharmony_ci 541bd4fe43Sopenharmony_citypedef I2C_DATA_S i2c_data; 551bd4fe43Sopenharmony_ci 561bd4fe43Sopenharmony_ci#endif 571bd4fe43Sopenharmony_ci 58