esi-sir.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*********************************************************************
  2. *
  3. * Filename: esi.c
  4. * Version: 1.6
  5. * Description: Driver for the Extended Systems JetEye PC dongle
  6. * Status: Experimental.
  7. * Author: Dag Brattli <dagb@cs.uit.no>
  8. * Created at: Sat Feb 21 18:54:38 1998
  9. * Modified at: Sun Oct 27 22:01:04 2002
  10. * Modified by: Martin Diehl <mad@mdiehl.de>
  11. *
  12. * Copyright (c) 1999 Dag Brattli, <dagb@cs.uit.no>,
  13. * Copyright (c) 1998 Thomas Davis, <ratbert@radiks.net>,
  14. * Copyright (c) 2002 Martin Diehl, <mad@mdiehl.de>,
  15. * All Rights Reserved.
  16. *
  17. * This program is free software; you can redistribute it and/or
  18. * modify it under the terms of the GNU General Public License as
  19. * published by the Free Software Foundation; either version 2 of
  20. * the License, or (at your option) any later version.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU General Public License
  28. * along with this program; if not, write to the Free Software
  29. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  30. * MA 02111-1307 USA
  31. *
  32. ********************************************************************/
  33. #include <linux/module.h>
  34. #include <linux/delay.h>
  35. #include <linux/init.h>
  36. #include <net/irda/irda.h>
  37. #include "sir-dev.h"
  38. static int esi_open(struct sir_dev *);
  39. static int esi_close(struct sir_dev *);
  40. static int esi_change_speed(struct sir_dev *, unsigned);
  41. static int esi_reset(struct sir_dev *);
  42. static struct dongle_driver esi = {
  43. .owner = THIS_MODULE,
  44. .driver_name = "JetEye PC ESI-9680 PC",
  45. .type = IRDA_ESI_DONGLE,
  46. .open = esi_open,
  47. .close = esi_close,
  48. .reset = esi_reset,
  49. .set_speed = esi_change_speed,
  50. };
  51. static int __init esi_sir_init(void)
  52. {
  53. return irda_register_dongle(&esi);
  54. }
  55. static void __exit esi_sir_cleanup(void)
  56. {
  57. irda_unregister_dongle(&esi);
  58. }
  59. static int esi_open(struct sir_dev *dev)
  60. {
  61. struct qos_info *qos = &dev->qos;
  62. /* Power up and set dongle to 9600 baud */
  63. sirdev_set_dtr_rts(dev, FALSE, TRUE);
  64. qos->baud_rate.bits &= IR_9600|IR_19200|IR_115200;
  65. qos->min_turn_time.bits = 0x01; /* Needs at least 10 ms */
  66. irda_qos_bits_to_value(qos);
  67. /* irda thread waits 50 msec for power settling */
  68. return 0;
  69. }
  70. static int esi_close(struct sir_dev *dev)
  71. {
  72. /* Power off dongle */
  73. sirdev_set_dtr_rts(dev, FALSE, FALSE);
  74. return 0;
  75. }
  76. /*
  77. * Function esi_change_speed (task)
  78. *
  79. * Set the speed for the Extended Systems JetEye PC ESI-9680 type dongle
  80. * Apparently (see old esi-driver) no delays are needed here...
  81. *
  82. */
  83. static int esi_change_speed(struct sir_dev *dev, unsigned speed)
  84. {
  85. int ret = 0;
  86. int dtr, rts;
  87. switch (speed) {
  88. case 19200:
  89. dtr = TRUE;
  90. rts = FALSE;
  91. break;
  92. case 115200:
  93. dtr = rts = TRUE;
  94. break;
  95. default:
  96. ret = -EINVAL;
  97. speed = 9600;
  98. /* fall through */
  99. case 9600:
  100. dtr = FALSE;
  101. rts = TRUE;
  102. break;
  103. }
  104. /* Change speed of dongle */
  105. sirdev_set_dtr_rts(dev, dtr, rts);
  106. dev->speed = speed;
  107. return ret;
  108. }
  109. /*
  110. * Function esi_reset (task)
  111. *
  112. * Reset dongle;
  113. *
  114. */
  115. static int esi_reset(struct sir_dev *dev)
  116. {
  117. sirdev_set_dtr_rts(dev, FALSE, FALSE);
  118. /* Hm, the old esi-driver left the dongle unpowered relying on
  119. * the following speed change to repower. This might work for
  120. * the esi because we only need the modem lines. However, now the
  121. * general rule is reset must bring the dongle to some working
  122. * well-known state because speed change might write to registers.
  123. * The old esi-driver didn't any delay here - let's hope it' fine.
  124. */
  125. sirdev_set_dtr_rts(dev, FALSE, TRUE);
  126. dev->speed = 9600;
  127. return 0;
  128. }
  129. MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>");
  130. MODULE_DESCRIPTION("Extended Systems JetEye PC dongle driver");
  131. MODULE_LICENSE("GPL");
  132. MODULE_ALIAS("irda-dongle-1"); /* IRDA_ESI_DONGLE */
  133. module_init(esi_sir_init);
  134. module_exit(esi_sir_cleanup);