2 * LIRC SIR driver, (C) 2000 Milan Pikula <www@fornax.sk>
4 * lirc_sir - Device driver for use with SIR (serial infra red)
5 * mode of IrDA on many notebooks.
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * 2000/09/16 Frank Przybylski <mail@frankprzybylski.de> :
23 * added timeout and relaxed pulse detection, removed gap bug
25 * 2000/12/15 Christoph Bartelmus <lirc@bartelmus.de> :
26 * added support for Tekram Irmate 210 (sending does not work yet,
27 * kind of disappointing that nobody was able to implement that
31 * 2001/02/27 Christoph Bartelmus <lirc@bartelmus.de> :
32 * added support for StrongARM SA1100 embedded microprocessor
33 * parts cut'n'pasted from sa1100_ir.c (C) 2000 Russell King
36 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
38 #include <linux/module.h>
39 #include <linux/sched.h>
40 #include <linux/errno.h>
41 #include <linux/signal.h>
43 #include <linux/interrupt.h>
44 #include <linux/ioport.h>
45 #include <linux/kernel.h>
46 #include <linux/serial_reg.h>
47 #include <linux/time.h>
48 #include <linux/string.h>
49 #include <linux/types.h>
50 #include <linux/wait.h>
52 #include <linux/delay.h>
53 #include <linux/poll.h>
56 #include <linux/fcntl.h>
57 #include <linux/platform_device.h>
59 #include <linux/timer.h>
61 #include <media/lirc.h>
62 #include <media/lirc_dev.h>
64 /* SECTION: Definitions */
66 /*** Tekram dongle ***/
67 #ifdef LIRC_SIR_TEKRAM
68 /* stolen from kernel source */
69 /* definitions for Tekram dongle */
70 #define TEKRAM_115200 0x00
71 #define TEKRAM_57600 0x01
72 #define TEKRAM_38400 0x02
73 #define TEKRAM_19200 0x03
74 #define TEKRAM_9600 0x04
75 #define TEKRAM_2400 0x08
77 #define TEKRAM_PW 0x10 /* Pulse select bit */
79 /* 10bit * 1s/115200bit in milliseconds = 87ms*/
80 #define TIME_CONST (10000000ul/115200ul)
84 #ifdef LIRC_SIR_ACTISYS_ACT200L
85 static void init_act200(void);
86 #elif defined(LIRC_SIR_ACTISYS_ACT220L)
87 static void init_act220(void);
93 #define LIRC_DRIVER_NAME "lirc_sir"
97 #ifndef LIRC_SIR_TEKRAM
98 /* 9bit * 1s/115200bit in milli seconds = 78.125ms*/
99 #define TIME_CONST (9000000ul/115200ul)
103 /* timeout for sequences in jiffies (=5/100s), must be longer than TIME_CONST */
104 #define SIR_TIMEOUT (HZ*5/100)
106 #ifndef LIRC_ON_SA1100
111 /* for external dongles, default to com1 */
112 #if defined(LIRC_SIR_ACTISYS_ACT200L) || \
113 defined(LIRC_SIR_ACTISYS_ACT220L) || \
114 defined(LIRC_SIR_TEKRAM)
115 #define LIRC_PORT 0x3f8
117 /* onboard sir ports are typically com3 */
118 #define LIRC_PORT 0x3e8
122 static int io
= LIRC_PORT
;
123 static int irq
= LIRC_IRQ
;
124 static int threshold
= 3;
127 static DEFINE_SPINLOCK(timer_lock
);
128 static struct timer_list timerlist
;
129 /* time of last signal change detected */
130 static struct timeval last_tv
= {0, 0};
131 /* time of last UART data ready interrupt */
132 static struct timeval last_intr_tv
= {0, 0};
133 static int last_value
;
135 static DECLARE_WAIT_QUEUE_HEAD(lirc_read_queue
);
137 static DEFINE_SPINLOCK(hardware_lock
);
139 static int rx_buf
[RBUF_LEN
];
140 static unsigned int rx_tail
, rx_head
;
144 /* SECTION: Prototypes */
146 /* Communication with user-space */
147 static unsigned int lirc_poll(struct file
*file
, poll_table
*wait
);
148 static ssize_t
lirc_read(struct file
*file
, char __user
*buf
, size_t count
,
150 static ssize_t
lirc_write(struct file
*file
, const char __user
*buf
, size_t n
,
152 static long lirc_ioctl(struct file
*filep
, unsigned int cmd
, unsigned long arg
);
153 static void add_read_queue(int flag
, unsigned long val
);
154 static int init_chrdev(void);
155 static void drop_chrdev(void);
157 static irqreturn_t
sir_interrupt(int irq
, void *dev_id
);
158 static void send_space(unsigned long len
);
159 static void send_pulse(unsigned long len
);
160 static int init_hardware(void);
161 static void drop_hardware(void);
163 static int init_port(void);
164 static void drop_port(void);
166 static inline unsigned int sinp(int offset
)
168 return inb(io
+ offset
);
171 static inline void soutp(int offset
, int value
)
173 outb(value
, io
+ offset
);
176 #ifndef MAX_UDELAY_MS
177 #define MAX_UDELAY_US 5000
179 #define MAX_UDELAY_US (MAX_UDELAY_MS*1000)
182 static void safe_udelay(unsigned long usecs
)
184 while (usecs
> MAX_UDELAY_US
) {
185 udelay(MAX_UDELAY_US
);
186 usecs
-= MAX_UDELAY_US
;
191 /* SECTION: Communication with user-space */
193 static unsigned int lirc_poll(struct file
*file
, poll_table
*wait
)
195 poll_wait(file
, &lirc_read_queue
, wait
);
196 if (rx_head
!= rx_tail
)
197 return POLLIN
| POLLRDNORM
;
201 static ssize_t
lirc_read(struct file
*file
, char __user
*buf
, size_t count
,
206 DECLARE_WAITQUEUE(wait
, current
);
208 if (count
% sizeof(int))
211 add_wait_queue(&lirc_read_queue
, &wait
);
212 set_current_state(TASK_INTERRUPTIBLE
);
214 if (rx_head
!= rx_tail
) {
215 if (copy_to_user(buf
+ n
,
221 rx_head
= (rx_head
+ 1) & (RBUF_LEN
- 1);
224 if (file
->f_flags
& O_NONBLOCK
) {
228 if (signal_pending(current
)) {
229 retval
= -ERESTARTSYS
;
233 set_current_state(TASK_INTERRUPTIBLE
);
236 remove_wait_queue(&lirc_read_queue
, &wait
);
237 set_current_state(TASK_RUNNING
);
238 return n
? n
: retval
;
240 static ssize_t
lirc_write(struct file
*file
, const char __user
*buf
, size_t n
,
247 count
= n
/ sizeof(int);
248 if (n
% sizeof(int) || count
% 2 == 0)
250 tx_buf
= memdup_user(buf
, n
);
252 return PTR_ERR(tx_buf
);
254 local_irq_save(flags
);
259 send_pulse(tx_buf
[i
]);
264 send_space(tx_buf
[i
]);
267 local_irq_restore(flags
);
272 static long lirc_ioctl(struct file
*filep
, unsigned int cmd
, unsigned long arg
)
274 u32 __user
*uptr
= (u32 __user
*)arg
;
278 if (cmd
== LIRC_GET_FEATURES
)
279 value
= LIRC_CAN_SEND_PULSE
| LIRC_CAN_REC_MODE2
;
280 else if (cmd
== LIRC_GET_SEND_MODE
)
281 value
= LIRC_MODE_PULSE
;
282 else if (cmd
== LIRC_GET_REC_MODE
)
283 value
= LIRC_MODE_MODE2
;
286 case LIRC_GET_FEATURES
:
287 case LIRC_GET_SEND_MODE
:
288 case LIRC_GET_REC_MODE
:
289 retval
= put_user(value
, uptr
);
292 case LIRC_SET_SEND_MODE
:
293 case LIRC_SET_REC_MODE
:
294 retval
= get_user(value
, uptr
);
297 retval
= -ENOIOCTLCMD
;
303 if (cmd
== LIRC_SET_REC_MODE
) {
304 if (value
!= LIRC_MODE_MODE2
)
306 } else if (cmd
== LIRC_SET_SEND_MODE
) {
307 if (value
!= LIRC_MODE_PULSE
)
314 static void add_read_queue(int flag
, unsigned long val
)
316 unsigned int new_rx_tail
;
319 pr_debug("add flag %d with val %lu\n", flag
, val
);
321 newval
= val
& PULSE_MASK
;
324 * statistically, pulses are ~TIME_CONST/2 too long. we could
325 * maybe make this more exact, but this is good enough
329 if (newval
> TIME_CONST
/2)
330 newval
-= TIME_CONST
/2;
331 else /* should not ever happen */
335 newval
+= TIME_CONST
/2;
337 new_rx_tail
= (rx_tail
+ 1) & (RBUF_LEN
- 1);
338 if (new_rx_tail
== rx_head
) {
339 pr_debug("Buffer overrun.\n");
342 rx_buf
[rx_tail
] = newval
;
343 rx_tail
= new_rx_tail
;
344 wake_up_interruptible(&lirc_read_queue
);
347 static const struct file_operations lirc_fops
= {
348 .owner
= THIS_MODULE
,
352 .unlocked_ioctl
= lirc_ioctl
,
354 .compat_ioctl
= lirc_ioctl
,
356 .open
= lirc_dev_fop_open
,
357 .release
= lirc_dev_fop_close
,
361 static int set_use_inc(void *data
)
366 static void set_use_dec(void *data
)
370 static struct lirc_driver driver
= {
371 .name
= LIRC_DRIVER_NAME
,
377 .set_use_inc
= set_use_inc
,
378 .set_use_dec
= set_use_dec
,
381 .owner
= THIS_MODULE
,
384 static struct platform_device
*lirc_sir_dev
;
386 static int init_chrdev(void)
388 driver
.dev
= &lirc_sir_dev
->dev
;
389 driver
.minor
= lirc_register_driver(&driver
);
390 if (driver
.minor
< 0) {
391 pr_err("init_chrdev() failed.\n");
397 static void drop_chrdev(void)
399 lirc_unregister_driver(driver
.minor
);
402 /* SECTION: Hardware */
403 static long delta(struct timeval
*tv1
, struct timeval
*tv2
)
407 deltv
= tv2
->tv_sec
- tv1
->tv_sec
;
411 deltv
= deltv
*1000000 +
417 static void sir_timeout(unsigned long data
)
420 * if last received signal was a pulse, but receiving stopped
421 * within the 9 bit frame, we need to finish this pulse and
422 * simulate a signal change to from pulse to space. Otherwise
423 * upper layers will receive two sequences next time.
427 unsigned long pulse_end
;
429 /* avoid interference with interrupt */
430 spin_lock_irqsave(&timer_lock
, flags
);
432 /* clear unread bits in UART and restart */
433 outb(UART_FCR_CLEAR_RCVR
, io
+ UART_FCR
);
434 /* determine 'virtual' pulse end: */
435 pulse_end
= delta(&last_tv
, &last_intr_tv
);
436 dev_dbg(driver
.dev
, "timeout add %d for %lu usec\n",
437 last_value
, pulse_end
);
438 add_read_queue(last_value
, pulse_end
);
440 last_tv
= last_intr_tv
;
442 spin_unlock_irqrestore(&timer_lock
, flags
);
445 static irqreturn_t
sir_interrupt(int irq
, void *dev_id
)
448 struct timeval curr_tv
;
449 static unsigned long deltv
;
450 unsigned long deltintrtv
;
454 while ((iir
= inb(io
+ UART_IIR
) & UART_IIR_ID
)) {
455 switch (iir
&UART_IIR_ID
) { /* FIXME toto treba preriedit */
457 (void) inb(io
+ UART_MSR
);
460 (void) inb(io
+ UART_LSR
);
464 if (lsr
& UART_LSR_THRE
) /* FIFO is empty */
465 outb(data
, io
+ UART_TX
)
469 /* avoid interference with timer */
470 spin_lock_irqsave(&timer_lock
, flags
);
472 del_timer(&timerlist
);
473 data
= inb(io
+ UART_RX
);
474 do_gettimeofday(&curr_tv
);
475 deltv
= delta(&last_tv
, &curr_tv
);
476 deltintrtv
= delta(&last_intr_tv
, &curr_tv
);
477 dev_dbg(driver
.dev
, "t %lu, d %d\n",
478 deltintrtv
, (int)data
);
480 * if nothing came in last X cycles,
483 if (deltintrtv
> TIME_CONST
* threshold
) {
485 dev_dbg(driver
.dev
, "GAP\n");
486 /* simulate signal change */
487 add_read_queue(last_value
,
494 last_intr_tv
.tv_usec
;
499 if (data
^ last_value
) {
501 * deltintrtv > 2*TIME_CONST, remember?
502 * the other case is timeout
504 add_read_queue(last_value
,
508 if (last_tv
.tv_usec
>= TIME_CONST
) {
509 last_tv
.tv_usec
-= TIME_CONST
;
512 last_tv
.tv_usec
+= 1000000 -
516 last_intr_tv
= curr_tv
;
519 * start timer for end of
522 timerlist
.expires
= jiffies
+
524 add_timer(&timerlist
);
527 lsr
= inb(io
+ UART_LSR
);
528 } while (lsr
& UART_LSR_DR
); /* data ready */
529 spin_unlock_irqrestore(&timer_lock
, flags
);
535 return IRQ_RETVAL(IRQ_HANDLED
);
538 static void send_space(unsigned long len
)
543 static void send_pulse(unsigned long len
)
545 long bytes_out
= len
/ TIME_CONST
;
550 while (bytes_out
--) {
551 outb(PULSE
, io
+ UART_TX
);
552 /* FIXME treba seriozne cakanie z char/serial.c */
553 while (!(inb(io
+ UART_LSR
) & UART_LSR_THRE
))
558 static int init_hardware(void)
562 spin_lock_irqsave(&hardware_lock
, flags
);
564 #if defined(LIRC_SIR_TEKRAM)
572 soutp(UART_LCR
, sinp(UART_LCR
) & (~UART_LCR_DLAB
));
574 /* First of all, disable all interrupts */
575 soutp(UART_IER
, sinp(UART_IER
) &
576 (~(UART_IER_MSI
|UART_IER_RLSI
|UART_IER_THRI
|UART_IER_RDI
)));
579 soutp(UART_LCR
, sinp(UART_LCR
) | UART_LCR_DLAB
);
581 /* Set divisor to 12 => 9600 Baud */
586 soutp(UART_LCR
, sinp(UART_LCR
) & (~UART_LCR_DLAB
));
589 soutp(UART_MCR
, UART_MCR_RTS
|UART_MCR_DTR
|UART_MCR_OUT2
);
590 safe_udelay(50*1000);
592 /* -DTR low -> reset PIC */
593 soutp(UART_MCR
, UART_MCR_RTS
|UART_MCR_OUT2
);
596 soutp(UART_MCR
, UART_MCR_RTS
|UART_MCR_DTR
|UART_MCR_OUT2
);
600 /* -RTS low -> send control byte */
601 soutp(UART_MCR
, UART_MCR_DTR
|UART_MCR_OUT2
);
603 soutp(UART_TX
, TEKRAM_115200
|TEKRAM_PW
);
605 /* one byte takes ~1042 usec to transmit at 9600,8N1 */
608 /* back to normal operation */
609 soutp(UART_MCR
, UART_MCR_RTS
|UART_MCR_DTR
|UART_MCR_OUT2
);
614 /* read previous control byte */
615 pr_info("0x%02x\n", sinp(UART_RX
));
618 soutp(UART_LCR
, sinp(UART_LCR
) | UART_LCR_DLAB
);
620 /* Set divisor to 1 => 115200 Baud */
624 /* Set DLAB 0, 8 Bit */
625 soutp(UART_LCR
, UART_LCR_WLEN8
);
626 /* enable interrupts */
627 soutp(UART_IER
, sinp(UART_IER
)|UART_IER_RDI
);
629 outb(0, io
+ UART_MCR
);
630 outb(0, io
+ UART_IER
);
632 /* set DLAB, speed = 115200 */
633 outb(UART_LCR_DLAB
| UART_LCR_WLEN7
, io
+ UART_LCR
);
634 outb(1, io
+ UART_DLL
); outb(0, io
+ UART_DLM
);
635 /* 7N1+start = 9 bits at 115200 ~ 3 bits at 44000 */
636 outb(UART_LCR_WLEN7
, io
+ UART_LCR
);
638 outb(UART_FCR_ENABLE_FIFO
, io
+ UART_FCR
);
640 /* outb(UART_IER_RLSI|UART_IER_RDI|UART_IER_THRI, io + UART_IER); */
641 outb(UART_IER_RDI
, io
+ UART_IER
);
643 outb(UART_MCR_DTR
|UART_MCR_RTS
|UART_MCR_OUT2
, io
+ UART_MCR
);
644 #ifdef LIRC_SIR_ACTISYS_ACT200L
646 #elif defined(LIRC_SIR_ACTISYS_ACT220L)
650 spin_unlock_irqrestore(&hardware_lock
, flags
);
654 static void drop_hardware(void)
658 spin_lock_irqsave(&hardware_lock
, flags
);
660 /* turn off interrupts */
661 outb(0, io
+ UART_IER
);
663 spin_unlock_irqrestore(&hardware_lock
, flags
);
666 /* SECTION: Initialisation */
668 static int init_port(void)
672 /* get I/O port access and IRQ line */
673 if (request_region(io
, 8, LIRC_DRIVER_NAME
) == NULL
) {
674 pr_err("i/o port 0x%.4x already in use.\n", io
);
677 retval
= request_irq(irq
, sir_interrupt
, 0,
678 LIRC_DRIVER_NAME
, NULL
);
680 release_region(io
, 8);
681 pr_err("IRQ %d already in use.\n", irq
);
684 pr_info("I/O port 0x%.4x, IRQ %d.\n", io
, irq
);
686 setup_timer(&timerlist
, sir_timeout
, 0);
691 static void drop_port(void)
694 del_timer_sync(&timerlist
);
695 release_region(io
, 8);
698 #ifdef LIRC_SIR_ACTISYS_ACT200L
699 /* Crystal/Cirrus CS8130 IR transceiver, used in Actisys Act200L dongle */
700 /* some code borrowed from Linux IRDA driver */
702 /* Register 0: Control register #1 */
703 #define ACT200L_REG0 0x00
704 #define ACT200L_TXEN 0x01 /* Enable transmitter */
705 #define ACT200L_RXEN 0x02 /* Enable receiver */
706 #define ACT200L_ECHO 0x08 /* Echo control chars */
708 /* Register 1: Control register #2 */
709 #define ACT200L_REG1 0x10
710 #define ACT200L_LODB 0x01 /* Load new baud rate count value */
711 #define ACT200L_WIDE 0x04 /* Expand the maximum allowable pulse */
713 /* Register 3: Transmit mode register #2 */
714 #define ACT200L_REG3 0x30
715 #define ACT200L_B0 0x01 /* DataBits, 0=6, 1=7, 2=8, 3=9(8P) */
716 #define ACT200L_B1 0x02 /* DataBits, 0=6, 1=7, 2=8, 3=9(8P) */
717 #define ACT200L_CHSY 0x04 /* StartBit Synced 0=bittime, 1=startbit */
719 /* Register 4: Output Power register */
720 #define ACT200L_REG4 0x40
721 #define ACT200L_OP0 0x01 /* Enable LED1C output */
722 #define ACT200L_OP1 0x02 /* Enable LED2C output */
723 #define ACT200L_BLKR 0x04
725 /* Register 5: Receive Mode register */
726 #define ACT200L_REG5 0x50
727 #define ACT200L_RWIDL 0x01 /* fixed 1.6us pulse mode */
728 /*.. other various IRDA bit modes, and TV remote modes..*/
730 /* Register 6: Receive Sensitivity register #1 */
731 #define ACT200L_REG6 0x60
732 #define ACT200L_RS0 0x01 /* receive threshold bit 0 */
733 #define ACT200L_RS1 0x02 /* receive threshold bit 1 */
735 /* Register 7: Receive Sensitivity register #2 */
736 #define ACT200L_REG7 0x70
737 #define ACT200L_ENPOS 0x04 /* Ignore the falling edge */
739 /* Register 8,9: Baud Rate Divider register #1,#2 */
740 #define ACT200L_REG8 0x80
741 #define ACT200L_REG9 0x90
743 #define ACT200L_2400 0x5f
744 #define ACT200L_9600 0x17
745 #define ACT200L_19200 0x0b
746 #define ACT200L_38400 0x05
747 #define ACT200L_57600 0x03
748 #define ACT200L_115200 0x01
750 /* Register 13: Control register #3 */
751 #define ACT200L_REG13 0xd0
752 #define ACT200L_SHDW 0x01 /* Enable access to shadow registers */
754 /* Register 15: Status register */
755 #define ACT200L_REG15 0xf0
757 /* Register 21: Control register #4 */
758 #define ACT200L_REG21 0x50
759 #define ACT200L_EXCK 0x02 /* Disable clock output driver */
760 #define ACT200L_OSCL 0x04 /* oscillator in low power, medium accuracy mode */
762 static void init_act200(void)
767 ACT200L_REG13
| ACT200L_SHDW
,
768 ACT200L_REG21
| ACT200L_EXCK
| ACT200L_OSCL
,
770 ACT200L_REG7
| ACT200L_ENPOS
,
771 ACT200L_REG6
| ACT200L_RS0
| ACT200L_RS1
,
772 ACT200L_REG5
| ACT200L_RWIDL
,
773 ACT200L_REG4
| ACT200L_OP0
| ACT200L_OP1
| ACT200L_BLKR
,
774 ACT200L_REG3
| ACT200L_B0
,
775 ACT200L_REG0
| ACT200L_TXEN
| ACT200L_RXEN
,
776 ACT200L_REG8
| (ACT200L_115200
& 0x0f),
777 ACT200L_REG9
| ((ACT200L_115200
>> 4) & 0x0f),
778 ACT200L_REG1
| ACT200L_LODB
| ACT200L_WIDE
782 soutp(UART_LCR
, UART_LCR_DLAB
| UART_LCR_WLEN8
);
784 /* Set divisor to 12 => 9600 Baud */
789 soutp(UART_LCR
, UART_LCR_WLEN8
);
790 /* Set divisor to 12 => 9600 Baud */
793 soutp(UART_MCR
, UART_MCR_RTS
|UART_MCR_DTR
|UART_MCR_OUT2
);
794 for (i
= 0; i
< 50; i
++)
797 /* Reset the dongle : set RTS low for 25 ms */
798 soutp(UART_MCR
, UART_MCR_DTR
|UART_MCR_OUT2
);
799 for (i
= 0; i
< 25; i
++)
802 soutp(UART_MCR
, UART_MCR_RTS
|UART_MCR_DTR
|UART_MCR_OUT2
);
805 /* Clear DTR and set RTS to enter command mode */
806 soutp(UART_MCR
, UART_MCR_RTS
|UART_MCR_OUT2
);
809 /* send out the control register settings for 115K 7N1 SIR operation */
810 for (i
= 0; i
< sizeof(control
); i
++) {
811 soutp(UART_TX
, control
[i
]);
812 /* one byte takes ~1042 usec to transmit at 9600,8N1 */
816 /* back to normal operation */
817 soutp(UART_MCR
, UART_MCR_RTS
|UART_MCR_DTR
|UART_MCR_OUT2
);
821 soutp(UART_LCR
, sinp(UART_LCR
) | UART_LCR_DLAB
);
824 soutp(UART_LCR
, UART_LCR_DLAB
| UART_LCR_WLEN7
);
826 /* Set divisor to 1 => 115200 Baud */
831 soutp(UART_LCR
, sinp(UART_LCR
) & (~UART_LCR_DLAB
));
833 /* Set DLAB 0, 7 Bit */
834 soutp(UART_LCR
, UART_LCR_WLEN7
);
836 /* enable interrupts */
837 soutp(UART_IER
, sinp(UART_IER
)|UART_IER_RDI
);
841 #ifdef LIRC_SIR_ACTISYS_ACT220L
843 * Derived from linux IrDA driver (net/irda/actisys.c)
844 * Drop me a mail for any kind of comment: maxx@spaceboyz.net
847 void init_act220(void)
852 soutp(UART_LCR
, UART_LCR_DLAB
|UART_LCR_WLEN7
);
859 soutp(UART_LCR
, UART_LCR_WLEN7
);
861 /* reset the dongle, set DTR low for 10us */
862 soutp(UART_MCR
, UART_MCR_RTS
|UART_MCR_OUT2
);
865 /* back to normal (still 9600) */
866 soutp(UART_MCR
, UART_MCR_DTR
|UART_MCR_RTS
|UART_MCR_OUT2
);
869 * send RTS pulses until we reach 115200
870 * i hope this is really the same for act220l/act220l+
872 for (i
= 0; i
< 3; i
++) {
874 /* set RTS low for 10 us */
875 soutp(UART_MCR
, UART_MCR_DTR
|UART_MCR_OUT2
);
877 /* set RTS high for 10 us */
878 soutp(UART_MCR
, UART_MCR_RTS
|UART_MCR_DTR
|UART_MCR_OUT2
);
881 /* back to normal operation */
882 udelay(1500); /* better safe than sorry ;) */
885 soutp(UART_LCR
, UART_LCR_DLAB
| UART_LCR_WLEN7
);
887 /* Set divisor to 1 => 115200 Baud */
891 /* Set DLAB 0, 7 Bit */
892 /* The dongle doesn't seem to have any problems with operation at 7N1 */
893 soutp(UART_LCR
, UART_LCR_WLEN7
);
895 /* enable interrupts */
896 soutp(UART_IER
, UART_IER_RDI
);
900 static int init_lirc_sir(void)
904 init_waitqueue_head(&lirc_read_queue
);
905 retval
= init_port();
909 pr_info("Installed.\n");
913 static int lirc_sir_probe(struct platform_device
*dev
)
918 static int lirc_sir_remove(struct platform_device
*dev
)
923 static struct platform_driver lirc_sir_driver
= {
924 .probe
= lirc_sir_probe
,
925 .remove
= lirc_sir_remove
,
931 static int __init
lirc_sir_init(void)
935 retval
= platform_driver_register(&lirc_sir_driver
);
937 pr_err("Platform driver register failed!\n");
941 lirc_sir_dev
= platform_device_alloc("lirc_dev", 0);
943 pr_err("Platform device alloc failed!\n");
945 goto pdev_alloc_fail
;
948 retval
= platform_device_add(lirc_sir_dev
);
950 pr_err("Platform device add failed!\n");
955 retval
= init_chrdev();
959 retval
= init_lirc_sir();
968 platform_device_del(lirc_sir_dev
);
970 platform_device_put(lirc_sir_dev
);
972 platform_driver_unregister(&lirc_sir_driver
);
976 static void __exit
lirc_sir_exit(void)
981 platform_device_unregister(lirc_sir_dev
);
982 platform_driver_unregister(&lirc_sir_driver
);
983 pr_info("Uninstalled.\n");
986 module_init(lirc_sir_init
);
987 module_exit(lirc_sir_exit
);
989 #ifdef LIRC_SIR_TEKRAM
990 MODULE_DESCRIPTION("Infrared receiver driver for Tekram Irmate 210");
991 MODULE_AUTHOR("Christoph Bartelmus");
992 #elif defined(LIRC_SIR_ACTISYS_ACT200L)
993 MODULE_DESCRIPTION("LIRC driver for Actisys Act200L");
994 MODULE_AUTHOR("Karl Bongers");
995 #elif defined(LIRC_SIR_ACTISYS_ACT220L)
996 MODULE_DESCRIPTION("LIRC driver for Actisys Act220L(+)");
997 MODULE_AUTHOR("Jan Roemisch");
999 MODULE_DESCRIPTION("Infrared receiver driver for SIR type serial ports");
1000 MODULE_AUTHOR("Milan Pikula");
1002 MODULE_LICENSE("GPL");
1004 module_param(io
, int, S_IRUGO
);
1005 MODULE_PARM_DESC(io
, "I/O address base (0x3f8 or 0x2f8)");
1007 module_param(irq
, int, S_IRUGO
);
1008 MODULE_PARM_DESC(irq
, "Interrupt (4 or 3)");
1010 module_param(threshold
, int, S_IRUGO
);
1011 MODULE_PARM_DESC(threshold
, "space detection threshold (3)");
1013 module_param(debug
, bool, S_IRUGO
| S_IWUSR
);
1014 MODULE_PARM_DESC(debug
, "Enable debugging messages");