old_belkin-sir.c 4.5 KB

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