2 eib-pei16.c - Low level EIB driver for BCU 1
4 Copyright (C) 2000 Bernd Thallner <bernd@kangaroo.at>
5 Copyright (C) 2005-2008 Martin Koegler <mkoegler@auto.tuwien.ac.at>
7 Ported to Linux 2.6 by Robert Kurevija
8 Heavily modfied and restructed by Martin Kögler
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License
12 as published by the Free Software Foundation; either version 2
13 of the License, or (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #include <linux/kernel.h>
26 #include <linux/module.h>
27 #include <linux/version.h>
29 #include <linux/sched.h>
31 #include "eib-common.h"
37 #define EIB_PRINT(fmt, args...) printk(KERN_NOTICE "eib: " fmt "\n", ## args)
41 # define PDEBUG(fmt, args...) printk(KERN_NOTICE "eib: " fmt "\n", ## args)
43 # define PDEBUG(fmt, args...) do {} while (0)
46 #define EIB_LOG(MSG, args...) do { struct timespec tv; getnstimeofday (&tv); PDEBUG("at %010ld.%09ld " MSG,tv.tv_sec,tv.tv_nsec,##args);tv.tv_nsec--;} while(0)
48 static int eib_major
= 0;
50 module_param (eib_major
, int, 0);
51 MODULE_PARM_DESC (eib_major
, "Major number for this device.");
53 MODULE_AUTHOR ("Martin Kögler, mkoegler@auto.tuwien.ac.at");
54 MODULE_AUTHOR ("Bernd Thallner, bernd@kangaroo.at");
55 MODULE_DESCRIPTION ("A low level EIB driver for BCU 1.");
56 MODULE_LICENSE ("GPL");
58 /* maximum time in usec to wait between rx interrupt raised and byte fully send */
59 #define MAX_TEMT_WAIT 1000
61 /* minimum time in usec to wait between byte fully send and clear rts signal */
62 #define WRITE_TEMT_CLRRTS_DELAY 100
64 /* minimum time in usec to wait between clear rts and set rts signal */
65 #define WRITE_CLRRTS_SETRTS_DELAY 80
67 /* timeout for data block transfer */
68 #define READ_WRITE_TIMEOUT 130000
70 /* maximum time between to interrupts if not in idle state */
71 #define MAX_TIME_BETWEEN_INT 80000
73 /* minimum time to wait after reset without any respond to signals */
74 #define MIN_RESET_WAIT_TIME 130000
76 /* maximum time between to wait for start sending */
77 #define MAX_INIT_SEND_TIMEOUT 100000
79 /* time to start transmission */
80 #define MAX_INIT_SEND_TIME 3000
82 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
84 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
85 #define HRTIMER_MODE_REL HRTIMER_REL
88 #include <linux/hrtimer.h>
89 #include <linux/ktime.h>
91 typedef struct eib_timer eib_timer
;
92 typedef void (*eib_timer_func
) (eib_timer
* timer
);
100 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
102 eib_timer_run (struct hrtimer
*data
)
104 static enum hrtimer_restart
105 eib_timer_run (struct hrtimer
*data
)
108 eib_timer
*t
= container_of (data
, eib_timer
, tl
);
110 return HRTIMER_NORESTART
;
114 init_eib_timer (eib_timer
* timer
, eib_timer_func func
)
116 hrtimer_init (&timer
->tl
, CLOCK_MONOTONIC
, HRTIMER_MODE_REL
);
118 timer
->tl
.function
= eib_timer_run
;
122 start_eib_timer (eib_timer
* timer
, unsigned long usec_offset
)
126 hrtimer_start (&timer
->tl
, ktime_set (0, usec_offset
* 1000),
131 stop_eib_timer (eib_timer
* timer
)
133 hrtimer_try_to_cancel (&timer
->tl
);
137 destroy_eib_timer (eib_timer
* timer
)
139 hrtimer_cancel (&timer
->tl
);
144 typedef struct eib_timer eib_timer
;
145 typedef void (*eib_timer_func
) (eib_timer
* timer
);
149 struct timer_list tl
;
154 eib_timer_run (unsigned long data
)
156 eib_timer
*t
= (eib_timer
*) data
;
161 init_eib_timer (eib_timer
* timer
, eib_timer_func func
)
163 init_timer (&timer
->tl
);
165 timer
->tl
.function
= eib_timer_run
;
166 timer
->tl
.data
= (unsigned long int) (void *) timer
;
170 start_eib_timer (eib_timer
* timer
, unsigned long usec_offset
)
172 mod_timer (&timer
->tl
,
173 usec_offset
? jiffies
+
174 usecs_to_jiffies (usec_offset
) : jiffies
+ 1);
178 stop_eib_timer (eib_timer
* timer
)
180 del_timer (&timer
->tl
);
184 destroy_eib_timer (eib_timer
* timer
)
186 del_timer_sync (&timer
->tl
);
191 struct eib_protocol_data
203 eib_timer initate_send_timer
;
204 eib_timer detect_reset_timer
;
205 eib_timer write_timer
;
207 struct timespec last_int_tv
;
208 struct timespec start_tv
;
209 struct timespec send_tv
;
210 struct timespec reset_tv
;
212 volatile int initate_send
;
217 bitcount (unsigned char x
)
221 for (b
= 0; x
!= 0; x
>>= 1)
229 time_difference (struct timespec
*tv1
, struct timespec
*tv2
)
235 getnstimeofday (&foo
);
239 return (tv2
->tv_nsec
- tv1
->tv_nsec
) / 1000 + /* usecs */
240 1000000 * (tv2
->tv_sec
- tv1
->tv_sec
); /* seconds * 1000000 */
244 add_initate_send_timer (eib_protocol_data
* dev
)
251 t1
= MAX_INIT_SEND_TIME
- time_difference (&dev
->last_int_tv
, NULL
);
252 t2
= MAX_INIT_SEND_TIMEOUT
- time_difference (&dev
->send_tv
, NULL
);
253 EIB_LOG ("add_initate_send: %ld %ld", t1
, t2
);
261 start_eib_timer (&dev
->initate_send_timer
, t1
);
265 add_detect_reset_timer (eib_protocol_data
* dev
)
274 t1
= MIN_RESET_WAIT_TIME
- time_difference (&dev
->reset_tv
, NULL
);
275 EIB_LOG ("add_detect_reset: %ld", t1
);
282 t1
= READ_WRITE_TIMEOUT
- time_difference (&dev
->start_tv
, NULL
);
283 t2
= MAX_TIME_BETWEEN_INT
- time_difference (&dev
->last_int_tv
, NULL
);
284 EIB_LOG ("add_detect_reset: %ld %ld", t1
, t2
);
293 start_eib_timer (&dev
->detect_reset_timer
, t1
);
297 add_write_timer (eib_protocol_data
* dev
, long timeout
)
303 EIB_LOG ("add_write_timer: %ld", timeout
);
304 start_eib_timer (&dev
->write_timer
, timeout
);
308 do_reset1 (eib_protocol_data
* dev
, unsigned long reason
, const char *msg
,
313 ("do_reset: state=%d, reason=%lx, initate_send=%d, getCTS()=%d, %s at %d",
314 dev
->state
, reason
, dev
->initate_send
, dev
->iface
->getCTS (dev
->dev
),
318 dev
->iface
->getserialint (dev
->dev
);
319 dev
->iface
->recv (dev
->dev
);
320 dev
->iface
->getCTS (dev
->dev
); /* clear MSR Delta */
321 getnstimeofday (&dev
->reset_tv
);
322 dev
->iface
->clrRTS (dev
->dev
);
325 #define do_reset(dev, MSG) do_reset1(dev, MSG , __LINE__)
327 #define ERR_1 0x00000001 , "no interrupt pending"
328 #define ERR_2 0x00000002 , "unexpected receive data interrupt"
329 #define ERR_4 0x00000004 , "unexpected receive data interrupt"
330 #define ERR_8 0x00000008 , "unexpected cts change to high"
331 #define ERR_10 0x00000010 , "read buffer overflow"
332 #define ERR_20 0x00000020 , "unexpected cts change to high"
333 #define ERR_40 0x00000040 , "unknown state"
334 #define ERR_80 0x00000080 , "overrun"
335 #define ERR_100 0x00000100 , "read forced"
336 #define ERR_200 0x00000200 , "unexpected receive data interrupt"
337 #define ERR_400 0x00000400 , "parity error"
338 #define ERR_800 0x00000800 , "unexpected receive data interrupt"
339 #define ERR_1000 0x00001000 , "exceed MAX_TEMT_WAIT"
340 #define ERR_2000 0x00002000 , "unexpected byte received"
341 #define ERR_4000 0x00004000 , "read forced && read buffer full"
342 #define ERR_8000 0x00008000 , "unexpected cts change"
343 #define ERR_10000 0x00010000 , "initate send with empty write buffer"
344 #define ERR_20000 0x00020000 , "bcu reset (info)"
345 #define ERR_40000 0x00040000 , "unexpected receive data interrupt"
346 #define ERR_80000 0x00080000 , "unexpected cts change to high"
347 #define ERR_100000 0x00100000 , "READ_WRITE_TIMEOUT"
348 #define ERR_200000 0x00200000 , "exceed MAX_TIME_BETWEEN_INT"
349 #define ERR_400000 0x00400000 , "clear write buffer"
350 #define ERR_800000 0x00800000 , "BCU reset"
351 #define ERR_10000000 0x10000000 , "INITIATESEND"
354 check_interrupt_pending (eib_protocol_data
* dev
)
356 switch (dev
->iface
->getserialint (dev
->dev
))
359 do_reset (dev
, ERR_40000
); // unexpected receive data interrupt
362 if (dev
->iface
->getCTS (dev
->dev
))
363 do_reset (dev
, ERR_80000
); // unexpected cts change to high
371 eib_handler (eib_protocol_data
* dev
, enum eib_reason reason
)
376 EIB_LOG ("Handler %d %d %d", reason
, dev
->state
,
377 dev
->iface
->getCTS (dev
->dev
));
380 { /* State machine state */
385 do_reset (dev
, ERR_2
); /* unexpected receive data interrupt */
388 if (dev
->iface
->getCTS (dev
->dev
))
390 if (dev
->initate_send
)
392 dev
->iface
->send (dev
->dev
, eib_writebuffer (dev
->cdev
)[0]);
393 dev
->initate_send
= 0;
401 add_detect_reset_timer (dev
);
402 if (eib_readbuffer_full (dev
->cdev
))
404 do_reset (dev
, ERR_10
); /* read buffer overflow */
408 getnstimeofday (&dev
->start_tv
);
409 dev
->iface
->setRTS (dev
->dev
);
410 dev
->iface
->send (dev
->dev
, 0xFF);
414 } // else !getCTS() -> state=0
421 do_reset (dev
, ERR_40
); /* unknown state */
432 do_reset (dev
, ERR_200
); // unexpected receive data interrupt
435 if (dev
->iface
->getCTS (dev
->dev
))
437 dev
->iface
->setRTS (dev
->dev
);
438 dev
->iface
->send (dev
->dev
, 0x00);
440 add_detect_reset_timer (dev
);
441 } // else !getCTS() -> state=1
448 do_reset (dev
, ERR_40
); /* unknown state */
459 tmp
= dev
->iface
->recv (dev
->dev
);
460 eib_readbuffer (dev
->cdev
)[dev
->read_pos
++] = tmp
;
461 if (dev
->iface
->overrun (dev
->dev
))
463 do_reset (dev
, ERR_80
); // overrun
466 if (tmp
== 0xA0 && dev
->read_pos
== 1)
468 eib_readbuffer (dev
->cdev
)[0] = 1;
469 eib_readbuffer (dev
->cdev
)[1] = tmp
;
470 eib_read_notify (dev
->cdev
);
471 do_reset (dev
, ERR_800000
); // BCU reset
475 if (tmp
== 0xFF && dev
->read_pos
== 1)
477 EIB_PRINT ("No data");
479 check_interrupt_pending (dev
);
480 dev
->iface
->clrRTS (dev
->dev
);
483 getnstimeofday (&dev
->last_int_tv
);
487 if (dev
->read_pos
== 1 && !(((tmp
& 0x60) == 0x20) &&
489 (bitcount (tmp
& 0x7f) % 2) * 0x80)))
491 do_reset (dev
, ERR_400
); // parity error
498 if (dev
->iface
->getCTS (dev
->dev
))
499 do_reset (dev
, ERR_20
); /* unexpected cts change to high */
506 do_reset (dev
, ERR_40
); /* unknown state */
517 do_reset (dev
, ERR_4
); /* unexpected receive data interrupt */
520 if (dev
->iface
->getCTS (dev
->dev
))
522 do_reset (dev
, ERR_8
); /* unexpected cts change to high */
525 if (dev
->read_pos
== (eib_readbuffer (dev
->cdev
)[0] & 0x1f) + 1)
528 if (eib_readbuffer (dev
->cdev
)[0] == 0xa0)
530 eib_readbuffer (dev
->cdev
)[0] = 1;
531 eib_readbuffer (dev
->cdev
)[0] = 0xa0;
532 eib_read_notify (dev
->cdev
);
533 EIB_PRINT ("BCU reset");
537 dev
->reset_count
= 0;
538 eib_readbuffer (dev
->cdev
)[0] &= 0x1f;
539 eib_read_notify (dev
->cdev
);
544 spin_lock_irqsave (&dev
->lock
, flags
);
546 if (!eib_writebuffer_empty (dev
->cdev
))
548 getnstimeofday (&dev
->send_tv
);
549 add_initate_send_timer (dev
);
555 spin_lock_irqsave (&dev
->lock
, flags
);
558 check_interrupt_pending (dev
);
559 dev
->iface
->clrRTS (dev
->dev
);
561 spin_unlock_irqrestore (&dev
->lock
, flags
);
563 getnstimeofday (&dev
->last_int_tv
);
580 do_reset (dev
, ERR_800
); /* unexpected receive data interrupt */
583 if (dev
->iface
->getCTS (dev
->dev
))
585 dev
->iface
->send (dev
->dev
,
586 eib_writebuffer (dev
->cdev
)[dev
->
589 add_detect_reset_timer (dev
);
590 } // else !getCTS() -> state=4
597 do_reset (dev
, ERR_40
); /* unknown state */
608 tmp
= dev
->iface
->recv (dev
->dev
);
612 if (dev
->iface
->overrun (dev
->dev
))
614 do_reset (dev
, ERR_80
); /* overun */
617 if (dev
->write_pos
== 1 && tmp
== 0xA0)
619 eib_readbuffer (dev
->cdev
)[1] = tmp
;
620 eib_readbuffer (dev
->cdev
)[0] = 1;
621 eib_read_notify (dev
->cdev
);
622 do_reset (dev
, ERR_800000
); // BCU reset
626 if (dev
->write_pos
== 1 && tmp
!= 0xff)
629 if (eib_readbuffer_full (dev
->cdev
))
631 do_reset (dev
, ERR_4000
); /* read forced && read buffer full */
636 if (((tmp
& 0x60) != 0x20) ||
637 ((tmp
& 0x80) != (bitcount (tmp
& 0x7f) % 2) * 0x80))
639 do_reset (dev
, ERR_400
); /* parity error */
643 eib_readbuffer (dev
->cdev
)[dev
->read_pos
++] = tmp
;
648 if (dev
->write_pos
> 1 && tmp
!= 0x00)
650 do_reset (dev
, ERR_2000
); /* unexpect byte received */
653 add_write_timer (dev
, MAX_TEMT_WAIT
+ WRITE_TEMT_CLRRTS_DELAY
);
656 do_reset (dev
, ERR_8000
); /* unexpected cts change */
663 do_reset (dev
, ERR_40
); /* unknown state */
674 do_reset (dev
, ERR_4
); /* unexpected receive data interrupt */
677 if (dev
->iface
->getCTS (dev
->dev
))
678 do_reset (dev
, ERR_8
); /* unexpected cts change to high */
685 if (!dev
->iface
->send_finished (dev
->dev
))
687 do_reset (dev
, ERR_1000
); // exceed MAX_TEMT_WAIT
691 if (dev
->write_pos
== (eib_writebuffer (dev
->cdev
)[0] & 0x1f) + 1)
693 dev
->reset_count
= 0;
694 eib_write_finish (dev
->cdev
, 1);
697 if (!eib_writebuffer_empty (dev
->cdev
))
699 getnstimeofday (&dev
->send_tv
);
700 add_initate_send_timer (dev
);
703 spin_lock_irqsave (&dev
->lock
, flags
);
708 check_interrupt_pending (dev
);
709 dev
->iface
->clrRTS (dev
->dev
);
710 spin_unlock_irqrestore (&dev
->lock
, flags
);
714 check_interrupt_pending (dev
);
716 dev
->iface
->clrRTS (dev
->dev
);
718 spin_lock_irqsave (&dev
->lock
, flags
);
720 add_write_timer (dev
, WRITE_CLRRTS_SETRTS_DELAY
);
721 spin_unlock_irqrestore (&dev
->lock
, flags
);
724 getnstimeofday (&dev
->last_int_tv
);
735 dev
->iface
->recv (dev
->dev
);
738 dev
->iface
->getCTS (dev
->dev
);
755 do_reset (dev
, ERR_4
); /* unexpected receive data interrupt */
758 if (dev
->iface
->getCTS (dev
->dev
))
759 do_reset (dev
, ERR_8
); /* unexpected cts change to high */
760 stop_eib_timer (&dev
->write_timer
);
769 spin_lock_irqsave (&dev
->lock
, flags
);
773 dev
->iface
->setRTS (dev
->dev
);
774 check_interrupt_pending (dev
);
775 spin_unlock_irqrestore (&dev
->lock
, flags
);
777 getnstimeofday (&dev
->last_int_tv
);
785 do_reset (dev
, ERR_40
); // unknown state
790 write_timer (eib_timer
* timer
)
792 eib_protocol_data
*proto
=
793 container_of (timer
, eib_protocol_data
, write_timer
);
795 eib_handler (proto
, EIB_TIME_WRITE
);
799 detect_reset_timer (eib_timer
* timer
)
801 eib_protocol_data
*dev
=
802 container_of (timer
, eib_protocol_data
, detect_reset_timer
);
805 spin_lock_irqsave (&dev
->lock
, flags
);
807 EIB_LOG ("detect_reset %d %d", dev
->state
, dev
->iface
->getCTS (dev
->dev
));
809 if (dev
->state
== 0 && !dev
->initate_send
&& !dev
->iface
->getCTS (dev
->dev
))
812 spin_unlock_irqrestore (&dev
->lock
, flags
);
816 else if (dev
->state
== 7)
818 if (time_difference (&dev
->reset_tv
, NULL
) > MIN_RESET_WAIT_TIME
)
820 getnstimeofday (&dev
->last_int_tv
);
821 if (!eib_writebuffer_empty (dev
->cdev
) && dev
->reset_count
> 10)
823 dev
->reset_count
= 0;
824 EIB_PRINT ("discard packet");
825 eib_write_finish (dev
->cdev
, -1);
827 if (!eib_writebuffer_empty (dev
->cdev
))
829 getnstimeofday (&dev
->send_tv
);
830 add_initate_send_timer (dev
);
836 spin_unlock_irqrestore (&dev
->lock
, flags
);
843 if (time_difference (&dev
->start_tv
, NULL
) > READ_WRITE_TIMEOUT
)
844 do_reset (dev
, ERR_100000
); // read write timeout
845 else if (time_difference (&dev
->last_int_tv
, NULL
) >
846 MAX_TIME_BETWEEN_INT
)
847 do_reset (dev
, ERR_200000
); // max time between int exceeded
849 add_detect_reset_timer (dev
);
851 spin_unlock_irqrestore (&dev
->lock
, flags
);
855 initate_send_timer (eib_timer
* timer
)
857 eib_protocol_data
*dev
=
858 container_of (timer
, eib_protocol_data
, initate_send_timer
);
861 EIB_LOG ("Initiate_Send %d %d", dev
->state
, dev
->iface
->getCTS (dev
->dev
));
863 if (eib_writebuffer_empty (dev
->cdev
))
865 EIB_PRINT ("initate send with empty buffer");
869 spin_lock_irqsave (&dev
->lock
, flags
);
871 if (dev
->state
== 0 && !dev
->iface
->getCTS (dev
->dev
) &&
872 time_difference (&dev
->last_int_tv
, NULL
) > MAX_INIT_SEND_TIME
)
875 dev
->initate_send
= 1;
876 getnstimeofday (&dev
->start_tv
);
877 getnstimeofday (&dev
->last_int_tv
);
879 dev
->iface
->setRTS (dev
->dev
);
880 add_detect_reset_timer (dev
);
882 spin_unlock_irqrestore (&dev
->lock
, flags
);
886 if (time_difference (&dev
->send_tv
, NULL
) > MAX_INIT_SEND_TIMEOUT
)
888 EIB_PRINT ("timeout initiate send");
890 do_reset (dev
, ERR_10000000
);
891 add_detect_reset_timer (dev
);
893 spin_unlock_irqrestore (&dev
->lock
, flags
);
898 add_initate_send_timer (dev
);
900 spin_unlock_irqrestore (&dev
->lock
, flags
);
904 bcu_interrupt_handler (void *data
, enum eib_reason reason
)
906 eib_protocol_data
*dev
= (eib_protocol_data
*) data
;
908 eib_handler (dev
, reason
);
910 if (dev
->state
!= 0 && dev
->state
!= 7 &&
911 time_difference (&dev
->start_tv
, NULL
) > READ_WRITE_TIMEOUT
)
912 do_reset (dev
, ERR_100000
); /* read write timeout */
914 getnstimeofday (&dev
->last_int_tv
);
918 eib_write_prepare (eib_protocol_data
* proto
, eib_buffer buf
, int len
)
927 temp
= (len
& 0x1f) | 0x20;
928 buf
[0] = temp
| (bitcount (temp
) % 2) * 0x80;
933 eib_write_start (eib_protocol_data
* proto
)
936 spin_lock_irqsave (&proto
->lock
, flags
);
937 getnstimeofday (&proto
->send_tv
);
938 add_initate_send_timer (proto
);
940 spin_unlock_irqrestore (&proto
->lock
, flags
);
943 #define EIB_BCU_VERSION 1 /* eib bcu version */
946 eib_proto_ioctl (eib_protocol_data
* dev
, unsigned int cmd
, unsigned long arg
)
951 case EIB_GET_BCU_VERSION
:
952 return EIB_BCU_VERSION
;
954 case EIB_GET_DEVICE_INFORMATION
:
957 case EIB_RESET_DEVICE_STATISTIC
:
960 case EIB_CLEAR_WRITE_BUFFER
:
961 eib_writebuffer_clear (dev
->cdev
);
963 stop_eib_timer (&dev
->initate_send_timer
);
964 add_detect_reset_timer (dev
);
965 dev
->initate_send
= 0;
966 do_reset (dev
, ERR_400000
);
970 case EIB_CLEAR_READ_BUFFER
:
971 eib_readbuffer_clear (dev
->cdev
);
973 stop_eib_timer (&dev
->initate_send_timer
);
974 add_detect_reset_timer (dev
);
975 do_reset (dev
, ERR_400000
);
979 case EIB_SINGLE_OPEN
:
989 static eib_protocol_data
*
990 eib_proto_create (int minor
, eib_chardev
* cdev
)
992 eib_protocol_data
*dev
;
996 EIB_PRINT ("open serial %d", minor
);
997 dev
= (void *) kmalloc (sizeof (eib_protocol_data
), GFP_KERNEL
);
999 return ERR_PTR (-ENOMEM
);
1001 memset (dev
, 0, sizeof (eib_protocol_data
));
1003 spin_lock_init (&dev
->lock
);
1007 eib_port_create (minor
, "eib", bcu_interrupt_handler
, dev
, &dev
->iface
);
1008 if (IS_ERR (dev
->dev
))
1010 retval
= PTR_ERR (dev
->dev
);
1014 spin_lock_irqsave (&dev
->lock
, flags
);
1015 init_eib_timer (&dev
->initate_send_timer
, initate_send_timer
);
1016 init_eib_timer (&dev
->detect_reset_timer
, detect_reset_timer
);
1017 init_eib_timer (&dev
->write_timer
, write_timer
);
1024 dev
->initate_send
= 0;
1025 dev
->reset_count
= 0;
1026 getnstimeofday (&dev
->last_int_tv
);
1028 dev
->iface
->open_port (dev
->dev
);
1029 spin_unlock_irqrestore (&dev
->lock
, flags
);
1031 EIB_PRINT ("resouces allocated %d", dev
->minor
);
1036 return ERR_PTR (retval
);
1040 eib_proto_shutdown (eib_protocol_data
* dev
)
1042 PDEBUG ("close %d", dev
->minor
);
1047 eib_proto_free (eib_protocol_data
* dev
)
1049 unsigned long flags
;
1050 spin_lock_irqsave (&dev
->lock
, flags
);
1051 dev
->iface
->close_port (dev
->dev
);
1052 dev
->iface
->free_serial (dev
->dev
);
1054 destroy_eib_timer (&dev
->initate_send_timer
);
1055 destroy_eib_timer (&dev
->write_timer
);
1056 destroy_eib_timer (&dev
->detect_reset_timer
);
1058 spin_unlock_irqrestore (&dev
->lock
, flags
);
1060 PDEBUG ("closed %d", dev
->minor
);
1063 static eib_protocol_ops eib_proto_ops
= {
1064 .write_prepare
= eib_write_prepare
,
1065 .write_start
= eib_write_start
,
1066 .ioctl
= eib_proto_ioctl
,
1067 .shutdown
= eib_proto_shutdown
,
1068 .free
= eib_proto_free
,
1069 .create
= eib_proto_create
,
1070 .owner
= THIS_MODULE
,
1074 eib_pei16_init (void)
1078 retval
= eib_driver_register ("eib", eib_major
, &eib_proto_ops
);
1082 EIB_PRINT ("pei16 driver loaded (%d)", eib_major
);
1088 eib_pei16_cleanup (void)
1090 eib_driver_unregister ("eib");
1091 EIB_PRINT ("pei16 driver successfully unloaded!\n");
1094 module_init (eib_pei16_init
);
1095 module_exit (eib_pei16_cleanup
);