0001
0002
0003
0004
0005
0006
0007
0008 #ifndef _ADP5588_H
0009 #define _ADP5588_H
0010
0011 #define DEV_ID 0x00
0012 #define CFG 0x01
0013 #define INT_STAT 0x02
0014 #define KEY_LCK_EC_STAT 0x03
0015 #define Key_EVENTA 0x04
0016 #define Key_EVENTB 0x05
0017 #define Key_EVENTC 0x06
0018 #define Key_EVENTD 0x07
0019 #define Key_EVENTE 0x08
0020 #define Key_EVENTF 0x09
0021 #define Key_EVENTG 0x0A
0022 #define Key_EVENTH 0x0B
0023 #define Key_EVENTI 0x0C
0024 #define Key_EVENTJ 0x0D
0025 #define KP_LCK_TMR 0x0E
0026 #define UNLOCK1 0x0F
0027 #define UNLOCK2 0x10
0028 #define GPIO_INT_STAT1 0x11
0029 #define GPIO_INT_STAT2 0x12
0030 #define GPIO_INT_STAT3 0x13
0031 #define GPIO_DAT_STAT1 0x14
0032 #define GPIO_DAT_STAT2 0x15
0033 #define GPIO_DAT_STAT3 0x16
0034 #define GPIO_DAT_OUT1 0x17
0035 #define GPIO_DAT_OUT2 0x18
0036 #define GPIO_DAT_OUT3 0x19
0037 #define GPIO_INT_EN1 0x1A
0038 #define GPIO_INT_EN2 0x1B
0039 #define GPIO_INT_EN3 0x1C
0040 #define KP_GPIO1 0x1D
0041 #define KP_GPIO2 0x1E
0042 #define KP_GPIO3 0x1F
0043 #define GPI_EM1 0x20
0044 #define GPI_EM2 0x21
0045 #define GPI_EM3 0x22
0046 #define GPIO_DIR1 0x23
0047 #define GPIO_DIR2 0x24
0048 #define GPIO_DIR3 0x25
0049 #define GPIO_INT_LVL1 0x26
0050 #define GPIO_INT_LVL2 0x27
0051 #define GPIO_INT_LVL3 0x28
0052 #define Debounce_DIS1 0x29
0053 #define Debounce_DIS2 0x2A
0054 #define Debounce_DIS3 0x2B
0055 #define GPIO_PULL1 0x2C
0056 #define GPIO_PULL2 0x2D
0057 #define GPIO_PULL3 0x2E
0058 #define CMP_CFG_STAT 0x30
0059 #define CMP_CONFG_SENS1 0x31
0060 #define CMP_CONFG_SENS2 0x32
0061 #define CMP1_LVL2_TRIP 0x33
0062 #define CMP1_LVL2_HYS 0x34
0063 #define CMP1_LVL3_TRIP 0x35
0064 #define CMP1_LVL3_HYS 0x36
0065 #define CMP2_LVL2_TRIP 0x37
0066 #define CMP2_LVL2_HYS 0x38
0067 #define CMP2_LVL3_TRIP 0x39
0068 #define CMP2_LVL3_HYS 0x3A
0069 #define CMP1_ADC_DAT_R1 0x3B
0070 #define CMP1_ADC_DAT_R2 0x3C
0071 #define CMP2_ADC_DAT_R1 0x3D
0072 #define CMP2_ADC_DAT_R2 0x3E
0073
0074 #define ADP5588_DEVICE_ID_MASK 0xF
0075
0076
0077 #define ADP5588_AUTO_INC (1 << 7)
0078 #define ADP5588_GPIEM_CFG (1 << 6)
0079 #define ADP5588_OVR_FLOW_M (1 << 5)
0080 #define ADP5588_INT_CFG (1 << 4)
0081 #define ADP5588_OVR_FLOW_IEN (1 << 3)
0082 #define ADP5588_K_LCK_IM (1 << 2)
0083 #define ADP5588_GPI_IEN (1 << 1)
0084 #define ADP5588_KE_IEN (1 << 0)
0085
0086
0087 #define ADP5588_CMP2_INT (1 << 5)
0088 #define ADP5588_CMP1_INT (1 << 4)
0089 #define ADP5588_OVR_FLOW_INT (1 << 3)
0090 #define ADP5588_K_LCK_INT (1 << 2)
0091 #define ADP5588_GPI_INT (1 << 1)
0092 #define ADP5588_KE_INT (1 << 0)
0093
0094
0095 #define ADP5588_K_LCK_EN (1 << 6)
0096 #define ADP5588_LCK21 0x30
0097 #define ADP5588_KEC 0xF
0098
0099 #define ADP5588_MAXGPIO 18
0100 #define ADP5588_BANK(offs) ((offs) >> 3)
0101 #define ADP5588_BIT(offs) (1u << ((offs) & 0x7))
0102
0103
0104
0105 #define ADP5588_KEYMAPSIZE 80
0106
0107 #define GPI_PIN_ROW0 97
0108 #define GPI_PIN_ROW1 98
0109 #define GPI_PIN_ROW2 99
0110 #define GPI_PIN_ROW3 100
0111 #define GPI_PIN_ROW4 101
0112 #define GPI_PIN_ROW5 102
0113 #define GPI_PIN_ROW6 103
0114 #define GPI_PIN_ROW7 104
0115 #define GPI_PIN_COL0 105
0116 #define GPI_PIN_COL1 106
0117 #define GPI_PIN_COL2 107
0118 #define GPI_PIN_COL3 108
0119 #define GPI_PIN_COL4 109
0120 #define GPI_PIN_COL5 110
0121 #define GPI_PIN_COL6 111
0122 #define GPI_PIN_COL7 112
0123 #define GPI_PIN_COL8 113
0124 #define GPI_PIN_COL9 114
0125
0126 #define GPI_PIN_ROW_BASE GPI_PIN_ROW0
0127 #define GPI_PIN_ROW_END GPI_PIN_ROW7
0128 #define GPI_PIN_COL_BASE GPI_PIN_COL0
0129 #define GPI_PIN_COL_END GPI_PIN_COL9
0130
0131 #define GPI_PIN_BASE GPI_PIN_ROW_BASE
0132 #define GPI_PIN_END GPI_PIN_COL_END
0133
0134 #define ADP5588_GPIMAPSIZE_MAX (GPI_PIN_END - GPI_PIN_BASE + 1)
0135
0136 struct adp5588_gpi_map {
0137 unsigned short pin;
0138 unsigned short sw_evt;
0139 };
0140
0141 struct adp5588_kpad_platform_data {
0142 int rows;
0143 int cols;
0144 const unsigned short *keymap;
0145 unsigned short keymapsize;
0146 unsigned repeat:1;
0147 unsigned en_keylock:1;
0148 unsigned short unlock_key1;
0149 unsigned short unlock_key2;
0150 const struct adp5588_gpi_map *gpimap;
0151 unsigned short gpimapsize;
0152 const struct adp5588_gpio_platform_data *gpio_data;
0153 };
0154
0155 struct i2c_client;
0156
0157 struct adp5588_gpio_platform_data {
0158 int gpio_start;
0159 const char *const *names;
0160 unsigned irq_base;
0161 unsigned pullup_dis_mask;
0162 int (*setup)(struct i2c_client *client,
0163 unsigned gpio, unsigned ngpio,
0164 void *context);
0165 int (*teardown)(struct i2c_client *client,
0166 unsigned gpio, unsigned ngpio,
0167 void *context);
0168 void *context;
0169 };
0170
0171 #endif