Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

input: Add onkey driver for Marvell 88PM886 PMIC

Marvell 88PM886 PMIC provides onkey among other things. Add client
driver to handle it. The driver currently only provides a basic support
omitting additional functions found in the vendor version, such as long
onkey and GPIO integration.

Signed-off-by: Karel Balej <balejk@matfyz.cz>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Link: https://lore.kernel.org/r/20240531175109.15599-5-balejk@matfyz.cz
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Karel Balej and committed by
Lee Jones
914089db 5d1a5144

+106
+98
drivers/input/misc/88pm886-onkey.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + #include <linux/input.h> 3 + #include <linux/interrupt.h> 4 + #include <linux/irq.h> 5 + #include <linux/platform_device.h> 6 + #include <linux/regmap.h> 7 + 8 + #include <linux/mfd/88pm886.h> 9 + 10 + struct pm886_onkey { 11 + struct input_dev *idev; 12 + struct pm886_chip *chip; 13 + }; 14 + 15 + static irqreturn_t pm886_onkey_irq_handler(int irq, void *data) 16 + { 17 + struct pm886_onkey *onkey = data; 18 + struct regmap *regmap = onkey->chip->regmap; 19 + struct input_dev *idev = onkey->idev; 20 + struct device *parent = idev->dev.parent; 21 + unsigned int val; 22 + int err; 23 + 24 + err = regmap_read(regmap, PM886_REG_STATUS1, &val); 25 + if (err) { 26 + dev_err(parent, "Failed to read status: %d\n", err); 27 + return IRQ_NONE; 28 + } 29 + val &= PM886_ONKEY_STS1; 30 + 31 + input_report_key(idev, KEY_POWER, val); 32 + input_sync(idev); 33 + 34 + return IRQ_HANDLED; 35 + } 36 + 37 + static int pm886_onkey_probe(struct platform_device *pdev) 38 + { 39 + struct pm886_chip *chip = dev_get_drvdata(pdev->dev.parent); 40 + struct device *dev = &pdev->dev; 41 + struct pm886_onkey *onkey; 42 + struct input_dev *idev; 43 + int irq, err; 44 + 45 + onkey = devm_kzalloc(dev, sizeof(*onkey), GFP_KERNEL); 46 + if (!onkey) 47 + return -ENOMEM; 48 + 49 + onkey->chip = chip; 50 + 51 + irq = platform_get_irq(pdev, 0); 52 + if (irq < 0) 53 + return dev_err_probe(dev, irq, "Failed to get IRQ\n"); 54 + 55 + idev = devm_input_allocate_device(dev); 56 + if (!idev) { 57 + dev_err(dev, "Failed to allocate input device\n"); 58 + return -ENOMEM; 59 + } 60 + onkey->idev = idev; 61 + 62 + idev->name = "88pm886-onkey"; 63 + idev->phys = "88pm886-onkey/input0"; 64 + idev->id.bustype = BUS_I2C; 65 + 66 + input_set_capability(idev, EV_KEY, KEY_POWER); 67 + 68 + err = devm_request_threaded_irq(dev, irq, NULL, pm886_onkey_irq_handler, 69 + IRQF_ONESHOT | IRQF_NO_SUSPEND, "onkey", 70 + onkey); 71 + if (err) 72 + return dev_err_probe(dev, err, "Failed to request IRQ\n"); 73 + 74 + err = input_register_device(idev); 75 + if (err) 76 + return dev_err_probe(dev, err, "Failed to register input device\n"); 77 + 78 + return 0; 79 + } 80 + 81 + static const struct platform_device_id pm886_onkey_id_table[] = { 82 + { "88pm886-onkey", }, 83 + { } 84 + }; 85 + MODULE_DEVICE_TABLE(platform, pm886_onkey_id_table); 86 + 87 + static struct platform_driver pm886_onkey_driver = { 88 + .driver = { 89 + .name = "88pm886-onkey", 90 + }, 91 + .probe = pm886_onkey_probe, 92 + .id_table = pm886_onkey_id_table, 93 + }; 94 + module_platform_driver(pm886_onkey_driver); 95 + 96 + MODULE_DESCRIPTION("Marvell 88PM886 onkey driver"); 97 + MODULE_AUTHOR("Karel Balej <balejk@matfyz.cz>"); 98 + MODULE_LICENSE("GPL");
+7
drivers/input/misc/Kconfig
··· 33 33 To compile this driver as a module, choose M here: the module 34 34 will be called 88pm80x_onkey. 35 35 36 + config INPUT_88PM886_ONKEY 37 + tristate "Marvell 88PM886 onkey support" 38 + depends on MFD_88PM886_PMIC 39 + help 40 + Support the onkey of Marvell 88PM886 PMIC as an input device 41 + reporting power button status. 42 + 36 43 config INPUT_AB8500_PONKEY 37 44 tristate "AB8500 Pon (PowerOn) Key" 38 45 depends on AB8500_CORE
+1
drivers/input/misc/Makefile
··· 7 7 8 8 obj-$(CONFIG_INPUT_88PM860X_ONKEY) += 88pm860x_onkey.o 9 9 obj-$(CONFIG_INPUT_88PM80X_ONKEY) += 88pm80x_onkey.o 10 + obj-$(CONFIG_INPUT_88PM886_ONKEY) += 88pm886-onkey.o 10 11 obj-$(CONFIG_INPUT_AB8500_PONKEY) += ab8500-ponkey.o 11 12 obj-$(CONFIG_INPUT_AD714X) += ad714x.o 12 13 obj-$(CONFIG_INPUT_AD714X_I2C) += ad714x-i2c.o