[go: nahoru, domu]

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, see <http://www.gnu.org/licenses/>.
26 *
27 ********************************************************************/
28
29#include <linux/module.h>
30#include <linux/delay.h>
31#include <linux/init.h>
32
33#include <net/irda/irda.h>
34// #include <net/irda/irda_device.h>
35
36#include "sir-dev.h"
37
38/*
39 * Belkin is selling a dongle called the SmartBeam.
40 * In fact, there is two hardware version of this dongle, of course with
41 * the same name and looking the exactly same (grrr...).
42 * I guess that I've got the old one, because inside I don't have
43 * a jumper for IrDA/ASK...
44 *
45 * As far as I can make it from info on their web site, the old dongle
46 * support only 9600 b/s, which make our life much simpler as far as
47 * the driver is concerned, but you might not like it very much ;-)
48 * The new SmartBeam does 115 kb/s, and I've not tested it...
49 *
50 * Belkin claim that the correct driver for the old dongle (in Windows)
51 * is the generic Parallax 9500a driver, but the Linux LiteLink driver
52 * fails for me (probably because Linux-IrDA doesn't rate fallback),
53 * so I created this really dumb driver...
54 *
55 * In fact, this driver doesn't do much. The only thing it does is to
56 * prevent Linux-IrDA to use any other speed than 9600 b/s ;-) This
57 * driver is called "old_belkin" so that when the new SmartBeam is supported
58 * its driver can be called "belkin" instead of "new_belkin".
59 *
60 * Note : this driver was written without any info/help from Belkin,
61 * so a lot of info here might be totally wrong. Blame me ;-)
62 */
63
64static int old_belkin_open(struct sir_dev *dev);
65static int old_belkin_close(struct sir_dev *dev);
66static int old_belkin_change_speed(struct sir_dev *dev, unsigned speed);
67static int old_belkin_reset(struct sir_dev *dev);
68
69static struct dongle_driver old_belkin = {
70	.owner		= THIS_MODULE,
71	.driver_name	= "Old Belkin SmartBeam",
72	.type		= IRDA_OLD_BELKIN_DONGLE,
73	.open		= old_belkin_open,
74	.close		= old_belkin_close,
75	.reset		= old_belkin_reset,
76	.set_speed	= old_belkin_change_speed,
77};
78
79static int __init old_belkin_sir_init(void)
80{
81	return irda_register_dongle(&old_belkin);
82}
83
84static void __exit old_belkin_sir_cleanup(void)
85{
86	irda_unregister_dongle(&old_belkin);
87}
88
89static int old_belkin_open(struct sir_dev *dev)
90{
91	struct qos_info *qos = &dev->qos;
92
93	IRDA_DEBUG(2, "%s()\n", __func__);
94
95	/* Power on dongle */
96	sirdev_set_dtr_rts(dev, TRUE, TRUE);
97
98	/* Not too fast, please... */
99	qos->baud_rate.bits &= IR_9600;
100	/* Needs at least 10 ms (totally wild guess, can do probably better) */
101	qos->min_turn_time.bits = 0x01;
102	irda_qos_bits_to_value(qos);
103
104	/* irda thread waits 50 msec for power settling */
105
106	return 0;
107}
108
109static int old_belkin_close(struct sir_dev *dev)
110{
111	IRDA_DEBUG(2, "%s()\n", __func__);
112
113	/* Power off dongle */
114	sirdev_set_dtr_rts(dev, FALSE, FALSE);
115
116	return 0;
117}
118
119/*
120 * Function old_belkin_change_speed (task)
121 *
122 *    With only one speed available, not much to do...
123 */
124static int old_belkin_change_speed(struct sir_dev *dev, unsigned speed)
125{
126	IRDA_DEBUG(2, "%s()\n", __func__);
127
128	dev->speed = 9600;
129	return (speed==dev->speed) ? 0 : -EINVAL;
130}
131
132/*
133 * Function old_belkin_reset (task)
134 *
135 *      Reset the Old-Belkin type dongle.
136 *
137 */
138static int old_belkin_reset(struct sir_dev *dev)
139{
140	IRDA_DEBUG(2, "%s()\n", __func__);
141
142	/* This dongles speed "defaults" to 9600 bps ;-) */
143	dev->speed = 9600;
144
145	return 0;
146}
147
148MODULE_AUTHOR("Jean Tourrilhes <jt@hpl.hp.com>");
149MODULE_DESCRIPTION("Belkin (old) SmartBeam dongle driver");
150MODULE_LICENSE("GPL");
151MODULE_ALIAS("irda-dongle-7"); /* IRDA_OLD_BELKIN_DONGLE */
152
153module_init(old_belkin_sir_init);
154module_exit(old_belkin_sir_cleanup);
155