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