Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * File: drivers/input/keyboard/adp5588_keys.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Description:  keypad driver for ADP5588 and ADP5587
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *		 I2C QWERTY Keypad and IO Expander
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Bugs: Enter bugs at http://blackfin.uclinux.org/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Copyright (C) 2008-2010 Analog Devices Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/workqueue.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/pm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/platform_data/adp5588.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) /* Key Event Register xy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #define KEY_EV_PRESSED		(1 << 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #define KEY_EV_MASK		(0x7F)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #define KP_SEL(x)		(0xFFFF >> (16 - x))	/* 2^x-1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define KEYP_MAX_EVENT		10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * Early pre 4.0 Silicon required to delay readout by at least 25ms,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * since the Event Counter Register updated 25ms after the interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * asserted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define WA_DELAYED_READOUT_REVID(rev)		((rev) < 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) struct adp5588_kpad {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	struct i2c_client *client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	struct input_dev *input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	struct delayed_work work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	unsigned long delay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	unsigned short keycode[ADP5588_KEYMAPSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	const struct adp5588_gpi_map *gpimap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	unsigned short gpimapsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #ifdef CONFIG_GPIOLIB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	unsigned char gpiomap[ADP5588_MAXGPIO];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	bool export_gpio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	struct gpio_chip gc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	struct mutex gpio_lock;	/* Protect cached dir, dat_out */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	u8 dat_out[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	u8 dir[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) static int adp5588_read(struct i2c_client *client, u8 reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	int ret = i2c_smbus_read_byte_data(client, reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		dev_err(&client->dev, "Read Error\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) static int adp5588_write(struct i2c_client *client, u8 reg, u8 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	return i2c_smbus_write_byte_data(client, reg, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) #ifdef CONFIG_GPIOLIB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	struct adp5588_kpad *kpad = gpiochip_get_data(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	int val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	mutex_lock(&kpad->gpio_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	if (kpad->dir[bank] & bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		val = kpad->dat_out[bank];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		val = adp5588_read(kpad->client, GPIO_DAT_STAT1 + bank);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	mutex_unlock(&kpad->gpio_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	return !!(val & bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) static void adp5588_gpio_set_value(struct gpio_chip *chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 				   unsigned off, int val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	struct adp5588_kpad *kpad = gpiochip_get_data(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	mutex_lock(&kpad->gpio_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	if (val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		kpad->dat_out[bank] |= bit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		kpad->dat_out[bank] &= ~bit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	adp5588_write(kpad->client, GPIO_DAT_OUT1 + bank,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 			   kpad->dat_out[bank]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	mutex_unlock(&kpad->gpio_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) static int adp5588_gpio_direction_input(struct gpio_chip *chip, unsigned off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	struct adp5588_kpad *kpad = gpiochip_get_data(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	mutex_lock(&kpad->gpio_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	kpad->dir[bank] &= ~bit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	ret = adp5588_write(kpad->client, GPIO_DIR1 + bank, kpad->dir[bank]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	mutex_unlock(&kpad->gpio_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) static int adp5588_gpio_direction_output(struct gpio_chip *chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 					 unsigned off, int val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	struct adp5588_kpad *kpad = gpiochip_get_data(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	mutex_lock(&kpad->gpio_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	kpad->dir[bank] |= bit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	if (val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		kpad->dat_out[bank] |= bit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		kpad->dat_out[bank] &= ~bit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	ret = adp5588_write(kpad->client, GPIO_DAT_OUT1 + bank,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 				 kpad->dat_out[bank]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	ret |= adp5588_write(kpad->client, GPIO_DIR1 + bank,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 				 kpad->dir[bank]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	mutex_unlock(&kpad->gpio_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) static int adp5588_build_gpiomap(struct adp5588_kpad *kpad,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 				const struct adp5588_kpad_platform_data *pdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	bool pin_used[ADP5588_MAXGPIO];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	int n_unused = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	memset(pin_used, 0, sizeof(pin_used));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	for (i = 0; i < pdata->rows; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		pin_used[i] = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	for (i = 0; i < pdata->cols; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		pin_used[i + GPI_PIN_COL_BASE - GPI_PIN_BASE] = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	for (i = 0; i < kpad->gpimapsize; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		pin_used[kpad->gpimap[i].pin - GPI_PIN_BASE] = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	for (i = 0; i < ADP5588_MAXGPIO; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		if (!pin_used[i])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 			kpad->gpiomap[n_unused++] = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	return n_unused;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) static int adp5588_gpio_add(struct adp5588_kpad *kpad)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	struct device *dev = &kpad->client->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	const struct adp5588_kpad_platform_data *pdata = dev_get_platdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	const struct adp5588_gpio_platform_data *gpio_data = pdata->gpio_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	int i, error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	if (!gpio_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	kpad->gc.ngpio = adp5588_build_gpiomap(kpad, pdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	if (kpad->gc.ngpio == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		dev_info(dev, "No unused gpios left to export\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	kpad->export_gpio = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	kpad->gc.direction_input = adp5588_gpio_direction_input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	kpad->gc.direction_output = adp5588_gpio_direction_output;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	kpad->gc.get = adp5588_gpio_get_value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	kpad->gc.set = adp5588_gpio_set_value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	kpad->gc.can_sleep = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	kpad->gc.base = gpio_data->gpio_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	kpad->gc.label = kpad->client->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	kpad->gc.owner = THIS_MODULE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	kpad->gc.names = gpio_data->names;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	mutex_init(&kpad->gpio_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	error = gpiochip_add_data(&kpad->gc, kpad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		dev_err(dev, "gpiochip_add failed, err: %d\n", error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	for (i = 0; i <= ADP5588_BANK(ADP5588_MAXGPIO); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		kpad->dat_out[i] = adp5588_read(kpad->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 						GPIO_DAT_OUT1 + i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		kpad->dir[i] = adp5588_read(kpad->client, GPIO_DIR1 + i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	if (gpio_data->setup) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		error = gpio_data->setup(kpad->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 					 kpad->gc.base, kpad->gc.ngpio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 					 gpio_data->context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 			dev_warn(dev, "setup failed, %d\n", error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) static void adp5588_gpio_remove(struct adp5588_kpad *kpad)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	struct device *dev = &kpad->client->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	const struct adp5588_kpad_platform_data *pdata = dev_get_platdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	const struct adp5588_gpio_platform_data *gpio_data = pdata->gpio_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	if (!kpad->export_gpio)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	if (gpio_data->teardown) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		error = gpio_data->teardown(kpad->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 					    kpad->gc.base, kpad->gc.ngpio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 					    gpio_data->context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 			dev_warn(dev, "teardown failed %d\n", error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	gpiochip_remove(&kpad->gc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) static inline int adp5588_gpio_add(struct adp5588_kpad *kpad)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) static inline void adp5588_gpio_remove(struct adp5588_kpad *kpad)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) static void adp5588_report_events(struct adp5588_kpad *kpad, int ev_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	int i, j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	for (i = 0; i < ev_cnt; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		int key = adp5588_read(kpad->client, Key_EVENTA + i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		int key_val = key & KEY_EV_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		if (key_val >= GPI_PIN_BASE && key_val <= GPI_PIN_END) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 			for (j = 0; j < kpad->gpimapsize; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 				if (key_val == kpad->gpimap[j].pin) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 					input_report_switch(kpad->input,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 							kpad->gpimap[j].sw_evt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 							key & KEY_EV_PRESSED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 					break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 			input_report_key(kpad->input,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 					 kpad->keycode[key_val - 1],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 					 key & KEY_EV_PRESSED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) static void adp5588_work(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	struct adp5588_kpad *kpad = container_of(work,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 						struct adp5588_kpad, work.work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	struct i2c_client *client = kpad->client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	int status, ev_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	status = adp5588_read(client, INT_STAT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	if (status & ADP5588_OVR_FLOW_INT)	/* Unlikely and should never happen */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 		dev_err(&client->dev, "Event Overflow Error\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	if (status & ADP5588_KE_INT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 		ev_cnt = adp5588_read(client, KEY_LCK_EC_STAT) & ADP5588_KEC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 		if (ev_cnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 			adp5588_report_events(kpad, ev_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 			input_sync(kpad->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	adp5588_write(client, INT_STAT, status); /* Status is W1C */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) static irqreturn_t adp5588_irq(int irq, void *handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	struct adp5588_kpad *kpad = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	 * use keventd context to read the event fifo registers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	 * Schedule readout at least 25ms after notification for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	 * REVID < 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	schedule_delayed_work(&kpad->work, kpad->delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) static int adp5588_setup(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	const struct adp5588_kpad_platform_data *pdata =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 			dev_get_platdata(&client->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	const struct adp5588_gpio_platform_data *gpio_data = pdata->gpio_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	int i, ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	unsigned char evt_mode1 = 0, evt_mode2 = 0, evt_mode3 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	ret = adp5588_write(client, KP_GPIO1, KP_SEL(pdata->rows));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	ret |= adp5588_write(client, KP_GPIO2, KP_SEL(pdata->cols) & 0xFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	ret |= adp5588_write(client, KP_GPIO3, KP_SEL(pdata->cols) >> 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	if (pdata->en_keylock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 		ret |= adp5588_write(client, UNLOCK1, pdata->unlock_key1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 		ret |= adp5588_write(client, UNLOCK2, pdata->unlock_key2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 		ret |= adp5588_write(client, KEY_LCK_EC_STAT, ADP5588_K_LCK_EN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	for (i = 0; i < KEYP_MAX_EVENT; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 		ret |= adp5588_read(client, Key_EVENTA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	for (i = 0; i < pdata->gpimapsize; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 		unsigned short pin = pdata->gpimap[i].pin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 		if (pin <= GPI_PIN_ROW_END) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 			evt_mode1 |= (1 << (pin - GPI_PIN_ROW_BASE));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 			evt_mode2 |= ((1 << (pin - GPI_PIN_COL_BASE)) & 0xFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 			evt_mode3 |= ((1 << (pin - GPI_PIN_COL_BASE)) >> 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	if (pdata->gpimapsize) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 		ret |= adp5588_write(client, GPI_EM1, evt_mode1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 		ret |= adp5588_write(client, GPI_EM2, evt_mode2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 		ret |= adp5588_write(client, GPI_EM3, evt_mode3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	if (gpio_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 		for (i = 0; i <= ADP5588_BANK(ADP5588_MAXGPIO); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 			int pull_mask = gpio_data->pullup_dis_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 			ret |= adp5588_write(client, GPIO_PULL1 + i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 				(pull_mask >> (8 * i)) & 0xFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	ret |= adp5588_write(client, INT_STAT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 				ADP5588_CMP2_INT | ADP5588_CMP1_INT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 				ADP5588_OVR_FLOW_INT | ADP5588_K_LCK_INT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 				ADP5588_GPI_INT | ADP5588_KE_INT); /* Status is W1C */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	ret |= adp5588_write(client, CFG, ADP5588_INT_CFG |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 					  ADP5588_OVR_FLOW_IEN |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 					  ADP5588_KE_IEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 		dev_err(&client->dev, "Write Error\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) static void adp5588_report_switch_state(struct adp5588_kpad *kpad)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	int gpi_stat1 = adp5588_read(kpad->client, GPIO_DAT_STAT1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	int gpi_stat2 = adp5588_read(kpad->client, GPIO_DAT_STAT2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	int gpi_stat3 = adp5588_read(kpad->client, GPIO_DAT_STAT3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	int gpi_stat_tmp, pin_loc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	for (i = 0; i < kpad->gpimapsize; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 		unsigned short pin = kpad->gpimap[i].pin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 		if (pin <= GPI_PIN_ROW_END) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 			gpi_stat_tmp = gpi_stat1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 			pin_loc = pin - GPI_PIN_ROW_BASE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 		} else if ((pin - GPI_PIN_COL_BASE) < 8) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 			gpi_stat_tmp = gpi_stat2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 			pin_loc = pin - GPI_PIN_COL_BASE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 			gpi_stat_tmp = gpi_stat3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 			pin_loc = pin - GPI_PIN_COL_BASE - 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 		if (gpi_stat_tmp < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 			dev_err(&kpad->client->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 				"Can't read GPIO_DAT_STAT switch %d default to OFF\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 				pin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 			gpi_stat_tmp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 		input_report_switch(kpad->input,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 				    kpad->gpimap[i].sw_evt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 				    !(gpi_stat_tmp & (1 << pin_loc)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	input_sync(kpad->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) static int adp5588_probe(struct i2c_client *client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 			 const struct i2c_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	struct adp5588_kpad *kpad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	const struct adp5588_kpad_platform_data *pdata =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 			dev_get_platdata(&client->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	struct input_dev *input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	unsigned int revid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	int ret, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	if (!i2c_check_functionality(client->adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 					I2C_FUNC_SMBUS_BYTE_DATA)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 		dev_err(&client->dev, "SMBUS Byte Data not Supported\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	if (!pdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 		dev_err(&client->dev, "no platform data?\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	if (!pdata->rows || !pdata->cols || !pdata->keymap) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 		dev_err(&client->dev, "no rows, cols or keymap from pdata\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	if (pdata->keymapsize != ADP5588_KEYMAPSIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 		dev_err(&client->dev, "invalid keymapsize\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	if (!pdata->gpimap && pdata->gpimapsize) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 		dev_err(&client->dev, "invalid gpimap from pdata\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	if (pdata->gpimapsize > ADP5588_GPIMAPSIZE_MAX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 		dev_err(&client->dev, "invalid gpimapsize\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 	for (i = 0; i < pdata->gpimapsize; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 		unsigned short pin = pdata->gpimap[i].pin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 		if (pin < GPI_PIN_BASE || pin > GPI_PIN_END) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 			dev_err(&client->dev, "invalid gpi pin data\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 		if (pin <= GPI_PIN_ROW_END) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 			if (pin - GPI_PIN_ROW_BASE + 1 <= pdata->rows) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 				dev_err(&client->dev, "invalid gpi row data\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 				return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 			if (pin - GPI_PIN_COL_BASE + 1 <= pdata->cols) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 				dev_err(&client->dev, "invalid gpi col data\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 				return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 	if (!client->irq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 		dev_err(&client->dev, "no IRQ?\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 	kpad = kzalloc(sizeof(*kpad), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 	input = input_allocate_device();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 	if (!kpad || !input) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 		error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 		goto err_free_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 	kpad->client = client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 	kpad->input = input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 	INIT_DELAYED_WORK(&kpad->work, adp5588_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 	ret = adp5588_read(client, DEV_ID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 		error = ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 		goto err_free_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 	revid = (u8) ret & ADP5588_DEVICE_ID_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 	if (WA_DELAYED_READOUT_REVID(revid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 		kpad->delay = msecs_to_jiffies(30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 	input->name = client->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 	input->phys = "adp5588-keys/input0";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 	input->dev.parent = &client->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 	input_set_drvdata(input, kpad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 	input->id.bustype = BUS_I2C;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 	input->id.vendor = 0x0001;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 	input->id.product = 0x0001;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 	input->id.version = revid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 	input->keycodesize = sizeof(kpad->keycode[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 	input->keycodemax = pdata->keymapsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 	input->keycode = kpad->keycode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 	memcpy(kpad->keycode, pdata->keymap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 		pdata->keymapsize * input->keycodesize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 	kpad->gpimap = pdata->gpimap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 	kpad->gpimapsize = pdata->gpimapsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 	/* setup input device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 	__set_bit(EV_KEY, input->evbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 	if (pdata->repeat)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 		__set_bit(EV_REP, input->evbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 	for (i = 0; i < input->keycodemax; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 		if (kpad->keycode[i] <= KEY_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 			__set_bit(kpad->keycode[i], input->keybit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 	__clear_bit(KEY_RESERVED, input->keybit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 	if (kpad->gpimapsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 		__set_bit(EV_SW, input->evbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 	for (i = 0; i < kpad->gpimapsize; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 		__set_bit(kpad->gpimap[i].sw_evt, input->swbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 	error = input_register_device(input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 		dev_err(&client->dev, "unable to register input device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 		goto err_free_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 	error = request_irq(client->irq, adp5588_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 			    IRQF_TRIGGER_FALLING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 			    client->dev.driver->name, kpad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 		dev_err(&client->dev, "irq %d busy?\n", client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 		goto err_unreg_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 	error = adp5588_setup(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 		goto err_free_irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 	if (kpad->gpimapsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 		adp5588_report_switch_state(kpad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 	error = adp5588_gpio_add(kpad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 		goto err_free_irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 	device_init_wakeup(&client->dev, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 	i2c_set_clientdata(client, kpad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 	dev_info(&client->dev, "Rev.%d keypad, irq %d\n", revid, client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588)  err_free_irq:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 	free_irq(client->irq, kpad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 	cancel_delayed_work_sync(&kpad->work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591)  err_unreg_dev:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 	input_unregister_device(input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 	input = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594)  err_free_mem:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 	input_free_device(input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 	kfree(kpad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 	return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) static int adp5588_remove(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 	struct adp5588_kpad *kpad = i2c_get_clientdata(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 	adp5588_write(client, CFG, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 	free_irq(client->irq, kpad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 	cancel_delayed_work_sync(&kpad->work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 	input_unregister_device(kpad->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 	adp5588_gpio_remove(kpad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 	kfree(kpad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) static int adp5588_suspend(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 	struct adp5588_kpad *kpad = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 	struct i2c_client *client = kpad->client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 	disable_irq(client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 	cancel_delayed_work_sync(&kpad->work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 	if (device_may_wakeup(&client->dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 		enable_irq_wake(client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) static int adp5588_resume(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 	struct adp5588_kpad *kpad = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 	struct i2c_client *client = kpad->client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 	if (device_may_wakeup(&client->dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 		disable_irq_wake(client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 	enable_irq(client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) static const struct dev_pm_ops adp5588_dev_pm_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 	.suspend = adp5588_suspend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 	.resume  = adp5588_resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) static const struct i2c_device_id adp5588_id[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 	{ "adp5588-keys", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 	{ "adp5587-keys", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 	{ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) MODULE_DEVICE_TABLE(i2c, adp5588_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) static struct i2c_driver adp5588_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 		.name = KBUILD_MODNAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 		.pm   = &adp5588_dev_pm_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 	.probe    = adp5588_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 	.remove   = adp5588_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) 	.id_table = adp5588_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) module_i2c_driver(adp5588_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) MODULE_DESCRIPTION("ADP5588/87 Keypad driver");