Input: adp5588-keys - unify common header defines

Unify adp5588-gpio and adp5588-keys common header defines (as per Andrew
Morton request). For consistency, move remaining defines and prefix
accordingly.

No functional changes.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

authored by Michael Hennerich and committed by Dmitry Torokhov 95716c0d c8ddb271

+39 -50
+25 -49
drivers/input/keyboard/adp5588-keys.c
··· 4 * I2C QWERTY Keypad and IO Expander 5 * Bugs: Enter bugs at http://blackfin.uclinux.org/ 6 * 7 - * Copyright (C) 2008-2009 Analog Devices Inc. 8 * Licensed under the GPL-2 or later. 9 */ 10 ··· 24 25 #include <linux/i2c/adp5588.h> 26 27 - /* Configuration Register1 */ 28 - #define AUTO_INC (1 << 7) 29 - #define GPIEM_CFG (1 << 6) 30 - #define OVR_FLOW_M (1 << 5) 31 - #define INT_CFG (1 << 4) 32 - #define OVR_FLOW_IEN (1 << 3) 33 - #define K_LCK_IM (1 << 2) 34 - #define GPI_IEN (1 << 1) 35 - #define KE_IEN (1 << 0) 36 - 37 - /* Interrupt Status Register */ 38 - #define CMP2_INT (1 << 5) 39 - #define CMP1_INT (1 << 4) 40 - #define OVR_FLOW_INT (1 << 3) 41 - #define K_LCK_INT (1 << 2) 42 - #define GPI_INT (1 << 1) 43 - #define KE_INT (1 << 0) 44 - 45 - /* Key Lock and Event Counter Register */ 46 - #define K_LCK_EN (1 << 6) 47 - #define LCK21 0x30 48 - #define KEC 0xF 49 - 50 /* Key Event Register xy */ 51 #define KEY_EV_PRESSED (1 << 7) 52 #define KEY_EV_MASK (0x7F) ··· 31 #define KP_SEL(x) (0xFFFF >> (16 - x)) /* 2^x-1 */ 32 33 #define KEYP_MAX_EVENT 10 34 - 35 - #define MAXGPIO 18 36 - #define ADP_BANK(offs) ((offs) >> 3) 37 - #define ADP_BIT(offs) (1u << ((offs) & 0x7)) 38 39 /* 40 * Early pre 4.0 Silicon required to delay readout by at least 25ms, ··· 48 const struct adp5588_gpi_map *gpimap; 49 unsigned short gpimapsize; 50 #ifdef CONFIG_GPIOLIB 51 - unsigned char gpiomap[MAXGPIO]; 52 bool export_gpio; 53 struct gpio_chip gc; 54 struct mutex gpio_lock; /* Protect cached dir, dat_out */ ··· 76 static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned off) 77 { 78 struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 79 - unsigned int bank = ADP_BANK(kpad->gpiomap[off]); 80 - unsigned int bit = ADP_BIT(kpad->gpiomap[off]); 81 82 return !!(adp5588_read(kpad->client, GPIO_DAT_STAT1 + bank) & bit); 83 } ··· 86 unsigned off, int val) 87 { 88 struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 89 - unsigned int bank = ADP_BANK(kpad->gpiomap[off]); 90 - unsigned int bit = ADP_BIT(kpad->gpiomap[off]); 91 92 mutex_lock(&kpad->gpio_lock); 93 ··· 105 static int adp5588_gpio_direction_input(struct gpio_chip *chip, unsigned off) 106 { 107 struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 108 - unsigned int bank = ADP_BANK(kpad->gpiomap[off]); 109 - unsigned int bit = ADP_BIT(kpad->gpiomap[off]); 110 int ret; 111 112 mutex_lock(&kpad->gpio_lock); ··· 123 unsigned off, int val) 124 { 125 struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 126 - unsigned int bank = ADP_BANK(kpad->gpiomap[off]); 127 - unsigned int bit = ADP_BIT(kpad->gpiomap[off]); 128 int ret; 129 130 mutex_lock(&kpad->gpio_lock); ··· 149 static int __devinit adp5588_build_gpiomap(struct adp5588_kpad *kpad, 150 const struct adp5588_kpad_platform_data *pdata) 151 { 152 - bool pin_used[MAXGPIO]; 153 int n_unused = 0; 154 int i; 155 ··· 164 for (i = 0; i < kpad->gpimapsize; i++) 165 pin_used[kpad->gpimap[i].pin - GPI_PIN_BASE] = true; 166 167 - for (i = 0; i < MAXGPIO; i++) 168 if (!pin_used[i]) 169 kpad->gpiomap[n_unused++] = i; 170 ··· 207 return error; 208 } 209 210 - for (i = 0; i <= ADP_BANK(MAXGPIO); i++) { 211 kpad->dat_out[i] = adp5588_read(kpad->client, 212 GPIO_DAT_OUT1 + i); 213 kpad->dir[i] = adp5588_read(kpad->client, GPIO_DIR1 + i); ··· 291 292 status = adp5588_read(client, INT_STAT); 293 294 - if (status & OVR_FLOW_INT) /* Unlikely and should never happen */ 295 dev_err(&client->dev, "Event Overflow Error\n"); 296 297 - if (status & KE_INT) { 298 - ev_cnt = adp5588_read(client, KEY_LCK_EC_STAT) & KEC; 299 if (ev_cnt) { 300 adp5588_report_events(kpad, ev_cnt); 301 input_sync(kpad->input); ··· 333 if (pdata->en_keylock) { 334 ret |= adp5588_write(client, UNLOCK1, pdata->unlock_key1); 335 ret |= adp5588_write(client, UNLOCK2, pdata->unlock_key2); 336 - ret |= adp5588_write(client, KEY_LCK_EC_STAT, K_LCK_EN); 337 } 338 339 for (i = 0; i < KEYP_MAX_EVENT; i++) ··· 357 } 358 359 if (gpio_data) { 360 - for (i = 0; i <= ADP_BANK(MAXGPIO); i++) { 361 int pull_mask = gpio_data->pullup_dis_mask; 362 363 ret |= adp5588_write(client, GPIO_PULL1 + i, ··· 365 } 366 } 367 368 - ret |= adp5588_write(client, INT_STAT, CMP2_INT | CMP1_INT | 369 - OVR_FLOW_INT | K_LCK_INT | 370 - GPI_INT | KE_INT); /* Status is W1C */ 371 372 - ret |= adp5588_write(client, CFG, INT_CFG | OVR_FLOW_IEN | KE_IEN); 373 374 if (ret < 0) { 375 dev_err(&client->dev, "Write Error\n");
··· 4 * I2C QWERTY Keypad and IO Expander 5 * Bugs: Enter bugs at http://blackfin.uclinux.org/ 6 * 7 + * Copyright (C) 2008-2010 Analog Devices Inc. 8 * Licensed under the GPL-2 or later. 9 */ 10 ··· 24 25 #include <linux/i2c/adp5588.h> 26 27 /* Key Event Register xy */ 28 #define KEY_EV_PRESSED (1 << 7) 29 #define KEY_EV_MASK (0x7F) ··· 54 #define KP_SEL(x) (0xFFFF >> (16 - x)) /* 2^x-1 */ 55 56 #define KEYP_MAX_EVENT 10 57 58 /* 59 * Early pre 4.0 Silicon required to delay readout by at least 25ms, ··· 75 const struct adp5588_gpi_map *gpimap; 76 unsigned short gpimapsize; 77 #ifdef CONFIG_GPIOLIB 78 + unsigned char gpiomap[ADP5588_MAXGPIO]; 79 bool export_gpio; 80 struct gpio_chip gc; 81 struct mutex gpio_lock; /* Protect cached dir, dat_out */ ··· 103 static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned off) 104 { 105 struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 106 + unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]); 107 + unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]); 108 109 return !!(adp5588_read(kpad->client, GPIO_DAT_STAT1 + bank) & bit); 110 } ··· 113 unsigned off, int val) 114 { 115 struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 116 + unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]); 117 + unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]); 118 119 mutex_lock(&kpad->gpio_lock); 120 ··· 132 static int adp5588_gpio_direction_input(struct gpio_chip *chip, unsigned off) 133 { 134 struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 135 + unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]); 136 + unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]); 137 int ret; 138 139 mutex_lock(&kpad->gpio_lock); ··· 150 unsigned off, int val) 151 { 152 struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 153 + unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]); 154 + unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]); 155 int ret; 156 157 mutex_lock(&kpad->gpio_lock); ··· 176 static int __devinit adp5588_build_gpiomap(struct adp5588_kpad *kpad, 177 const struct adp5588_kpad_platform_data *pdata) 178 { 179 + bool pin_used[ADP5588_MAXGPIO]; 180 int n_unused = 0; 181 int i; 182 ··· 191 for (i = 0; i < kpad->gpimapsize; i++) 192 pin_used[kpad->gpimap[i].pin - GPI_PIN_BASE] = true; 193 194 + for (i = 0; i < ADP5588_MAXGPIO; i++) 195 if (!pin_used[i]) 196 kpad->gpiomap[n_unused++] = i; 197 ··· 234 return error; 235 } 236 237 + for (i = 0; i <= ADP5588_BANK(ADP5588_MAXGPIO); i++) { 238 kpad->dat_out[i] = adp5588_read(kpad->client, 239 GPIO_DAT_OUT1 + i); 240 kpad->dir[i] = adp5588_read(kpad->client, GPIO_DIR1 + i); ··· 318 319 status = adp5588_read(client, INT_STAT); 320 321 + if (status & ADP5588_OVR_FLOW_INT) /* Unlikely and should never happen */ 322 dev_err(&client->dev, "Event Overflow Error\n"); 323 324 + if (status & ADP5588_KE_INT) { 325 + ev_cnt = adp5588_read(client, KEY_LCK_EC_STAT) & ADP5588_KEC; 326 if (ev_cnt) { 327 adp5588_report_events(kpad, ev_cnt); 328 input_sync(kpad->input); ··· 360 if (pdata->en_keylock) { 361 ret |= adp5588_write(client, UNLOCK1, pdata->unlock_key1); 362 ret |= adp5588_write(client, UNLOCK2, pdata->unlock_key2); 363 + ret |= adp5588_write(client, KEY_LCK_EC_STAT, ADP5588_K_LCK_EN); 364 } 365 366 for (i = 0; i < KEYP_MAX_EVENT; i++) ··· 384 } 385 386 if (gpio_data) { 387 + for (i = 0; i <= ADP5588_BANK(ADP5588_MAXGPIO); i++) { 388 int pull_mask = gpio_data->pullup_dis_mask; 389 390 ret |= adp5588_write(client, GPIO_PULL1 + i, ··· 392 } 393 } 394 395 + ret |= adp5588_write(client, INT_STAT, 396 + ADP5588_CMP2_INT | ADP5588_CMP1_INT | 397 + ADP5588_OVR_FLOW_INT | ADP5588_K_LCK_INT | 398 + ADP5588_GPI_INT | ADP5588_KE_INT); /* Status is W1C */ 399 400 + ret |= adp5588_write(client, CFG, ADP5588_INT_CFG | 401 + ADP5588_OVR_FLOW_IEN | 402 + ADP5588_KE_IEN); 403 404 if (ret < 0) { 405 dev_err(&client->dev, "Write Error\n");
+14 -1
include/linux/i2c/adp5588.h
··· 1 /* 2 * Analog Devices ADP5588 I/O Expander and QWERTY Keypad Controller 3 * 4 - * Copyright 2009 Analog Devices Inc. 5 * 6 * Licensed under the GPL-2 or later. 7 */ ··· 77 /* Configuration Register1 */ 78 #define ADP5588_AUTO_INC (1 << 7) 79 #define ADP5588_GPIEM_CFG (1 << 6) 80 #define ADP5588_INT_CFG (1 << 4) 81 #define ADP5588_GPI_IEN (1 << 1) 82 83 /* Interrupt Status Register */ 84 #define ADP5588_GPI_INT (1 << 1) 85 #define ADP5588_KE_INT (1 << 0) 86 87 #define ADP5588_MAXGPIO 18 88 #define ADP5588_BANK(offs) ((offs) >> 3)
··· 1 /* 2 * Analog Devices ADP5588 I/O Expander and QWERTY Keypad Controller 3 * 4 + * Copyright 2009-2010 Analog Devices Inc. 5 * 6 * Licensed under the GPL-2 or later. 7 */ ··· 77 /* Configuration Register1 */ 78 #define ADP5588_AUTO_INC (1 << 7) 79 #define ADP5588_GPIEM_CFG (1 << 6) 80 + #define ADP5588_OVR_FLOW_M (1 << 5) 81 #define ADP5588_INT_CFG (1 << 4) 82 + #define ADP5588_OVR_FLOW_IEN (1 << 3) 83 + #define ADP5588_K_LCK_IM (1 << 2) 84 #define ADP5588_GPI_IEN (1 << 1) 85 + #define ADP5588_KE_IEN (1 << 0) 86 87 /* Interrupt Status Register */ 88 + #define ADP5588_CMP2_INT (1 << 5) 89 + #define ADP5588_CMP1_INT (1 << 4) 90 + #define ADP5588_OVR_FLOW_INT (1 << 3) 91 + #define ADP5588_K_LCK_INT (1 << 2) 92 #define ADP5588_GPI_INT (1 << 1) 93 #define ADP5588_KE_INT (1 << 0) 94 + 95 + /* Key Lock and Event Counter Register */ 96 + #define ADP5588_K_LCK_EN (1 << 6) 97 + #define ADP5588_LCK21 0x30 98 + #define ADP5588_KEC 0xF 99 100 #define ADP5588_MAXGPIO 18 101 #define ADP5588_BANK(offs) ((offs) >> 3)