From patchwork Sun Dec 17 13:16:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karel Balej X-Patchwork-Id: 180008 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp700608dyi; Sun, 17 Dec 2023 05:20:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IEAkv4oLzFYjk5eQDI8WRYjRny6+28GHsAZCMRD02m3FQFbx+jUqL08tGhFyRwwDUMDRosE X-Received: by 2002:a05:600c:4193:b0:40c:3276:253e with SMTP id p19-20020a05600c419300b0040c3276253emr8612938wmh.86.1702819239307; Sun, 17 Dec 2023 05:20:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702819239; cv=none; d=google.com; s=arc-20160816; b=bK/iDzG1eHq6/1BBGVewcrszAgB7IuSUrigXyipOw0DaQuAnJ/2tW+49kZQVVX9CQ2 6siW50tiEcxO1L6uhbDUYnPeez7ptwS5bgYcxoWAEmKscUi7gAInu2mSdywaU+fyj5m4 tBdo49c7s6dg9N1avSNm5fSXMudHQq/vIkbHkP1PaV+c+rUOgcYc1DX9Bs+EPB8T/SQB yyQvUXuPnj15+04tMFufmrv4/ftlSLzQKi4f/QXk+937iqsVP8T5CJXWEa01ka+Lnc1s CcgQuZMuTKfAbT870Nh8IMsFKHfO/SNysw2Kx9X3VsAQ5Pu/YfpJPkrXHmjf3FVdbAkC /3Hg== 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=qP+2SKh6YVsuO7Mi8pHKLqQ7+a6eIrefH/tNra/ANO8=; fh=byZQJBCQWs0FCWKszxE7A5Om/MlZEW9RXICqsSfEzlA=; b=JdOYgyyuW6x+NOcOMhFxxYMdir4Mv2DO6BZ3isAMXSmvHPOig0ET+77OgGSg8qjrBA 55Hp7xUoBQ6uCBRBIln/xAXvPqK4MchIhvcQzVrc7P6DwABqwvIeg9V8QWLDUyIz9eWD rjFFvPKAsZrZ/M8BzD8eE1GH19B4WQETtrb4MD+xwoRUr6nejbTjTI3ZBte0zlYyfucX wwHCKrPtzZFoXtZJ2qGMuotJO+iFJvTi/jOXLqWIel9A8xVFElcqdML5/I+LCDDxAd7d CI2p2rNhGLWu1PG7KS5FU1AiXnlBEgRi9uytZoVuRDD1aw2vHT+393WB0OueL/bSBvWf OR3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gimli.ms.mff.cuni.cz header.s=gen1 header.b="Q/BNtnt+"; spf=pass (google.com: domain of linux-kernel+bounces-2601-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2601-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gimli.ms.mff.cuni.cz Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id j23-20020a1709064b5700b00a2356a0b4f3si179577ejv.82.2023.12.17.05.20.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 05:20:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2601-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gimli.ms.mff.cuni.cz header.s=gen1 header.b="Q/BNtnt+"; spf=pass (google.com: domain of linux-kernel+bounces-2601-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2601-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 am.mirrors.kernel.org (Postfix) with ESMTPS id C040B1F21FC4 for ; Sun, 17 Dec 2023 13:20:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9837A4438C; Sun, 17 Dec 2023 13:20:21 +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="Q/BNtnt+" 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 2B7C844361; Sun, 17 Dec 2023 13:20:14 +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 07D3228C344; Sun, 17 Dec 2023 14:20:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gimli.ms.mff.cuni.cz; s=gen1; t=1702819213; 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=qP+2SKh6YVsuO7Mi8pHKLqQ7+a6eIrefH/tNra/ANO8=; b=Q/BNtnt+Znw9AyDvAGAHx+qfoEuC4HEKUyKtH1yc4tXABKmi4fu6lU92YBsHhAa9mUJbNa E+Xk81MuQUuWvQPtPLdNWsAYtNVHc/8Vrg8Vag5B4cWhXDyf8yJ7xAc1TVTAO8Mc4J86aw mkr7k0zpZcLKVCDU9FQ1sua/a80g4jw= 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 DA5F844AF99; Sun, 17 Dec 2023 14:20:12 +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 1/5] dt-bindings: mfd: add entry for the Marvell 88PM88X PMICs Date: Sun, 17 Dec 2023 14:16:59 +0100 Message-ID: <20231217131838.7569-2-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: 1785535386423545652 X-GMAIL-MSGID: 1785535386423545652 From: Karel Balej Marvell 88PM880 and 88PM886 are two similar PMICs with mostly matching register mapping and subdevices such as onkey, regulators or battery and charger. Both seem to come in two revisions which seem to be handled slightly differently in some subdevice drivers. Signed-off-by: Karel Balej --- .../bindings/mfd/marvell,88pm88x.yaml | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/marvell,88pm88x.yaml diff --git a/Documentation/devicetree/bindings/mfd/marvell,88pm88x.yaml b/Documentation/devicetree/bindings/mfd/marvell,88pm88x.yaml new file mode 100644 index 000000000000..e075729c360f --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/marvell,88pm88x.yaml @@ -0,0 +1,55 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/marvell,88pm88x.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Marvell 88PM88X PMIC core MFD + +maintainers: + - Karel Balej + +description: | + Marvell 88PM880 and 88PM886 are two similar PMICs providing + several functions such as onkey, regulators or battery and + charger. Both seem to come in two revisions -- A0 and A1. + +properties: + compatible: + const: marvell,88pm886-a1 + + reg: + description: I2C device address + maxItems: 1 + + interrupt-controller: true + + interrupts: + maxItems: 1 + + "#interrupt-cells": + const: 2 + +required: + - compatible + - reg + - interrupt-controller + - interrupts + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + pmic0: 88pm886@30 { + compatible = "marvell,88pm886-a1"; + reg = <0x30>; + interrupts = <0 4 IRQ_TYPE_LEVEL_HIGH>; + interrupt-parent = <&gic>; + interrupt-controller; + #interrupt-cells = <1>; + }; + }; +... From patchwork Sun Dec 17 13:17:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karel Balej X-Patchwork-Id: 180009 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp700720dyi; Sun, 17 Dec 2023 05:20:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYFiBQwMhraxdIL9mEPPpmCmPrqwv3KhD0Ga5UJ1CGULeC0642BKB0kIupIF7Ta9lZN/nC X-Received: by 2002:a0c:c784:0:b0:67a:a721:7838 with SMTP id k4-20020a0cc784000000b0067aa7217838mr15954362qvj.93.1702819257396; Sun, 17 Dec 2023 05:20:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702819257; cv=none; d=google.com; s=arc-20160816; b=Q3QOaot3c7aA/B85A9MT/L1W15GDnhUAjJBXXPT6zjNDODrf2+Hx7J8iPbE3CFxbxe ySFMzb8o/kBt84F3vk/I2XtvdSRGJRA/xA8FpSpcLKDo7a6z64Oue/ITD02i8/ZFtkyF n3UcY4T4E1khpVIu1ijQbOT8yDuF1NWme2QH7ID2rNLVrqiTi6U1cNbsVKxut0jNzqKd S5iiJZoNfynxJP0WePDzpfyBmT1ej6d9h9iP30MLY50Umhibpcd7z+/a6moNOW9gWO3J iRqOpH9rCaFD45Bq1ek+CZ8C12aeSE2KPde41ySq3JZXPBsw6jqX5Os7z7aUet4bU+DH vDEw== 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=wvYhe1HTlC8OK5D+YolHQgHF1zQFZby+es+2ouNx1Xs=; fh=byZQJBCQWs0FCWKszxE7A5Om/MlZEW9RXICqsSfEzlA=; b=wF5oU/Af+gXfzAFgySktQsIJHAoFxO5fHKfvBJvW0zlIBCTJMynO6lvkRLcjUuVxUB xvR6f/MCy1ESe/a7Ga0cFcYu2lJni2ar4c+BsPYL5vhwJoWzdog7IOXNxJiwAPkPuLS2 RT2Asij3JApELGKTvPUfeL/jxo9SjTI/9vJTW1EpbOUTMOzJs0C97OHKjwby0tcQoxZq dWOUbrgo1lasJYiCs9DNFmE3rgo0pNHcH1EBfU+RpvC8hL44UFXAA3rQ/D2MPFud2daA 04W/4jigT1l40HBZXICmVEU/S6nG91xCWEdBSkei9DhEQrYZBf86i93Q9Oz1ZNLoy2cz NLjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gimli.ms.mff.cuni.cz header.s=gen1 header.b=P9Bgm7UJ; spf=pass (google.com: domain of linux-kernel+bounces-2602-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2602-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gimli.ms.mff.cuni.cz Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id h4-20020a05620a284400b0077f039bb628si22323758qkp.422.2023.12.17.05.20.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 05:20:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2602-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gimli.ms.mff.cuni.cz header.s=gen1 header.b=P9Bgm7UJ; spf=pass (google.com: domain of linux-kernel+bounces-2602-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2602-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 060041C20FB4 for ; Sun, 17 Dec 2023 13:20:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 084A244C6A; Sun, 17 Dec 2023 13:20:28 +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="P9Bgm7UJ" 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 A2F5844361; Sun, 17 Dec 2023 13:20:22 +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 9949A28C345; Sun, 17 Dec 2023 14:20:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gimli.ms.mff.cuni.cz; s=gen1; t=1702819220; 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=wvYhe1HTlC8OK5D+YolHQgHF1zQFZby+es+2ouNx1Xs=; b=P9Bgm7UJ7B4AQnlFt8wC6YQFn6BmjMCEvD222Liu+ojmLi0cuHg/h9IgLHLo419ur899Q2 eTS3u9VtyIEbY6FAo9JmkE61k9k4JWI7ghgAxtDO2yHgh5CBu3ZvG7uIwExbJo6OmLYyBh F7S3snrgBCpZnlqU9QtEKyy1SNeRb+U= 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 75ADD44AF99; Sun, 17 Dec 2023 14:20:20 +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 2/5] mfd: add 88pm88x driver Date: Sun, 17 Dec 2023 14:17:00 +0100 Message-ID: <20231217131838.7569-3-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: 1785535405705332770 X-GMAIL-MSGID: 1785535405705332770 From: Karel Balej Marvell 88PM880 and 8PM886 are two similar PMICs with mostly matching register mapping. They provide various functions such as onkey, battery, charger and regulators. Add support for 88PM886 found for instance in the samsung,coreprimevelte smartphone with which this was tested. Support for 88PM880 is not implemented here but should be straightforward to add. Implement only the most basic support omitting the currently unused registers and I2C subclients which should thus be added with the respective subdevices. However, add support for the onkey already. Signed-off-by: Karel Balej --- drivers/mfd/88pm88x.c | 199 ++++++++++++++++++++++++++++++++++++ drivers/mfd/Kconfig | 11 ++ drivers/mfd/Makefile | 1 + include/linux/mfd/88pm88x.h | 60 +++++++++++ 4 files changed, 271 insertions(+) create mode 100644 drivers/mfd/88pm88x.c create mode 100644 include/linux/mfd/88pm88x.h diff --git a/drivers/mfd/88pm88x.c b/drivers/mfd/88pm88x.c new file mode 100644 index 000000000000..5db6c65b667d --- /dev/null +++ b/drivers/mfd/88pm88x.c @@ -0,0 +1,199 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include +#include +#include +#include +#include +#include + +#include + +/* interrupt status registers */ +#define PM88X_REG_INT_STATUS1 0x05 + +#define PM88X_REG_INT_ENA_1 0x0a +#define PM88X_INT_ENA1_ONKEY BIT(0) + +enum pm88x_irq_number { + PM88X_IRQ_ONKEY, + + PM88X_MAX_IRQ +}; + +static struct regmap_irq pm88x_regmap_irqs[] = { + REGMAP_IRQ_REG(PM88X_IRQ_ONKEY, 0, PM88X_INT_ENA1_ONKEY), +}; + +static struct regmap_irq_chip pm88x_regmap_irq_chip = { + .name = "88pm88x", + .irqs = pm88x_regmap_irqs, + .num_irqs = ARRAY_SIZE(pm88x_regmap_irqs), + .num_regs = 4, + .status_base = PM88X_REG_INT_STATUS1, + .ack_base = PM88X_REG_INT_STATUS1, + .unmask_base = PM88X_REG_INT_ENA_1, +}; + +static struct reg_sequence pm886_presets[] = { + /* disable watchdog */ + REG_SEQ0(PM88X_REG_WDOG, 0x01), + /* GPIO1: DVC, GPIO0: input */ + REG_SEQ0(PM88X_REG_GPIO_CTRL1, 0x40), + /* GPIO2: input */ + REG_SEQ0(PM88X_REG_GPIO_CTRL2, 0x00), + /* DVC2, DVC1 */ + REG_SEQ0(PM88X_REG_GPIO_CTRL3, 0x44), + /* GPIO5V_1:input, GPIO5V_2: input */ + REG_SEQ0(PM88X_REG_GPIO_CTRL4, 0x00), + /* output 32 kHz from XO */ + REG_SEQ0(PM88X_REG_AON_CTRL2, 0x2a), + /* OSC_FREERUN = 1, to lock FLL */ + REG_SEQ0(PM88X_REG_BK_OSC_CTRL1, 0x0f), + /* XO_LJ = 1, enable low jitter for 32 kHz */ + REG_SEQ0(PM88X_REG_LOWPOWER2, 0x20), + /* OV_VSYS and UV_VSYS1 comparators on VSYS disabled, VSYS_OVER_TH : 5.6V */ + REG_SEQ0(PM88X_REG_LOWPOWER4, 0xc8), + /* set the duty cycle of charger DC/DC to max */ + REG_SEQ0(PM88X_REG_BK_OSC_CTRL3, 0xc0), +}; + +static struct resource onkey_resources[] = { + DEFINE_RES_IRQ_NAMED(PM88X_IRQ_ONKEY, "88pm88x-onkey"), +}; + +static struct mfd_cell pm88x_devs[] = { + { + .name = "88pm88x-onkey", + .num_resources = ARRAY_SIZE(onkey_resources), + .resources = onkey_resources, + .id = -1, + }, +}; + +static struct pm88x_data pm886_a1_data = { + .whoami = PM886_A1_WHOAMI, + .presets = pm886_presets, + .num_presets = ARRAY_SIZE(pm886_presets), +}; + +static const struct regmap_config pm88x_i2c_regmap = { + .reg_bits = 8, + .val_bits = 8, + .max_register = 0xfe, +}; + +static int pm88x_power_off_handler(struct sys_off_data *data) +{ + struct pm88x_chip *chip = data->cb_data; + int ret; + + ret = regmap_update_bits(chip->regmaps[PM88X_REGMAP_BASE], PM88X_REG_MISC_CONFIG1, + PM88X_SW_PDOWN, PM88X_SW_PDOWN); + if (ret) { + dev_err(&chip->client->dev, "Failed to power off the device: %d\n", ret); + return NOTIFY_BAD; + } + return NOTIFY_DONE; +} + +static int pm88x_setup_irq(struct pm88x_chip *chip) +{ + int ret; + + /* set interrupt clearing mode to clear on write */ + ret = regmap_update_bits(chip->regmaps[PM88X_REGMAP_BASE], PM88X_REG_MISC_CONFIG2, + PM88X_INT_INV | PM88X_INT_CLEAR | PM88X_INT_MASK_MODE, + PM88X_INT_WC); + if (ret) { + dev_err(&chip->client->dev, "Failed to set interrupt clearing mode: %d\n", ret); + return ret; + } + + ret = devm_regmap_add_irq_chip(&chip->client->dev, chip->regmaps[PM88X_REGMAP_BASE], + chip->client->irq, IRQF_ONESHOT, -1, &pm88x_regmap_irq_chip, + &chip->irq_data); + if (ret) { + dev_err(&chip->client->dev, "Failed to request IRQ: %d\n", ret); + return ret; + } + + return 0; +} + +static int pm88x_probe(struct i2c_client *client) +{ + struct pm88x_chip *chip; + int ret = 0; + unsigned int chip_id; + + chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); + if (!chip) + return -ENOMEM; + + chip->client = client; + chip->data = device_get_match_data(&client->dev); + i2c_set_clientdata(client, chip); + + device_init_wakeup(&client->dev, 1); + + chip->regmaps[PM88X_REGMAP_BASE] = devm_regmap_init_i2c(client, &pm88x_i2c_regmap); + if (IS_ERR(chip->regmaps[PM88X_REGMAP_BASE])) { + ret = PTR_ERR(chip->regmaps[PM88X_REGMAP_BASE]); + dev_err(&client->dev, "Failed to initialize regmap: %d\n", ret); + return ret; + } + + ret = regmap_read(chip->regmaps[PM88X_REGMAP_BASE], PM88X_REG_ID, &chip_id); + if (ret) { + dev_err(&client->dev, "Failed to read chip ID: %d\n", ret); + return ret; + } + if (chip->data->whoami != chip_id) { + dev_err(&client->dev, "Device reported wrong chip ID: %u\n", chip_id); + return -EINVAL; + } + + ret = pm88x_setup_irq(chip); + if (ret) + return ret; + + ret = devm_mfd_add_devices(&client->dev, 0, pm88x_devs, ARRAY_SIZE(pm88x_devs), + NULL, 0, regmap_irq_get_domain(chip->irq_data)); + if (ret) { + dev_err(&client->dev, "Failed to add devices: %d\n", ret); + return ret; + } + + ret = regmap_register_patch(chip->regmaps[PM88X_REGMAP_BASE], chip->data->presets, + chip->data->num_presets); + if (ret) { + dev_err(&client->dev, "Failed to register regmap patch: %d\n", ret); + return ret; + } + + ret = devm_register_power_off_handler(&client->dev, pm88x_power_off_handler, chip); + if (ret) { + dev_err(&client->dev, "Failed to register power off handler: %d\n", ret); + return ret; + } + + return 0; +} + +const struct of_device_id pm88x_of_match[] = { + { .compatible = "marvell,88pm886-a1", .data = &pm886_a1_data }, + { }, +}; + +static struct i2c_driver pm88x_i2c_driver = { + .driver = { + .name = "88pm88x", + .of_match_table = of_match_ptr(pm88x_of_match), + }, + .probe = pm88x_probe, +}; +module_i2c_driver(pm88x_i2c_driver); + +MODULE_DESCRIPTION("Marvell 88PM88X PMIC driver"); +MODULE_AUTHOR("Karel Balej "); +MODULE_LICENSE("GPL"); diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 90ce58fd629e..c593279fd766 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -794,6 +794,17 @@ config MFD_88PM860X select individual components like voltage regulators, RTC and battery-charger under the corresponding menus. +config MFD_88PM88X + bool "Marvell 88PM886" + depends on I2C=y + select REGMAP_I2C + select REGMAP_IRQ + select MFD_CORE + help + This enables support for Marvell 88PM886 Power Management IC. + This includes the I2C driver and the core APIs _only_, you have to + select individual components like onkey under the corresponding menus. + config MFD_MAX14577 tristate "Maxim Semiconductor MAX14577/77836 MUIC + Charger Support" depends on I2C diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index c66f07edcd0e..14e42b045c92 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_MFD_88PM860X) += 88pm860x.o obj-$(CONFIG_MFD_88PM800) += 88pm800.o 88pm80x.o obj-$(CONFIG_MFD_88PM805) += 88pm805.o 88pm80x.o +obj-$(CONFIG_MFD_88PM88X) += 88pm88x.o obj-$(CONFIG_MFD_ACT8945A) += act8945a.o obj-$(CONFIG_MFD_SM501) += sm501.o obj-$(CONFIG_ARCH_BCM2835) += bcm2835-pm.o diff --git a/include/linux/mfd/88pm88x.h b/include/linux/mfd/88pm88x.h new file mode 100644 index 000000000000..a34c57447827 --- /dev/null +++ b/include/linux/mfd/88pm88x.h @@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __LINUX_MFD_88PM88X_H +#define __LINUX_MFD_88PM88X_H + +#include + +#define PM886_A1_WHOAMI 0xa1 + +#define PM88X_REG_ID 0x00 + +#define PM88X_REG_STATUS1 0x01 +#define PM88X_ONKEY_STS1 BIT(0) + +#define PM88X_REG_MISC_CONFIG1 0x14 +#define PM88X_SW_PDOWN BIT(5) + +#define PM88X_REG_MISC_CONFIG2 0x15 +#define PM88X_INT_INV BIT(0) +#define PM88X_INT_CLEAR BIT(1) +#define PM88X_INT_RC 0x00 +#define PM88X_INT_WC BIT(1) +#define PM88X_INT_MASK_MODE BIT(2) + +#define PM88X_REG_WDOG 0x1d + +#define PM88X_REG_LOWPOWER2 0x21 +#define PM88X_REG_LOWPOWER4 0x23 + +#define PM88X_REG_GPIO_CTRL1 0x30 + +#define PM88X_REG_GPIO_CTRL2 0x31 + +#define PM88X_REG_GPIO_CTRL3 0x32 + +#define PM88X_REG_GPIO_CTRL4 0x33 + +#define PM88X_REG_BK_OSC_CTRL1 0x50 +#define PM88X_REG_BK_OSC_CTRL3 0x52 + +#define PM88X_REG_AON_CTRL2 0xe2 + +enum pm88x_regmap_index { + PM88X_REGMAP_BASE, + + PM88X_REGMAP_NR +}; + +struct pm88x_data { + unsigned int whoami; + struct reg_sequence *presets; + unsigned int num_presets; +}; + +struct pm88x_chip { + struct i2c_client *client; + struct regmap_irq_chip_data *irq_data; + const struct pm88x_data *data; + struct regmap *regmaps[PM88X_REGMAP_NR]; +}; +#endif /* __LINUX_MFD_88PM88X_H */ From patchwork Sun Dec 17 13:17:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karel Balej X-Patchwork-Id: 180010 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp700831dyi; Sun, 17 Dec 2023 05:21:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IFF75//Of7b3jtr39s0VlTJs8fyBXVkfW+KktxfWxtlbh4N0TGP7LNhxn6VFD2N7DvnYmYr X-Received: by 2002:a05:6a20:2926:b0:18f:97c:3861 with SMTP id t38-20020a056a20292600b0018f097c3861mr15433963pzf.59.1702819274953; Sun, 17 Dec 2023 05:21:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702819274; cv=none; d=google.com; s=arc-20160816; b=xlyFb1GJvYoKdX0Qekjv22CS5EbVRFuw7fkm1gSoF9Jr/Ofd6gnHAXo0tagPD2nHLJ PyLEHVcVh7JfqE7VgHU75hEFxkyL0pjAVNEQ3K5SyORxMw+9duju7d1gB85VUghgd0Ke thpE4OESrQHipxJL7LAsvKYs4pSwb3iIT5ApHuYQmjzt40kCWZ//OhkQST+Mmqki24r+ C24i1yvrvsadJbDq1Brmwo+dTtrHjEJcEOMeyy8Y5xM1FjbSHS9b7IiQNIVXlSN90SME DFsGnr/vS/H6LOHwrMYkUQJj0sUvO96zdezijQn7O+eeTocxuNAJRsnJkjll67r6QQaY rYpw== 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=Eb9PVlKyWd9Gv3amt/ROTpeJ3I3AAA7g4+9KAFbwvF0=; fh=byZQJBCQWs0FCWKszxE7A5Om/MlZEW9RXICqsSfEzlA=; b=bPf+NEXaZbJvb+pn7Ijf7chsTOBxjPjzmfi/K9mSwsmbixCu89cI4/E8oHBHseVMcu h7iXlJ6AugLh1peqYx/Kl0Zr0aw/zB0//Px7EgrxeKs3WrQKmR27k2SujLznDoKTfHTk Tc4p1e69nHvWk1jRC1V8r0Ta8Anfp8IHAYbiXkqBxlehsPYkufI5VKh+ubB7rfHTxTLp qVnwtbmI0bHu3hs5qHEhCGpAa8udBfvmgtmTmtk6MZrmUfbcZ/syxeYBokskA0Xvy1uE 3ufB1WHhKDFTxpiRc1A+8909PGC0emtC/Mk0au5LnmZKgzq9im0fvNXFkg1t54ORVul+ Ne5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gimli.ms.mff.cuni.cz header.s=gen1 header.b=n50GR606; spf=pass (google.com: domain of linux-kernel+bounces-2603-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2603-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gimli.ms.mff.cuni.cz Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i186-20020a636dc3000000b005cd786d8e3asi2799523pgc.133.2023.12.17.05.21.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 05:21:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2603-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gimli.ms.mff.cuni.cz header.s=gen1 header.b=n50GR606; spf=pass (google.com: domain of linux-kernel+bounces-2603-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2603-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A9A7C2827B0 for ; Sun, 17 Dec 2023 13:21:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EA5BF44C7F; Sun, 17 Dec 2023 13:20:42 +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="n50GR606" 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 D5EAD44374; Sun, 17 Dec 2023 13:20:37 +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 196CA28C344; Sun, 17 Dec 2023 14:20:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gimli.ms.mff.cuni.cz; s=gen1; t=1702819236; 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=Eb9PVlKyWd9Gv3amt/ROTpeJ3I3AAA7g4+9KAFbwvF0=; b=n50GR606JCxk3wTlY6K8oEcsHsL5WwJN+ynH18c4+9esFAs7FIxEXCGVR/ZdMfQE65is0d Zd7Gc98o2TRutKx3cx8SPH0ZytCT5Vk7291TX0a3dTSd4bdgPkNXpOB/B0MuNSVqwYxjLe mmsYForXoLgITl62li1r9Hvd3aeWfkw= 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 E960644AF99; Sun, 17 Dec 2023 14:20:35 +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 3/5] dt-bindings: input: add entry for 88pm88x-onkey Date: Sun, 17 Dec 2023 14:17:01 +0100 Message-ID: <20231217131838.7569-4-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: 1785535423926268098 X-GMAIL-MSGID: 1785535423926268098 From: Karel Balej Marvell 88PM88X PMICs provide onkey functionality. Document it. Signed-off-by: Karel Balej --- .../bindings/input/marvell,88pm88x-onkey.yaml | 30 +++++++++++++++++++ .../bindings/mfd/marvell,88pm88x.yaml | 4 +++ 2 files changed, 34 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/marvell,88pm88x-onkey.yaml diff --git a/Documentation/devicetree/bindings/input/marvell,88pm88x-onkey.yaml b/Documentation/devicetree/bindings/input/marvell,88pm88x-onkey.yaml new file mode 100644 index 000000000000..aeb7673189f8 --- /dev/null +++ b/Documentation/devicetree/bindings/input/marvell,88pm88x-onkey.yaml @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/marvell,88pm88x-onkey.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Onkey driver for Marvell 88PM88X PMICs. + +maintainers: + - Karel Balej + +description: | + This module is part of the 88PM88X MFD device. For more details + see Documentation/devicetree/bindings/mfd/marvell,88pm88x.yaml. + + The onkey controller is represented as a sub-node of the PMIC node in + the device tree. + +allOf: + - $ref: input.yaml# + +properties: + compatible: + const: marvell,88pm88x-onkey + +required: + - compatible + +additionalProperties: false +... diff --git a/Documentation/devicetree/bindings/mfd/marvell,88pm88x.yaml b/Documentation/devicetree/bindings/mfd/marvell,88pm88x.yaml index e075729c360f..115b41c9f22c 100644 --- a/Documentation/devicetree/bindings/mfd/marvell,88pm88x.yaml +++ b/Documentation/devicetree/bindings/mfd/marvell,88pm88x.yaml @@ -50,6 +50,10 @@ examples: interrupt-parent = <&gic>; interrupt-controller; #interrupt-cells = <1>; + + onkey { + compatible = "marvell,88pm88x-onkey"; + }; }; }; ... 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 From patchwork Sun Dec 17 13:17:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karel Balej X-Patchwork-Id: 180012 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp701772dyi; Sun, 17 Dec 2023 05:23:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IGIw82jRe+UkGnRo7f30RH2p3G20qsOwyztZDMbWdhJ9ExISAlFDO5+0tiXrw6RzrnTkhuZ X-Received: by 2002:a17:903:2b0e:b0:1d3:6b17:5eb with SMTP id mc14-20020a1709032b0e00b001d36b1705ebmr8088120plb.49.1702819421178; Sun, 17 Dec 2023 05:23:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702819421; cv=none; d=google.com; s=arc-20160816; b=EaNxi6tueAFfNiE0A/4pMeu9hVOBgw4aUhrOGbsbnv63kFQL1u+fOpt76BpePstre6 u8jwr8HWKd+H9a2Dy2E1inLOseq5CVYAfO5XIWQD8Qdrb7M8e4rDy+0AUm/Jv4fGGUiY TPzFdLLGMI8Yqj8YXrk6osGXKYGgDUTbsPaL4nxiGyCk0f/Bn4/u6DT8W3iVbv9e8UoM BK8tAA1Bo8JPpIu8gxb8w+ZnVkq9wCLVTisK+haFI+JySimWdIBnSHq4R7V9H3NL+PgD 80DqCXY4VTeIBUWD8DxpydG8Y6O5qNIEie2cGgLE2XQA0oKvD3WQ2M0zTfzzjF+pFzA9 aD6w== 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=2SD3taSO+f1UM86Cr/JcCY5HUjl3SAc3qWRqT3ByZoE=; fh=byZQJBCQWs0FCWKszxE7A5Om/MlZEW9RXICqsSfEzlA=; b=sYjjvWLipFZo5E9k3CTr8CAI3z6xW+4FKafADgzIJ36dAJX5TaDRjwfuVtPVVe/NDs ogFy6IyyipiTJmWD2UrIoePIM6fi5RjzU/KBxWxC/rMDDDFPjGqv6D5eTNGAF3MaBBcu DQH7RsY5M9XbUvb7sPpm6KxgV8YPgAkFa4xWXygx7eLFlDPNcBesDCEn8JyYiZShHB1M foAuB4MsBMNVwngqdf36/jhBCAFOOFWB8uWnbkhMfAFZ+jqn3T66VHcYb6AOzsKe3Xbr j2l7Aw/AabxbL43mudf8vSgTH2Js09Lz8dTX2Tyms7tTsllQlDsVMSie/02kNsDaUwse ui1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gimli.ms.mff.cuni.cz header.s=gen1 header.b=qA0PjjFm; spf=pass (google.com: domain of linux-kernel+bounces-2605-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2605-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 iz15-20020a170902ef8f00b001d3b14e8e22si593030plb.107.2023.12.17.05.23.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 05:23:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2605-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=qA0PjjFm; spf=pass (google.com: domain of linux-kernel+bounces-2605-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2605-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 43EA2B21F9C for ; Sun, 17 Dec 2023 13:21:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1416A45BF2; Sun, 17 Dec 2023 13:20:54 +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="qA0PjjFm" 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 CAA4644361; Sun, 17 Dec 2023 13:20:49 +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 E674728C344; Sun, 17 Dec 2023 14:20:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gimli.ms.mff.cuni.cz; s=gen1; t=1702819247; 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=2SD3taSO+f1UM86Cr/JcCY5HUjl3SAc3qWRqT3ByZoE=; b=qA0PjjFm1+I4j5Z919u1bq1xSAoukywGOAIiT9do2HZ/NAxyetmEZzTcKiYk5lWLu/97lM TAOX6Zr22H+Uh5EmDipRGGqJtVhujiuXyRhNbUz1vQIn9rQlCUkFTzQP0rqgUDhx8bTF2j IUFYES9HVURnzJt46w2vlllL+ATH8OE= 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 C5A7B44AF99; Sun, 17 Dec 2023 14:20:47 +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 5/5] MAINTAINERS: add myself for Marvell 88PM88X PMICs Date: Sun, 17 Dec 2023 14:17:03 +0100 Message-ID: <20231217131838.7569-6-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: 1785535577386652017 X-GMAIL-MSGID: 1785535577386652017 From: Karel Balej Add an entry to MAINTAINERS for the Marvell 88PM88X PMICs MFD and onkey drivers. Signed-off-by: Karel Balej --- MAINTAINERS | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index e2c6187a3ac8..eb0171cd2323 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12737,6 +12737,15 @@ F: drivers/net/dsa/mv88e6xxx/ F: include/linux/dsa/mv88e6xxx.h F: include/linux/platform_data/mv88e6xxx.h +MARVELL 88PM88X PMIC MFD DRIVER +M: Karel Balej +S: Maintained +F: Documentation/devicetree/bindings/input/marvell,88pm88x-onkey.yaml +F: Documentation/devicetree/bindings/mfd/marvell,88pm88x.yaml +F: drivers/input/misc/88pm88x-onkey.c +F: drivers/mfd/88pm88x.c +F: include/linux/mfd/88pm88x.h + MARVELL ARMADA 3700 PHY DRIVERS M: Miquel Raynal S: Maintained