From patchwork Thu May 6 15:37:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattijs Korpershoek X-Patchwork-Id: 12242601 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BB28C433ED for ; Thu, 6 May 2021 15:40:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4FB36610E9 for ; Thu, 6 May 2021 15:40:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235188AbhEFPlW (ORCPT ); Thu, 6 May 2021 11:41:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235689AbhEFPlG (ORCPT ); Thu, 6 May 2021 11:41:06 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEED7C061763 for ; Thu, 6 May 2021 08:37:28 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id l14so6113153wrx.5 for ; Thu, 06 May 2021 08:37:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oW516jzYudrgPpoHV87MKKEstdKadYWrqHFNhZ2YbXA=; b=IXg8o5wjRe5tnEMU6NOudBSTzNqehm2jpqFD2uSexwVdQ672TmU2uAGQncSu7UqNPg CrmtEvYFXjnGmexJXSdcPrvaMYM4qX+uDtCdp+LN273fLznYzyJauDUJs6JdXXOh/A1B D28RQVcG6mYoPM4bd1jPQY/9glaZLpZcZBBzjg3pmhTTpBtX9AnHox6ZmjmMf54Bj0Ii 1UMpTJAw6qlB6BBe1QYcxAT0u6McMDdrxqadMq8o2OgnN47ITYFV31M0a1F8x7Ccr2y5 52CjetHDs27ekPEpbpBuhXlxPLSzp3ER/awpJiJtAlhfBwWO1Hw5Z37t2HvpUc+jhN+i GaIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oW516jzYudrgPpoHV87MKKEstdKadYWrqHFNhZ2YbXA=; b=MGws8e4PqL4h+1GgsBPF3xeeDiRXIvibRcaFE4ySMx0TJ9hArsWmb6RChqvQHmx9V5 HIT87FDPWgpD5IENkY20MSzWPqNJ85t4fwzzf74cV52o6wRS+IdWpKw90D5X2ekKNXZs NE51AnlpdxgSApTEG8A+btQP1Uv42CYpgOk/Mha5wMbbDYG2O8+XqQ6mNqCBR1B+ng+z Cc/has7baXd2dbZxoRDqu80yahfc6lod08xXRVHlQPlmxjfm0kbkisYABqolk4BmyS5W 9ZnhttDerYzLRMfP4lzzf/Iy0h3VQt3C2/EDqovlYeJ2aBnLlMuKJoL7TADsaZ6Wexnn qgyA== X-Gm-Message-State: AOAM530ur2tQifT5DTDtVO7YI6EVCj0wmMDfpfJaS6uZYkv80WBuamZN GXprPAHc72GIXsv4kcrqMiwyXA== X-Google-Smtp-Source: ABdhPJyd0JoHB9yNIkDQl4FPDKaa1IAPD7vl4654KnfHoAWsbt2C1ycq3EFe43odqrh+MHp1zRA6hw== X-Received: by 2002:a5d:408f:: with SMTP id o15mr5845999wrp.89.1620315447483; Thu, 06 May 2021 08:37:27 -0700 (PDT) Received: from groot.home ([2a01:cb19:826e:8e00:5fe0:3a70:ad4a:a29b]) by smtp.gmail.com with ESMTPSA id o13sm3788673wmh.34.2021.05.06.08.37.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 May 2021 08:37:27 -0700 (PDT) From: Mattijs Korpershoek To: Dmitry Torokhov , Matthias Brugger Cc: Fabien Parent , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Mattijs Korpershoek , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH 1/3] Input: mtk-pmic-keys - use get_irq_byname() instead of index Date: Thu, 6 May 2021 17:37:16 +0200 Message-Id: <20210506153718.256903-2-mkorpershoek@baylibre.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210506153718.256903-1-mkorpershoek@baylibre.com> References: <20210506153718.256903-1-mkorpershoek@baylibre.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Some pmics of the mt6397 family (such as MT6358), have two IRQs per physical key: one for press event, another for release event. The mtk-pmic-keys driver assumes that each key only has one IRQ. The key index and the RES_IRQ resource index have a 1/1 mapping. This won't work for MT6358, as we have multiple resources (2) for one key. To prepare mtk-pmic-keys to support MT6358, retrieve IRQs by name instead of by index. Signed-off-by: Mattijs Korpershoek --- drivers/input/keyboard/mtk-pmic-keys.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c index 62391d6c7da6..d1abf95d5701 100644 --- a/drivers/input/keyboard/mtk-pmic-keys.c +++ b/drivers/input/keyboard/mtk-pmic-keys.c @@ -241,6 +241,7 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev) unsigned int keycount; struct mt6397_chip *pmic_chip = dev_get_drvdata(pdev->dev.parent); struct device_node *node = pdev->dev.of_node, *child; + static const char *const irqnames[] = { "powerkey", "homekey" }; struct mtk_pmic_keys *keys; const struct mtk_pmic_regs *mtk_pmic_regs; struct input_dev *input_dev; @@ -268,7 +269,8 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev) input_dev->id.version = 0x0001; keycount = of_get_available_child_count(node); - if (keycount > MTK_PMIC_MAX_KEY_COUNT) { + if (keycount > MTK_PMIC_MAX_KEY_COUNT || + keycount > ARRAY_SIZE(irqnames)) { dev_err(keys->dev, "too many keys defined (%d)\n", keycount); return -EINVAL; } @@ -276,7 +278,8 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev) for_each_child_of_node(node, child) { keys->keys[index].regs = &mtk_pmic_regs->keys_regs[index]; - keys->keys[index].irq = platform_get_irq(pdev, index); + keys->keys[index].irq = + platform_get_irq_byname(pdev, irqnames[index]); if (keys->keys[index].irq < 0) { of_node_put(child); return keys->keys[index].irq; From patchwork Thu May 6 15:37:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattijs Korpershoek X-Patchwork-Id: 12242603 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B7A2C43462 for ; Thu, 6 May 2021 15:40:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 05AAF610E7 for ; Thu, 6 May 2021 15:40:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235943AbhEFPlY (ORCPT ); Thu, 6 May 2021 11:41:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235481AbhEFPlH (ORCPT ); Thu, 6 May 2021 11:41:07 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF3F3C06125E for ; Thu, 6 May 2021 08:37:29 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id s82so3619753wmf.3 for ; Thu, 06 May 2021 08:37:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lzfTe4NYom6dNO0HLbV+l/ZlHA7iI3yej9+BU8sy+1w=; b=TxdA95xr9NvNrTqX2glo6DuRNrRFdtE85RIavTmpnvW546k6YjimPwfcuVXjPXwcCF rrK12TcDVC4TOR2Im2bSV/5Yt8oQIBx+4nJAz4z2gtd9vqerj6maM/0xDbDVFmZnyM9F anOYodAQO5oPW2skhSrdXa1+8OtfiT2mvIN43vmm7ay3ZQnjl86L5QGRqasdLcjuj4VZ kqB1avcVQUTFGE2xB6GGkogTe5nzZQJfSIMi1DtOybpVESuhxLSMPzDdNolXzZozqs9Z 6nnYEfwk1Nn6qNLfjkvh6nYCxUBmw6feIndbTkCIpVgS7L7pm7J25YajIHH5XTHtkk1S n3Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lzfTe4NYom6dNO0HLbV+l/ZlHA7iI3yej9+BU8sy+1w=; b=b3dSSFov9KjB71HMFs0JlcytfAdt4/DMCdf7pX/VL4U2UU1qakC+m4bf9+qoGkfkFk x/cyQSE3opROp4MA6bbmyWKbHGnd/z358JTWes+WwU6MKIxhjAI4UNmVPy8UTjOeZjuO 2GJqstwFPJz8YKqmfGLotC3pY2X6cgqNGS77ik0G3E0VCkL8TdQxdDUAaosQuwjtiNHa klxm4JA6WAI6bCP1ygZEL/mdMPSjAKlG8ZyywtZx4uhw9sbBIeS1gqH5TnxTl2OI/2dA gJwsJ/Al6nQ8BllQqmawbnqDJNsYWM4mwkgQ73poIJ7n02QPhwdBxTWO8WEQcC20QluC eO7A== X-Gm-Message-State: AOAM533dn6GinthBjjjATKuenoF5EKd56usfH0WDusX8xZCGJp7bj4lj ivtcdMidbxXQ2aNJ4Z4uYDzoaQ== X-Google-Smtp-Source: ABdhPJxnDa8+QB/P9YvBx7Q0p5ZbONAbd3z3myIbhHyV4Pm3jy9jW1JOlvP0Wp/CbE3H9YaEACRDgg== X-Received: by 2002:a1c:7205:: with SMTP id n5mr15842002wmc.131.1620315448603; Thu, 06 May 2021 08:37:28 -0700 (PDT) Received: from groot.home ([2a01:cb19:826e:8e00:5fe0:3a70:ad4a:a29b]) by smtp.gmail.com with ESMTPSA id o13sm3788673wmh.34.2021.05.06.08.37.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 May 2021 08:37:28 -0700 (PDT) From: Mattijs Korpershoek To: Dmitry Torokhov , Matthias Brugger , Rob Herring Cc: Fabien Parent , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Mattijs Korpershoek , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH 2/3] dt-bindings: input: mtk-pmic-keys: add MT6358 binding definition Date: Thu, 6 May 2021 17:37:17 +0200 Message-Id: <20210506153718.256903-3-mkorpershoek@baylibre.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210506153718.256903-1-mkorpershoek@baylibre.com> References: <20210506153718.256903-1-mkorpershoek@baylibre.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add the binding documentation of the mtk-pmic-keys for the MT6358 PMICs. MT6358 is a little different since it used separate IRQs for the release key (_r) event Signed-off-by: Mattijs Korpershoek Acked-by: Rob Herring --- Documentation/devicetree/bindings/input/mtk-pmic-keys.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt b/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt index 535d92885372..9d00f2a8e13a 100644 --- a/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt +++ b/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt @@ -9,7 +9,10 @@ For MT6397/MT6323 MFD bindings see: Documentation/devicetree/bindings/mfd/mt6397.txt Required properties: -- compatible: "mediatek,mt6397-keys" or "mediatek,mt6323-keys" +- compatible: Should be one of: + - "mediatek,mt6397-keys" + - "mediatek,mt6323-keys" + - "mediatek,mt6358-keys" - linux,keycodes: See Documentation/devicetree/bindings/input/input.yaml Optional Properties: From patchwork Thu May 6 15:37:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattijs Korpershoek X-Patchwork-Id: 12242605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5060C433ED for ; Thu, 6 May 2021 15:40:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6A8D9610C8 for ; Thu, 6 May 2021 15:40:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235712AbhEFPli (ORCPT ); Thu, 6 May 2021 11:41:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235888AbhEFPlL (ORCPT ); Thu, 6 May 2021 11:41:11 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC29BC061263 for ; Thu, 6 May 2021 08:37:30 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id u5-20020a7bc0450000b02901480e40338bso4998662wmc.1 for ; Thu, 06 May 2021 08:37:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IEDSCcz9DuURhhNfs/tK0QYp1lnSjVV5pxew10G8dSk=; b=V/zeaR1TaQIoeM9XJufp+iP5G92k1G7iWvx0YDJBs9KSTMlmsMkOC9Ez5goto83id3 VXJxFioSnQras5VmtoC1mS86Qn6xMuxeNrsN/w4dmPcZZwzKkzT1j184TkYmlgqNOGsG D7mX3kuycZVBBaJHLTu1jL1YE7cH2iwDCqLePnMy8MsUUpKaZvLyUA9YciXt4I3M7J2n 8bFSPupQId613OvNqc/ecuxQ67Bn2wha7tcANjBBO7oitXR669EwypI8JNq+BavI82WX 5zjHjOWvU5ig2060eSyBeA0UVJAhBeNAgxSDXHRlho7sk2UkPALdYWnKdS8RBX5s+mOn Qjkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IEDSCcz9DuURhhNfs/tK0QYp1lnSjVV5pxew10G8dSk=; b=DzDN3UZLj7s74zic664C+/ytjHm+Fjbwca/OA5bnl5GrdSK1GyoXzEyTx/NIoOVIdK YzAiklrRnDHby6qVeEEY7IBRAguwnmmJdtroP9RBW2gL6N9+M5AVwGsz+2lzh9v1X7tr L9Cy4HunZU4hWYvDu1qdQjeIilmQrzt+SC00wWOpVZrjUXMEf8Md962NybiVsADkjf8T AyKCLcd+P/3MFOi8XAvv3RziopkIU15lxnycRrA93D0udldNstPOUaQlziuQdMyeF4l8 hTidzlwmbeyskPJyIikrGxqs6SyWEYjkJCsD+5xBWfJG5dGeeEu+r5NZiU7/0L94xxYi zhEw== X-Gm-Message-State: AOAM532fGk3dCCCoi5Jgo0+KZrwbaL/yGMv6h2Qnd7rcXzw0rzhsb04t hB2i4+fqSe96STfqAFd8AMANFg== X-Google-Smtp-Source: ABdhPJxAlzAXFBB33Dmk47O2hysPZnFEIjDmjMGitDd9gQpK+W5laXn9eipEYkrU5GFJKGiqW4CfSw== X-Received: by 2002:a05:600c:322a:: with SMTP id r42mr4723194wmp.98.1620315449674; Thu, 06 May 2021 08:37:29 -0700 (PDT) Received: from groot.home ([2a01:cb19:826e:8e00:5fe0:3a70:ad4a:a29b]) by smtp.gmail.com with ESMTPSA id o13sm3788673wmh.34.2021.05.06.08.37.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 May 2021 08:37:29 -0700 (PDT) From: Mattijs Korpershoek To: Dmitry Torokhov , Matthias Brugger Cc: Fabien Parent , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Mattijs Korpershoek , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH 3/3] Input: mtk-pmic-keys - add support for MT6358 Date: Thu, 6 May 2021 17:37:18 +0200 Message-Id: <20210506153718.256903-4-mkorpershoek@baylibre.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210506153718.256903-1-mkorpershoek@baylibre.com> References: <20210506153718.256903-1-mkorpershoek@baylibre.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org MT6358 pmic keys behave differently than mt6397 and mt6323: there are two interrupts per key: one for press, the other one for release (_r) Signed-off-by: Mattijs Korpershoek Reported-by: kernel test robot Reported-by: kernel test robot --- drivers/input/keyboard/mtk-pmic-keys.c | 49 ++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c index d1abf95d5701..5496a7020104 100644 --- a/drivers/input/keyboard/mtk-pmic-keys.c +++ b/drivers/input/keyboard/mtk-pmic-keys.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -74,11 +75,22 @@ static const struct mtk_pmic_regs mt6323_regs = { .pmic_rst_reg = MT6323_TOP_RST_MISC, }; +static const struct mtk_pmic_regs mt6358_regs = { + .keys_regs[MTK_PMIC_PWRKEY_INDEX] = + MTK_PMIC_KEYS_REGS(MT6358_TOPSTATUS, + 0x2, MT6358_PSC_TOP_INT_CON0, 0x5), + .keys_regs[MTK_PMIC_HOMEKEY_INDEX] = + MTK_PMIC_KEYS_REGS(MT6358_TOPSTATUS, + 0x8, MT6358_PSC_TOP_INT_CON0, 0xa), + .pmic_rst_reg = MT6358_TOP_RST_MISC, +}; + struct mtk_pmic_keys_info { struct mtk_pmic_keys *keys; const struct mtk_pmic_keys_regs *regs; unsigned int keycode; int irq; + int irq_r; /* optional: release irq if different */ bool wakeup:1; }; @@ -188,6 +200,19 @@ static int mtk_pmic_key_setup(struct mtk_pmic_keys *keys, return ret; } + if (info->irq_r > 0) { + ret = devm_request_threaded_irq( + keys->dev, info->irq_r, NULL, + mtk_pmic_keys_irq_handler_thread, + IRQF_ONESHOT | IRQF_TRIGGER_HIGH, "mtk-pmic-keys", + info); + if (ret) { + dev_err(keys->dev, "Failed to request IRQ_r: %d: %d\n", + info->irq, ret); + return ret; + } + } + input_set_capability(keys->input_dev, EV_KEY, info->keycode); return 0; @@ -199,8 +224,11 @@ static int __maybe_unused mtk_pmic_keys_suspend(struct device *dev) int index; for (index = 0; index < MTK_PMIC_MAX_KEY_COUNT; index++) { - if (keys->keys[index].wakeup) + if (keys->keys[index].wakeup) { enable_irq_wake(keys->keys[index].irq); + if (keys->keys[index].irq_r > 0) + enable_irq_wake(keys->keys[index].irq_r); + } } return 0; @@ -212,8 +240,11 @@ static int __maybe_unused mtk_pmic_keys_resume(struct device *dev) int index; for (index = 0; index < MTK_PMIC_MAX_KEY_COUNT; index++) { - if (keys->keys[index].wakeup) + if (keys->keys[index].wakeup) { disable_irq_wake(keys->keys[index].irq); + if (keys->keys[index].irq_r > 0) + disable_irq_wake(keys->keys[index].irq_r); + } } return 0; @@ -229,6 +260,9 @@ static const struct of_device_id of_mtk_pmic_keys_match_tbl[] = { }, { .compatible = "mediatek,mt6323-keys", .data = &mt6323_regs, + }, { + .compatible = "mediatek,mt6358-keys", + .data = &mt6358_regs, }, { /* sentinel */ } @@ -242,6 +276,7 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev) struct mt6397_chip *pmic_chip = dev_get_drvdata(pdev->dev.parent); struct device_node *node = pdev->dev.of_node, *child; static const char *const irqnames[] = { "powerkey", "homekey" }; + static const char *const irqnames_r[] = { "powerkey_r", "homekey_r" }; struct mtk_pmic_keys *keys; const struct mtk_pmic_regs *mtk_pmic_regs; struct input_dev *input_dev; @@ -285,6 +320,16 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev) return keys->keys[index].irq; } + if (of_device_is_compatible(node, "mediatek,mt6358-keys")) { + keys->keys[index].irq_r = platform_get_irq_byname( + pdev, irqnames_r[index]); + + if (keys->keys[index].irq_r < 0) { + of_node_put(child); + return keys->keys[index].irq_r; + } + } + error = of_property_read_u32(child, "linux,keycodes", &keys->keys[index].keycode); if (error) {