ep7211_ir.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * IR port driver for the Cirrus Logic EP7211 processor.
  3. *
  4. * Copyright 2001, Blue Mug Inc. All rights reserved.
  5. */
  6. #include <linux/module.h>
  7. #include <linux/delay.h>
  8. #include <linux/tty.h>
  9. #include <linux/init.h>
  10. #include <net/irda/irda.h>
  11. #include <net/irda/irda_device.h>
  12. #include <asm/io.h>
  13. #include <asm/hardware.h>
  14. #define MIN_DELAY 25 /* 15 us, but wait a little more to be sure */
  15. #define MAX_DELAY 10000 /* 1 ms */
  16. static void ep7211_ir_open(dongle_t *self, struct qos_info *qos);
  17. static void ep7211_ir_close(dongle_t *self);
  18. static int ep7211_ir_change_speed(struct irda_task *task);
  19. static int ep7211_ir_reset(struct irda_task *task);
  20. static struct dongle_reg dongle = {
  21. .type = IRDA_EP7211_IR,
  22. .open = ep7211_ir_open,
  23. .close = ep7211_ir_close,
  24. .reset = ep7211_ir_reset,
  25. .change_speed = ep7211_ir_change_speed,
  26. .owner = THIS_MODULE,
  27. };
  28. static void ep7211_ir_open(dongle_t *self, struct qos_info *qos)
  29. {
  30. unsigned int syscon1, flags;
  31. save_flags(flags); cli();
  32. /* Turn on the SIR encoder. */
  33. syscon1 = clps_readl(SYSCON1);
  34. syscon1 |= SYSCON1_SIREN;
  35. clps_writel(syscon1, SYSCON1);
  36. /* XXX: We should disable modem status interrupts on the first
  37. UART (interrupt #14). */
  38. restore_flags(flags);
  39. }
  40. static void ep7211_ir_close(dongle_t *self)
  41. {
  42. unsigned int syscon1, flags;
  43. save_flags(flags); cli();
  44. /* Turn off the SIR encoder. */
  45. syscon1 = clps_readl(SYSCON1);
  46. syscon1 &= ~SYSCON1_SIREN;
  47. clps_writel(syscon1, SYSCON1);
  48. /* XXX: If we've disabled the modem status interrupts, we should
  49. reset them back to their original state. */
  50. restore_flags(flags);
  51. }
  52. /*
  53. * Function ep7211_ir_change_speed (task)
  54. *
  55. * Change speed of the EP7211 I/R port. We don't really have to do anything
  56. * for the EP7211 as long as the rate is being changed at the serial port
  57. * level.
  58. */
  59. static int ep7211_ir_change_speed(struct irda_task *task)
  60. {
  61. irda_task_next_state(task, IRDA_TASK_DONE);
  62. return 0;
  63. }
  64. /*
  65. * Function ep7211_ir_reset (task)
  66. *
  67. * Reset the EP7211 I/R. We don't really have to do anything.
  68. *
  69. */
  70. static int ep7211_ir_reset(struct irda_task *task)
  71. {
  72. irda_task_next_state(task, IRDA_TASK_DONE);
  73. return 0;
  74. }
  75. /*
  76. * Function ep7211_ir_init(void)
  77. *
  78. * Initialize EP7211 I/R module
  79. *
  80. */
  81. static int __init ep7211_ir_init(void)
  82. {
  83. return irda_device_register_dongle(&dongle);
  84. }
  85. /*
  86. * Function ep7211_ir_cleanup(void)
  87. *
  88. * Cleanup EP7211 I/R module
  89. *
  90. */
  91. static void __exit ep7211_ir_cleanup(void)
  92. {
  93. irda_device_unregister_dongle(&dongle);
  94. }
  95. MODULE_AUTHOR("Jon McClintock <jonm@bluemug.com>");
  96. MODULE_DESCRIPTION("EP7211 I/R driver");
  97. MODULE_LICENSE("GPL");
  98. MODULE_ALIAS("irda-dongle-8"); /* IRDA_EP7211_IR */
  99. module_init(ep7211_ir_init);
  100. module_exit(ep7211_ir_cleanup);