root/i2c/trunk/kernel/i2c-algo-biths.c @ 3749

Revision 3749, 17.5 KB (checked in by kmalkki, 10 years ago)

(Kyösti) Use rdtscl() on x86 machines to get better resolution for bus

speed. Currently running this at 1 MHz (250ns delay) on a BT848
board with no problems so far. Falls back to udelay() with maximum
bus clock of 250 kHz if rdtscl() not defined.

Byte and bit level access functions now loop internally over write
and read buffer to remove a considerable amount of stack operations.

Divide flags to ctrl and errors, and other changes in
i2c_algo_biths_data.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* ------------------------------------------------------------------------- */
2/* i2c-algo-biths.c i2c driver algorithms for bit-shift adapters             */
3/* ------------------------------------------------------------------------- */
4/*   Copyright (C) 1995-2000 Simon G. Vogl
5     Copyright (C) 2002-2003 Kyösti Mälkki
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */
20/* ------------------------------------------------------------------------- */
21
22/* $Id$ */
23
24#include <linux/kernel.h>
25#include <linux/module.h>
26#include <linux/delay.h>
27#include <linux/slab.h>
28#include <linux/version.h>
29#include <linux/init.h>
30#include <asm/uaccess.h>
31#include <linux/ioport.h>
32#include <linux/errno.h>
33#include <linux/sched.h>
34#include "i2c.h"
35#include "i2c-algo-biths.h"
36
37/* ----- global defines ----------------------------------------------- */
38
39/* If non-zero, adapter code written for original i2c-algo-bit can be used unmodified.
40 * As this export same symbols, you should either remove i2c-algo-bit.o from depmod
41 * directories, or load this module manually.
42 */
43#ifndef ALGO_BIT_COMPATIBILITY
44#define ALGO_BIT_COMPATIBILITY 0
45#endif
46
47#define FATAL_BUS       0
48#define MODULE_STATUS   1
49#define FATAL_MSG       2
50#define FATAL_PROTOCOL  3
51#define ALL_MSG         4
52#define ALL_PROTOCOL    5
53
54#define DEB1(x)         if (i2c_debug>=MODULE_STATUS) (x);
55static void proto_s(char *d, const char *s) { strcat(d, s); }
56static void proto_x(char *d, const char *x, unsigned char y) { while (*d) d++; sprintf(d, x, y); }
57#define PROTO_S(x)      if (adap->dstr) proto_s(adap->dstr, x)
58#define PROTO_X(x,y)    if (adap->dstr) proto_x(adap->dstr, x, y)
59
60#if 1
61#define PROTO_B(x)
62#define PROTO_MAX_DUMP 512  // upto 50 x " [xx] [xx]"
63#else
64#define PROTO_B(x) PROTO_S(x)
65#define PROTO_MAX_DUMP 1024  // 50 x ".oooooooo [xx] .i[xx]"
66#endif
67
68/* ----- global variables --------------------------------------------- */
69
70/* module parameters:
71 */
72static int i2c_debug; 
73static int bit_test;    /* see if the line-setting functions work       */
74
75/* Bus timing for 50/50 duty cycle :  T_setup + T_hold = T_scllo = T_sclhi */
76/* Run setscl/setsda with a special flag */
77#define T_min   0               /* after any SCL SDA change     */
78#define T_sclhi _HS_DBL_DT      /* SCL high                     */
79#define T_scllo _HS_DBL_DT      /* SCL low                      */
80#define T_setup 0               /* SDA change to SCL rise       */
81#define T_hold  0               /* SCL fall to SDA change       */
82
83#define _sf(a)          adap->ctrl|=(a)
84#define _cf(a)          adap->ctrl&=~(a)
85#define ___setscl(b)    if (b) _sf(_HS_SCL); else _cf(_HS_SCL);\
86                        adap->setstate(adap); adap->setscl(adap)
87#define ___setsda(b)    if (b) _sf(_HS_SDA); else _cf(_HS_SDA);\
88                        adap->setstate(adap); adap->setsda(adap)
89
90#define __setdt(x,dt)   if (dt) _sf(dt); x; if (dt) _cf(dt)
91#define __setscl(b,dt)  __setdt(___setscl(b),dt);
92#define __setsda(b,dt)  __setdt(___setsda(b),dt);
93#define __getscl()      adap->getscl(adap)
94#define __getsda()      adap->getsda(adap)
95
96
97#define RETURN_ON_FAILURE(x)            x; if (adap->errors) return
98#define TRY(x) RETURN_ON_FAILURE(x)
99
100#define _setscl(b,dt)   RETURN_ON_FAILURE(__setscl(b,dt))
101#define _setsda(b,dt)   RETURN_ON_FAILURE(__setsda(b,dt))
102#define _getscl         __getscl
103#define _getsda         __getsda
104
105#define _sclhi(dt)      _setscl(1,dt)
106#define _scllo(dt)      _setscl(0,dt)
107#define _sdahi(dt)      _setsda(1,dt)
108#define _sdalo(dt)      _setsda(0,dt)
109
110/* --- other auxiliary functions -------------------------------------- */
111/* start, repstart */
112static void i2c_start(struct i2c_algo_biths_data *adap)
113{
114        PROTO_S("S");
115        /* assert: scl, sda undef */
116        adap->errors = 0;
117        _sdahi(T_setup);
118        _sclhi(T_min);
119        _sdalo(T_min);
120        _scllo(T_hold);
121        /* assert: scl, sda low */
122}
123
124static void i2c_stop(struct i2c_algo_biths_data *adap)
125{
126        PROTO_S(" P");
127        /* scl undef after error, sda, scl freedom unknown */
128        adap->ctrl &= ~(_HS_SDA_FREE | _HS_DBL_DT);
129        if (adap->errors) {
130            adap->errors = 0;
131            _scllo(T_hold);
132        }
133        /* assert: scl low, sda undef */
134        _sdalo(T_setup);
135        _sclhi(T_min);
136        _sdahi(T_min);
137        /* assert: scl, sda high */
138}
139
140
141static void i2c_outbits(struct i2c_algo_biths_data *adap, int i) 
142{
143        /* assert: scl is low */
144        PROTO_B(".");
145        while  (i--) {
146            PROTO_B("o");
147            _setsda(adap->shiftreg & 0x80, T_setup);
148            _sclhi(T_sclhi);
149            _scllo(T_hold);
150            adap->shiftreg<<=1;
151        }
152        /* assert: scl is low */
153}
154
155static void i2c_inbits(struct i2c_algo_biths_data *adap, int i)
156{
157        /* assert: scl is low, sda undef */
158        adap->ctrl |= _HS_SDA_FREE;
159        PROTO_B(".");
160        while  (i--) {
161            PROTO_B("i");
162            _sdahi(T_setup); 
163            _sclhi(T_sclhi);   
164            adap->shiftreg<<=1;
165            if (_getsda())
166                adap->shiftreg |= 0x01;
167            _scllo(T_hold);
168        }
169        adap->ctrl &= ~_HS_SDA_FREE;
170        /* assert: scl is low */
171}
172
173static void i2c_outb(struct i2c_algo_biths_data *adap, unsigned short flags,
174                     char *buf, int *count) 
175{
176        while (*count) {
177            adap->shiftreg = *buf++;
178            TRY(i2c_outbits(adap, 8));
179            PROTO_X(" %02X ", adap->shiftreg);
180           
181            /* read ack: SDA should be pulled down by slave */
182            TRY(i2c_inbits(adap, 1));
183           
184            if (! (adap->shiftreg & 0x01)) { 
185                PROTO_S("[A]");
186            } else if (flags & I2C_M_IGNORE_NAK) {
187                PROTO_S("[NA]");
188            } else {
189                PROTO_S("[NA]");
190                adap->errors |= _HS_NAK;
191            }
192            if (adap->errors) return;
193            (*count)--;
194        }
195}
196
197static void i2c_inb(struct i2c_algo_biths_data *adap, unsigned short flags,
198                    char *buf, int *count) 
199{
200        while (*count) {
201            TRY(i2c_inbits(adap, 8));
202            *buf++ = adap->shiftreg;
203            PROTO_X(" [%02X] ", adap->shiftreg);
204           
205            if (! (flags & I2C_M_NO_RD_ACK)) {
206                if (*count == 1) /* was last */
207                    adap->shiftreg = 0x80;
208                else
209                    adap->shiftreg = 0x00;
210                TRY(i2c_outbits(adap,1));
211
212                if (*count == 1) {
213                    PROTO_S("NA");
214                } else {
215                    PROTO_S("A");
216                }
217            }
218            (*count)--;
219        }
220}
221
222
223static void debug_protocol(struct i2c_algo_biths_data *adap, int retval)
224{
225    if (! adap->dstr) return;
226
227    if ( ((retval<0) && (i2c_debug>=FATAL_PROTOCOL)) || 
228         (i2c_debug>=ALL_PROTOCOL) ) {
229        printk(KERN_DEBUG "i2c-algo-biths.o: %s: %s\n", adap->name, adap->dstr); 
230    }
231    *adap->dstr = 0;
232}
233
234static const char * i2c_strerr(int retval)
235{ 
236    switch (retval) {
237        case 2:
238            return "ack";
239               
240        case 1:
241            return "no ack (ignored)";
242
243        case 0:
244            return "not reached";
245
246        case -EREMOTEIO:
247            return "no ack";
248
249        case -ETIMEDOUT:
250            return "SCL rise timeout";
251         
252        case -ECOMM:
253            return "SDA arbitration";
254
255        case -ENODEV:
256            return "SCL/SDA failure";
257
258        default:
259            return "unknown";
260    }
261}
262
263static int errflag(int flags)
264{
265    if (! flags)
266        return 2;
267    if (flags & _HS_HW_FAIL)
268        return -ENODEV;
269    if (flags & _HS_SDA_ARB)
270        return -ECOMM;
271    if (flags & _HS_TIMEOUT)
272        return -ETIMEDOUT;
273    if (flags & _HS_NAK)
274        return -EREMOTEIO;
275}
276
277static void debug_printout(struct i2c_adapter *i2c_adap, int num, int retval)
278{ 
279    if ( ((retval<0) && (i2c_debug>=FATAL_MSG)) ||
280         (i2c_debug>=ALL_MSG) ) {
281        printk(KERN_ERR "i2c-algo-biths.o: %s: msg #%d %s\n", i2c_adap->name, num, i2c_strerr(retval));
282    }
283}
284
285/*
286 * Sanity check for the adapter hardware
287 */
288static int test_bus(struct i2c_algo_biths_data *adap)
289{
290
291    int sscl, ssda, gscl, gsda, i=0;
292    int errors;
293    int test[][2] = {{1,1}, {0,1}, {1,1}, {1,0}, {1,1}, {-1,-1}}; // SDA, SCL pair
294
295    printk(KERN_INFO "i2c-algo-biths.o: %s bus test\n", adap->name);
296
297    while ( test[i][0]!=-1 ) {
298        ssda = test[i][0];
299        sscl = test[i][1];
300
301        adap->errors = 0;
302        __setsda(ssda, T_min);
303        gsda = __getsda() ? 1 : 0;
304        errors = adap->errors & (_HS_HW_FAIL | _HS_SDA_ARB);
305        if (errors)
306            printk(KERN_WARNING "i2c-algo-biths.o: %s %s\n", adap->name,
307                   i2c_strerr(errflag(errors)));
308           
309        __setscl(sscl, T_min);
310        gscl = __getscl() ? 1 : 0;
311        errors = adap->errors & (_HS_HW_FAIL | _HS_TIMEOUT);
312        if (errors)
313            printk(KERN_WARNING "i2c-algo-biths.o: %s %s\n", adap->name,
314                   i2c_strerr(errflag(errors)));
315
316        printk(KERN_DEBUG "i2c-algo-biths.o: %s SCL: %d  SDA: %d\n", adap->name, gscl, gsda);
317        if ( sscl!=gscl )
318            printk(KERN_WARNING "i2c-algo-biths.o: %s SCL set %d, got %d!\n", adap->name, sscl, gscl);
319        if ( ssda!=gsda )
320            printk(KERN_WARNING "i2c-algo-biths.o: %s SDA set %d, got %d!\n", adap->name, ssda, gsda);
321        if ( (adap->errors) || sscl!=gscl || ssda!=gsda )
322            break;
323        i++;
324    }
325   
326    __setsda(1,0);
327    __setscl(1,0);
328    adap->errors = 0;
329
330    if (test[i][0]==-1) {
331        printk(KERN_INFO "i2c-algo-biths.o: %s passed bus test.\n",adap->name);
332        return 0;
333    } else {
334        printk(KERN_INFO "i2c-algo-biths.o: %s failed bus test.\n",adap->name);
335        return -ENODEV;
336    }
337}
338
339
340/* doAddress transmits the address in the necessary format to handle
341 * reads, writes as well as 10bit-addresses.
342 */
343
344static void doAddress(struct i2c_algo_biths_data *adap, struct i2c_msg *msg) 
345{
346        unsigned char addr[2];
347        int count;
348
349        if ( msg->flags & I2C_M_TEN ) { 
350                /* a ten bit address */
351                count = 2;
352                addr[0] = 0xf0 | (( msg->addr >> 7) & 0x03);
353                addr[1] = msg->addr & 0x7f;
354
355                /* try extended address code ... and the remaining 8 bit address */
356                TRY(i2c_outb(adap, msg->flags, addr, &count));
357
358                if ( msg->flags & I2C_M_RD ) {
359                        TRY(i2c_start(adap));
360                       
361                        /* okay, now switch into reading mode */
362                        count = 1;
363                        addr[0] |= 0x01;
364                        TRY(i2c_outb(adap, msg->flags, addr, &count));
365                }
366        } else {                /* normal 7bit address  */
367                count = 1;
368                addr[0] = ( msg->addr << 1 );
369                if (msg->flags & I2C_M_RD )
370                        addr[0] |= 1;
371                if (msg->flags & I2C_M_REV_DIR_ADDR )
372                        addr[0] ^= 1;
373                TRY(i2c_outb(adap, msg->flags, addr, &count));
374        }
375}
376
377/*
378 * return values:
379 * 1 ACK
380 * 0 IGNORED client NAK
381 * -EREMOTEIO  client NAK
382 * -ETIMEDOUT  from sclhi()
383 */
384
385
386static int bit_xfer(struct i2c_adapter *i2c_adap,
387                    struct i2c_msg msgs[], int num)
388{
389        struct i2c_msg *msg = msgs;
390        struct i2c_algo_biths_data *adap = i2c_adap->algo_data;
391        int mn, j, state;
392        enum { MSG_INIT, MSG_START, MSG_ADDRESS, MSG_DATA, MSG_READY, MSG_STOP, MSG_EXIT };
393
394        state = MSG_INIT;
395        mn=0;
396
397        adap->dstr=NULL;
398        if (i2c_debug>=FATAL_PROTOCOL) {
399            adap->dstr = kmalloc(PROTO_MAX_DUMP, GFP_KERNEL);
400            if (adap->dstr) {
401                *adap->dstr = 0;
402            } else {
403                printk(KERN_DEBUG "i2c-algo-biths.o %s: missing protocol dump (-ENOMEM)\n", adap->name);
404            }
405        }
406
407        for (j=0; j<num; j++) msgs[j].err = 0; // unprocessed
408
409        do switch (state) {
410           
411            case MSG_INIT:
412                msg = &msgs[mn];
413                if ((msg->flags & I2C_M_NOSTART) && (mn)) {
414                    state = MSG_DATA;
415                    break;
416                }
417
418            case MSG_START:     
419                i2c_start(adap);
420                if (adap->errors) {
421                    state = MSG_STOP;   
422                    break;
423                }       
424                   
425            case MSG_ADDRESS:
426                doAddress(adap, msg);
427                if (adap->errors) {
428                    state = MSG_STOP;
429                    break;
430                }
431
432            case MSG_DATA:
433                j = msg->len;
434                if ( msg->flags & I2C_M_RD ) {
435                    i2c_inb(adap, msg->flags, msg->buf, &j);
436                } else {
437                    i2c_outb(adap, msg->flags, msg->buf, &j);
438                }
439                msg->done = msg->len - j;
440                if (adap->errors) {
441                    state = MSG_STOP;
442                    break;
443                }
444       
445            case MSG_READY:
446                mn++;
447                if (mn<num) {
448                    msg->err = errflag(adap->errors);
449                    debug_protocol(adap, msg->err);
450                    state = MSG_INIT;
451                    break;
452                }
453
454            case MSG_STOP:
455                msg->err = errflag(adap->errors);
456                i2c_stop(adap);
457                j = 0;
458                while (adap->errors) {
459                    if ( ++j > 10) {
460                        msg->err = -ENODEV;
461                        break;
462                    }
463                    i2c_stop(adap);
464                }
465                debug_protocol(adap, msg->err);
466                state = MSG_EXIT;
467                break;
468
469            default: /* not reached */
470                state = MSG_EXIT;
471                msg->err = -EINVAL;
472                break;
473                                 
474        } while (state != MSG_EXIT);
475       
476        if (adap->dstr) kfree(adap->dstr);
477
478        for (j=0; j<num; j++)
479            debug_printout(i2c_adap, j, msgs[j].err);
480
481        return (msg->err < 0) ? msg->err : mn;
482}
483
484static int algo_control(struct i2c_adapter *i2c_adap, 
485        unsigned int cmd, unsigned long arg)
486{
487        return 0;
488}
489
490static u32 bit_func(struct i2c_adapter *i2c_adap)
491{
492        return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR | 
493               I2C_FUNC_PROTOCOL_MANGLING;
494}
495
496
497/* -----exported algorithm data: -------------------------------------  */
498
499static struct i2c_algorithm i2c_algo_biths = {
500        "Bit-shift algorithm",
501        I2C_ALGO_BIT,
502        bit_xfer,
503        NULL,
504        NULL,                           /* slave_xmit           */
505        NULL,                           /* slave_recv           */
506        algo_control,                   /* ioctl                */
507        bit_func,                       /* functionality        */
508};
509
510
511#if ALGO_BIT_COMPATIBILITY
512#include "i2c-algo-bit.h"
513
514static inline void _hw_setscl(struct i2c_algo_bit_data *old, int state)
515{
516        old->setscl(old->data, state & _HS_SCL);
517}
518
519static inline void _hw_setsda(struct i2c_algo_bit_data *old, int state)
520{
521        old->setsda(old->data, state & _HS_SDA);
522}
523
524static inline int _hw_getscl(struct i2c_algo_bit_data *old)
525{
526        return old->getscl(old->data);
527}
528
529static inline int _hw_getsda(struct i2c_algo_bit_data *old)
530{
531        return old->getsda(old->data);
532}
533
534#define INCLUDE_BITHS_INLINES
535#include "i2c-algo-biths.h"
536static  _HS_ATTR_ void _old_setstate(struct i2c_algo_biths_data *adap)
537{
538        adap->hw_state = adap->ctrl;
539}
540
541static _HS_ATTR_ void _old_setscl(struct i2c_algo_biths_data *adap)
542{
543        i2c_bit_setscl(adap);
544}
545static _HS_ATTR_ void _old_setsda(struct i2c_algo_biths_data *adap)
546{
547        i2c_bit_setsda(adap);
548}
549static _HS_ATTR_ int _old_getscl(struct i2c_algo_biths_data *adap)
550{
551        return i2c_bit_getscl(adap);
552}
553static _HS_ATTR_ int _old_getsda(struct i2c_algo_biths_data *adap)
554{
555        return i2c_bit_getsda(adap);
556}
557
558static struct i2c_algo_biths_data _old_template = {
559    setstate:  _old_setstate,
560    setsda:  _old_setsda,
561    setscl:  _old_setscl,
562    getsda:  _old_getsda,
563    getscl:  _old_getscl,
564};
565
566/*
567 * registering functions to load algorithms at runtime
568 */
569int i2c_bit_add_bus(struct i2c_adapter *i2c_adap)
570{
571        int i;
572        struct i2c_algo_bit_data *old_adap = i2c_adap->algo_data;
573        struct i2c_algo_biths_data *adap;
574
575        adap = kmalloc(sizeof(struct i2c_algo_biths_data), GFP_KERNEL);
576        if (adap==NULL)
577            return -ENOMEM;
578
579        memcpy(adap, &_old_template, sizeof(struct i2c_algo_biths_data));
580        adap->hw_data = old_adap;
581        adap->xloops = old_adap->udelay * 0x0863; /* 1/4 vs 1/2 cycle, 0x10c6 / 2 */
582        adap->timeout = old_adap->timeout;
583        i2c_adap->algo_data = adap;
584
585        return i2c_biths_add_bus(i2c_adap);
586}
587
588
589int i2c_bit_del_bus(struct i2c_adapter *i2c_adap)
590{
591        int res;
592
593        if ((res = i2c_biths_del_bus(i2c_adap)) < 0)
594            return res;
595
596        kfree(i2c_adap->algo_data);
597        return 0;
598}
599
600EXPORT_SYMBOL(i2c_bit_add_bus);
601EXPORT_SYMBOL(i2c_bit_del_bus);
602
603#endif
604
605#ifdef rdtscl
606/* TSC stuff from arch/i386/lib/delay.c */
607
608static _HS_ATTR_ void i2c_tsc_set(struct i2c_algo_biths_data *adap)
609{
610    rdtscl(adap->bclock);
611}
612
613static _HS_ATTR_ void i2c_tsc_run(struct i2c_algo_biths_data *adap)
614{
615    unsigned long now, loops, xloops;
616    int d0;
617    xloops = adap->xloops; 
618    __asm__("mull %0"
619            :"=d" (xloops), "=&a" (d0)
620            :"1" (xloops),"0" (current_cpu_data.loops_per_jiffy));
621    loops = xloops * HZ;
622    do
623    {
624        rep_nop();
625        rdtscl(now);
626    } while ( (now - adap->bclock) < loops );
627}
628
629#else
630
631static _HS_ATTR_ void i2c_udelay_set(struct i2c_algo_biths_data *adap) {}
632
633static _HS_ATTR_ void i2c_udelay_run(struct i2c_algo_biths_data *adap)
634{
635    int usecs;
636    /* adap->xloops = usecs * 0x000010c6 / 2; */
637    usecs = ((adap->xloops + 0x0863) >> 12); 
638    if (adap->ctrl & _HS_DBL_DT)
639        usecs<<=1;
640    udelay(usecs);
641}
642
643#endif /* rdtscl */
644
645
646/*
647 * registering functions to load algorithms at runtime
648 */
649int i2c_biths_add_bus(struct i2c_adapter *i2c_adap)
650{
651        int i;
652        struct i2c_algo_biths_data *adap = i2c_adap->algo_data;
653
654        /* get name */
655        adap->name = i2c_adap->name;
656        adap->dstr = 0; // no protocol dump buffer
657
658        if (adap->set_timer == NULL) {
659#ifdef rdtscl   /* if (x86_udelay_tsc) here instead ? */
660                adap->set_timer = i2c_tsc_set;
661                adap->run_timer = i2c_tsc_run;
662#else
663                adap->set_timer = i2c_udelay_set;
664                adap->run_timer = i2c_udelay_run;
665#endif
666        }
667
668        if (bit_test) {
669            int ret = test_bus(adap);
670            if (ret<0)
671                return ret;
672        }
673
674        DEB1(printk(KERN_DEBUG "i2c-algo-biths.o: hw routines for %s registered.\n",
675                    i2c_adap->name));
676       
677        /* register new adapter to i2c module... */
678
679        i2c_adap->id |= i2c_algo_biths.id;
680        i2c_adap->algo = &i2c_algo_biths;
681
682        i2c_adap->timeout = HZ; /* default values, should       */
683        i2c_adap->retries = 3;  /* be replaced by defines       */
684
685#ifdef MODULE
686        MOD_INC_USE_COUNT;
687#endif
688        i2c_add_adapter(i2c_adap);
689
690        return 0;
691}
692
693
694int i2c_biths_del_bus(struct i2c_adapter *i2c_adap)
695{
696        int res;
697
698        if ((res = i2c_del_adapter(i2c_adap)) < 0)
699                return res;
700
701        DEB1(printk(KERN_DEBUG "i2c-algo-biths.o: adapter unregistered: %s\n",i2c_adap->name));
702
703#ifdef MODULE
704        MOD_DEC_USE_COUNT;
705#endif
706        return 0;
707}
708
709int __init i2c_algo_biths_init (void)
710{
711        printk(KERN_INFO "i2c-algo-biths.o: i2c high-speed bit algorithm module version %s (%s)\n", I2C_VERSION, I2C_DATE);
712#ifdef rdtscl
713        DEB1(printk(KERN_DEBUG "i2c-algo-biths.o:  ... will use rdtscl() for bus clock\n"));
714#else
715        DEB1(printk(KERN_DEBUG "i2c-algo-biths.o:  ... will use udelay() for bus clock\n");
716#endif
717        return 0;
718}
719
720
721
722EXPORT_SYMBOL(i2c_biths_add_bus);
723EXPORT_SYMBOL(i2c_biths_del_bus);
724
725#ifdef MODULE
726MODULE_AUTHOR("Kyösti Mälkki <kmalkki@cc.hut.fi>");
727MODULE_DESCRIPTION("I2C-Bus bit-banging algorithm");
728#ifdef MODULE_LICENSE
729MODULE_LICENSE("GPL");
730#endif
731
732MODULE_PARM(bit_test, "i");
733MODULE_PARM(i2c_debug,"i");
734
735MODULE_PARM_DESC(bit_test, "Test the lines of the bus to see if it is stuck");
736MODULE_PARM_DESC(i2c_debug,
737            "debug level - 1 use; 2 fatal, 3 +proto; 4 all, 5 +proto");
738
739int init_module(void) 
740{
741        return i2c_algo_biths_init();
742}
743
744void cleanup_module(void) 
745{
746}
747#endif
Note: See TracBrowser for help on using the browser.