From patchwork Wed Apr 28 16:42:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattijs Korpershoek X-Patchwork-Id: 12229671 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=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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 3E778C433B4 for ; Wed, 28 Apr 2021 16:44:47 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 94DA160E08 for ; Wed, 28 Apr 2021 16:44:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94DA160E08 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=m08ub+CAezSUcKdFHeUZX/Nc6yUJRwjejbEiSwad9sg=; b=GFjpcImMRPl5xbfRW2bgTEQt1 cyuhM7BC3yeKFBhIe/RnDdHy4EJ04OdN2fY761zj9OmuuvZX5Nko0YvOydP6FENo/wmIUEQjcXnj9 hn6tPgJ+yRhnGb5vRCPv7CGchv3ksre4bguLAfokWCW19731lAq9bs5XCTf9Hgavy5rSjzXyTo+Cq gyw5+t99P6vEpwErKu26uzzChcExllNHkDQ1/UGpWQH9taZs5vOsStQ/Y+jbIrQp+oDuGB8GVmq57 xnzo/mlSeGchTxTzlSXzD/Mx9Y0QnFLOvz6aujVNxjzAjkUOJClI/0zWAdxABbgJZXXE+aBQrNfck I3f4O0taA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lbnHO-003rPr-Sm; Wed, 28 Apr 2021 16:43:15 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbnGi-003rGl-DH for linux-arm-kernel@desiato.infradead.org; Wed, 28 Apr 2021 16:42:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=aE6tbol598vm7TcSOWd/ixIJR/NZPP5/XzZKCEl8Zf8=; b=x6YM2b96kZ8bdCiW9wSviMA8jD 0quXOC8Asd/ZS1Nz4TvWoO8nTjr0BQQSyoV0pp4A9/2H5UmyBeTLperPKZ4YjCdLvAiprTthRKTcv rjtdBca2cWPyk3dH3sIU1iC8XnAEFABtTEc/A2ye/pw9q/4litPSolneC1nddxd7FxTLo8owfENJA OYhPGCrOprINetKhmjUbpR13LwH8fjUnsra/JZ5VeGPKRKCZP9KyXh6Xhj7OtoFUFr40UzSfpMzML Yx+VmxA2RgvvSCGzIrJhFxSzkEPGdy0qXw+vJ1EtiYpFKISWzl66LYpANgG04aNv/TiHpgvhCE3sf 32/IoZUg==; Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbnGf-0001eW-RQ for linux-arm-kernel@lists.infradead.org; Wed, 28 Apr 2021 16:42:31 +0000 Received: by mail-wm1-x330.google.com with SMTP id i129so7235437wma.3 for ; Wed, 28 Apr 2021 09:42: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=aE6tbol598vm7TcSOWd/ixIJR/NZPP5/XzZKCEl8Zf8=; b=J4dqcVhdcBzsqgSFLeh+i1+i5o0SxHlpn8OGQobH8KV71ucEb/6O56IXT8ve1pcz4F 4VKoRxjcAAUGn+wTtkxSK+khCRvmSVVstBfHNcxI3I8ikMuMvedh6k54p84Ee3nOmlUX 10ddhHbR2H1KqB2Q+YU+knIDw/qNWId1at7U/vK5K7LbV/2IYmO3Qdp+xUBsaro9qc7s yI8E9KY6rJGj/CpuP/xcz56ui3AnHXxkW/NTVr9C3h83kt2XnJfv++P7DNQY6qaSBbc4 NTuwPTxqFnTRJ8G37M9Gr00xh0SmAi0p69hTXdcC0BGQmSxbC/noKyP85oM/DgNhWXSP yfiw== 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=aE6tbol598vm7TcSOWd/ixIJR/NZPP5/XzZKCEl8Zf8=; b=Pacup5eSZz5jXBo374RC4kqlTdiWIokROIWeBQDxOIfw3Qcyywj7iM1veBpVd/XMWL P3T2NIMWt4vCKcRTQcmRVRElcyMW6Yu+BmwAaMb6ZsX1hnfUm/PbTod4jix79kk5CXrn tSUbYdk8upmjVzk0NOxjiRKVNhXRkV0/QVmZZX6a1UMgBn3kHXnohw4yHOQf/gOIlfvU 5iwD50sKR+gb/nQEWmpmmHVOvmSsW/5rUpEBzod7eGfAX0YV98zBH9kelYlFeg5Wi3dh y51tixezUqKInzNfj2fAsj9vLFc63osa7voDCwSBSvba5gTUWEvgMKGeiAguShntXcXy Euww== X-Gm-Message-State: AOAM533Nq8Rii3DVc68iksxMCojKWCGQhIcP4jB05FZK2Z5OOVBY+fO0 jxPDN6uiH3aUEblyZAbh1CSnjQ== X-Google-Smtp-Source: ABdhPJyVYbQkgOcOPhTj6Vjo77V2V6rBqhdeMpvSmiZrGZE7iyBdjx+zJuPQ8eC1m25VyF+WiKW55A== X-Received: by 2002:a1c:740c:: with SMTP id p12mr13689713wmc.112.1619628147980; Wed, 28 Apr 2021 09:42:27 -0700 (PDT) Received: from groot.home ([2a01:cb19:826e:8e00:5864:ddd1:d623:f912]) by smtp.gmail.com with ESMTPSA id o10sm351299wrx.35.2021.04.28.09.42.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 09:42:27 -0700 (PDT) From: Mattijs Korpershoek To: Dmitry Torokhov , Matthias Brugger , Lee Jones Cc: fparent@baylibre.com, Mattijs Korpershoek , linux-input@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/7] mfd: mt6397: keys: use named IRQs instead of index Date: Wed, 28 Apr 2021 18:42:15 +0200 Message-Id: <20210428164219.1115537-4-mkorpershoek@baylibre.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210428164219.1115537-1-mkorpershoek@baylibre.com> References: <20210428164219.1115537-1-mkorpershoek@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210428_094229_911047_9633FB1B X-CRM114-Status: GOOD ( 16.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org For some compatible pmics (such as MT6358), there are two IRQs per physical key: one for press event, another for release event. Currently, 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. Note: The keys_resources are not part of the device-tree bindings so this won't break any DT schemas. Signed-off-by: Mattijs Korpershoek --- drivers/input/keyboard/mtk-pmic-keys.c | 7 +++++-- drivers/mfd/mt6397-core.c | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c index 12c449eed026..b877bf98db38 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; @@ -271,7 +272,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; } @@ -279,7 +281,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; diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c index 7518d74c3b4c..8738b5524783 100644 --- a/drivers/mfd/mt6397-core.c +++ b/drivers/mfd/mt6397-core.c @@ -46,13 +46,13 @@ static const struct resource mt6397_rtc_resources[] = { }; static const struct resource mt6323_keys_resources[] = { - DEFINE_RES_IRQ(MT6323_IRQ_STATUS_PWRKEY), - DEFINE_RES_IRQ(MT6323_IRQ_STATUS_FCHRKEY), + DEFINE_RES_IRQ_NAMED(MT6323_IRQ_STATUS_PWRKEY, "powerkey"), + DEFINE_RES_IRQ_NAMED(MT6323_IRQ_STATUS_FCHRKEY, "homekey"), }; static const struct resource mt6397_keys_resources[] = { - DEFINE_RES_IRQ(MT6397_IRQ_PWRKEY), - DEFINE_RES_IRQ(MT6397_IRQ_HOMEKEY), + DEFINE_RES_IRQ_NAMED(MT6397_IRQ_PWRKEY, "powerkey"), + DEFINE_RES_IRQ_NAMED(MT6397_IRQ_HOMEKEY, "homekey"), }; static const struct resource mt6323_pwrc_resources[] = {