Received: by 2002:a05:7412:8d08:b0:f9:2d0a:d759 with SMTP id bj8csp128097rdb; Sun, 17 Dec 2023 05:22:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IG2+kQh4HXCxDPD/LEXuFJxwkr/JjIVZL6KgbtbIfN5yHIL/ICEJZj3oYesuckImTHo6xCi X-Received: by 2002:a05:6a21:3284:b0:18f:fe5a:8bb7 with SMTP id yt4-20020a056a21328400b0018ffe5a8bb7mr18579579pzb.24.1702819377254; Sun, 17 Dec 2023 05:22:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702819377; cv=none; d=google.com; s=arc-20160816; b=DKDNEsmnig/C0+TiAW7TeOtSqmQVaRPlnYVOkopba21uvcpGx+QOMg/o0aGf8zxFZy 6AiOCIo9C5K/WvxBBJpMaUZ0WAYjA4y4GkhilonJyTDbh5kzGF7XAJoZHTX+3NdowfHm o5I9WtqXvUxFqQzerKGL0x+5inC8ZbnX8YaIc1PAA085N/9GbHbWplhq9Nebc7/pydEO VdvImhstEKBY/iZY6CL9YGWCsqz2270BJOzAXgxzvqAnnvlbu5kJopMY1nyay0t5i9mj BxXE1vBGyTWqNp22Sw5FZJdmu/7if3gDXX0erl+INVl57WE/IWLb6bdM2cY42+zRra/Y n0Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=6yoAgGvzxp2LXZX3HWE9kIBevrSNqm5WiSJMYva5oJ4=; fh=byZQJBCQWs0FCWKszxE7A5Om/MlZEW9RXICqsSfEzlA=; b=LmJZg7SpMSAGZUStQTecIl2Rh1Kg1fJltCMd3VMt4uhEcE0W9urvTo7UnN3WKzcZZy MlyV3tOimtkoPbuao4ThWL8LvR0ODSKchsi3ObRomllBfU1xlUocprH3IvBy1dns6kV9 R4N3Oi12JlEvE+hJJnC5WcrHU97xg4ASkj8DShgblXcFqkEwRKGN+dlC1rBb6BCvOZje 6rVQraAPzmsDc1/nZsvm7IWxs5PY5sI5SoHn+u5J05VNj3rMU2hqFXpcSp7U/2GISwIY pvvCkHds2OriwjQGTcZJtc33C9CvJE6wIWaTMD2ydreMMwBLccjMR67VUbXi2sPZc4Fq 5GmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gimli.ms.mff.cuni.cz header.s=gen1 header.b=l3irfuFF; spf=pass (google.com: domain of linux-kernel+bounces-2604-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2604-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gimli.ms.mff.cuni.cz Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b5-20020a056a000cc500b006ce7ad8c148si16433410pfv.183.2023.12.17.05.22.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 05:22:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2604-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gimli.ms.mff.cuni.cz header.s=gen1 header.b=l3irfuFF; spf=pass (google.com: domain of linux-kernel+bounces-2604-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2604-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gimli.ms.mff.cuni.cz Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 0F50DB22488 for ; Sun, 17 Dec 2023 13:21:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7F4F944C8D; Sun, 17 Dec 2023 13:20:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=gimli.ms.mff.cuni.cz header.i=@gimli.ms.mff.cuni.cz header.b="l3irfuFF" X-Original-To: linux-kernel@vger.kernel.org Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD29644C7C; Sun, 17 Dec 2023 13:20:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gimli.ms.mff.cuni.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gimli.ms.mff.cuni.cz Received: from gimli.ms.mff.cuni.cz (gimli.ms.mff.cuni.cz [195.113.20.176]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by nikam.ms.mff.cuni.cz (Postfix) with ESMTPS id 00EB128C344; Sun, 17 Dec 2023 14:20:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gimli.ms.mff.cuni.cz; s=gen1; t=1702819241; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6yoAgGvzxp2LXZX3HWE9kIBevrSNqm5WiSJMYva5oJ4=; b=l3irfuFFU8NH1Ngln2H8soa+NMwk0zv080srBnjsivIoPYPuw4n9UGNMLScevJaU0WGJzk D5iGRTWX6vKf9rTL2zIQ/BEozjfdZYbJtl5L3k9A+s7CsASe8S+vfjNKgjSbn0JiIorek6 vwQco2ohz0CaL8JgVQA3j2wUBD2TGOM= Received: from localhost (internet5.mraknet.com [185.200.108.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: karelb) by gimli.ms.mff.cuni.cz (Postfix) with ESMTPSA id D37C544AF99; Sun, 17 Dec 2023 14:20:40 +0100 (CET) From: Karel Balej To: Karel Balej , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Duje=20Mihanovi=C4=87?= , ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org Subject: [RFC PATCH 4/5] input: add onkey driver for Marvell 88PM88X PMICs Date: Sun, 17 Dec 2023 14:17:02 +0100 Message-ID: <20231217131838.7569-5-karelb@gimli.ms.mff.cuni.cz> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231217131838.7569-1-karelb@gimli.ms.mff.cuni.cz> References: <20231217131838.7569-1-karelb@gimli.ms.mff.cuni.cz> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Karel Balej The Marvell 88PM88X PMICs provide 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 --- drivers/input/misc/88pm88x-onkey.c | 103 +++++++++++++++++++++++++++++ drivers/input/misc/Kconfig | 10 +++ drivers/input/misc/Makefile | 1 + 3 files changed, 114 insertions(+) create mode 100644 drivers/input/misc/88pm88x-onkey.c diff --git a/drivers/input/misc/88pm88x-onkey.c b/drivers/input/misc/88pm88x-onkey.c new file mode 100644 index 000000000000..0d6056a3cab2 --- /dev/null +++ b/drivers/input/misc/88pm88x-onkey.c @@ -0,0 +1,103 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include +#include +#include +#include +#include +#include +#include + +#include + +struct pm88x_onkey { + struct input_dev *idev; + struct pm88x_chip *chip; + int irq; +}; + +static irqreturn_t pm88x_onkey_irq_handler(int irq, void *data) +{ + struct pm88x_onkey *onkey = data; + unsigned int val; + int ret = 0; + + ret = regmap_read(onkey->chip->regmaps[PM88X_REGMAP_BASE], PM88X_REG_STATUS1, &val); + if (ret) { + dev_err(onkey->idev->dev.parent, "Failed to read status: %d\n", ret); + return IRQ_NONE; + } + val &= PM88X_ONKEY_STS1; + + input_report_key(onkey->idev, KEY_POWER, val); + input_sync(onkey->idev); + + return IRQ_HANDLED; +} + +static int pm88x_onkey_probe(struct platform_device *pdev) +{ + struct pm88x_chip *chip = dev_get_drvdata(pdev->dev.parent); + struct pm88x_onkey *onkey; + int err; + + onkey = devm_kzalloc(&pdev->dev, sizeof(*onkey), GFP_KERNEL); + if (!onkey) + return -ENOMEM; + + onkey->chip = chip; + + onkey->irq = platform_get_irq(pdev, 0); + if (onkey->irq < 0) { + dev_err(&pdev->dev, "Failed to get IRQ\n"); + return -EINVAL; + } + + onkey->idev = devm_input_allocate_device(&pdev->dev); + if (!onkey->idev) { + dev_err(&pdev->dev, "Failed to allocate input device\n"); + return -ENOMEM; + } + + onkey->idev->name = "88pm88x-onkey"; + onkey->idev->phys = "88pm88x-onkey/input0"; + onkey->idev->id.bustype = BUS_I2C; + onkey->idev->dev.parent = &pdev->dev; + onkey->idev->evbit[0] = BIT_MASK(EV_KEY); + onkey->idev->keybit[BIT_WORD(KEY_POWER)] = BIT_MASK(KEY_POWER); + + err = devm_request_threaded_irq(&pdev->dev, onkey->irq, NULL, pm88x_onkey_irq_handler, + IRQF_ONESHOT | IRQF_NO_SUSPEND, "onkey", onkey); + if (err) { + dev_err(&pdev->dev, "Failed to request IRQ: %d\n", err); + return err; + } + + err = input_register_device(onkey->idev); + if (err) { + dev_err(&pdev->dev, "Failed to register input device: %d\n", err); + return err; + } + + device_init_wakeup(&pdev->dev, 1); + + return 0; +} + +static const struct of_device_id pm88x_onkey_of_match[] = { + { .compatible = "marvell,88pm88x-onkey", }, + { }, +}; +MODULE_DEVICE_TABLE(of, pm88x_onkey_of_match); + +static struct platform_driver pm88x_onkey_driver = { + .driver = { + .name = "88pm88x-onkey", + .of_match_table = of_match_ptr(pm88x_onkey_of_match), + }, + .probe = pm88x_onkey_probe, +}; +module_platform_driver(pm88x_onkey_driver); + +MODULE_DESCRIPTION("Marvell 88PM88X onkey driver"); +MODULE_AUTHOR("Karel Balej "); +MODULE_LICENSE("GPL"); diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 6ba984d7f0b1..fdfa3e23c3cf 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -33,6 +33,16 @@ config INPUT_88PM80X_ONKEY To compile this driver as a module, choose M here: the module will be called 88pm80x_onkey. +config INPUT_88PM88X_ONKEY + tristate "Marvell 88PM88X onkey support" + depends on MFD_88PM88X + help + Support the onkey of Marvell 88PM88X PMICs as an input device + reporting power button status. + + To compile this driver as a module, choose M here: the module + will be called 88pm88x-onkey. + config INPUT_AB8500_PONKEY tristate "AB8500 Pon (PowerOn) Key" depends on AB8500_CORE diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index 04296a4abe8e..eab7a364188c 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_INPUT_88PM860X_ONKEY) += 88pm860x_onkey.o obj-$(CONFIG_INPUT_88PM80X_ONKEY) += 88pm80x_onkey.o +obj-$(CONFIG_INPUT_88PM88X_ONKEY) += 88pm88x-onkey.o obj-$(CONFIG_INPUT_AB8500_PONKEY) += ab8500-ponkey.o obj-$(CONFIG_INPUT_AD714X) += ad714x.o obj-$(CONFIG_INPUT_AD714X_I2C) += ad714x-i2c.o -- 2.43.0