Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
i2c.h
Go to the documentation of this file.
1 /* ------------------------------------------------------------------------- */
2 /* */
3 /* i2c.h - definitions for the i2c-bus interface */
4 /* */
5 /* ------------------------------------------------------------------------- */
6 /* Copyright (C) 1995-2000 Simon G. Vogl
7 
8  This program is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21  MA 02110-1301 USA. */
22 /* ------------------------------------------------------------------------- */
23 
24 /* With some changes from Kyösti Mälkki <[email protected]> and
25  Frodo Looijaard <[email protected]> */
26 
27 #ifndef _UAPI_LINUX_I2C_H
28 #define _UAPI_LINUX_I2C_H
29 
30 #include <linux/types.h>
31 
68 struct i2c_msg {
69  __u16 addr; /* slave address */
71 #define I2C_M_TEN 0x0010 /* this is a ten bit chip address */
72 #define I2C_M_RD 0x0001 /* read data, from slave to master */
73 #define I2C_M_STOP 0x8000 /* if I2C_FUNC_PROTOCOL_MANGLING */
74 #define I2C_M_NOSTART 0x4000 /* if I2C_FUNC_NOSTART */
75 #define I2C_M_REV_DIR_ADDR 0x2000 /* if I2C_FUNC_PROTOCOL_MANGLING */
76 #define I2C_M_IGNORE_NAK 0x1000 /* if I2C_FUNC_PROTOCOL_MANGLING */
77 #define I2C_M_NO_RD_ACK 0x0800 /* if I2C_FUNC_PROTOCOL_MANGLING */
78 #define I2C_M_RECV_LEN 0x0400 /* length will be first received byte */
79  __u16 len; /* msg length */
80  __u8 *buf; /* pointer to msg data */
81 };
82 
83 /* To determine what functionality is present */
84 
85 #define I2C_FUNC_I2C 0x00000001
86 #define I2C_FUNC_10BIT_ADDR 0x00000002
87 #define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_IGNORE_NAK etc. */
88 #define I2C_FUNC_SMBUS_PEC 0x00000008
89 #define I2C_FUNC_NOSTART 0x00000010 /* I2C_M_NOSTART */
90 #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */
91 #define I2C_FUNC_SMBUS_QUICK 0x00010000
92 #define I2C_FUNC_SMBUS_READ_BYTE 0x00020000
93 #define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000
94 #define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000
95 #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000
96 #define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000
97 #define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000
98 #define I2C_FUNC_SMBUS_PROC_CALL 0x00800000
99 #define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000
100 #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
101 #define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */
102 #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */
103 
104 #define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \
105  I2C_FUNC_SMBUS_WRITE_BYTE)
106 #define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \
107  I2C_FUNC_SMBUS_WRITE_BYTE_DATA)
108 #define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \
109  I2C_FUNC_SMBUS_WRITE_WORD_DATA)
110 #define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \
111  I2C_FUNC_SMBUS_WRITE_BLOCK_DATA)
112 #define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \
113  I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)
114 
115 #define I2C_FUNC_SMBUS_EMUL (I2C_FUNC_SMBUS_QUICK | \
116  I2C_FUNC_SMBUS_BYTE | \
117  I2C_FUNC_SMBUS_BYTE_DATA | \
118  I2C_FUNC_SMBUS_WORD_DATA | \
119  I2C_FUNC_SMBUS_PROC_CALL | \
120  I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \
121  I2C_FUNC_SMBUS_I2C_BLOCK | \
122  I2C_FUNC_SMBUS_PEC)
123 
124 /*
125  * Data for SMBus Messages
126  */
127 #define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */
131  __u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */
132  /* and one more for user-space compatibility */
133 };
134 
135 /* i2c_smbus_xfer read or write markers */
136 #define I2C_SMBUS_READ 1
137 #define I2C_SMBUS_WRITE 0
138 
139 /* SMBus transaction types (size parameter in the above functions)
140  Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */
141 #define I2C_SMBUS_QUICK 0
142 #define I2C_SMBUS_BYTE 1
143 #define I2C_SMBUS_BYTE_DATA 2
144 #define I2C_SMBUS_WORD_DATA 3
145 #define I2C_SMBUS_PROC_CALL 4
146 #define I2C_SMBUS_BLOCK_DATA 5
147 #define I2C_SMBUS_I2C_BLOCK_BROKEN 6
148 #define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */
149 #define I2C_SMBUS_I2C_BLOCK_DATA 8
150 
151 #endif /* _UAPI_LINUX_I2C_H */