adp5589.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*
  2. * Analog Devices ADP5589/ADP5585 I/O Expander and QWERTY Keypad Controller
  3. *
  4. * Copyright 2010-2011 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2.
  7. */
  8. #ifndef _ADP5589_H
  9. #define _ADP5589_H
  10. /*
  11. * ADP5589 specific GPI and Keymap defines
  12. */
  13. #define ADP5589_KEYMAPSIZE 88
  14. #define ADP5589_GPI_PIN_ROW0 97
  15. #define ADP5589_GPI_PIN_ROW1 98
  16. #define ADP5589_GPI_PIN_ROW2 99
  17. #define ADP5589_GPI_PIN_ROW3 100
  18. #define ADP5589_GPI_PIN_ROW4 101
  19. #define ADP5589_GPI_PIN_ROW5 102
  20. #define ADP5589_GPI_PIN_ROW6 103
  21. #define ADP5589_GPI_PIN_ROW7 104
  22. #define ADP5589_GPI_PIN_COL0 105
  23. #define ADP5589_GPI_PIN_COL1 106
  24. #define ADP5589_GPI_PIN_COL2 107
  25. #define ADP5589_GPI_PIN_COL3 108
  26. #define ADP5589_GPI_PIN_COL4 109
  27. #define ADP5589_GPI_PIN_COL5 110
  28. #define ADP5589_GPI_PIN_COL6 111
  29. #define ADP5589_GPI_PIN_COL7 112
  30. #define ADP5589_GPI_PIN_COL8 113
  31. #define ADP5589_GPI_PIN_COL9 114
  32. #define ADP5589_GPI_PIN_COL10 115
  33. #define GPI_LOGIC1 116
  34. #define GPI_LOGIC2 117
  35. #define ADP5589_GPI_PIN_ROW_BASE ADP5589_GPI_PIN_ROW0
  36. #define ADP5589_GPI_PIN_ROW_END ADP5589_GPI_PIN_ROW7
  37. #define ADP5589_GPI_PIN_COL_BASE ADP5589_GPI_PIN_COL0
  38. #define ADP5589_GPI_PIN_COL_END ADP5589_GPI_PIN_COL10
  39. #define ADP5589_GPI_PIN_BASE ADP5589_GPI_PIN_ROW_BASE
  40. #define ADP5589_GPI_PIN_END ADP5589_GPI_PIN_COL_END
  41. #define ADP5589_GPIMAPSIZE_MAX (ADP5589_GPI_PIN_END - ADP5589_GPI_PIN_BASE + 1)
  42. /*
  43. * ADP5585 specific GPI and Keymap defines
  44. */
  45. #define ADP5585_KEYMAPSIZE 30
  46. #define ADP5585_GPI_PIN_ROW0 37
  47. #define ADP5585_GPI_PIN_ROW1 38
  48. #define ADP5585_GPI_PIN_ROW2 39
  49. #define ADP5585_GPI_PIN_ROW3 40
  50. #define ADP5585_GPI_PIN_ROW4 41
  51. #define ADP5585_GPI_PIN_ROW5 42
  52. #define ADP5585_GPI_PIN_COL0 43
  53. #define ADP5585_GPI_PIN_COL1 44
  54. #define ADP5585_GPI_PIN_COL2 45
  55. #define ADP5585_GPI_PIN_COL3 46
  56. #define ADP5585_GPI_PIN_COL4 47
  57. #define GPI_LOGIC 48
  58. #define ADP5585_GPI_PIN_ROW_BASE ADP5585_GPI_PIN_ROW0
  59. #define ADP5585_GPI_PIN_ROW_END ADP5585_GPI_PIN_ROW5
  60. #define ADP5585_GPI_PIN_COL_BASE ADP5585_GPI_PIN_COL0
  61. #define ADP5585_GPI_PIN_COL_END ADP5585_GPI_PIN_COL4
  62. #define ADP5585_GPI_PIN_BASE ADP5585_GPI_PIN_ROW_BASE
  63. #define ADP5585_GPI_PIN_END ADP5585_GPI_PIN_COL_END
  64. #define ADP5585_GPIMAPSIZE_MAX (ADP5585_GPI_PIN_END - ADP5585_GPI_PIN_BASE + 1)
  65. struct adp5589_gpi_map {
  66. unsigned short pin;
  67. unsigned short sw_evt;
  68. };
  69. /* scan_cycle_time */
  70. #define ADP5589_SCAN_CYCLE_10ms 0
  71. #define ADP5589_SCAN_CYCLE_20ms 1
  72. #define ADP5589_SCAN_CYCLE_30ms 2
  73. #define ADP5589_SCAN_CYCLE_40ms 3
  74. /* RESET_CFG */
  75. #define RESET_PULSE_WIDTH_500us 0
  76. #define RESET_PULSE_WIDTH_1ms 1
  77. #define RESET_PULSE_WIDTH_2ms 2
  78. #define RESET_PULSE_WIDTH_10ms 3
  79. #define RESET_TRIG_TIME_0ms (0 << 2)
  80. #define RESET_TRIG_TIME_1000ms (1 << 2)
  81. #define RESET_TRIG_TIME_1500ms (2 << 2)
  82. #define RESET_TRIG_TIME_2000ms (3 << 2)
  83. #define RESET_TRIG_TIME_2500ms (4 << 2)
  84. #define RESET_TRIG_TIME_3000ms (5 << 2)
  85. #define RESET_TRIG_TIME_3500ms (6 << 2)
  86. #define RESET_TRIG_TIME_4000ms (7 << 2)
  87. #define RESET_PASSTHRU_EN (1 << 5)
  88. #define RESET1_POL_HIGH (1 << 6)
  89. #define RESET1_POL_LOW (0 << 6)
  90. #define RESET2_POL_HIGH (1 << 7)
  91. #define RESET2_POL_LOW (0 << 7)
  92. /* ADP5589 Mask Bits:
  93. * C C C C C C C C C C C | R R R R R R R R
  94. * 1 9 8 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0
  95. * 0
  96. * ---------------- BIT ------------------
  97. * 1 1 1 1 1 1 1 1 1 0 0 | 0 0 0 0 0 0 0 0
  98. * 8 7 6 5 4 3 2 1 0 9 8 | 7 6 5 4 3 2 1 0
  99. */
  100. #define ADP_ROW(x) (1 << (x))
  101. #define ADP_COL(x) (1 << (x + 8))
  102. #define ADP5589_ROW_MASK 0xFF
  103. #define ADP5589_COL_MASK 0xFF
  104. #define ADP5589_COL_SHIFT 8
  105. #define ADP5589_MAX_ROW_NUM 7
  106. #define ADP5589_MAX_COL_NUM 10
  107. /* ADP5585 Mask Bits:
  108. * C C C C C | R R R R R R
  109. * 4 3 2 1 0 | 5 4 3 2 1 0
  110. *
  111. * ---- BIT -- -----------
  112. * 1 0 0 0 0 | 0 0 0 0 0 0
  113. * 0 9 8 7 6 | 5 4 3 2 1 0
  114. */
  115. #define ADP5585_ROW_MASK 0x3F
  116. #define ADP5585_COL_MASK 0x1F
  117. #define ADP5585_ROW_SHIFT 0
  118. #define ADP5585_COL_SHIFT 6
  119. #define ADP5585_MAX_ROW_NUM 5
  120. #define ADP5585_MAX_COL_NUM 4
  121. #define ADP5585_ROW(x) (1 << ((x) & ADP5585_ROW_MASK))
  122. #define ADP5585_COL(x) (1 << (((x) & ADP5585_COL_MASK) + ADP5585_COL_SHIFT))
  123. /* Put one of these structures in i2c_board_info platform_data */
  124. struct adp5589_kpad_platform_data {
  125. unsigned keypad_en_mask; /* Keypad (Rows/Columns) enable mask */
  126. const unsigned short *keymap; /* Pointer to keymap */
  127. unsigned short keymapsize; /* Keymap size */
  128. bool repeat; /* Enable key repeat */
  129. bool en_keylock; /* Enable key lock feature (ADP5589 only)*/
  130. unsigned char unlock_key1; /* Unlock Key 1 (ADP5589 only) */
  131. unsigned char unlock_key2; /* Unlock Key 2 (ADP5589 only) */
  132. unsigned char unlock_timer; /* Time in seconds [0..7] between the two unlock keys 0=disable (ADP5589 only) */
  133. unsigned char scan_cycle_time; /* Time between consecutive scan cycles */
  134. unsigned char reset_cfg; /* Reset config */
  135. unsigned short reset1_key_1; /* Reset Key 1 */
  136. unsigned short reset1_key_2; /* Reset Key 2 */
  137. unsigned short reset1_key_3; /* Reset Key 3 */
  138. unsigned short reset2_key_1; /* Reset Key 1 */
  139. unsigned short reset2_key_2; /* Reset Key 2 */
  140. unsigned debounce_dis_mask; /* Disable debounce mask */
  141. unsigned pull_dis_mask; /* Disable all pull resistors mask */
  142. unsigned pullup_en_100k; /* Pull-Up 100k Enable Mask */
  143. unsigned pullup_en_300k; /* Pull-Up 300k Enable Mask */
  144. unsigned pulldown_en_300k; /* Pull-Down 300k Enable Mask */
  145. const struct adp5589_gpi_map *gpimap;
  146. unsigned short gpimapsize;
  147. const struct adp5589_gpio_platform_data *gpio_data;
  148. };
  149. struct i2c_client; /* forward declaration */
  150. struct adp5589_gpio_platform_data {
  151. int gpio_start; /* GPIO Chip base # */
  152. int (*setup)(struct i2c_client *client,
  153. int gpio, unsigned ngpio,
  154. void *context);
  155. int (*teardown)(struct i2c_client *client,
  156. int gpio, unsigned ngpio,
  157. void *context);
  158. void *context;
  159. };
  160. #endif