^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) * Touchkey driver for MELFAS MCS5000/5080 controller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2010 Samsung Electronics Co.Ltd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Author: HeungJun Kim <riverful.kim@samsung.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Author: Joonyoung Shim <jy0922.shim@samsung.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/i2c.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/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/platform_data/mcs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/pm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) /* MCS5000 Touchkey */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define MCS5000_TOUCHKEY_STATUS 0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define MCS5000_TOUCHKEY_STATUS_PRESS 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define MCS5000_TOUCHKEY_FW 0x0a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define MCS5000_TOUCHKEY_BASE_VAL 0x61
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) /* MCS5080 Touchkey */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define MCS5080_TOUCHKEY_STATUS 0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define MCS5080_TOUCHKEY_STATUS_PRESS 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define MCS5080_TOUCHKEY_FW 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define MCS5080_TOUCHKEY_BASE_VAL 0x1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) enum mcs_touchkey_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) MCS5000_TOUCHKEY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) MCS5080_TOUCHKEY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) struct mcs_touchkey_chip {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) unsigned int status_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) unsigned int pressbit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) unsigned int press_invert;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) unsigned int baseval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct mcs_touchkey_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) void (*poweron)(bool);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) struct i2c_client *client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) struct input_dev *input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) struct mcs_touchkey_chip chip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) unsigned int key_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) unsigned int key_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) unsigned short keycodes[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) static irqreturn_t mcs_touchkey_interrupt(int irq, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) struct mcs_touchkey_data *data = dev_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct mcs_touchkey_chip *chip = &data->chip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) struct i2c_client *client = data->client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct input_dev *input = data->input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) unsigned int key_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) unsigned int pressed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) int val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) val = i2c_smbus_read_byte_data(client, chip->status_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) if (val < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) dev_err(&client->dev, "i2c read error [%d]\n", val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) pressed = (val & (1 << chip->pressbit)) >> chip->pressbit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) if (chip->press_invert)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) pressed ^= chip->press_invert;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /* key_val is 0 when released, so we should use key_val of press. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) if (pressed) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) key_val = val & (0xff >> (8 - chip->pressbit));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) if (!key_val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) key_val -= chip->baseval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) data->key_code = data->keycodes[key_val];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) data->key_val = key_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) input_event(input, EV_MSC, MSC_SCAN, data->key_val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) input_report_key(input, data->key_code, pressed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) input_sync(input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) dev_dbg(&client->dev, "key %d %d %s\n", data->key_val, data->key_code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) pressed ? "pressed" : "released");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) static int mcs_touchkey_probe(struct i2c_client *client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) const struct i2c_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) const struct mcs_platform_data *pdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) struct mcs_touchkey_data *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct input_dev *input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) unsigned int fw_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) int fw_ver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) pdata = dev_get_platdata(&client->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) if (!pdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) dev_err(&client->dev, "no platform data defined\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) data = kzalloc(struct_size(data, keycodes, pdata->key_maxval + 1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) input_dev = input_allocate_device();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) if (!data || !input_dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) dev_err(&client->dev, "Failed to allocate memory\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) goto err_free_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) data->client = client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) data->input_dev = input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) if (id->driver_data == MCS5000_TOUCHKEY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) data->chip.status_reg = MCS5000_TOUCHKEY_STATUS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) data->chip.pressbit = MCS5000_TOUCHKEY_STATUS_PRESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) data->chip.baseval = MCS5000_TOUCHKEY_BASE_VAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) fw_reg = MCS5000_TOUCHKEY_FW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) data->chip.status_reg = MCS5080_TOUCHKEY_STATUS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) data->chip.pressbit = MCS5080_TOUCHKEY_STATUS_PRESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) data->chip.press_invert = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) data->chip.baseval = MCS5080_TOUCHKEY_BASE_VAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) fw_reg = MCS5080_TOUCHKEY_FW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) fw_ver = i2c_smbus_read_byte_data(client, fw_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) if (fw_ver < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) error = fw_ver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) dev_err(&client->dev, "i2c read error[%d]\n", error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) goto err_free_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) dev_info(&client->dev, "Firmware version: %d\n", fw_ver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) input_dev->name = "MELFAS MCS Touchkey";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) input_dev->id.bustype = BUS_I2C;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) input_dev->dev.parent = &client->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) input_dev->evbit[0] = BIT_MASK(EV_KEY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) if (!pdata->no_autorepeat)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) input_dev->evbit[0] |= BIT_MASK(EV_REP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) input_dev->keycode = data->keycodes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) input_dev->keycodesize = sizeof(data->keycodes[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) input_dev->keycodemax = pdata->key_maxval + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) for (i = 0; i < pdata->keymap_size; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) unsigned int val = MCS_KEY_VAL(pdata->keymap[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) unsigned int code = MCS_KEY_CODE(pdata->keymap[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) data->keycodes[val] = code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) __set_bit(code, input_dev->keybit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) input_set_capability(input_dev, EV_MSC, MSC_SCAN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) input_set_drvdata(input_dev, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) if (pdata->cfg_pin)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) pdata->cfg_pin();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) if (pdata->poweron) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) data->poweron = pdata->poweron;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) data->poweron(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) error = request_threaded_irq(client->irq, NULL, mcs_touchkey_interrupt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) client->dev.driver->name, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) dev_err(&client->dev, "Failed to register interrupt\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) goto err_free_mem;
^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) error = input_register_device(input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) goto err_free_irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) i2c_set_clientdata(client, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) err_free_irq:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) free_irq(client->irq, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) err_free_mem:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) input_free_device(input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) kfree(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) static int mcs_touchkey_remove(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) struct mcs_touchkey_data *data = i2c_get_clientdata(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) free_irq(client->irq, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) if (data->poweron)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) data->poweron(false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) input_unregister_device(data->input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) kfree(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) static void mcs_touchkey_shutdown(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) struct mcs_touchkey_data *data = i2c_get_clientdata(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) if (data->poweron)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) data->poweron(false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) #ifdef CONFIG_PM_SLEEP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) static int mcs_touchkey_suspend(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) struct mcs_touchkey_data *data = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) struct i2c_client *client = data->client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) /* Disable the work */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) disable_irq(client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) /* Finally turn off the power */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) if (data->poweron)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) data->poweron(false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) static int mcs_touchkey_resume(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) struct mcs_touchkey_data *data = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) struct i2c_client *client = data->client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) /* Enable the device first */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) if (data->poweron)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) data->poweron(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) /* Enable irq again */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) enable_irq(client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) static SIMPLE_DEV_PM_OPS(mcs_touchkey_pm_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) mcs_touchkey_suspend, mcs_touchkey_resume);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) static const struct i2c_device_id mcs_touchkey_id[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) { "mcs5000_touchkey", MCS5000_TOUCHKEY },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) { "mcs5080_touchkey", MCS5080_TOUCHKEY },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) MODULE_DEVICE_TABLE(i2c, mcs_touchkey_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) static struct i2c_driver mcs_touchkey_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) .name = "mcs_touchkey",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) .pm = &mcs_touchkey_pm_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) .probe = mcs_touchkey_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) .remove = mcs_touchkey_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) .shutdown = mcs_touchkey_shutdown,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) .id_table = mcs_touchkey_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) module_i2c_driver(mcs_touchkey_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) /* Module information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) MODULE_AUTHOR("HeungJun Kim <riverful.kim@samsung.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) MODULE_DESCRIPTION("Touchkey driver for MELFAS MCS5000/5080 controller");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) MODULE_LICENSE("GPL");