old_belkin.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. #include <linux/module.h>
  31. #include <linux/delay.h>
  32. #include <linux/tty.h>
  33. #include <linux/init.h>
  34. #include <net/irda/irda.h>
  35. #include <net/irda/irda_device.h>
  36. /*
  37. * Belkin is selling a dongle called the SmartBeam.
  38. * In fact, there is two hardware version of this dongle, of course with
  39. * the same name and looking the exactly same (grrr...).
  40. * I guess that I've got the old one, because inside I don't have
  41. * a jumper for IrDA/ASK...
  42. *
  43. * As far as I can make it from info on their web site, the old dongle
  44. * support only 9600 b/s, which make our life much simpler as far as
  45. * the driver is concerned, but you might not like it very much ;-)
  46. * The new SmartBeam does 115 kb/s, and I've not tested it...
  47. *
  48. * Belkin claim that the correct driver for the old dongle (in Windows)
  49. * is the generic Parallax 9500a driver, but the Linux LiteLink driver
  50. * fails for me (probably because Linux-IrDA doesn't rate fallback),
  51. * so I created this really dumb driver...
  52. *
  53. * In fact, this driver doesn't do much. The only thing it does is to
  54. * prevent Linux-IrDA to use any other speed than 9600 b/s ;-) This
  55. * driver is called "old_belkin" so that when the new SmartBeam is supported
  56. * its driver can be called "belkin" instead of "new_belkin".
  57. *
  58. * Note : this driver was written without any info/help from Belkin,
  59. * so a lot of info here might be totally wrong. Blame me ;-)
  60. */
  61. /* Let's guess */
  62. #define MIN_DELAY 25 /* 15 us, but wait a little more to be sure */
  63. static void old_belkin_open(dongle_t *self, struct qos_info *qos);
  64. static void old_belkin_close(dongle_t *self);
  65. static int old_belkin_change_speed(struct irda_task *task);
  66. static int old_belkin_reset(struct irda_task *task);
  67. /* These are the baudrates supported */
  68. /* static __u32 baud_rates[] = { 9600 }; */
  69. static struct dongle_reg dongle = {
  70. .type = IRDA_OLD_BELKIN_DONGLE,
  71. .open = old_belkin_open,
  72. .close = old_belkin_close,
  73. .reset = old_belkin_reset,
  74. .change_speed = old_belkin_change_speed,
  75. .owner = THIS_MODULE,
  76. };
  77. static int __init old_belkin_init(void)
  78. {
  79. return irda_device_register_dongle(&dongle);
  80. }
  81. static void __exit old_belkin_cleanup(void)
  82. {
  83. irda_device_unregister_dongle(&dongle);
  84. }
  85. static void old_belkin_open(dongle_t *self, struct qos_info *qos)
  86. {
  87. /* Not too fast, please... */
  88. qos->baud_rate.bits &= IR_9600;
  89. /* Needs at least 10 ms (totally wild guess, can do probably better) */
  90. qos->min_turn_time.bits = 0x01;
  91. }
  92. static void old_belkin_close(dongle_t *self)
  93. {
  94. /* Power off dongle */
  95. self->set_dtr_rts(self->dev, FALSE, FALSE);
  96. }
  97. /*
  98. * Function old_belkin_change_speed (task)
  99. *
  100. * With only one speed available, not much to do...
  101. */
  102. static int old_belkin_change_speed(struct irda_task *task)
  103. {
  104. irda_task_next_state(task, IRDA_TASK_DONE);
  105. return 0;
  106. }
  107. /*
  108. * Function old_belkin_reset (task)
  109. *
  110. * Reset the Old-Belkin type dongle.
  111. *
  112. */
  113. static int old_belkin_reset(struct irda_task *task)
  114. {
  115. dongle_t *self = (dongle_t *) task->instance;
  116. /* Power on dongle */
  117. self->set_dtr_rts(self->dev, TRUE, TRUE);
  118. /* Sleep a minimum of 15 us */
  119. udelay(MIN_DELAY);
  120. /* This dongles speed "defaults" to 9600 bps ;-) */
  121. self->speed = 9600;
  122. irda_task_next_state(task, IRDA_TASK_DONE);
  123. return 0;
  124. }
  125. MODULE_AUTHOR("Jean Tourrilhes <jt@hpl.hp.com>");
  126. MODULE_DESCRIPTION("Belkin (old) SmartBeam dongle driver");
  127. MODULE_LICENSE("GPL");
  128. MODULE_ALIAS("irda-dongle-7"); /* IRDA_OLD_BELKIN_DONGLE */
  129. /*
  130. * Function init_module (void)
  131. *
  132. * Initialize Old-Belkin module
  133. *
  134. */
  135. module_init(old_belkin_init);
  136. /*
  137. * Function cleanup_module (void)
  138. *
  139. * Cleanup Old-Belkin module
  140. *
  141. */
  142. module_exit(old_belkin_cleanup);