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
35 #include <linux/delay.h>
36 #include <linux/tty.h>
37 #include <linux/sched.h>
38 #include <linux/init.h>
39
40 #include <net/irda/irda.h>
41 #include <net/irda/irmod.h>
42 #include <net/irda/irda_device.h>
43
44 static void esi_open(dongle_t *self, struct qos_info *qos);
45 static void esi_close(dongle_t *self);
46 static int esi_change_speed(struct irda_task *task);
47 static int esi_reset(struct irda_task *task);
48
49 static struct dongle_reg dongle = {
50 Q_NULL,
51 IRDA_ESI_DONGLE,
52 esi_open,
53 esi_close,
54 esi_reset,
55 esi_change_speed,
56 };
57
esi_init(void)58 int __init esi_init(void)
59 {
60 return irda_device_register_dongle(&dongle);
61 }
62
esi_cleanup(void)63 void esi_cleanup(void)
64 {
65 irda_device_unregister_dongle(&dongle);
66 }
67
esi_open(dongle_t * self,struct qos_info * qos)68 static void esi_open(dongle_t *self, struct qos_info *qos)
69 {
70 qos->baud_rate.bits &= IR_9600|IR_19200|IR_115200;
71 qos->min_turn_time.bits = 0x01; /* Needs at least 10 ms */
72
73 MOD_INC_USE_COUNT;
74 }
75
esi_close(dongle_t * dongle)76 static void esi_close(dongle_t *dongle)
77 {
78 /* Power off dongle */
79 dongle->set_dtr_rts(dongle->dev, FALSE, FALSE);
80
81 MOD_DEC_USE_COUNT;
82 }
83
84 /*
85 * Function esi_change_speed (task)
86 *
87 * Set the speed for the Extended Systems JetEye PC ESI-9680 type dongle
88 *
89 */
esi_change_speed(struct irda_task * task)90 static int esi_change_speed(struct irda_task *task)
91 {
92 dongle_t *self = (dongle_t *) task->instance;
93 __u32 speed = (__u32) task->param;
94 int dtr, rts;
95
96 switch (speed) {
97 case 19200:
98 dtr = TRUE;
99 rts = FALSE;
100 break;
101 case 115200:
102 dtr = rts = TRUE;
103 break;
104 case 9600:
105 default:
106 dtr = FALSE;
107 rts = TRUE;
108 break;
109 }
110
111 /* Change speed of dongle */
112 self->set_dtr_rts(self->dev, dtr, rts);
113 self->speed = speed;
114
115 irda_task_next_state(task, IRDA_TASK_DONE);
116
117 return 0;
118 }
119
120 /*
121 * Function esi_reset (task)
122 *
123 * Reset dongle;
124 *
125 */
esi_reset(struct irda_task * task)126 static int esi_reset(struct irda_task *task)
127 {
128 dongle_t *self = (dongle_t *) task->instance;
129
130 self->set_dtr_rts(self->dev, FALSE, FALSE);
131 irda_task_next_state(task, IRDA_TASK_DONE);
132
133 return 0;
134 }
135
136 #ifdef MODULE
137 MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>");
138 MODULE_DESCRIPTION("Extended Systems JetEye PC dongle driver");
139 MODULE_LICENSE("GPL");
140
141 /*
142 * Function init_module (void)
143 *
144 * Initialize ESI module
145 *
146 */
init_module(void)147 int init_module(void)
148 {
149 return esi_init();
150 }
151
152 /*
153 * Function cleanup_module (void)
154 *
155 * Cleanup ESI module
156 *
157 */
cleanup_module(void)158 void cleanup_module(void)
159 {
160 esi_cleanup();
161 }
162 #endif /* MODULE */
163
164