]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/net/irda/esi.c
Linux-2.6.12-rc2
[mirror_ubuntu-artful-kernel.git] / drivers / net / irda / esi.c
1 /*********************************************************************
2 *
3 * Filename: esi.c
4 * Version: 1.5
5 * Description: Driver for the Extended Systems JetEye PC dongle
6 * Status: Experimental.
7 * Author: Dag Brattli <dagb@cs.uit.no>
8 * Created at: Sat Feb 21 18:54:38 1998
9 * Modified at: Fri Dec 17 09:14:04 1999
10 * Modified by: Dag Brattli <dagb@cs.uit.no>
11 *
12 * Copyright (c) 1999 Dag Brattli, <dagb@cs.uit.no>,
13 * Copyright (c) 1998 Thomas Davis, <ratbert@radiks.net>,
14 * All Rights Reserved.
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
30 *
31 ********************************************************************/
32
33 #include <linux/module.h>
34 #include <linux/delay.h>
35 #include <linux/tty.h>
36 #include <linux/init.h>
37
38 #include <net/irda/irda.h>
39 #include <net/irda/irda_device.h>
40
41 static void esi_open(dongle_t *self, struct qos_info *qos);
42 static void esi_close(dongle_t *self);
43 static int esi_change_speed(struct irda_task *task);
44 static int esi_reset(struct irda_task *task);
45
46 static struct dongle_reg dongle = {
47 .type = IRDA_ESI_DONGLE,
48 .open = esi_open,
49 .close = esi_close,
50 .reset = esi_reset,
51 .change_speed = esi_change_speed,
52 .owner = THIS_MODULE,
53 };
54
55 static int __init esi_init(void)
56 {
57 return irda_device_register_dongle(&dongle);
58 }
59
60 static void __exit esi_cleanup(void)
61 {
62 irda_device_unregister_dongle(&dongle);
63 }
64
65 static void esi_open(dongle_t *self, struct qos_info *qos)
66 {
67 qos->baud_rate.bits &= IR_9600|IR_19200|IR_115200;
68 qos->min_turn_time.bits = 0x01; /* Needs at least 10 ms */
69 }
70
71 static void esi_close(dongle_t *dongle)
72 {
73 /* Power off dongle */
74 dongle->set_dtr_rts(dongle->dev, FALSE, FALSE);
75 }
76
77 /*
78 * Function esi_change_speed (task)
79 *
80 * Set the speed for the Extended Systems JetEye PC ESI-9680 type dongle
81 *
82 */
83 static int esi_change_speed(struct irda_task *task)
84 {
85 dongle_t *self = (dongle_t *) task->instance;
86 __u32 speed = (__u32) task->param;
87 int dtr, rts;
88
89 switch (speed) {
90 case 19200:
91 dtr = TRUE;
92 rts = FALSE;
93 break;
94 case 115200:
95 dtr = rts = TRUE;
96 break;
97 case 9600:
98 default:
99 dtr = FALSE;
100 rts = TRUE;
101 break;
102 }
103
104 /* Change speed of dongle */
105 self->set_dtr_rts(self->dev, dtr, rts);
106 self->speed = speed;
107
108 irda_task_next_state(task, IRDA_TASK_DONE);
109
110 return 0;
111 }
112
113 /*
114 * Function esi_reset (task)
115 *
116 * Reset dongle;
117 *
118 */
119 static int esi_reset(struct irda_task *task)
120 {
121 dongle_t *self = (dongle_t *) task->instance;
122
123 self->set_dtr_rts(self->dev, FALSE, FALSE);
124 irda_task_next_state(task, IRDA_TASK_DONE);
125
126 return 0;
127 }
128
129 MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>");
130 MODULE_DESCRIPTION("Extended Systems JetEye PC dongle driver");
131 MODULE_LICENSE("GPL");
132 MODULE_ALIAS("irda-dongle-1"); /* IRDA_ESI_DONGLE */
133
134 /*
135 * Function init_module (void)
136 *
137 * Initialize ESI module
138 *
139 */
140 module_init(esi_init);
141
142 /*
143 * Function cleanup_module (void)
144 *
145 * Cleanup ESI module
146 *
147 */
148 module_exit(esi_cleanup);
149