ep7211_ir.c 2.8 KB

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