ep7211-sir.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * IR port driver for the Cirrus Logic EP7211 processor.
  3. *
  4. * Copyright 2001, Blue Mug Inc. All rights reserved.
  5. * Copyright 2007, Samuel Ortiz <samuel@sortiz.org>
  6. */
  7. #include <linux/module.h>
  8. #include <linux/delay.h>
  9. #include <linux/tty.h>
  10. #include <linux/init.h>
  11. #include <linux/spinlock.h>
  12. #include <net/irda/irda.h>
  13. #include <net/irda/irda_device.h>
  14. #include <asm/io.h>
  15. #include <mach/hardware.h>
  16. #include "sir-dev.h"
  17. #define MIN_DELAY 25 /* 15 us, but wait a little more to be sure */
  18. #define MAX_DELAY 10000 /* 1 ms */
  19. static int ep7211_open(struct sir_dev *dev);
  20. static int ep7211_close(struct sir_dev *dev);
  21. static int ep7211_change_speed(struct sir_dev *dev, unsigned speed);
  22. static int ep7211_reset(struct sir_dev *dev);
  23. static struct dongle_driver ep7211 = {
  24. .owner = THIS_MODULE,
  25. .driver_name = "EP7211 IR driver",
  26. .type = IRDA_EP7211_DONGLE,
  27. .open = ep7211_open,
  28. .close = ep7211_close,
  29. .reset = ep7211_reset,
  30. .set_speed = ep7211_change_speed,
  31. };
  32. static int __init ep7211_sir_init(void)
  33. {
  34. return irda_register_dongle(&ep7211);
  35. }
  36. static void __exit ep7211_sir_cleanup(void)
  37. {
  38. irda_unregister_dongle(&ep7211);
  39. }
  40. static int ep7211_open(struct sir_dev *dev)
  41. {
  42. unsigned int syscon;
  43. /* Turn on the SIR encoder. */
  44. syscon = clps_readl(SYSCON1);
  45. syscon |= SYSCON1_SIREN;
  46. clps_writel(syscon, SYSCON1);
  47. return 0;
  48. }
  49. static int ep7211_close(struct sir_dev *dev)
  50. {
  51. unsigned int syscon;
  52. /* Turn off the SIR encoder. */
  53. syscon = clps_readl(SYSCON1);
  54. syscon &= ~SYSCON1_SIREN;
  55. clps_writel(syscon, SYSCON1);
  56. return 0;
  57. }
  58. static int ep7211_change_speed(struct sir_dev *dev, unsigned speed)
  59. {
  60. return 0;
  61. }
  62. static int ep7211_reset(struct sir_dev *dev)
  63. {
  64. return 0;
  65. }
  66. MODULE_AUTHOR("Samuel Ortiz <samuel@sortiz.org>");
  67. MODULE_DESCRIPTION("EP7211 IR dongle driver");
  68. MODULE_LICENSE("GPL");
  69. MODULE_ALIAS("irda-dongle-13"); /* IRDA_EP7211_DONGLE */
  70. module_init(ep7211_sir_init);
  71. module_exit(ep7211_sir_cleanup);