| @@ -1,149 +1,149 @@ | | | @@ -1,149 +1,149 @@ |
1 | /* $NetBSD: i2c.h,v 1.6 2014/08/23 08:03:33 riastradh Exp $ */ | | 1 | /* $NetBSD: i2c.h,v 1.7 2015/03/05 15:02:36 riastradh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Taylor R. Campbell. | | 8 | * by Taylor R. Campbell. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
15 | * 2. Redistributions in binary form must reproduce the above copyright | | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in the | | 16 | * notice, this list of conditions and the following disclaimer in the |
17 | * documentation and/or other materials provided with the distribution. | | 17 | * documentation and/or other materials provided with the distribution. |
18 | * | | 18 | * |
19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #ifndef _LINUX_I2C_H_ | | 32 | #ifndef _LINUX_I2C_H_ |
33 | #define _LINUX_I2C_H_ | | 33 | #define _LINUX_I2C_H_ |
34 | | | 34 | |
35 | #include <sys/types.h> | | 35 | #include <sys/types.h> |
36 | #include <sys/device_if.h> | | 36 | #include <sys/device_if.h> |
37 | #include <sys/queue.h> /* XXX include order botch: i2cvar.h needs */ | | 37 | #include <sys/queue.h> /* XXX include order botch: i2cvar.h needs */ |
38 | | | 38 | |
39 | #include <dev/i2c/i2cvar.h> | | 39 | #include <dev/i2c/i2cvar.h> |
40 | | | 40 | |
41 | struct i2c_adapter; | | 41 | struct i2c_adapter; |
42 | struct i2c_algorithm; | | 42 | struct i2c_algorithm; |
43 | struct i2c_msg; | | 43 | struct i2c_msg; |
44 | | | 44 | |
45 | #define I2C_NAME_SIZE 20 | | 45 | #define I2C_NAME_SIZE 20 |
46 | | | 46 | |
47 | #define I2C_CLASS_DDC 0x01 | | 47 | #define I2C_CLASS_DDC 0x01 |
48 | | | 48 | |
49 | struct i2c_board_info { | | 49 | struct i2c_board_info { |
50 | char type[I2C_NAME_SIZE]; | | 50 | char type[I2C_NAME_SIZE]; |
51 | uint16_t addr; | | 51 | uint16_t addr; |
52 | void *platform_data; | | 52 | void *platform_data; |
53 | }; | | 53 | }; |
54 | | | 54 | |
55 | #define I2C_BOARD_INFO(board_type, board_addr) \ | | 55 | #define I2C_BOARD_INFO(board_type, board_addr) \ |
56 | .type = (board_type), \ | | 56 | .type = (board_type), \ |
57 | .addr = (board_addr) | | 57 | .addr = (board_addr) |
58 | | | 58 | |
59 | static inline void | | 59 | static inline void |
60 | i2c_new_device(const struct i2c_adapter *adapter __unused, | | 60 | i2c_new_device(const struct i2c_adapter *adapter __unused, |
61 | const struct i2c_board_info *board __unused) | | 61 | const struct i2c_board_info *board __unused) |
62 | { | | 62 | { |
63 | } | | 63 | } |
64 | | | 64 | |
65 | struct i2c_driver { | | 65 | struct i2c_driver { |
66 | }; | | 66 | }; |
67 | | | 67 | |
68 | struct module; | | 68 | struct module; |
69 | static inline int | | 69 | static inline int |
70 | i2c_register_driver(const struct module *owner __unused, | | 70 | i2c_register_driver(const struct module *owner __unused, |
71 | const struct i2c_driver *driver __unused) | | 71 | const struct i2c_driver *driver __unused) |
72 | { | | 72 | { |
73 | return 0; | | 73 | return 0; |
74 | } | | 74 | } |
75 | | | 75 | |
76 | static inline void | | 76 | static inline void |
77 | i2c_del_driver(const struct i2c_driver *driver __unused) | | 77 | i2c_del_driver(const struct i2c_driver *driver __unused) |
78 | { | | 78 | { |
79 | } | | 79 | } |
80 | | | 80 | |
81 | struct i2c_client; | | 81 | struct i2c_client; |
82 | | | 82 | |
83 | struct i2c_adapter { | | 83 | struct i2c_adapter { |
84 | char name[I2C_NAME_SIZE]; | | 84 | char name[I2C_NAME_SIZE]; |
85 | const struct i2c_algorithm *algo; | | 85 | const struct i2c_algorithm *algo; |
86 | void *algo_data; | | 86 | void *algo_data; |
87 | int retries; | | 87 | int retries; |
88 | struct module *owner; | | 88 | struct module *owner; |
89 | unsigned int class; | | 89 | unsigned int class; |
90 | struct { | | 90 | struct { |
91 | device_t parent; | | 91 | device_t parent; |
92 | } dev; /* XXX Kludge for intel_dp. */ | | 92 | } dev; |
93 | void *i2ca_adapdata; | | 93 | void *i2ca_adapdata; |
94 | }; | | 94 | }; |
95 | | | 95 | |
96 | static inline int | | 96 | static inline int |
97 | i2c_add_adapter(struct i2c_adapter *adapter __unused) | | 97 | i2c_add_adapter(struct i2c_adapter *adapter __unused) |
98 | { | | 98 | { |
99 | return 0; | | 99 | return 0; |
100 | } | | 100 | } |
101 | | | 101 | |
102 | static inline void | | 102 | static inline void |
103 | i2c_del_adapter(struct i2c_adapter *adapter __unused) | | 103 | i2c_del_adapter(struct i2c_adapter *adapter __unused) |
104 | { | | 104 | { |
105 | } | | 105 | } |
106 | | | 106 | |
107 | static inline void * | | 107 | static inline void * |
108 | i2c_get_adapdata(const struct i2c_adapter *adapter) | | 108 | i2c_get_adapdata(const struct i2c_adapter *adapter) |
109 | { | | 109 | { |
110 | | | 110 | |
111 | return adapter->i2ca_adapdata; | | 111 | return adapter->i2ca_adapdata; |
112 | } | | 112 | } |
113 | | | 113 | |
114 | static inline void | | 114 | static inline void |
115 | i2c_set_adapdata(struct i2c_adapter *adapter, void *data) | | 115 | i2c_set_adapdata(struct i2c_adapter *adapter, void *data) |
116 | { | | 116 | { |
117 | | | 117 | |
118 | adapter->i2ca_adapdata = data; | | 118 | adapter->i2ca_adapdata = data; |
119 | } | | 119 | } |
120 | | | 120 | |
121 | struct i2c_msg { | | 121 | struct i2c_msg { |
122 | i2c_addr_t addr; | | 122 | i2c_addr_t addr; |
123 | uint16_t flags; | | 123 | uint16_t flags; |
124 | uint16_t len; | | 124 | uint16_t len; |
125 | uint8_t *buf; | | 125 | uint8_t *buf; |
126 | }; | | 126 | }; |
127 | | | 127 | |
128 | #define I2C_M_RD 0x01 | | 128 | #define I2C_M_RD 0x01 |
129 | #define I2C_M_NOSTART 0x02 | | 129 | #define I2C_M_NOSTART 0x02 |
130 | | | 130 | |
131 | #define I2C_FUNC_I2C 0x01 | | 131 | #define I2C_FUNC_I2C 0x01 |
132 | #define I2C_FUNC_NOSTART 0x02 | | 132 | #define I2C_FUNC_NOSTART 0x02 |
133 | #define I2C_FUNC_SMBUS_EMUL 0x04 | | 133 | #define I2C_FUNC_SMBUS_EMUL 0x04 |
134 | #define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x08 | | 134 | #define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x08 |
135 | #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x10 | | 135 | #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x10 |
136 | #define I2C_FUNC_10BIT_ADDR 0x20 | | 136 | #define I2C_FUNC_10BIT_ADDR 0x20 |
137 | | | 137 | |
138 | struct i2c_algorithm { | | 138 | struct i2c_algorithm { |
139 | int (*master_xfer)(struct i2c_adapter *, struct i2c_msg *, | | 139 | int (*master_xfer)(struct i2c_adapter *, struct i2c_msg *, |
140 | int); | | 140 | int); |
141 | uint32_t (*functionality)(struct i2c_adapter *); | | 141 | uint32_t (*functionality)(struct i2c_adapter *); |
142 | }; | | 142 | }; |
143 | | | 143 | |
144 | /* XXX Make the nm output a little more greppable... */ | | 144 | /* XXX Make the nm output a little more greppable... */ |
145 | #define i2c_transfer linux_i2c_transfer | | 145 | #define i2c_transfer linux_i2c_transfer |
146 | | | 146 | |
147 | int i2c_transfer(struct i2c_adapter *, struct i2c_msg *, int); | | 147 | int i2c_transfer(struct i2c_adapter *, struct i2c_msg *, int); |
148 | | | 148 | |
149 | #endif /* _LINUX_I2C_H_ */ | | 149 | #endif /* _LINUX_I2C_H_ */ |