xref: /dragonfly/sys/dev/drm/include/uapi/linux/i2c.h (revision 0085a56d)
1 /*
2  * Copyright (c) 2013-2016 François Tigeot
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice unmodified, this list of conditions, and the following
10  *    disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 
27 #ifndef _UAPI_UAPI_I2C_H_
28 #define _UAPI_UAPI_I2C_H_
29 
30 #include <linux/types.h>
31 
32 struct i2c_msg {
33 	uint16_t addr;
34 	uint16_t flags;
35 	uint16_t len;
36 	uint8_t *buf;
37 };
38 
39 #define I2C_M_TEN		0x0010
40 #define I2C_M_RECV_LEN		0x0400
41 #define I2C_M_NO_RD_ACK		0x0800
42 #define I2C_M_IGNORE_NAK	0x1000
43 #define I2C_M_REV_DIR_ADDR	0x2000
44 
45 #define I2C_FUNC_I2C			0x00000001
46 #define I2C_FUNC_10BIT_ADDR		0x00000002
47 #define I2C_FUNC_PROTOCOL_MANGLING	0x00000004
48 #define I2C_FUNC_SMBUS_PEC		0x00000008
49 #define I2C_FUNC_NOSTART		0x00000010
50 #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL	0x00008000
51 #define I2C_FUNC_SMBUS_QUICK		0x00010000
52 #define I2C_FUNC_SMBUS_READ_BYTE	0x00020000
53 #define I2C_FUNC_SMBUS_WRITE_BYTE	0x00040000
54 #define I2C_FUNC_SMBUS_READ_BYTE_DATA	0x00080000
55 #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA	0x00100000
56 #define I2C_FUNC_SMBUS_READ_WORD_DATA	0x00200000
57 #define I2C_FUNC_SMBUS_WRITE_WORD_DATA	0x00400000
58 #define I2C_FUNC_SMBUS_PROC_CALL	0x00800000
59 #define I2C_FUNC_SMBUS_READ_BLOCK_DATA	0x01000000
60 #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
61 #define I2C_FUNC_SMBUS_READ_I2C_BLOCK	0x04000000
62 #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK	0x08000000
63 
64 
65 
66 #define I2C_FUNC_SMBUS_BYTE		(I2C_FUNC_SMBUS_READ_BYTE | \
67 					 I2C_FUNC_SMBUS_WRITE_BYTE)
68 
69 #define I2C_FUNC_SMBUS_BYTE_DATA	(I2C_FUNC_SMBUS_READ_BYTE_DATA | \
70 					 I2C_FUNC_SMBUS_WRITE_BYTE_DATA)
71 
72 #define I2C_FUNC_SMBUS_WORD_DATA	(I2C_FUNC_SMBUS_READ_WORD_DATA | \
73 					 I2C_FUNC_SMBUS_WRITE_WORD_DATA)
74 
75 #define I2C_FUNC_SMBUS_I2C_BLOCK	(I2C_FUNC_SMBUS_READ_I2C_BLOCK | \
76 					 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)
77 
78 #define I2C_FUNC_SMBUS_EMUL		(I2C_FUNC_SMBUS_QUICK | \
79 					 I2C_FUNC_SMBUS_BYTE | \
80 					 I2C_FUNC_SMBUS_BYTE_DATA | \
81 					 I2C_FUNC_SMBUS_WORD_DATA | \
82 					 I2C_FUNC_SMBUS_PROC_CALL | \
83 					 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \
84 					 I2C_FUNC_SMBUS_I2C_BLOCK | \
85 					 I2C_FUNC_SMBUS_PEC)
86 
87 #define I2C_SMBUS_BLOCK_MAX	32
88 
89 #endif	/* _UAPI_LINUX_I2C_H_ */
90