Lines Matching +full:mpr121 +full:- +full:touchkey

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Touchkey driver for Freescale MPR121 Controllor
54 /* MPR121 has 12 keys */
123 struct mpr121_touchkey *mpr121 = input_get_drvdata(dev); in mpr_touchkey_report() local
124 struct input_dev *input = mpr121->input_dev; in mpr_touchkey_report()
125 struct i2c_client *client = mpr121->client; in mpr_touchkey_report()
132 dev_err(&client->dev, "i2c read error [%d]\n", reg); in mpr_touchkey_report()
139 dev_err(&client->dev, "i2c read error [%d]\n", reg); in mpr_touchkey_report()
145 bit_changed = reg ^ mpr121->statusbits; in mpr_touchkey_report()
146 mpr121->statusbits = reg; in mpr_touchkey_report()
147 for_each_set_bit(key_num, &bit_changed, mpr121->keycount) { in mpr_touchkey_report()
151 key_val = mpr121->keycodes[key_num]; in mpr_touchkey_report()
156 dev_dbg(&client->dev, "key %d %d %s\n", key_num, key_val, in mpr_touchkey_report()
165 struct mpr121_touchkey *mpr121 = dev_id; in mpr_touchkey_interrupt() local
167 mpr_touchkey_report(mpr121->input_dev); in mpr_touchkey_interrupt()
172 static int mpr121_phys_init(struct mpr121_touchkey *mpr121, in mpr121_phys_init() argument
179 /* Set up touch/release threshold for ele0-ele11 */ in mpr121_phys_init()
194 ret = i2c_smbus_write_byte_data(client, reg->addr, reg->val); in mpr121_phys_init()
202 * The internal MPR121-auto-configuration can do this if it's in mpr121_phys_init()
206 usl = ((vdd - 700) * 256) / vdd; in mpr121_phys_init()
218 eleconf = mpr121->keycount | ELECTRODE_CONF_QUICK_CHARGE; in mpr121_phys_init()
224 dev_dbg(&client->dev, "set up with %x keys.\n", mpr121->keycount); in mpr121_phys_init()
229 dev_err(&client->dev, "i2c write error: %d\n", ret); in mpr121_phys_init()
236 struct device *dev = &client->dev; in mpr_touchkey_probe()
239 struct mpr121_touchkey *mpr121; in mpr_touchkey_probe() local
251 mpr121 = devm_kzalloc(dev, sizeof(*mpr121), GFP_KERNEL); in mpr_touchkey_probe()
252 if (!mpr121) in mpr_touchkey_probe()
253 return -ENOMEM; in mpr_touchkey_probe()
257 return -ENOMEM; in mpr_touchkey_probe()
259 mpr121->client = client; in mpr_touchkey_probe()
260 mpr121->input_dev = input_dev; in mpr_touchkey_probe()
261 mpr121->keycount = device_property_count_u32(dev, "linux,keycodes"); in mpr_touchkey_probe()
262 if (mpr121->keycount > MPR121_MAX_KEY_COUNT) { in mpr_touchkey_probe()
263 dev_err(dev, "too many keys defined (%d)\n", mpr121->keycount); in mpr_touchkey_probe()
264 return -EINVAL; in mpr_touchkey_probe()
268 mpr121->keycodes, in mpr_touchkey_probe()
269 mpr121->keycount); in mpr_touchkey_probe()
276 input_dev->name = "Freescale MPR121 Touchkey"; in mpr_touchkey_probe()
277 input_dev->id.bustype = BUS_I2C; in mpr_touchkey_probe()
278 input_dev->dev.parent = dev; in mpr_touchkey_probe()
280 __set_bit(EV_REP, input_dev->evbit); in mpr_touchkey_probe()
282 input_set_drvdata(input_dev, mpr121); in mpr_touchkey_probe()
284 input_dev->keycode = mpr121->keycodes; in mpr_touchkey_probe()
285 input_dev->keycodesize = sizeof(mpr121->keycodes[0]); in mpr_touchkey_probe()
286 input_dev->keycodemax = mpr121->keycount; in mpr_touchkey_probe()
288 for (i = 0; i < mpr121->keycount; i++) in mpr_touchkey_probe()
289 input_set_capability(input_dev, EV_KEY, mpr121->keycodes[i]); in mpr_touchkey_probe()
291 error = mpr121_phys_init(mpr121, client, vdd_uv); in mpr_touchkey_probe()
297 device_property_read_u32(dev, "poll-interval", &poll_interval); in mpr_touchkey_probe()
299 if (client->irq) { in mpr_touchkey_probe()
300 error = devm_request_threaded_irq(dev, client->irq, NULL, in mpr_touchkey_probe()
304 dev->driver->name, mpr121); in mpr_touchkey_probe()
311 return -EINVAL; in mpr_touchkey_probe()
314 return -EINVAL; in mpr_touchkey_probe()
330 return -EINVAL; in mpr_touchkey_probe()
337 i2c_set_clientdata(client, mpr121); in mpr_touchkey_probe()
339 device_property_read_bool(dev, "wakeup-source")); in mpr_touchkey_probe()
348 if (device_may_wakeup(&client->dev)) in mpr_suspend()
349 enable_irq_wake(client->irq); in mpr_suspend()
359 struct mpr121_touchkey *mpr121 = i2c_get_clientdata(client); in mpr_resume() local
361 if (device_may_wakeup(&client->dev)) in mpr_resume()
362 disable_irq_wake(client->irq); in mpr_resume()
365 mpr121->keycount); in mpr_resume()
380 { .compatible = "fsl,mpr121-touchkey" },
388 .name = "mpr121",
400 MODULE_DESCRIPTION("Touch Key driver for Freescale MPR121 Chip");