it8172_cir.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. *
  3. * BRIEF MODULE DESCRIPTION
  4. * IT8172 Consumer IR port defines.
  5. *
  6. * Copyright 2001 MontaVista Software Inc.
  7. * Author: MontaVista Software, Inc.
  8. * ppopov@mvista.com or source@mvista.com
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the
  12. * Free Software Foundation; either version 2 of the License, or (at your
  13. * option) any later version.
  14. *
  15. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  16. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  17. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  18. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  19. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  20. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  21. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  22. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  24. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. *
  26. * You should have received a copy of the GNU General Public License along
  27. * with this program; if not, write to the Free Software Foundation, Inc.,
  28. * 675 Mass Ave, Cambridge, MA 02139, USA.
  29. */
  30. #define NUM_CIR_PORTS 2
  31. /* Master Control Register */
  32. #define CIR_RESET 0x1
  33. #define CIR_FIFO_CLEAR 0x2
  34. #define CIR_SET_FIFO_TL(x) (((x)&0x3)<<2)
  35. #define CIR_ILE 0x10
  36. #define CIR_ILSEL 0x20
  37. /* Interrupt Enable Register */
  38. #define CIR_TLDLIE 0x1
  39. #define CIR_RDAIE 0x2
  40. #define CIR_RFOIE 0x4
  41. #define CIR_IEC 0x80
  42. /* Interrupt Identification Register */
  43. #define CIR_TLDLI 0x1
  44. #define CIR_RDAI 0x2
  45. #define CIR_RFOI 0x4
  46. #define CIR_NIP 0x80
  47. /* Carrier Frequency Register */
  48. #define CIR_SET_CF(x) ((x)&0x1f)
  49. #define CFQ_38_480 0xB /* 38 KHz low, 480 KHz high */
  50. #define CIR_HCFS 0x20
  51. #define CIR_SET_HS(x) (((x)&0x1)<<5)
  52. /* Receiver Control Register */
  53. #define CIR_SET_RXDCR(x) ((x)&0x7)
  54. #define CIR_RXACT 0x8
  55. #define CIR_RXEND 0x10
  56. #define CIR_RDWOS 0x20
  57. #define CIR_SET_RDWOS(x) (((x)&0x1)<<5)
  58. #define CIR_RXEN 0x80
  59. /* Transmitter Control Register */
  60. #define CIR_SET_TXMPW(x) ((x)&0x7)
  61. #define CIR_SET_TXMPM(x) (((x)&0x3)<<3)
  62. #define CIR_TXENDF 0x20
  63. #define CIR_TXRLE 0x40
  64. /* Receiver FIFO Status Register */
  65. #define CIR_RXFBC_MASK 0x3f
  66. #define CIR_RXFTO 0x80
  67. /* Wakeup Code Length Register */
  68. #define CIR_SET_WCL ((x)&0x3f)
  69. #define CIR_WCL_MASK(x) ((x)&0x3f)
  70. /* Wakeup Power Control/Status Register */
  71. #define CIR_BTMON 0x2
  72. #define CIR_CIRON 0x4
  73. #define CIR_RCRST 0x10
  74. #define CIR_WCRST 0x20
  75. struct cir_port {
  76. int port;
  77. unsigned short baud_rate;
  78. unsigned char fifo_tl;
  79. unsigned char cfq;
  80. unsigned char hcfs;
  81. unsigned char rdwos;
  82. unsigned char rxdcr;
  83. };
  84. struct it8172_cir_regs {
  85. unsigned char dr; /* data */
  86. char pad;
  87. unsigned char mstcr; /* master control */
  88. char pad1;
  89. unsigned char ier; /* interrupt enable */
  90. char pad2;
  91. unsigned char iir; /* interrupt identification */
  92. char pad3;
  93. unsigned char cfr; /* carrier frequency */
  94. char pad4;
  95. unsigned char rcr; /* receiver control */
  96. char pad5;
  97. unsigned char tcr; /* transmitter control */
  98. char pad6;
  99. char pad7;
  100. char pad8;
  101. unsigned char bdlr; /* baud rate divisor low byte */
  102. char pad9;
  103. unsigned char bdhr; /* baud rate divisor high byte */
  104. char pad10;
  105. unsigned char tfsr; /* tx fifo byte count */
  106. char pad11;
  107. unsigned char rfsr; /* rx fifo status */
  108. char pad12;
  109. unsigned char wcl; /* wakeup code length */
  110. char pad13;
  111. unsigned char wcr; /* wakeup code read/write */
  112. char pad14;
  113. unsigned char wps; /* wakeup power control/status */
  114. };
  115. int cir_port_init(struct cir_port *cir);
  116. extern void clear_fifo(struct cir_port *cir);
  117. extern void enable_receiver(struct cir_port *cir);
  118. extern void disable_receiver(struct cir_port *cir);
  119. extern void enable_rx_demodulation(struct cir_port *cir);
  120. extern void disable_rx_demodulation(struct cir_port *cir);
  121. extern void set_rx_active(struct cir_port *cir);
  122. extern void int_enable(struct cir_port *cir);
  123. extern void rx_int_enable(struct cir_port *cir);
  124. extern char get_int_status(struct cir_port *cir);
  125. extern int cir_get_rx_count(struct cir_port *cir);
  126. extern char cir_read_data(struct cir_port *cir);