ir9561.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. #ifndef _IR_H
  2. #define _IR_H
  3. #include <linux/module.h>
  4. #include <linux/moduleparam.h>
  5. #include <linux/init.h>
  6. #include <linux/kernel.h>
  7. #include <linux/ioport.h>
  8. #include <linux/delay.h>
  9. #include <linux/nmi.h>
  10. #include <linux/mutex.h>
  11. #include <asm/io.h>
  12. #include <linux/interrupt.h>
  13. #include <asm/irq.h>
  14. #include <linux/errno.h>
  15. #include <linux/types.h>
  16. #include <linux/ioctl.h>
  17. #include <linux/cdev.h>
  18. #include <linux/input.h>
  19. #include <linux/workqueue.h>
  20. #include <linux/version.h>
  21. #include <drv_devices.h>
  22. #ifndef INIT_BY_KMF
  23. #define DBG_MSG1(id, fmt,args...) do{ printk(KERN_DEBUG " " fmt, ## args); }while(0)
  24. #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
  25. #include <drv_dev.h>
  26. #else
  27. #include <asm-mips/mips-boards/sisdev.h> //Change the location of sisdev.h to sis516
  28. #endif
  29. #define AndroidtoTV(void)
  30. // #define kmf_register_platformfunc(MODULEID_IR, SiS_IR_Suspend, SiS_IR_Resume)
  31. #else
  32. #include <drv_debug.h>
  33. #include <drv_platform.h>
  34. #endif
  35. #include <drv_ir_def.h>
  36. #include "irexport.h"
  37. #define MMIOBASE_IR 0xBE080000
  38. #define MMIOBASE_IR2 0xBE080500
  39. #define IRQ_IR 59
  40. #define SIS326_IR_REG_NUM (0x5c/4) // = 0x4C / 4
  41. /*******************************************************************************
  42. *******************************************************************************/
  43. #define STATUS_SUCCESS 0
  44. #define STATUS_DEVICE_ID_ERROR 1
  45. #define STATUS_DATA_ERROR 2
  46. #define STATUS_SYSTEM_ERROR 3
  47. #define DebugPrint(fmt,args...) printk(KERN_NOTICE fmt "\n",## args)
  48. typedef struct _IRDEV {
  49. UINT8* mmio_vbase;
  50. UINT8* mmio_vbase2;
  51. int irq;
  52. ULONG flagINT0;
  53. struct cdev cdev;
  54. IR_IOC_IOData dataBuf;
  55. #if IR_Auto_Test
  56. Message userMessage;
  57. #endif
  58. }IRDEV, *IRDEVPTR;
  59. typedef struct _IR_Hardware_Parameter{
  60. union{
  61. ULONG dwValue[SIS326_IR_REG_NUM]; // 0x00 ~ 0x4b
  62. struct{
  63. union{ // 0x00 ~ 0x03 IR ID Registers
  64. ULONG Value00;
  65. struct{
  66. // 0x00 ~ 0x01
  67. ULONG DeviceID:16;
  68. // 0x02
  69. ULONG VersionID:8;
  70. // 0x03
  71. ULONG Reserved03:8;
  72. } Reg00;
  73. };
  74. union{ // 0x04 ~ 0x07
  75. ULONG Value04;
  76. struct{
  77. // 0x04 IR Protocol Registers
  78. ULONG reg_rc5_en:1; // Enable Philips RC-5 decoding
  79. ULONG reg_sirc_en:1; // Enable Sony SIRC decoding
  80. ULONG reg_nec_en:1; // Enable NEC decoding
  81. ULONG reg_jvc_en:1; // Enable JVC decoding
  82. ULONG reg_rc6_en:1; // Enable Philips RC-6 decoding
  83. ULONG Reserved04:3;
  84. // 0x05 ~ 0x06 IR Global Option Registers
  85. ULONG reg_reorder_en:1;
  86. ULONG reg_key_prs_cnt_en:1;
  87. ULONG reg_intr_every_pkt_en:1; // Enable interrupts for all packets (old path)
  88. ULONG Reserved05:5;
  89. ULONG reg_filt_lnth:6;
  90. ULONG Reserved06:1;
  91. ULONG reg_polarity:1; // Inverse input polarity of IR decoder
  92. // 0x07 IR Address / Command Length Registers
  93. ULONG reg_cmd_lnth:4; // Custom code, command length
  94. ULONG reg_adr_lnth:4; // Data code, address length
  95. } Reg04;
  96. };
  97. union{ // 0x08 ~ 0x0b
  98. ULONG Value08;
  99. struct{
  100. ULONG Reserved:32;
  101. } Reg08;
  102. };
  103. union{ // 0x0c ~ 0x0f
  104. ULONG Value0C;
  105. struct{
  106. // 0x0c ~ 0x0d IR Decoder Received Data Registers
  107. ULONG reg_cmd:8; // Command code (Raw bit-stream if reg_reorder_en = 0) ; Valid if reg_single_sts = 1
  108. ULONG reg_adr:8; // Address code (Raw bit-stream if reg_reorder_en = 0) ; Valid if reg_single_sts = 1
  109. // 0x0e IR Interrupt Status Registers
  110. ULONG reg_intr_sts:1; // IR global interrupt status; Write 1 Clear
  111. ULONG reg_single_sts:1; // Single key interrupt status
  112. ULONG reg_rpt_start_sts:1; // Repeating key start interrupt status
  113. ULONG reg_rpt_end_sts:1; // Repeating key end interrupt status
  114. ULONG reg_rpt_sts:1; // Repeating key interrupt status (Keep sending interrupts)
  115. ULONG Reserved0E:3;
  116. // 0x0f Number of Interrupts in Queue
  117. ULONG reg_cmdq_cnt:5; // Number of remaining interrupts in queue
  118. ULONG Reserved0F:3;
  119. } Reg0C;
  120. };
  121. union{ // 0x10 ~ 0x13
  122. ULONG Value10;
  123. struct{
  124. ULONG Reserved:32;
  125. } Reg10;
  126. };
  127. union{ // 0x14 ~ 0x17
  128. ULONG Value14;
  129. struct{
  130. ULONG Reserved:32;
  131. } Reg14;
  132. };
  133. union{ // 0x18 ~ 0x1b
  134. ULONG Value18;
  135. struct{
  136. ULONG Reserved:32;
  137. } Reg18;
  138. };
  139. union{ // 0x1c ~ 0x1f
  140. ULONG Value1C;
  141. struct{
  142. ULONG Reserved:32;
  143. } Reg1C;
  144. };
  145. union{ // 0x20 ~ 0x23
  146. ULONG Value20;
  147. struct{
  148. ULONG Reserved:32;
  149. } Reg20;
  150. };
  151. union{ // 0x24 ~ 0x27
  152. ULONG Value24;
  153. struct{
  154. ULONG Reserved:32;
  155. } Reg24;
  156. };
  157. union{ // 0x28 ~ 0x2b
  158. ULONG Value28;
  159. struct{
  160. ULONG Reserved:32;
  161. } Reg28;
  162. };
  163. union{ // 0x2c ~ 0x2f
  164. ULONG Value2C;
  165. struct{
  166. ULONG Reserved:32;
  167. } Reg2C;
  168. };
  169. union{ // 0x30 ~ 0x33
  170. ULONG Value30;
  171. struct{
  172. ULONG Reserved:32;
  173. } Reg30;
  174. };
  175. union{ // 0x34 ~ 0x37
  176. ULONG Value34;
  177. struct{
  178. ULONG Reserved:32;
  179. } Reg34;
  180. };
  181. union{ // 0x38 ~ 0x3b
  182. ULONG Value38;
  183. struct{
  184. ULONG Reserved:32;
  185. } Reg38;
  186. };
  187. union{ // 0x3c ~ 0x3f
  188. ULONG Value3C;
  189. struct{
  190. ULONG Reserved:32;
  191. } Reg3C;
  192. };
  193. union{ // 0x40 ~ 0x43
  194. ULONG Value40;
  195. struct{
  196. ULONG Reserved:32;
  197. } Reg40;
  198. };
  199. union{ // 0x44 ~ 0x47
  200. ULONG Value44;
  201. struct{
  202. ULONG Reserved:32;
  203. } Reg44;
  204. };
  205. union{ // 0x48 ~ 0x4b
  206. ULONG Value48;
  207. struct{
  208. ULONG Reserved:32;
  209. } Reg48;
  210. };
  211. union{ // 0x4c ~ 0x4f
  212. ULONG Value4C;
  213. struct{
  214. ULONG Reserved:32;
  215. } Reg4C;
  216. };
  217. union{ // 0x50 ~ 0x53
  218. ULONG Value50;
  219. struct{
  220. ULONG Reserved:32;
  221. } Reg50;
  222. };
  223. union{ // 0x54 ~ 0x57
  224. ULONG Value54;
  225. struct{
  226. ULONG Reserved:32;
  227. } Reg54;
  228. };
  229. union{ // 0x58 ~ 0x5B
  230. ULONG Value58;
  231. struct{
  232. ULONG Reserved:32;
  233. } Reg58;
  234. };
  235. } Registers;
  236. };
  237. }IR_Hardware_Parameter;
  238. typedef struct _IRdatas{
  239. union{
  240. ULONG Value;
  241. struct{
  242. ULONG reg_cmd:8; // Command code (Raw bit-stream if reg_reorder_en = 0) ; Valid if reg_single_sts = 1
  243. ULONG reg_adr:8; // Address code (Raw bit-stream if reg_reorder_en = 0) ; Valid if reg_single_sts = 1
  244. // 0x0e IR Interrupt Status Registers
  245. ULONG reg_intr_sts:1; // IR global interrupt status; Write 1 Clear
  246. ULONG reg_single_sts:1; // Single key interrupt status
  247. ULONG reg_rpt_start_sts:1; // Repeating key start interrupt status
  248. ULONG reg_rpt_end_sts:1; // Repeating key end interrupt status
  249. ULONG reg_rpt_sts:1; // Repeating key interrupt status (Keep sending interrupts)
  250. ULONG Reserved0E:3;
  251. // 0x0f Number of Interrupts in Queue
  252. ULONG reg_cmdq_cnt:5; // Number of remaining interrupts in queue
  253. ULONG Reserved0F:3;
  254. } Reg;
  255. };
  256. } IRdatas;
  257. //function
  258. void sisir_initfun(void);
  259. void sisir_exitfun(IRDEVPTR pir);
  260. void sisir_isrfun(UINT8* mmiobase, UINT8* mmiobase2, IR_IOC_IOData* dataBuf);
  261. int IRHandlerInit(void);
  262. #endif // end of #ifndef _IR_H