esi.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*********************************************************************
  2. *
  3. * Filename: esi.c
  4. * Version: 1.5
  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: Fri Dec 17 09:14:04 1999
  10. * Modified by: Dag Brattli <dagb@cs.uit.no>
  11. *
  12. * Copyright (c) 1999 Dag Brattli, <dagb@cs.uit.no>,
  13. * Copyright (c) 1998 Thomas Davis, <ratbert@radiks.net>,
  14. * All Rights Reserved.
  15. *
  16. * This program is free software; you can redistribute it and/or
  17. * modify it under the terms of the GNU General Public License as
  18. * published by the Free Software Foundation; either version 2 of
  19. * the License, or (at your option) any later version.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program; if not, write to the Free Software
  28. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  29. * MA 02111-1307 USA
  30. *
  31. ********************************************************************/
  32. #include <linux/module.h>
  33. #include <linux/delay.h>
  34. #include <linux/tty.h>
  35. #include <linux/init.h>
  36. #include <net/irda/irda.h>
  37. #include <net/irda/irda_device.h>
  38. static void esi_open(dongle_t *self, struct qos_info *qos);
  39. static void esi_close(dongle_t *self);
  40. static int esi_change_speed(struct irda_task *task);
  41. static int esi_reset(struct irda_task *task);
  42. static struct dongle_reg dongle = {
  43. .type = IRDA_ESI_DONGLE,
  44. .open = esi_open,
  45. .close = esi_close,
  46. .reset = esi_reset,
  47. .change_speed = esi_change_speed,
  48. .owner = THIS_MODULE,
  49. };
  50. static int __init esi_init(void)
  51. {
  52. return irda_device_register_dongle(&dongle);
  53. }
  54. static void __exit esi_cleanup(void)
  55. {
  56. irda_device_unregister_dongle(&dongle);
  57. }
  58. static void esi_open(dongle_t *self, struct qos_info *qos)
  59. {
  60. qos->baud_rate.bits &= IR_9600|IR_19200|IR_115200;
  61. qos->min_turn_time.bits = 0x01; /* Needs at least 10 ms */
  62. }
  63. static void esi_close(dongle_t *dongle)
  64. {
  65. /* Power off dongle */
  66. dongle->set_dtr_rts(dongle->dev, FALSE, FALSE);
  67. }
  68. /*
  69. * Function esi_change_speed (task)
  70. *
  71. * Set the speed for the Extended Systems JetEye PC ESI-9680 type dongle
  72. *
  73. */
  74. static int esi_change_speed(struct irda_task *task)
  75. {
  76. dongle_t *self = (dongle_t *) task->instance;
  77. __u32 speed = (__u32) task->param;
  78. int dtr, rts;
  79. switch (speed) {
  80. case 19200:
  81. dtr = TRUE;
  82. rts = FALSE;
  83. break;
  84. case 115200:
  85. dtr = rts = TRUE;
  86. break;
  87. case 9600:
  88. default:
  89. dtr = FALSE;
  90. rts = TRUE;
  91. break;
  92. }
  93. /* Change speed of dongle */
  94. self->set_dtr_rts(self->dev, dtr, rts);
  95. self->speed = speed;
  96. irda_task_next_state(task, IRDA_TASK_DONE);
  97. return 0;
  98. }
  99. /*
  100. * Function esi_reset (task)
  101. *
  102. * Reset dongle;
  103. *
  104. */
  105. static int esi_reset(struct irda_task *task)
  106. {
  107. dongle_t *self = (dongle_t *) task->instance;
  108. self->set_dtr_rts(self->dev, FALSE, FALSE);
  109. irda_task_next_state(task, IRDA_TASK_DONE);
  110. return 0;
  111. }
  112. MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>");
  113. MODULE_DESCRIPTION("Extended Systems JetEye PC dongle driver");
  114. MODULE_LICENSE("GPL");
  115. MODULE_ALIAS("irda-dongle-1"); /* IRDA_ESI_DONGLE */
  116. /*
  117. * Function init_module (void)
  118. *
  119. * Initialize ESI module
  120. *
  121. */
  122. module_init(esi_init);
  123. /*
  124. * Function cleanup_module (void)
  125. *
  126. * Cleanup ESI module
  127. *
  128. */
  129. module_exit(esi_cleanup);