keypad.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _KEYPAD_H_
  13. #define _KEYPAD_H_
  14. // Auto generated by dtools(see dtools.txt for its version).
  15. // Don't edit it manually!
  16. #define KEY_NB (36)
  17. #define LOW_KEY_NB (30)
  18. #define HIGH_KEY_NB (6)
  19. #define REG_KEYPAD_BASE (0x51706000)
  20. typedef volatile struct
  21. {
  22. uint32_t kp_data_l; // 0x00000000
  23. uint32_t kp_data_h; // 0x00000004
  24. uint32_t kp_status; // 0x00000008
  25. uint32_t kp_ctrl; // 0x0000000c
  26. uint32_t kp_irq_mask; // 0x00000010
  27. uint32_t kp_irq_cause; // 0x00000014
  28. uint32_t kp_irq_clr; // 0x00000018
  29. } HWP_KEYPAD_T;
  30. #define hwp_keypad ((HWP_KEYPAD_T *)REG_ACCESS_ADDRESS(REG_KEYPAD_BASE))
  31. // kp_status
  32. typedef union {
  33. uint32_t v;
  34. struct
  35. {
  36. uint32_t keyin_status : 8; // [7:0], read only
  37. uint32_t __30_8 : 23; // [30:8]
  38. uint32_t kp_on : 1; // [31], read only
  39. } b;
  40. } REG_KEYPAD_KP_STATUS_T;
  41. // kp_ctrl
  42. typedef union {
  43. uint32_t v;
  44. struct
  45. {
  46. uint32_t kp_en : 1; // [0]
  47. uint32_t __1_1 : 1; // [1]
  48. uint32_t kp_dbn_time : 8; // [9:2]
  49. uint32_t kp_itv_time : 6; // [15:10]
  50. uint32_t kp_in_mask : 8; // [23:16]
  51. uint32_t kp_out_mask : 8; // [31:24]
  52. } b;
  53. } REG_KEYPAD_KP_CTRL_T;
  54. // kp_irq_mask
  55. typedef union {
  56. uint32_t v;
  57. struct
  58. {
  59. uint32_t kp_evt0_irq_mask : 1; // [0]
  60. uint32_t kp_evt1_irq_mask : 1; // [1]
  61. uint32_t kp_itv_irq_mask : 1; // [2]
  62. uint32_t __31_3 : 29; // [31:3]
  63. } b;
  64. } REG_KEYPAD_KP_IRQ_MASK_T;
  65. // kp_irq_cause
  66. typedef union {
  67. uint32_t v;
  68. struct
  69. {
  70. uint32_t kp_evt0_irq_cause : 1; // [0], read only
  71. uint32_t kp_evt1_irq_cause : 1; // [1], read only
  72. uint32_t kp_itv_irq_cause : 1; // [2], read only
  73. uint32_t __15_3 : 13; // [15:3]
  74. uint32_t kp_evt0_irq_status : 1; // [16], read only
  75. uint32_t kp_evt1_irq_status : 1; // [17], read only
  76. uint32_t kp_itv_irq_status : 1; // [18], read only
  77. uint32_t __31_19 : 13; // [31:19]
  78. } b;
  79. } REG_KEYPAD_KP_IRQ_CAUSE_T;
  80. // kp_irq_clr
  81. typedef union {
  82. uint32_t v;
  83. struct
  84. {
  85. uint32_t kp_irq_clr : 1; // [0], write clear
  86. uint32_t __31_1 : 31; // [31:1]
  87. } b;
  88. } REG_KEYPAD_KP_IRQ_CLR_T;
  89. // kp_status
  90. #define KEYPAD_KEYIN_STATUS(n) (((n)&0xff) << 0)
  91. #define KEYPAD_KP_ON (1 << 31)
  92. // kp_ctrl
  93. #define KEYPAD_KP_EN (1 << 0)
  94. #define KEYPAD_KP_DBN_TIME(n) (((n)&0xff) << 2)
  95. #define KEYPAD_KP_ITV_TIME(n) (((n)&0x3f) << 10)
  96. #define KEYPAD_KP_IN_MASK(n) (((n)&0xff) << 16)
  97. #define KEYPAD_KP_OUT_MASK(n) (((n)&0xff) << 24)
  98. // kp_irq_mask
  99. #define KEYPAD_KP_EVT0_IRQ_MASK (1 << 0)
  100. #define KEYPAD_KP_EVT1_IRQ_MASK (1 << 1)
  101. #define KEYPAD_KP_ITV_IRQ_MASK (1 << 2)
  102. // kp_irq_cause
  103. #define KEYPAD_KP_EVT0_IRQ_CAUSE (1 << 0)
  104. #define KEYPAD_KP_EVT1_IRQ_CAUSE (1 << 1)
  105. #define KEYPAD_KP_ITV_IRQ_CAUSE (1 << 2)
  106. #define KEYPAD_KP_EVT0_IRQ_STATUS (1 << 16)
  107. #define KEYPAD_KP_EVT1_IRQ_STATUS (1 << 17)
  108. #define KEYPAD_KP_ITV_IRQ_STATUS (1 << 18)
  109. // kp_irq_clr
  110. #define KEYPAD_KP_IRQ_CLR (1 << 0)
  111. #endif // _KEYPAD_H_