33 #include <linux/types.h>
34 #include <linux/i2c-dev.h>
35 #include <sys/ioctl.h>
43 #define I2C_M_TEN 0x10
45 #define I2C_M_NOSTART 0x4000
46 #define I2C_M_REV_DIR_ADDR 0x2000
47 #define I2C_M_IGNORE_NAK 0x1000
48 #define I2C_M_NO_RD_ACK 0x0800
55 #define I2C_FUNC_I2C 0x00000001
56 #define I2C_FUNC_10BIT_ADDR 0x00000002
57 #define I2C_FUNC_PROTOCOL_MANGLING 0x00000004
58 #define I2C_FUNC_SMBUS_PEC 0x00000008
59 #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000
60 #define I2C_FUNC_SMBUS_QUICK 0x00010000
61 #define I2C_FUNC_SMBUS_READ_BYTE 0x00020000
62 #define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000
63 #define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000
64 #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000
65 #define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000
66 #define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000
67 #define I2C_FUNC_SMBUS_PROC_CALL 0x00800000
68 #define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000
69 #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
70 #define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000
71 #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000
73 #define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \
74 I2C_FUNC_SMBUS_WRITE_BYTE)
75 #define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \
76 I2C_FUNC_SMBUS_WRITE_BYTE_DATA)
77 #define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \
78 I2C_FUNC_SMBUS_WRITE_WORD_DATA)
79 #define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \
80 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA)
81 #define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \
82 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)
85 #define I2C_FUNC_SMBUS_HWPEC_CALC I2C_FUNC_SMBUS_PEC
90 #define I2C_SMBUS_BLOCK_MAX 32
91 #define I2C_SMBUS_I2C_BLOCK_MAX 32
100 #define I2C_SMBUS_READ 1
101 #define I2C_SMBUS_WRITE 0
105 #define I2C_SMBUS_QUICK 0
106 #define I2C_SMBUS_BYTE 1
107 #define I2C_SMBUS_BYTE_DATA 2
108 #define I2C_SMBUS_WORD_DATA 3
109 #define I2C_SMBUS_PROC_CALL 4
110 #define I2C_SMBUS_BLOCK_DATA 5
111 #define I2C_SMBUS_I2C_BLOCK_BROKEN 6
112 #define I2C_SMBUS_BLOCK_PROC_CALL 7
113 #define I2C_SMBUS_I2C_BLOCK_DATA 8
122 #define I2C_RETRIES 0x0701
125 #define I2C_TIMEOUT 0x0702
129 #define I2C_SLAVE 0x0703
131 #define I2C_SLAVE_FORCE 0x0706
135 #define I2C_TENBIT 0x0704
137 #define I2C_FUNCS 0x0705
138 #define I2C_RDWR 0x0707
139 #define I2C_PEC 0x0708
141 #define I2C_SMBUS 0x0720
152 struct i2c_smbus_ioctl_data args;
154 args.read_write = read_write;
155 args.command = command;
173 return 0x0FF & data.
byte;
190 return 0x0FF & data.
byte;
210 return 0x0FFFF & data.
word;
231 return 0x0FFFF & data.
word;
246 for (i = 1; i <= data.
block[0]; i++) {
247 values[i - 1] = data.
block[i];
249 return data.
block[0];
254 __u8 length, __u8 *values)
261 for (i = 1; i <= length; i++) {
262 data.
block[i] = values[i - 1];
264 data.
block[0] = length;
274 __u8 length, __u8 *values)
282 data.
block[0] = length;
288 for (i = 1; i <= data.
block[0]; i++) {
289 values[i - 1] = data.
block[i];
291 return data.
block[0];
296 __u8 length, __u8 *values)
303 for (i = 1; i <= length; i++) {
304 data.
block[i] = values[i - 1];
306 data.
block[0] = length;
313 __u8 length, __u8 *values)
320 for (i = 1; i <= length; i++) {
321 data.
block[i] = values[i - 1];
323 data.
block[0] = length;
328 for (i = 1; i <= data.
block[0]; i++) {
329 values[i - 1] = data.
block[i];
331 return data.
block[0];
#define I2C_SMBUS_BLOCK_MAX
#define I2C_SMBUS_I2C_BLOCK_BROKEN
static __s32 i2c_smbus_access(int file, char read_write, __u8 command, int size, union i2c_smbus_data *data)
#define I2C_SMBUS_BLOCK_DATA
static __s32 i2c_smbus_read_i2c_block_data(int file, __u8 command, __u8 length, __u8 *values)
#define I2C_SMBUS_BYTE_DATA
static __s32 i2c_smbus_write_quick(int file, __u8 value)
#define I2C_SMBUS_WORD_DATA
static __s32 i2c_smbus_block_process_call(int file, __u8 command, __u8 length, __u8 *values)
#define I2C_SMBUS_PROC_CALL
static __s32 i2c_smbus_write_block_data(int file, __u8 command, __u8 length, __u8 *values)
static __s32 i2c_smbus_write_byte_data(int file, __u8 command, __u8 value)
static __s32 i2c_smbus_write_byte(int file, __u8 value)
static __s32 i2c_smbus_read_byte_data(int file, __u8 command)
static __s32 i2c_smbus_write_word_data(int file, __u8 command, __u16 value)
__u8 block[I2C_SMBUS_BLOCK_MAX+2]
static __s32 i2c_smbus_read_block_data(int file, __u8 command, __u8 *values)
static __s32 i2c_smbus_write_i2c_block_data(int file, __u8 command, __u8 length, __u8 *values)
#define I2C_SMBUS_I2C_BLOCK_DATA
static __s32 i2c_smbus_read_word_data(int file, __u8 command)
#define I2C_SMBUS_BLOCK_PROC_CALL
static __s32 i2c_smbus_process_call(int file, __u8 command, __u16 value)
static __s32 i2c_smbus_read_byte(int file)