Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Analog Devices ADP5589/ADP5585 I/O Expander and QWERTY Keypad Controller
0004  *
0005  * Copyright 2010-2011 Analog Devices Inc.
0006  */
0007 
0008 #ifndef _ADP5589_H
0009 #define _ADP5589_H
0010 
0011 /*
0012  * ADP5589 specific GPI and Keymap defines
0013  */
0014 
0015 #define ADP5589_KEYMAPSIZE  88
0016 
0017 #define ADP5589_GPI_PIN_ROW0 97
0018 #define ADP5589_GPI_PIN_ROW1 98
0019 #define ADP5589_GPI_PIN_ROW2 99
0020 #define ADP5589_GPI_PIN_ROW3 100
0021 #define ADP5589_GPI_PIN_ROW4 101
0022 #define ADP5589_GPI_PIN_ROW5 102
0023 #define ADP5589_GPI_PIN_ROW6 103
0024 #define ADP5589_GPI_PIN_ROW7 104
0025 #define ADP5589_GPI_PIN_COL0 105
0026 #define ADP5589_GPI_PIN_COL1 106
0027 #define ADP5589_GPI_PIN_COL2 107
0028 #define ADP5589_GPI_PIN_COL3 108
0029 #define ADP5589_GPI_PIN_COL4 109
0030 #define ADP5589_GPI_PIN_COL5 110
0031 #define ADP5589_GPI_PIN_COL6 111
0032 #define ADP5589_GPI_PIN_COL7 112
0033 #define ADP5589_GPI_PIN_COL8 113
0034 #define ADP5589_GPI_PIN_COL9 114
0035 #define ADP5589_GPI_PIN_COL10 115
0036 #define GPI_LOGIC1 116
0037 #define GPI_LOGIC2 117
0038 
0039 #define ADP5589_GPI_PIN_ROW_BASE ADP5589_GPI_PIN_ROW0
0040 #define ADP5589_GPI_PIN_ROW_END ADP5589_GPI_PIN_ROW7
0041 #define ADP5589_GPI_PIN_COL_BASE ADP5589_GPI_PIN_COL0
0042 #define ADP5589_GPI_PIN_COL_END ADP5589_GPI_PIN_COL10
0043 
0044 #define ADP5589_GPI_PIN_BASE ADP5589_GPI_PIN_ROW_BASE
0045 #define ADP5589_GPI_PIN_END ADP5589_GPI_PIN_COL_END
0046 
0047 #define ADP5589_GPIMAPSIZE_MAX (ADP5589_GPI_PIN_END - ADP5589_GPI_PIN_BASE + 1)
0048 
0049 /*
0050  * ADP5585 specific GPI and Keymap defines
0051  */
0052 
0053 #define ADP5585_KEYMAPSIZE  30
0054 
0055 #define ADP5585_GPI_PIN_ROW0 37
0056 #define ADP5585_GPI_PIN_ROW1 38
0057 #define ADP5585_GPI_PIN_ROW2 39
0058 #define ADP5585_GPI_PIN_ROW3 40
0059 #define ADP5585_GPI_PIN_ROW4 41
0060 #define ADP5585_GPI_PIN_ROW5 42
0061 #define ADP5585_GPI_PIN_COL0 43
0062 #define ADP5585_GPI_PIN_COL1 44
0063 #define ADP5585_GPI_PIN_COL2 45
0064 #define ADP5585_GPI_PIN_COL3 46
0065 #define ADP5585_GPI_PIN_COL4 47
0066 #define GPI_LOGIC 48
0067 
0068 #define ADP5585_GPI_PIN_ROW_BASE ADP5585_GPI_PIN_ROW0
0069 #define ADP5585_GPI_PIN_ROW_END ADP5585_GPI_PIN_ROW5
0070 #define ADP5585_GPI_PIN_COL_BASE ADP5585_GPI_PIN_COL0
0071 #define ADP5585_GPI_PIN_COL_END ADP5585_GPI_PIN_COL4
0072 
0073 #define ADP5585_GPI_PIN_BASE ADP5585_GPI_PIN_ROW_BASE
0074 #define ADP5585_GPI_PIN_END ADP5585_GPI_PIN_COL_END
0075 
0076 #define ADP5585_GPIMAPSIZE_MAX (ADP5585_GPI_PIN_END - ADP5585_GPI_PIN_BASE + 1)
0077 
0078 struct adp5589_gpi_map {
0079     unsigned short pin;
0080     unsigned short sw_evt;
0081 };
0082 
0083 /* scan_cycle_time */
0084 #define ADP5589_SCAN_CYCLE_10ms     0
0085 #define ADP5589_SCAN_CYCLE_20ms     1
0086 #define ADP5589_SCAN_CYCLE_30ms     2
0087 #define ADP5589_SCAN_CYCLE_40ms     3
0088 
0089 /* RESET_CFG */
0090 #define RESET_PULSE_WIDTH_500us     0
0091 #define RESET_PULSE_WIDTH_1ms       1
0092 #define RESET_PULSE_WIDTH_2ms       2
0093 #define RESET_PULSE_WIDTH_10ms      3
0094 
0095 #define RESET_TRIG_TIME_0ms     (0 << 2)
0096 #define RESET_TRIG_TIME_1000ms      (1 << 2)
0097 #define RESET_TRIG_TIME_1500ms      (2 << 2)
0098 #define RESET_TRIG_TIME_2000ms      (3 << 2)
0099 #define RESET_TRIG_TIME_2500ms      (4 << 2)
0100 #define RESET_TRIG_TIME_3000ms      (5 << 2)
0101 #define RESET_TRIG_TIME_3500ms      (6 << 2)
0102 #define RESET_TRIG_TIME_4000ms      (7 << 2)
0103 
0104 #define RESET_PASSTHRU_EN       (1 << 5)
0105 #define RESET1_POL_HIGH         (1 << 6)
0106 #define RESET1_POL_LOW          (0 << 6)
0107 #define RESET2_POL_HIGH         (1 << 7)
0108 #define RESET2_POL_LOW          (0 << 7)
0109 
0110 /* ADP5589 Mask Bits:
0111  * C C C C C C C C C C C | R R R R R R R R
0112  * 1 9 8 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0
0113  * 0
0114  * ---------------- BIT ------------------
0115  * 1 1 1 1 1 1 1 1 1 0 0 | 0 0 0 0 0 0 0 0
0116  * 8 7 6 5 4 3 2 1 0 9 8 | 7 6 5 4 3 2 1 0
0117  */
0118 
0119 #define ADP_ROW(x)  (1 << (x))
0120 #define ADP_COL(x)  (1 << (x + 8))
0121 #define ADP5589_ROW_MASK        0xFF
0122 #define ADP5589_COL_MASK        0xFF
0123 #define ADP5589_COL_SHIFT       8
0124 #define ADP5589_MAX_ROW_NUM     7
0125 #define ADP5589_MAX_COL_NUM     10
0126 
0127 /* ADP5585 Mask Bits:
0128  * C C C C C | R R R R R R
0129  * 4 3 2 1 0 | 5 4 3 2 1 0
0130  *
0131  * ---- BIT -- -----------
0132  * 1 0 0 0 0 | 0 0 0 0 0 0
0133  * 0 9 8 7 6 | 5 4 3 2 1 0
0134  */
0135 
0136 #define ADP5585_ROW_MASK        0x3F
0137 #define ADP5585_COL_MASK        0x1F
0138 #define ADP5585_ROW_SHIFT       0
0139 #define ADP5585_COL_SHIFT       6
0140 #define ADP5585_MAX_ROW_NUM     5
0141 #define ADP5585_MAX_COL_NUM     4
0142 
0143 #define ADP5585_ROW(x)  (1 << ((x) & ADP5585_ROW_MASK))
0144 #define ADP5585_COL(x)  (1 << (((x) & ADP5585_COL_MASK) + ADP5585_COL_SHIFT))
0145 
0146 /* Put one of these structures in i2c_board_info platform_data */
0147 
0148 struct adp5589_kpad_platform_data {
0149     unsigned keypad_en_mask;    /* Keypad (Rows/Columns) enable mask */
0150     const unsigned short *keymap;   /* Pointer to keymap */
0151     unsigned short keymapsize;  /* Keymap size */
0152     bool repeat;            /* Enable key repeat */
0153     bool en_keylock;        /* Enable key lock feature (ADP5589 only)*/
0154     unsigned char unlock_key1;  /* Unlock Key 1 (ADP5589 only) */
0155     unsigned char unlock_key2;  /* Unlock Key 2 (ADP5589 only) */
0156     unsigned char unlock_timer; /* Time in seconds [0..7] between the two unlock keys 0=disable (ADP5589 only) */
0157     unsigned char scan_cycle_time;  /* Time between consecutive scan cycles */
0158     unsigned char reset_cfg;    /* Reset config */
0159     unsigned short reset1_key_1;    /* Reset Key 1 */
0160     unsigned short reset1_key_2;    /* Reset Key 2 */
0161     unsigned short reset1_key_3;    /* Reset Key 3 */
0162     unsigned short reset2_key_1;    /* Reset Key 1 */
0163     unsigned short reset2_key_2;    /* Reset Key 2 */
0164     unsigned debounce_dis_mask; /* Disable debounce mask */
0165     unsigned pull_dis_mask;     /* Disable all pull resistors mask */
0166     unsigned pullup_en_100k;    /* Pull-Up 100k Enable Mask */
0167     unsigned pullup_en_300k;    /* Pull-Up 300k Enable Mask */
0168     unsigned pulldown_en_300k;  /* Pull-Down 300k Enable Mask */
0169     const struct adp5589_gpi_map *gpimap;
0170     unsigned short gpimapsize;
0171     const struct adp5589_gpio_platform_data *gpio_data;
0172 };
0173 
0174 struct i2c_client; /* forward declaration */
0175 
0176 struct adp5589_gpio_platform_data {
0177     int gpio_start; /* GPIO Chip base # */
0178 };
0179 
0180 #endif