1 /*********************************************************************
2  *
3  * Filename:      old_belkin.c
4  * Version:       1.1
5  * Description:   Driver for the Belkin (old) SmartBeam dongle
6  * Status:        Experimental...
7  * Author:        Jean Tourrilhes <jt@hpl.hp.com>
8  * Created at:    22/11/99
9  * Modified at:   Fri Dec 17 09:13:32 1999
10  * Modified by:   Dag Brattli <dagb@cs.uit.no>
11  *
12  *     Copyright (c) 1999 Jean Tourrilhes, All Rights Reserved.
13  *
14  *     This program is free software; you can redistribute it and/or
15  *     modify it under the terms of the GNU General Public License as
16  *     published by the Free Software Foundation; either version 2 of
17  *     the License, or (at your option) any later version.
18  *
19  *     This program is distributed in the hope that it will be useful,
20  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
21  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  *     GNU General Public License for more details.
23  *
24  *     You should have received a copy of the GNU General Public License
25  *     along with this program; if not, write to the Free Software
26  *     Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27  *     MA 02111-1307 USA
28  *
29  ********************************************************************/
30 
31 #include <linux/module.h>
32 #include <linux/delay.h>
33 #include <linux/tty.h>
34 #include <linux/sched.h>
35 #include <linux/init.h>
36 #include <linux/irda.h>
37 
38 #include <net/irda/irda.h>
39 #include <net/irda/irmod.h>
40 #include <net/irda/irda_device.h>
41 
42 /*
43  * Belkin is selling a dongle called the SmartBeam.
44  * In fact, there is two hardware version of this dongle, of course with
45  * the same name and looking the exactly same (grrr...).
46  * I guess that I've got the old one, because inside I don't have
47  * a jumper for IrDA/ASK...
48  *
49  * As far as I can make it from info on their web site, the old dongle
50  * support only 9600 b/s, which make our life much simpler as far as
51  * the driver is concerned, but you might not like it very much ;-)
52  * The new SmartBeam does 115 kb/s, and I've not tested it...
53  *
54  * Belkin claim that the correct driver for the old dongle (in Windows)
55  * is the generic Parallax 9500a driver, but the Linux LiteLink driver
56  * fails for me (probably because Linux-IrDA doesn't rate fallback),
57  * so I created this really dumb driver...
58  *
59  * In fact, this driver doesn't do much. The only thing it does is to
60  * prevent Linux-IrDA to use any other speed than 9600 b/s ;-) This
61  * driver is called "old_belkin" so that when the new SmartBeam is supported
62  * its driver can be called "belkin" instead of "new_belkin".
63  *
64  * Note : this driver was written without any info/help from Belkin,
65  * so a lot of info here might be totally wrong. Blame me ;-)
66  */
67 
68 /* Let's guess */
69 #define MIN_DELAY 25      /* 15 us, but wait a little more to be sure */
70 
71 static void old_belkin_open(dongle_t *self, struct qos_info *qos);
72 static void old_belkin_close(dongle_t *self);
73 static int  old_belkin_change_speed(struct irda_task *task);
74 static int  old_belkin_reset(struct irda_task *task);
75 
76 /* These are the baudrates supported */
77 /* static __u32 baud_rates[] = { 9600 }; */
78 
79 static struct dongle_reg dongle = {
80 	Q_NULL,
81 	IRDA_OLD_BELKIN_DONGLE,
82 	old_belkin_open,
83 	old_belkin_close,
84 	old_belkin_reset,
85 	old_belkin_change_speed,
86 };
87 
old_belkin_init(void)88 int __init old_belkin_init(void)
89 {
90 	return irda_device_register_dongle(&dongle);
91 }
92 
old_belkin_cleanup(void)93 void old_belkin_cleanup(void)
94 {
95 	irda_device_unregister_dongle(&dongle);
96 }
97 
old_belkin_open(dongle_t * self,struct qos_info * qos)98 static void old_belkin_open(dongle_t *self, struct qos_info *qos)
99 {
100 	/* Not too fast, please... */
101 	qos->baud_rate.bits &= IR_9600;
102 	/* Needs at least 10 ms (totally wild guess, can do probably better) */
103 	qos->min_turn_time.bits = 0x01;
104 
105 	MOD_INC_USE_COUNT;
106 }
107 
old_belkin_close(dongle_t * self)108 static void old_belkin_close(dongle_t *self)
109 {
110 	/* Power off dongle */
111 	self->set_dtr_rts(self->dev, FALSE, FALSE);
112 
113 	MOD_DEC_USE_COUNT;
114 }
115 
116 /*
117  * Function old_belkin_change_speed (task)
118  *
119  *    With only one speed available, not much to do...
120  */
old_belkin_change_speed(struct irda_task * task)121 static int old_belkin_change_speed(struct irda_task *task)
122 {
123 	irda_task_next_state(task, IRDA_TASK_DONE);
124 
125 	return 0;
126 }
127 
128 /*
129  * Function old_belkin_reset (task)
130  *
131  *      Reset the Old-Belkin type dongle.
132  *
133  */
old_belkin_reset(struct irda_task * task)134 static int old_belkin_reset(struct irda_task *task)
135 {
136 	dongle_t *self = (dongle_t *) task->instance;
137 
138 	/* Power on dongle */
139 	self->set_dtr_rts(self->dev, TRUE, TRUE);
140 
141 	/* Sleep a minimum of 15 us */
142 	udelay(MIN_DELAY);
143 
144 	/* This dongles speed "defaults" to 9600 bps ;-) */
145 	self->speed = 9600;
146 
147 	irda_task_next_state(task, IRDA_TASK_DONE);
148 
149 	return 0;
150 }
151 
152 #ifdef MODULE
153 MODULE_AUTHOR("Jean Tourrilhes <jt@hpl.hp.com>");
154 MODULE_DESCRIPTION("Belkin (old) SmartBeam dongle driver");
155 MODULE_LICENSE("GPL");
156 
157 
158 /*
159  * Function init_module (void)
160  *
161  *    Initialize Old-Belkin module
162  *
163  */
init_module(void)164 int init_module(void)
165 {
166 	return old_belkin_init();
167 }
168 
169 /*
170  * Function cleanup_module (void)
171  *
172  *    Cleanup Old-Belkin module
173  *
174  */
cleanup_module(void)175 void cleanup_module(void)
176 {
177 	old_belkin_cleanup();
178 }
179 #endif /* MODULE */
180 
181