blob: 977211fec137bdcf668ef7a022f23548e38ae11b [file] [log] [blame]
Patrick Boettcher42afd062006-07-29 17:33:44 -03001#include <linux/i2c.h>
Paul Gortmaker7a707b82011-07-03 14:03:12 -04002#include <linux/module.h>
Patrick Boettcher42afd062006-07-29 17:33:44 -03003
4#include "dibx000_common.h"
5
6static int debug;
7module_param(debug, int, 0644);
8MODULE_PARM_DESC(debug, "turn on debugging (default: 0)");
9
Olivier Grenie03245a52009-12-04 13:27:57 -030010#define dprintk(args...) do { if (debug) { printk(KERN_DEBUG "DiBX000: "); printk(args); printk("\n"); } } while (0)
Patrick Boettcher42afd062006-07-29 17:33:44 -030011
12static int dibx000_write_word(struct dibx000_i2c_master *mst, u16 reg, u16 val)
13{
Olivier Grenie5a0deee2011-05-03 12:27:33 -030014 mst->i2c_write_buffer[0] = (reg >> 8) & 0xff;
15 mst->i2c_write_buffer[1] = reg & 0xff;
16 mst->i2c_write_buffer[2] = (val >> 8) & 0xff;
17 mst->i2c_write_buffer[3] = val & 0xff;
Olivier Grenieb994d192011-01-03 15:39:35 -030018
Olivier Grenie5a0deee2011-05-03 12:27:33 -030019 memset(mst->msg, 0, sizeof(struct i2c_msg));
20 mst->msg[0].addr = mst->i2c_addr;
21 mst->msg[0].flags = 0;
22 mst->msg[0].buf = mst->i2c_write_buffer;
23 mst->msg[0].len = 4;
24
25 return i2c_transfer(mst->i2c_adap, mst->msg, 1) != 1 ? -EREMOTEIO : 0;
Patrick Boettcher42afd062006-07-29 17:33:44 -030026}
27
Olivier Grenieb994d192011-01-03 15:39:35 -030028static u16 dibx000_read_word(struct dibx000_i2c_master *mst, u16 reg)
29{
Olivier Grenie5a0deee2011-05-03 12:27:33 -030030 mst->i2c_write_buffer[0] = reg >> 8;
31 mst->i2c_write_buffer[1] = reg & 0xff;
Olivier Grenieb994d192011-01-03 15:39:35 -030032
Olivier Grenie5a0deee2011-05-03 12:27:33 -030033 memset(mst->msg, 0, 2 * sizeof(struct i2c_msg));
34 mst->msg[0].addr = mst->i2c_addr;
35 mst->msg[0].flags = 0;
36 mst->msg[0].buf = mst->i2c_write_buffer;
37 mst->msg[0].len = 2;
38 mst->msg[1].addr = mst->i2c_addr;
39 mst->msg[1].flags = I2C_M_RD;
40 mst->msg[1].buf = mst->i2c_read_buffer;
41 mst->msg[1].len = 2;
42
43 if (i2c_transfer(mst->i2c_adap, mst->msg, 2) != 2)
Olivier Grenieb994d192011-01-03 15:39:35 -030044 dprintk("i2c read error on %d", reg);
45
Olivier Grenie5a0deee2011-05-03 12:27:33 -030046 return (mst->i2c_read_buffer[0] << 8) | mst->i2c_read_buffer[1];
Olivier Grenieb994d192011-01-03 15:39:35 -030047}
48
49static int dibx000_is_i2c_done(struct dibx000_i2c_master *mst)
50{
Olivier Grenieb4d6046e2011-01-04 13:08:14 -030051 int i = 100;
Olivier Grenieb994d192011-01-03 15:39:35 -030052 u16 status;
53
Olivier Grenieb4d6046e2011-01-04 13:08:14 -030054 while (((status = dibx000_read_word(mst, mst->base_reg + 2)) & 0x0100) == 0 && --i > 0)
55 ;
Olivier Grenieb994d192011-01-03 15:39:35 -030056
57 /* i2c timed out */
58 if (i == 0)
59 return -EREMOTEIO;
60
61 /* no acknowledge */
62 if ((status & 0x0080) == 0)
63 return -EREMOTEIO;
64
65 return 0;
66}
67
68static int dibx000_master_i2c_write(struct dibx000_i2c_master *mst, struct i2c_msg *msg, u8 stop)
69{
70 u16 data;
71 u16 da;
72 u16 i;
73 u16 txlen = msg->len, len;
74 const u8 *b = msg->buf;
75
76 while (txlen) {
Olivier Grenieb4d6046e2011-01-04 13:08:14 -030077 dibx000_read_word(mst, mst->base_reg + 2);
Olivier Grenieb994d192011-01-03 15:39:35 -030078
79 len = txlen > 8 ? 8 : txlen;
80 for (i = 0; i < len; i += 2) {
81 data = *b++ << 8;
82 if (i+1 < len)
83 data |= *b++;
84 dibx000_write_word(mst, mst->base_reg, data);
85 }
Olivier Grenieb4d6046e2011-01-04 13:08:14 -030086 da = (((u8) (msg->addr)) << 9) |
87 (1 << 8) |
88 (1 << 7) |
89 (0 << 6) |
90 (0 << 5) |
91 ((len & 0x7) << 2) |
92 (0 << 1) |
93 (0 << 0);
Olivier Grenieb994d192011-01-03 15:39:35 -030094
95 if (txlen == msg->len)
96 da |= 1 << 5; /* start */
97
98 if (txlen-len == 0 && stop)
99 da |= 1 << 6; /* stop */
100
101 dibx000_write_word(mst, mst->base_reg+1, da);
102
103 if (dibx000_is_i2c_done(mst) != 0)
104 return -EREMOTEIO;
105 txlen -= len;
106 }
107
108 return 0;
109}
110
111static int dibx000_master_i2c_read(struct dibx000_i2c_master *mst, struct i2c_msg *msg)
112{
113 u16 da;
114 u8 *b = msg->buf;
115 u16 rxlen = msg->len, len;
116
117 while (rxlen) {
118 len = rxlen > 8 ? 8 : rxlen;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -0300119 da = (((u8) (msg->addr)) << 9) |
120 (1 << 8) |
121 (1 << 7) |
122 (0 << 6) |
123 (0 << 5) |
124 ((len & 0x7) << 2) |
125 (1 << 1) |
126 (0 << 0);
Olivier Grenieb994d192011-01-03 15:39:35 -0300127
128 if (rxlen == msg->len)
129 da |= 1 << 5; /* start */
130
131 if (rxlen-len == 0)
132 da |= 1 << 6; /* stop */
133 dibx000_write_word(mst, mst->base_reg+1, da);
134
135 if (dibx000_is_i2c_done(mst) != 0)
136 return -EREMOTEIO;
137
138 rxlen -= len;
139
140 while (len) {
141 da = dibx000_read_word(mst, mst->base_reg);
142 *b++ = (da >> 8) & 0xff;
143 len--;
144 if (len >= 1) {
145 *b++ = da & 0xff;
146 len--;
147 }
148 }
149 }
150
151 return 0;
152}
153
154int dibx000_i2c_set_speed(struct i2c_adapter *i2c_adap, u16 speed)
155{
156 struct dibx000_i2c_master *mst = i2c_get_adapdata(i2c_adap);
157
158 if (mst->device_rev < DIB7000MC && speed < 235)
159 speed = 235;
160 return dibx000_write_word(mst, mst->base_reg + 3, (u16)(60000 / speed));
161
162}
163EXPORT_SYMBOL(dibx000_i2c_set_speed);
164
165static u32 dibx000_i2c_func(struct i2c_adapter *adapter)
166{
167 return I2C_FUNC_I2C;
168}
Patrick Boettcher42afd062006-07-29 17:33:44 -0300169
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -0300170static int dibx000_i2c_select_interface(struct dibx000_i2c_master *mst,
171 enum dibx000_i2c_interface intf)
Patrick Boettcher42afd062006-07-29 17:33:44 -0300172{
173 if (mst->device_rev > DIB3000MC && mst->selected_interface != intf) {
Olivier Grenie03245a52009-12-04 13:27:57 -0300174 dprintk("selecting interface: %d", intf);
Patrick Boettcher42afd062006-07-29 17:33:44 -0300175 mst->selected_interface = intf;
176 return dibx000_write_word(mst, mst->base_reg + 4, intf);
177 }
178 return 0;
179}
180
Olivier Grenieb994d192011-01-03 15:39:35 -0300181static int dibx000_i2c_master_xfer_gpio12(struct i2c_adapter *i2c_adap, struct i2c_msg msg[], int num)
182{
183 struct dibx000_i2c_master *mst = i2c_get_adapdata(i2c_adap);
184 int msg_index;
185 int ret = 0;
186
187 dibx000_i2c_select_interface(mst, DIBX000_I2C_INTERFACE_GPIO_1_2);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -0300188 for (msg_index = 0; msg_index < num; msg_index++) {
189 if (msg[msg_index].flags & I2C_M_RD) {
Olivier Grenieb994d192011-01-03 15:39:35 -0300190 ret = dibx000_master_i2c_read(mst, &msg[msg_index]);
191 if (ret != 0)
192 return 0;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -0300193 } else {
Olivier Grenieb994d192011-01-03 15:39:35 -0300194 ret = dibx000_master_i2c_write(mst, &msg[msg_index], 1);
195 if (ret != 0)
196 return 0;
197 }
198 }
199
200 return num;
201}
202
203static int dibx000_i2c_master_xfer_gpio34(struct i2c_adapter *i2c_adap, struct i2c_msg msg[], int num)
204{
205 struct dibx000_i2c_master *mst = i2c_get_adapdata(i2c_adap);
206 int msg_index;
207 int ret = 0;
208
209 dibx000_i2c_select_interface(mst, DIBX000_I2C_INTERFACE_GPIO_3_4);
Olivier Grenieb4d6046e2011-01-04 13:08:14 -0300210 for (msg_index = 0; msg_index < num; msg_index++) {
211 if (msg[msg_index].flags & I2C_M_RD) {
Olivier Grenieb994d192011-01-03 15:39:35 -0300212 ret = dibx000_master_i2c_read(mst, &msg[msg_index]);
213 if (ret != 0)
214 return 0;
Olivier Grenieb4d6046e2011-01-04 13:08:14 -0300215 } else {
Olivier Grenieb994d192011-01-03 15:39:35 -0300216 ret = dibx000_master_i2c_write(mst, &msg[msg_index], 1);
217 if (ret != 0)
218 return 0;
219 }
220 }
221
222 return num;
223}
224
225static struct i2c_algorithm dibx000_i2c_master_gpio12_xfer_algo = {
226 .master_xfer = dibx000_i2c_master_xfer_gpio12,
227 .functionality = dibx000_i2c_func,
228};
229
230static struct i2c_algorithm dibx000_i2c_master_gpio34_xfer_algo = {
231 .master_xfer = dibx000_i2c_master_xfer_gpio34,
232 .functionality = dibx000_i2c_func,
233};
234
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -0300235static int dibx000_i2c_gate_ctrl(struct dibx000_i2c_master *mst, u8 tx[4],
236 u8 addr, int onoff)
Patrick Boettcher42afd062006-07-29 17:33:44 -0300237{
238 u16 val;
239
240
241 if (onoff)
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -0300242 val = addr << 8; // bit 7 = use master or not, if 0, the gate is open
Patrick Boettcher42afd062006-07-29 17:33:44 -0300243 else
244 val = 1 << 7;
245
246 if (mst->device_rev > DIB7000)
247 val <<= 1;
248
249 tx[0] = (((mst->base_reg + 1) >> 8) & 0xff);
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -0300250 tx[1] = ((mst->base_reg + 1) & 0xff);
Patrick Boettcher42afd062006-07-29 17:33:44 -0300251 tx[2] = val >> 8;
252 tx[3] = val & 0xff;
253
254 return 0;
255}
256
Olivier Grenieb994d192011-01-03 15:39:35 -0300257static int dibx000_i2c_gated_gpio67_xfer(struct i2c_adapter *i2c_adap,
258 struct i2c_msg msg[], int num)
Patrick Boettcher42afd062006-07-29 17:33:44 -0300259{
Olivier Grenieb994d192011-01-03 15:39:35 -0300260 struct dibx000_i2c_master *mst = i2c_get_adapdata(i2c_adap);
Olivier Grenieb994d192011-01-03 15:39:35 -0300261
Olivier Grenie5a0deee2011-05-03 12:27:33 -0300262 if (num > 32) {
263 dprintk("%s: too much I2C message to be transmitted (%i).\
264 Maximum is 32", __func__, num);
265 return -ENOMEM;
266 }
267
268 memset(mst->msg, 0, sizeof(struct i2c_msg) * (2 + num));
Olivier Grenieb994d192011-01-03 15:39:35 -0300269
270 dibx000_i2c_select_interface(mst, DIBX000_I2C_INTERFACE_GPIO_6_7);
271
Olivier Grenie5a0deee2011-05-03 12:27:33 -0300272 /* open the gate */
273 dibx000_i2c_gate_ctrl(mst, &mst->i2c_write_buffer[0], msg[0].addr, 1);
274 mst->msg[0].addr = mst->i2c_addr;
275 mst->msg[0].buf = &mst->i2c_write_buffer[0];
276 mst->msg[0].len = 4;
Olivier Grenieb994d192011-01-03 15:39:35 -0300277
Olivier Grenie5a0deee2011-05-03 12:27:33 -0300278 memcpy(&mst->msg[1], msg, sizeof(struct i2c_msg) * num);
Olivier Grenieb994d192011-01-03 15:39:35 -0300279
Olivier Grenie5a0deee2011-05-03 12:27:33 -0300280 /* close the gate */
281 dibx000_i2c_gate_ctrl(mst, &mst->i2c_write_buffer[4], 0, 0);
282 mst->msg[num + 1].addr = mst->i2c_addr;
283 mst->msg[num + 1].buf = &mst->i2c_write_buffer[4];
284 mst->msg[num + 1].len = 4;
Olivier Grenieb994d192011-01-03 15:39:35 -0300285
Olivier Grenie5a0deee2011-05-03 12:27:33 -0300286 return i2c_transfer(mst->i2c_adap, mst->msg, 2 + num) == 2 + num ? num : -EIO;
Patrick Boettcher42afd062006-07-29 17:33:44 -0300287}
288
Olivier Grenieb994d192011-01-03 15:39:35 -0300289static struct i2c_algorithm dibx000_i2c_gated_gpio67_algo = {
290 .master_xfer = dibx000_i2c_gated_gpio67_xfer,
291 .functionality = dibx000_i2c_func,
292};
293
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -0300294static int dibx000_i2c_gated_tuner_xfer(struct i2c_adapter *i2c_adap,
295 struct i2c_msg msg[], int num)
Patrick Boettcher42afd062006-07-29 17:33:44 -0300296{
297 struct dibx000_i2c_master *mst = i2c_get_adapdata(i2c_adap);
Patrick Boettcher42afd062006-07-29 17:33:44 -0300298
Olivier Grenie5a0deee2011-05-03 12:27:33 -0300299 if (num > 32) {
300 dprintk("%s: too much I2C message to be transmitted (%i).\
301 Maximum is 32", __func__, num);
302 return -ENOMEM;
303 }
304
305 memset(mst->msg, 0, sizeof(struct i2c_msg) * (2 + num));
Patrick Boettcher42afd062006-07-29 17:33:44 -0300306
307 dibx000_i2c_select_interface(mst, DIBX000_I2C_INTERFACE_TUNER);
308
Olivier Grenie5a0deee2011-05-03 12:27:33 -0300309 /* open the gate */
310 dibx000_i2c_gate_ctrl(mst, &mst->i2c_write_buffer[0], msg[0].addr, 1);
311 mst->msg[0].addr = mst->i2c_addr;
312 mst->msg[0].buf = &mst->i2c_write_buffer[0];
313 mst->msg[0].len = 4;
Patrick Boettcher42afd062006-07-29 17:33:44 -0300314
Olivier Grenie5a0deee2011-05-03 12:27:33 -0300315 memcpy(&mst->msg[1], msg, sizeof(struct i2c_msg) * num);
Patrick Boettcher42afd062006-07-29 17:33:44 -0300316
Olivier Grenie5a0deee2011-05-03 12:27:33 -0300317 /* close the gate */
318 dibx000_i2c_gate_ctrl(mst, &mst->i2c_write_buffer[4], 0, 0);
319 mst->msg[num + 1].addr = mst->i2c_addr;
320 mst->msg[num + 1].buf = &mst->i2c_write_buffer[4];
321 mst->msg[num + 1].len = 4;
Patrick Boettcher42afd062006-07-29 17:33:44 -0300322
Olivier Grenie5a0deee2011-05-03 12:27:33 -0300323 return i2c_transfer(mst->i2c_adap, mst->msg, 2 + num) == 2 + num ? num : -EIO;
Patrick Boettcher42afd062006-07-29 17:33:44 -0300324}
325
326static struct i2c_algorithm dibx000_i2c_gated_tuner_algo = {
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -0300327 .master_xfer = dibx000_i2c_gated_tuner_xfer,
Patrick Boettcher42afd062006-07-29 17:33:44 -0300328 .functionality = dibx000_i2c_func,
329};
330
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -0300331struct i2c_adapter *dibx000_get_i2c_adapter(struct dibx000_i2c_master *mst,
Olivier Grenieb994d192011-01-03 15:39:35 -0300332 enum dibx000_i2c_interface intf,
333 int gating)
Patrick Boettcher42afd062006-07-29 17:33:44 -0300334{
335 struct i2c_adapter *i2c = NULL;
336
337 switch (intf) {
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -0300338 case DIBX000_I2C_INTERFACE_TUNER:
339 if (gating)
340 i2c = &mst->gated_tuner_i2c_adap;
341 break;
Olivier Grenieb994d192011-01-03 15:39:35 -0300342 case DIBX000_I2C_INTERFACE_GPIO_1_2:
343 if (!gating)
344 i2c = &mst->master_i2c_adap_gpio12;
345 break;
346 case DIBX000_I2C_INTERFACE_GPIO_3_4:
347 if (!gating)
348 i2c = &mst->master_i2c_adap_gpio34;
349 break;
350 case DIBX000_I2C_INTERFACE_GPIO_6_7:
351 if (gating)
352 i2c = &mst->master_i2c_adap_gpio67;
353 break;
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -0300354 default:
355 printk(KERN_ERR "DiBX000: incorrect I2C interface selected\n");
356 break;
Patrick Boettcher42afd062006-07-29 17:33:44 -0300357 }
358
359 return i2c;
360}
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -0300361
Patrick Boettcher42afd062006-07-29 17:33:44 -0300362EXPORT_SYMBOL(dibx000_get_i2c_adapter);
363
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -0300364void dibx000_reset_i2c_master(struct dibx000_i2c_master *mst)
365{
366 /* initialize the i2c-master by closing the gate */
367 u8 tx[4];
368 struct i2c_msg m = {.addr = mst->i2c_addr,.buf = tx,.len = 4 };
369
370 dibx000_i2c_gate_ctrl(mst, tx, 0, 0);
371 i2c_transfer(mst->i2c_adap, &m, 1);
372 mst->selected_interface = 0xff; // the first time force a select of the I2C
373 dibx000_i2c_select_interface(mst, DIBX000_I2C_INTERFACE_TUNER);
374}
375
376EXPORT_SYMBOL(dibx000_reset_i2c_master);
377
378static int i2c_adapter_init(struct i2c_adapter *i2c_adap,
Olivier Grenieb994d192011-01-03 15:39:35 -0300379 struct i2c_algorithm *algo, const char *name,
380 struct dibx000_i2c_master *mst)
Patrick Boettcher42afd062006-07-29 17:33:44 -0300381{
David Brownell2096b952007-05-01 23:26:28 +0200382 strncpy(i2c_adap->name, name, sizeof(i2c_adap->name));
Jean Delvare2c2742d2010-11-05 07:35:35 -0300383 i2c_adap->algo = algo;
Patrick Boettcher42afd062006-07-29 17:33:44 -0300384 i2c_adap->algo_data = NULL;
385 i2c_set_adapdata(i2c_adap, mst);
386 if (i2c_add_adapter(i2c_adap) < 0)
387 return -ENODEV;
388 return 0;
389}
390
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -0300391int dibx000_init_i2c_master(struct dibx000_i2c_master *mst, u16 device_rev,
Olivier Grenieb994d192011-01-03 15:39:35 -0300392 struct i2c_adapter *i2c_adap, u8 i2c_addr)
Patrick Boettcher42afd062006-07-29 17:33:44 -0300393{
394 u8 tx[4];
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -0300395 struct i2c_msg m = {.addr = i2c_addr >> 1,.buf = tx,.len = 4 };
Patrick Boettcher42afd062006-07-29 17:33:44 -0300396
397 mst->device_rev = device_rev;
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -0300398 mst->i2c_adap = i2c_adap;
399 mst->i2c_addr = i2c_addr >> 1;
Patrick Boettcher42afd062006-07-29 17:33:44 -0300400
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -0300401 if (device_rev == DIB7000P || device_rev == DIB8000)
Patrick Boettcher42afd062006-07-29 17:33:44 -0300402 mst->base_reg = 1024;
403 else
404 mst->base_reg = 768;
405
Olivier Grenieb994d192011-01-03 15:39:35 -0300406 mst->gated_tuner_i2c_adap.dev.parent = mst->i2c_adap->dev.parent;
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -0300407 if (i2c_adapter_init
Olivier Grenieb994d192011-01-03 15:39:35 -0300408 (&mst->gated_tuner_i2c_adap, &dibx000_i2c_gated_tuner_algo,
409 "DiBX000 tuner I2C bus", mst) != 0)
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -0300410 printk(KERN_ERR
Olivier Grenieb994d192011-01-03 15:39:35 -0300411 "DiBX000: could not initialize the tuner i2c_adapter\n");
412
413 mst->master_i2c_adap_gpio12.dev.parent = mst->i2c_adap->dev.parent;
414 if (i2c_adapter_init
415 (&mst->master_i2c_adap_gpio12, &dibx000_i2c_master_gpio12_xfer_algo,
416 "DiBX000 master GPIO12 I2C bus", mst) != 0)
417 printk(KERN_ERR
418 "DiBX000: could not initialize the master i2c_adapter\n");
419
420 mst->master_i2c_adap_gpio34.dev.parent = mst->i2c_adap->dev.parent;
421 if (i2c_adapter_init
422 (&mst->master_i2c_adap_gpio34, &dibx000_i2c_master_gpio34_xfer_algo,
423 "DiBX000 master GPIO34 I2C bus", mst) != 0)
424 printk(KERN_ERR
425 "DiBX000: could not initialize the master i2c_adapter\n");
426
427 mst->master_i2c_adap_gpio67.dev.parent = mst->i2c_adap->dev.parent;
428 if (i2c_adapter_init
429 (&mst->master_i2c_adap_gpio67, &dibx000_i2c_gated_gpio67_algo,
430 "DiBX000 master GPIO67 I2C bus", mst) != 0)
431 printk(KERN_ERR
432 "DiBX000: could not initialize the master i2c_adapter\n");
Patrick Boettcher42afd062006-07-29 17:33:44 -0300433
434 /* initialize the i2c-master by closing the gate */
435 dibx000_i2c_gate_ctrl(mst, tx, 0, 0);
436
437 return i2c_transfer(i2c_adap, &m, 1) == 1;
438}
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -0300439
Patrick Boettcher42afd062006-07-29 17:33:44 -0300440EXPORT_SYMBOL(dibx000_init_i2c_master);
441
442void dibx000_exit_i2c_master(struct dibx000_i2c_master *mst)
443{
444 i2c_del_adapter(&mst->gated_tuner_i2c_adap);
Olivier Grenieb994d192011-01-03 15:39:35 -0300445 i2c_del_adapter(&mst->master_i2c_adap_gpio12);
446 i2c_del_adapter(&mst->master_i2c_adap_gpio34);
447 i2c_del_adapter(&mst->master_i2c_adap_gpio67);
Patrick Boettcher42afd062006-07-29 17:33:44 -0300448}
449EXPORT_SYMBOL(dibx000_exit_i2c_master);
Patrick Boettcherc6d74c22006-08-06 08:49:09 -0300450
Olivier Grenie03245a52009-12-04 13:27:57 -0300451
Randy Dunlap7ccf1ee2010-02-14 23:39:32 -0300452u32 systime(void)
Olivier Grenie03245a52009-12-04 13:27:57 -0300453{
Olivier Grenieb994d192011-01-03 15:39:35 -0300454 struct timespec t;
Olivier Grenie03245a52009-12-04 13:27:57 -0300455
Olivier Grenieb994d192011-01-03 15:39:35 -0300456 t = current_kernel_time();
457 return (t.tv_sec * 10000) + (t.tv_nsec / 100000);
Olivier Grenie03245a52009-12-04 13:27:57 -0300458}
459EXPORT_SYMBOL(systime);
460
Patrick Boettcherc6d74c22006-08-06 08:49:09 -0300461MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>");
462MODULE_DESCRIPTION("Common function the DiBcom demodulator family");
463MODULE_LICENSE("GPL");