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