From patchwork Sun Dec 17 13:17:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karel Balej X-Patchwork-Id: 180011 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp701593dyi; Sun, 17 Dec 2023 05:23:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IH/mnq3RAP7nyhnn4+D8CdooAUT0g4KMwvEtz9fCa1BMcX67/7epmCqKBTwSfJh//Udj1mj X-Received: by 2002:a17:90b:1d0b:b0:28b:6004:c29e with SMTP id on11-20020a17090b1d0b00b0028b6004c29emr1819500pjb.23.1702819392525; Sun, 17 Dec 2023 05:23:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702819392; cv=none; d=google.com; s=arc-20160816; b=gIe+Oqeu8nLg2o9Lrn8aCMMO2nBF6XJ6KzrJInvm3EIR3ahSn1/OmSXhwMvkhMcIUh eyucfD8DJiohMfH2+ccoOlODh79ieKMZ6ByCAQvDf6romfXs5sfc40stLyIhYXmWyBw7 oAAD5cJYRuyLYy3MT01Fbie4H9dArajDDHRcnF7JgqhR9QsDvaBFSCYI3GUqKuAqrR4C pfrPlO28S8bDytipog3hzEwqr1AccEqayRrI9AJTy7Wvo3oFG4X8wFHDRiAZf+OH6bLl 3Z5XHHtIZ3lUtSp0XSIclEuItIn7QoE+86ppOf6heBGHCNcbFV+NSz/yfAnc9w+WXR5m Bl4g== 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2604-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gimli.ms.mff.cuni.cz Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id w7-20020a17090a780700b0028b054de82bsi795863pjk.168.2023.12.17.05.23.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 05:23:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2604-ouuuleilei=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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2604-ouuuleilei=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 4C4BEB2280C for ; Sun, 17 Dec 2023 13:21:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BB98F44C9B; Sun, 17 Dec 2023 13:20:47 +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_Mihanovi=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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785535547119811035 X-GMAIL-MSGID: 1785535547119811035 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