Release 4.11 drivers/input/keyboard/adp5589-keys.c
/*
* Description: keypad driver for ADP5589, ADP5585
* I2C QWERTY Keypad and IO Expander
* Bugs: Enter bugs at http://blackfin.uclinux.org/
*
* Copyright (C) 2010-2011 Analog Devices Inc.
* Licensed under the GPL-2.
*/
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/workqueue.h>
#include <linux/errno.h>
#include <linux/pm.h>
#include <linux/platform_device.h>
#include <linux/input.h>
#include <linux/i2c.h>
#include <linux/gpio.h>
#include <linux/slab.h>
#include <linux/input/adp5589.h>
/* ADP5589/ADP5585 Common Registers */
#define ADP5589_5_ID 0x00
#define ADP5589_5_INT_STATUS 0x01
#define ADP5589_5_STATUS 0x02
#define ADP5589_5_FIFO_1 0x03
#define ADP5589_5_FIFO_2 0x04
#define ADP5589_5_FIFO_3 0x05
#define ADP5589_5_FIFO_4 0x06
#define ADP5589_5_FIFO_5 0x07
#define ADP5589_5_FIFO_6 0x08
#define ADP5589_5_FIFO_7 0x09
#define ADP5589_5_FIFO_8 0x0A
#define ADP5589_5_FIFO_9 0x0B
#define ADP5589_5_FIFO_10 0x0C
#define ADP5589_5_FIFO_11 0x0D
#define ADP5589_5_FIFO_12 0x0E
#define ADP5589_5_FIFO_13 0x0F
#define ADP5589_5_FIFO_14 0x10
#define ADP5589_5_FIFO_15 0x11
#define ADP5589_5_FIFO_16 0x12
#define ADP5589_5_GPI_INT_STAT_A 0x13
#define ADP5589_5_GPI_INT_STAT_B 0x14
/* ADP5589 Registers */
#define ADP5589_GPI_INT_STAT_C 0x15
#define ADP5589_GPI_STATUS_A 0x16
#define ADP5589_GPI_STATUS_B 0x17
#define ADP5589_GPI_STATUS_C 0x18
#define ADP5589_RPULL_CONFIG_A 0x19
#define ADP5589_RPULL_CONFIG_B 0x1A
#define ADP5589_RPULL_CONFIG_C 0x1B
#define ADP5589_RPULL_CONFIG_D 0x1C
#define ADP5589_RPULL_CONFIG_E 0x1D
#define ADP5589_GPI_INT_LEVEL_A 0x1E
#define ADP5589_GPI_INT_LEVEL_B 0x1F
#define ADP5589_GPI_INT_LEVEL_C 0x20
#define ADP5589_GPI_EVENT_EN_A 0x21
#define ADP5589_GPI_EVENT_EN_B 0x22
#define ADP5589_GPI_EVENT_EN_C 0x23
#define ADP5589_GPI_INTERRUPT_EN_A 0x24
#define ADP5589_GPI_INTERRUPT_EN_B 0x25
#define ADP5589_GPI_INTERRUPT_EN_C 0x26
#define ADP5589_DEBOUNCE_DIS_A 0x27
#define ADP5589_DEBOUNCE_DIS_B 0x28
#define ADP5589_DEBOUNCE_DIS_C 0x29
#define ADP5589_GPO_DATA_OUT_A 0x2A
#define ADP5589_GPO_DATA_OUT_B 0x2B
#define ADP5589_GPO_DATA_OUT_C 0x2C
#define ADP5589_GPO_OUT_MODE_A 0x2D
#define ADP5589_GPO_OUT_MODE_B 0x2E
#define ADP5589_GPO_OUT_MODE_C 0x2F
#define ADP5589_GPIO_DIRECTION_A 0x30
#define ADP5589_GPIO_DIRECTION_B 0x31
#define ADP5589_GPIO_DIRECTION_C 0x32
#define ADP5589_UNLOCK1 0x33
#define ADP5589_UNLOCK2 0x34
#define ADP5589_EXT_LOCK_EVENT 0x35
#define ADP5589_UNLOCK_TIMERS 0x36
#define ADP5589_LOCK_CFG 0x37
#define ADP5589_RESET1_EVENT_A 0x38
#define ADP5589_RESET1_EVENT_B 0x39
#define ADP5589_RESET1_EVENT_C 0x3A
#define ADP5589_RESET2_EVENT_A 0x3B
#define ADP5589_RESET2_EVENT_B 0x3C
#define ADP5589_RESET_CFG 0x3D
#define ADP5589_PWM_OFFT_LOW 0x3E
#define ADP5589_PWM_OFFT_HIGH 0x3F
#define ADP5589_PWM_ONT_LOW 0x40
#define ADP5589_PWM_ONT_HIGH 0x41
#define ADP5589_PWM_CFG 0x42
#define ADP5589_CLOCK_DIV_CFG 0x43
#define ADP5589_LOGIC_1_CFG 0x44
#define ADP5589_LOGIC_2_CFG 0x45
#define ADP5589_LOGIC_FF_CFG 0x46
#define ADP5589_LOGIC_INT_EVENT_EN 0x47
#define ADP5589_POLL_PTIME_CFG 0x48
#define ADP5589_PIN_CONFIG_A 0x49
#define ADP5589_PIN_CONFIG_B 0x4A
#define ADP5589_PIN_CONFIG_C 0x4B
#define ADP5589_PIN_CONFIG_D 0x4C
#define ADP5589_GENERAL_CFG 0x4D
#define ADP5589_INT_EN 0x4E
/* ADP5585 Registers */
#define ADP5585_GPI_STATUS_A 0x15
#define ADP5585_GPI_STATUS_B 0x16
#define ADP5585_RPULL_CONFIG_A 0x17
#define ADP5585_RPULL_CONFIG_B 0x18
#define ADP5585_RPULL_CONFIG_C 0x19
#define ADP5585_RPULL_CONFIG_D 0x1A
#define ADP5585_GPI_INT_LEVEL_A 0x1B
#define ADP5585_GPI_INT_LEVEL_B 0x1C
#define ADP5585_GPI_EVENT_EN_A 0x1D
#define ADP5585_GPI_EVENT_EN_B 0x1E
#define ADP5585_GPI_INTERRUPT_EN_A 0x1F
#define ADP5585_GPI_INTERRUPT_EN_B 0x20
#define ADP5585_DEBOUNCE_DIS_A 0x21
#define ADP5585_DEBOUNCE_DIS_B 0x22
#define ADP5585_GPO_DATA_OUT_A 0x23
#define ADP5585_GPO_DATA_OUT_B 0x24
#define ADP5585_GPO_OUT_MODE_A 0x25
#define ADP5585_GPO_OUT_MODE_B 0x26
#define ADP5585_GPIO_DIRECTION_A 0x27
#define ADP5585_GPIO_DIRECTION_B 0x28
#define ADP5585_RESET1_EVENT_A 0x29
#define ADP5585_RESET1_EVENT_B 0x2A
#define ADP5585_RESET1_EVENT_C 0x2B
#define ADP5585_RESET2_EVENT_A 0x2C
#define ADP5585_RESET2_EVENT_B 0x2D
#define ADP5585_RESET_CFG 0x2E
#define ADP5585_PWM_OFFT_LOW 0x2F
#define ADP5585_PWM_OFFT_HIGH 0x30
#define ADP5585_PWM_ONT_LOW 0x31
#define ADP5585_PWM_ONT_HIGH 0x32
#define ADP5585_PWM_CFG 0x33
#define ADP5585_LOGIC_CFG 0x34
#define ADP5585_LOGIC_FF_CFG 0x35
#define ADP5585_LOGIC_INT_EVENT_EN 0x36
#define ADP5585_POLL_PTIME_CFG 0x37
#define ADP5585_PIN_CONFIG_A 0x38
#define ADP5585_PIN_CONFIG_B 0x39
#define ADP5585_PIN_CONFIG_D 0x3A
#define ADP5585_GENERAL_CFG 0x3B
#define ADP5585_INT_EN 0x3C
/* ID Register */
#define ADP5589_5_DEVICE_ID_MASK 0xF
#define ADP5589_5_MAN_ID_MASK 0xF
#define ADP5589_5_MAN_ID_SHIFT 4
#define ADP5589_5_MAN_ID 0x02
/* GENERAL_CFG Register */
#define OSC_EN (1 << 7)
#define CORE_CLK(x) (((x) & 0x3) << 5)
#define LCK_TRK_LOGIC (1 << 4)
/* ADP5589 only */
#define LCK_TRK_GPI (1 << 3)
/* ADP5589 only */
#define INT_CFG (1 << 1)
#define RST_CFG (1 << 0)
/* INT_EN Register */
#define LOGIC2_IEN (1 << 5)
/* ADP5589 only */
#define LOGIC1_IEN (1 << 4)
#define LOCK_IEN (1 << 3)
/* ADP5589 only */
#define OVRFLOW_IEN (1 << 2)
#define GPI_IEN (1 << 1)
#define EVENT_IEN (1 << 0)
/* Interrupt Status Register */
#define LOGIC2_INT (1 << 5)
/* ADP5589 only */
#define LOGIC1_INT (1 << 4)
#define LOCK_INT (1 << 3)
/* ADP5589 only */
#define OVRFLOW_INT (1 << 2)
#define GPI_INT (1 << 1)
#define EVENT_INT (1 << 0)
/* STATUS Register */
#define LOGIC2_STAT (1 << 7)
/* ADP5589 only */
#define LOGIC1_STAT (1 << 6)
#define LOCK_STAT (1 << 5)
/* ADP5589 only */
#define KEC 0x1F
/* PIN_CONFIG_D Register */
#define C4_EXTEND_CFG (1 << 6)
/* RESET2 */
#define R4_EXTEND_CFG (1 << 5)
/* RESET1 */
/* LOCK_CFG */
#define LOCK_EN (1 << 0)
#define PTIME_MASK 0x3
#define LTIME_MASK 0x3
/* ADP5589 only */
/* Key Event Register xy */
#define KEY_EV_PRESSED (1 << 7)
#define KEY_EV_MASK (0x7F)
#define KEYP_MAX_EVENT 16
#define ADP5589_MAXGPIO 19
#define ADP5585_MAXGPIO 11
/* 10 on the ADP5585-01, 11 on ADP5585-02 */
enum {
ADP5589,
ADP5585_01,
ADP5585_02
};
struct adp_constants {
u8 maxgpio;
u8 keymapsize;
u8 gpi_pin_row_base;
u8 gpi_pin_row_end;
u8 gpi_pin_col_base;
u8 gpi_pin_base;
u8 gpi_pin_end;
u8 gpimapsize_max;
u8 max_row_num;
u8 max_col_num;
u8 row_mask;
u8 col_mask;
u8 col_shift;
u8 c4_extend_cfg;
u8 (*bank) (u8 offset);
u8 (*bit) (u8 offset);
u8 (*reg) (u8 reg);
};
struct adp5589_kpad {
struct i2c_client *client;
struct input_dev *input;
const struct adp_constants *var;
unsigned short keycode[ADP5589_KEYMAPSIZE];
const struct adp5589_gpi_map *gpimap;
unsigned short gpimapsize;
unsigned extend_cfg;
bool is_adp5585;
bool support_row5;
#ifdef CONFIG_GPIOLIB
unsigned char gpiomap[ADP5589_MAXGPIO];
bool export_gpio;
struct gpio_chip gc;
struct mutex gpio_lock; /* Protect cached dir, dat_out */
u8 dat_out[3];
u8 dir[3];
#endif
};
/*
* ADP5589 / ADP5585 derivative / variant handling
*/
/* ADP5589 */
static unsigned char adp5589_bank(unsigned char offset)
{
return offset >> 3;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Michael Hennerich | 16 | 100.00% | 1 | 100.00% |
Total | 16 | 100.00% | 1 | 100.00% |
static unsigned char adp5589_bit(unsigned char offset)
{
return 1u << (offset & 0x7);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Michael Hennerich | 20 | 100.00% | 1 | 100.00% |
Total | 20 | 100.00% | 1 | 100.00% |
static unsigned char adp5589_reg(unsigned char reg)
{
return reg;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Michael Hennerich | 14 | 100.00% | 1 | 100.00% |
Total | 14 | 100.00% | 1 | 100.00% |
static const struct adp_constants const_adp5589 = {
.maxgpio = ADP5589_MAXGPIO,
.keymapsize = ADP5589_KEYMAPSIZE,
.gpi_pin_row_base = ADP5589_GPI_PIN_ROW_BASE,
.gpi_pin_row_end = ADP5589_GPI_PIN_ROW_END,
.gpi_pin_col_base = ADP5589_GPI_PIN_COL_BASE,
.gpi_pin_base = ADP5589_GPI_PIN_BASE,
.gpi_pin_end = ADP5589_GPI_PIN_END,
.gpimapsize_max = ADP5589_GPIMAPSIZE_MAX,
.c4_extend_cfg = 12,
.max_row_num = ADP5589_MAX_ROW_NUM,
.max_col_num = ADP5589_MAX_COL_NUM,
.row_mask = ADP5589_ROW_MASK,
.col_mask = ADP5589_COL_MASK,
.col_shift = ADP5589_COL_SHIFT,
.bank = adp5589_bank,
.bit = adp5589_bit,
.reg = adp5589_reg,
};
/* ADP5585 */
static unsigned char adp5585_bank(unsigned char offset)
{
return offset > ADP5585_MAX_ROW_NUM;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Michael Hennerich | 16 | 100.00% | 1 | 100.00% |
Total | 16 | 100.00% | 1 | 100.00% |
static unsigned char adp5585_bit(unsigned char offset)
{
return (offset > ADP5585_MAX_ROW_NUM) ?
1u << (offset - ADP5585_COL_SHIFT) : 1u << offset;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Michael Hennerich | 30 | 100.00% | 1 | 100.00% |
Total | 30 | 100.00% | 1 | 100.00% |
static const unsigned char adp5585_reg_lut[] = {
[ADP5589_GPI_STATUS_A] = ADP5585_GPI_STATUS_A,
[ADP5589_GPI_STATUS_B] = ADP5585_GPI_STATUS_B,
[ADP5589_RPULL_CONFIG_A] = ADP5585_RPULL_CONFIG_A,
[ADP5589_RPULL_CONFIG_B] = ADP5585_RPULL_CONFIG_B,
[ADP5589_RPULL_CONFIG_C] = ADP5585_RPULL_CONFIG_C,
[ADP5589_RPULL_CONFIG_D] = ADP5585_RPULL_CONFIG_D,
[ADP5589_GPI_INT_LEVEL_A] = ADP5585_GPI_INT_LEVEL_A,
[ADP5589_GPI_INT_LEVEL_B] = ADP5585_GPI_INT_LEVEL_B,
[ADP5589_GPI_EVENT_EN_A] = ADP5585_GPI_EVENT_EN_A,
[ADP5589_GPI_EVENT_EN_B] = ADP5585_GPI_EVENT_EN_B,
[ADP5589_GPI_INTERRUPT_EN_A] = ADP5585_GPI_INTERRUPT_EN_A,
[ADP5589_GPI_INTERRUPT_EN_B] = ADP5585_GPI_INTERRUPT_EN_B,
[ADP5589_DEBOUNCE_DIS_A] = ADP5585_DEBOUNCE_DIS_A,
[ADP5589_DEBOUNCE_DIS_B] = ADP5585_DEBOUNCE_DIS_B,
[ADP5589_GPO_DATA_OUT_A] = ADP5585_GPO_DATA_OUT_A,
[ADP5589_GPO_DATA_OUT_B] = ADP5585_GPO_DATA_OUT_B,
[ADP5589_GPO_OUT_MODE_A] = ADP5585_GPO_OUT_MODE_A,
[ADP5589_GPO_OUT_MODE_B] = ADP5585_GPO_OUT_MODE_B,
[ADP5589_GPIO_DIRECTION_A] = ADP5585_GPIO_DIRECTION_A,
[ADP5589_GPIO_DIRECTION_B] = ADP5585_GPIO_DIRECTION_B,
[ADP5589_RESET1_EVENT_A] = ADP5585_RESET1_EVENT_A,
[ADP5589_RESET1_EVENT_B] = ADP5585_RESET1_EVENT_B,
[ADP5589_RESET1_EVENT_C] = ADP5585_RESET1_EVENT_C,
[ADP5589_RESET2_EVENT_A] = ADP5585_RESET2_EVENT_A,
[ADP5589_RESET2_EVENT_B] = ADP5585_RESET2_EVENT_B,
[ADP5589_RESET_CFG] = ADP5585_RESET_CFG,
[ADP5589_PWM_OFFT_LOW] = ADP5585_PWM_OFFT_LOW,
[ADP5589_PWM_OFFT_HIGH] = ADP5585_PWM_OFFT_HIGH,
[ADP5589_PWM_ONT_LOW] = ADP5585_PWM_ONT_LOW,
[ADP5589_PWM_ONT_HIGH] = ADP5585_PWM_ONT_HIGH,
[ADP5589_PWM_CFG] = ADP5585_PWM_CFG,
[ADP5589_LOGIC_1_CFG] = ADP5585_LOGIC_CFG,
[ADP5589_LOGIC_FF_CFG] = ADP5585_LOGIC_FF_CFG,
[ADP5589_LOGIC_INT_EVENT_EN] = ADP5585_LOGIC_INT_EVENT_EN,
[ADP5589_POLL_PTIME_CFG] = ADP5585_POLL_PTIME_CFG,
[ADP5589_PIN_CONFIG_A] = ADP5585_PIN_CONFIG_A,
[ADP5589_PIN_CONFIG_B] = ADP5585_PIN_CONFIG_B,
[ADP5589_PIN_CONFIG_D] = ADP5585_PIN_CONFIG_D,
[ADP5589_GENERAL_CFG] = ADP5585_GENERAL_CFG,
[ADP5589_INT_EN] = ADP5585_INT_EN,
};
static unsigned char adp5585_reg(unsigned char reg)
{
return adp5585_reg_lut[reg];
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Michael Hennerich | 17 | 100.00% | 2 | 100.00% |
Total | 17 | 100.00% | 2 | 100.00% |
static const struct adp_constants const_adp5585 = {
.maxgpio = ADP5585_MAXGPIO,
.keymapsize = ADP5585_KEYMAPSIZE,
.gpi_pin_row_base = ADP5585_GPI_PIN_ROW_BASE,
.gpi_pin_row_end = ADP5585_GPI_PIN_ROW_END,
.gpi_pin_col_base = ADP5585_GPI_PIN_COL_BASE,
.gpi_pin_base = ADP5585_GPI_PIN_BASE,
.gpi_pin_end = ADP5585_GPI_PIN_END,
.gpimapsize_max = ADP5585_GPIMAPSIZE_MAX,
.c4_extend_cfg = 10,
.max_row_num = ADP5585_MAX_ROW_NUM,
.max_col_num = ADP5585_MAX_COL_NUM,
.row_mask = ADP5585_ROW_MASK,
.col_mask = ADP5585_COL_MASK,
.col_shift = ADP5585_COL_SHIFT,
.bank = adp5585_bank,
.bit = adp5585_bit,
.reg = adp5585_reg,
};
static int adp5589_read(struct i2c_client *client, u8 reg)
{
int ret = i2c_smbus_read_byte_data(client, reg);
if (ret < 0)
dev_err(&client->dev, "Read Error\n");
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Michael Hennerich | 43 | 100.00% | 1 | 100.00% |
Total | 43 | 100.00% | 1 | 100.00% |
static int adp5589_write(struct i2c_client *client, u8 reg, u8 val)
{
return i2c_smbus_write_byte_data(client, reg, val);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Michael Hennerich | 27 | 100.00% | 1 | 100.00% |
Total | 27 | 100.00% | 1 | 100.00% |
#ifdef CONFIG_GPIOLIB
static int adp5589_gpio_get_value(struct gpio_chip *chip, unsigned off)
{
struct adp5589_kpad *kpad = gpiochip_get_data(chip);
unsigned int bank = kpad->var->bank(kpad->gpiomap[off]);
unsigned int bit = kpad->var->bit(kpad->gpiomap[off]);
return !!(adp5589_read(kpad->client,
kpad->var->reg(ADP5589_GPI_STATUS_A) + bank) &
bit);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Michael Hennerich | 84 | 98.82% | 2 | 66.67% |
Linus Walleij | 1 | 1.18% | 1 | 33.33% |
Total | 85 | 100.00% | 3 | 100.00% |
static void adp5589_gpio_set_value(struct gpio_chip *chip,
unsigned off, int val)
{
struct adp5589_kpad *kpad = gpiochip_get_data(chip);
unsigned int bank = kpad->var->bank(kpad->gpiomap[off]);
unsigned int bit = kpad->var->bit(kpad->gpiomap[off]);
mutex_lock(&kpad->gpio_lock);
if (val)
kpad->dat_out[bank] |= bit;
else
kpad->dat_out[bank] &= ~bit;
adp5589_write(kpad->client, kpad->var->reg(ADP5589_GPO_DATA_OUT_A) +
bank, kpad->dat_out[bank]);
mutex_unlock(&kpad->gpio_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Michael Hennerich | 127 | 99.22% | 2 | 66.67% |
Linus Walleij | 1 | 0.78% | 1 | 33.33% |
Total | 128 | 100.00% | 3 | 100.00% |
static int adp5589_gpio_direction_input(struct gpio_chip *chip, unsigned off)
{
struct adp5589_kpad *kpad = gpiochip_get_data(chip);
unsigned int bank = kpad->var->bank(kpad->gpiomap[off]);
unsigned int bit = kpad->var->bit(kpad->gpiomap[off]);
int ret;
mutex_lock(&kpad->gpio_lock);
kpad->dir[bank] &= ~bit;
ret = adp5589_write(kpad->client,
kpad->var->reg(ADP5589_GPIO_DIRECTION_A) + bank,
kpad->dir[bank]);
mutex_unlock(&kpad->gpio_lock);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Michael Hennerich | 118 | 99.16% | 2 | 66.67% |
Linus Walleij | 1 | 0.84% | 1 | 33.33% |
Total | 119 | 100.00% | 3 | 100.00% |
static int adp5589_gpio_direction_output(struct gpio_chip *chip,
unsigned off, int val)
{
struct adp5589_kpad *kpad = gpiochip_get_data(chip);
unsigned int bank = kpad->var->bank(kpad->gpiomap[off]);
unsigned int bit = kpad->var->bit(kpad->gpiomap[off]);
int ret;
mutex_lock(&kpad->gpio_lock);
kpad->dir[bank] |= bit;
if (val)
kpad->dat_out[bank] |= bit;
else
kpad->dat_out[bank] &= ~bit;
ret = adp5589_write(kpad->client, kpad->var->reg(ADP5589_GPO_DATA_OUT_A)
+ bank, kpad->dat_out[bank]);
ret |= adp5589_write(kpad->client,
kpad->var->reg(ADP5589_GPIO_DIRECTION_A) + bank,
kpad->dir[bank]);
mutex_unlock(&kpad->gpio_lock);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Michael Hennerich | 171 | 99.42% | 2 | 66.67% |
Linus Walleij | 1 | 0.58% | 1 | 33.33% |
Total | 172 | 100.00% | 3 | 100.00% |
static int adp5589_build_gpiomap(struct adp5589_kpad *kpad,
const struct adp5589_kpad_platform_data *pdata)
{
bool pin_used[ADP5589_MAXGPIO];
int n_unused = 0;
int i;
memset(pin_used, false, sizeof(pin_used));
for (i = 0; i < kpad->var->maxgpio; i++)
if (pdata->keypad_en_mask & (1 << i))
pin_used[i] = true;
for (i = 0; i < kpad->gpimapsize; i++)
pin_used[kpad->gpimap[i].pin - kpad->var->gpi_pin_base] = true;
if (kpad->extend_cfg & R4_EXTEND_CFG)
pin_used[4] = true;
if (kpad->extend_cfg & C4_EXTEND_CFG)
pin_used[kpad->var->c4_extend_cfg] = true;
if (!kpad->support_row5)
pin_used[5] = true;
for (i = 0; i < kpad->var->maxgpio; i++)
if (!pin_used[i])
kpad->gpiomap[n_unused++] = i;
return n_unused;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Michael Hennerich | 199 | 99.50% | 2 | 66.67% |
Lars-Peter Clausen | 1 | 0.50% | 1 | 33.33% |
Total | 200 | 100.00% | 3 | 100.00% |
static int adp5589_gpio_add(struct adp5589_kpad *kpad)
{
struct device *dev = &kpad->client->dev;
const struct adp5589_kpad_platform_data *pdata = dev_get_platdata(dev);
const struct adp5589_gpio_platform_data *gpio_data = pdata->gpio_data;
int i, error;
if (!gpio_data)
return 0;
kpad->gc.ngpio = adp5589_build_gpiomap(kpad, pdata);
if (kpad->gc.ngpio == 0) {
dev_info(dev, "No unused gpios left to export\n");
return 0;
}
kpad->export_gpio = true;
kpad->gc.direction_input = adp5589_gpio_direction_input;
kpad->gc.direction_output = adp5589_gpio_direction_output;
kpad->gc.get = adp5589_gpio_get_value;
kpad->gc.set = adp5589_gpio_set_value;
kpad->gc.can_sleep = 1;
kpad->gc.base = gpio_data->gpio_start;
kpad->gc.label = kpad->client->name;
kpad->gc.owner = THIS_MODULE;
mutex_init(&kpad->gpio_lock);
error = gpiochip_add_data(&kpad->gc, kpad);
if (error) {
dev_err(dev, "gpiochip_add_data() failed, err: %d\n", error);
return error;
}
for (i = 0; i <= kpad->var->bank(kpad->var->maxgpio); i++) {
kpad->dat_out[i] = adp5589_read(kpad->client, kpad->var->reg(
ADP5589_GPO_DATA_OUT_A) + i);
kpad->dir[i] = adp5589_read(kpad->client, kpad->var->reg(
ADP5589_GPIO_DIRECTION_A) + i);
}
if (gpio_data->setup) {
error = gpio_data->setup(kpad->client,
kpad->gc.base, kpad->gc.ngpio,
gpio_data->context);
if (error)
dev_warn(dev, "setup failed, %d\n", error);
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Michael Hennerich | 326 | 97.90% | 2 | 50.00% |
Linus Walleij | 4 | 1.20% | 1 | 25.00% |
Jingoo Han | 3 | 0.90% | 1 | 25.00% |
Total | 333 | 100.00% | 4 | 100.00% |
static void adp5589_gpio_remove(struct adp5589_kpad *kpad)
{
struct device *dev = &kpad->client->dev;
const struct adp5589_kpad_platform_data *pdata = dev_get_platdata(dev);
const struct adp5589_gpio_platform_data *gpio_data = pdata->gpio_data;
int error;
if (!kpad->export_gpio)
return;
if (gpio_data->teardown) {
error = gpio_data->teardown(kpad->client,
kpad->gc.base, kpad->gc.ngpio,
gpio_data->context);
if (error)
dev_warn(dev, "teardown failed %d\n", error);
}
gpiochip_remove(&kpad->gc);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Michael Hennerich | 108 | 97.30% | 1 | 50.00% |
Jingoo Han | 3 | 2.70% | 1 | 50.00% |
Total | 111 | 100.00% | 2 | 100.00% |
#else
static inline int adp5589_gpio_add(struct adp5589_kpad *kpad)
{
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Michael Hennerich | 15 | 100.00% | 1 | 100.00% |
Total | 15 | 100.00% | 1 | 100.00% |
static inline void adp5589_gpio_remove(struct adp5589_kpad *kpad)
{
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Michael Hennerich | 11 | 100.00% | 1 | 100.00% |
Total | 11 | 100.00% | 1 | 100.00% |
#endif
static void adp5589_report_switches(struct adp5589_kpad *kpad,
int key, int key_val)
{
int i;
for (i = 0; i < kpad->gpimapsize; i++) {
if (key_val == kpad->gpimap[i].pin) {
input_report_switch