1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun i2c-dev.h - i2c-bus driver, char device interface 4*4882a593Smuzhiyun 5*4882a593Smuzhiyun Copyright (C) 1995-97 Simon G. Vogl 6*4882a593Smuzhiyun Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl> 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun This program is free software; you can redistribute it and/or modify 9*4882a593Smuzhiyun it under the terms of the GNU General Public License as published by 10*4882a593Smuzhiyun the Free Software Foundation; either version 2 of the License, or 11*4882a593Smuzhiyun (at your option) any later version. 12*4882a593Smuzhiyun 13*4882a593Smuzhiyun This program is distributed in the hope that it will be useful, 14*4882a593Smuzhiyun but WITHOUT ANY WARRANTY; without even the implied warranty of 15*4882a593Smuzhiyun MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16*4882a593Smuzhiyun GNU General Public License for more details. 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun You should have received a copy of the GNU General Public License 19*4882a593Smuzhiyun along with this program; if not, write to the Free Software 20*4882a593Smuzhiyun Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 21*4882a593Smuzhiyun MA 02110-1301 USA. 22*4882a593Smuzhiyun */ 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun #ifndef _UAPI_LINUX_I2C_DEV_H 25*4882a593Smuzhiyun #define _UAPI_LINUX_I2C_DEV_H 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun #include <linux/types.h> 28*4882a593Smuzhiyun #include <linux/compiler.h> 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun /* /dev/i2c-X ioctl commands. The ioctl's parameter is always an 31*4882a593Smuzhiyun * unsigned long, except for: 32*4882a593Smuzhiyun * - I2C_FUNCS, takes pointer to an unsigned long 33*4882a593Smuzhiyun * - I2C_RDWR, takes pointer to struct i2c_rdwr_ioctl_data 34*4882a593Smuzhiyun * - I2C_SMBUS, takes pointer to struct i2c_smbus_ioctl_data 35*4882a593Smuzhiyun */ 36*4882a593Smuzhiyun #define I2C_RETRIES 0x0701 /* number of times a device address should 37*4882a593Smuzhiyun be polled when not acknowledging */ 38*4882a593Smuzhiyun #define I2C_TIMEOUT 0x0702 /* set timeout in units of 10 ms */ 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun /* NOTE: Slave address is 7 or 10 bits, but 10-bit addresses 41*4882a593Smuzhiyun * are NOT supported! (due to code brokenness) 42*4882a593Smuzhiyun */ 43*4882a593Smuzhiyun #define I2C_SLAVE 0x0703 /* Use this slave address */ 44*4882a593Smuzhiyun #define I2C_SLAVE_FORCE 0x0706 /* Use this slave address, even if it 45*4882a593Smuzhiyun is already in use by a driver! */ 46*4882a593Smuzhiyun #define I2C_TENBIT 0x0704 /* 0 for 7 bit addrs, != 0 for 10 bit */ 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun #define I2C_FUNCS 0x0705 /* Get the adapter functionality mask */ 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun #define I2C_RDWR 0x0707 /* Combined R/W transfer (one STOP only) */ 51*4882a593Smuzhiyun 52*4882a593Smuzhiyun #define I2C_PEC 0x0708 /* != 0 to use PEC with SMBus */ 53*4882a593Smuzhiyun #define I2C_SMBUS 0x0720 /* SMBus transfer */ 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun 56*4882a593Smuzhiyun /* This is the structure as used in the I2C_SMBUS ioctl call */ 57*4882a593Smuzhiyun struct i2c_smbus_ioctl_data { 58*4882a593Smuzhiyun __u8 read_write; 59*4882a593Smuzhiyun __u8 command; 60*4882a593Smuzhiyun __u32 size; 61*4882a593Smuzhiyun union i2c_smbus_data __user *data; 62*4882a593Smuzhiyun }; 63*4882a593Smuzhiyun 64*4882a593Smuzhiyun /* This is the structure as used in the I2C_RDWR ioctl call */ 65*4882a593Smuzhiyun struct i2c_rdwr_ioctl_data { 66*4882a593Smuzhiyun struct i2c_msg __user *msgs; /* pointers to i2c_msgs */ 67*4882a593Smuzhiyun __u32 nmsgs; /* number of i2c_msgs */ 68*4882a593Smuzhiyun }; 69*4882a593Smuzhiyun 70*4882a593Smuzhiyun #define I2C_RDWR_IOCTL_MAX_MSGS 42 71*4882a593Smuzhiyun /* Originally defined with a typo, keep it for compatibility */ 72*4882a593Smuzhiyun #define I2C_RDRW_IOCTL_MAX_MSGS I2C_RDWR_IOCTL_MAX_MSGS 73*4882a593Smuzhiyun 74*4882a593Smuzhiyun 75*4882a593Smuzhiyun #endif /* _UAPI_LINUX_I2C_DEV_H */ 76