From patchwork Wed May 12 15:26:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattijs Korpershoek X-Patchwork-Id: 12254149 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.4 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_NONE,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 1F92BC433B4 for ; Wed, 12 May 2021 15:28:48 +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 771786187E for ; Wed, 12 May 2021 15:28:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 771786187E 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=HW9gMFmQQhrWfTo4YBVQfM8uvws4cVSDxECtah3A+4o=; b=eoRIRU9bGiF+IRgcysXWHJxXb VhrksHm7voFfbdk8htHHgd4V3FhUVKleQgY/Atl9ekkPcWtkAdQs13WXiOBu0V/Aig2QUKaMyA4Zm GCN36fQ3hHs+kM/iaQmPsCHVpel6HqlhYMCeYnEA5hzi6YqItyQlAaECo1BTRUYJXirKjWQYkgn8v RmMuisJ317goH3yg7Csqdjvfl2om4YjFENluqaVhetUzHAJ2lfSsPGaqavMjIv8Q5vH6AvYu3WZyC I/L7gueN9VNE7gGKtsd+7dnmjRCtUz+XkN4vFxYkxe/kDERSFsQUCqX/CWKuiUhkLXEx7tkMtXd3F dxOfLY+oA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgqlg-003Bsz-5U; Wed, 12 May 2021 15:27:24 +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 1lgqlG-003Bnb-Ao for linux-arm-kernel@desiato.infradead.org; Wed, 12 May 2021 15:26:58 +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=oW516jzYudrgPpoHV87MKKEstdKadYWrqHFNhZ2YbXA=; b=FV21UBjz5OO0/TZa/fp4+XtCEA G1pL4hTshinDaH9oDj1Bknl0BLyARJDeNVVRWZIVB+tWDdwvF1cBwtbaUJTEpUsnMr1olZTqdGmmy DPt+QnG7OusdBGFoLLJ8Vi8Bu54IvOpco4G0nqRoSkVNWOJLCzda+oMdkm1FHpRhCMve0GIzAYrUM WCqRQpnGAkjpekTuAh0BUsUFv4mtrndcDt81miEpU39XxRWs0sMMXQ9PY5Si9/kuwsLYGLUcFCUAc wDqQX2wvMasU6DnDFxNhYOflbUdUoy0zdQoXKc/tq/3IoVREtNr0J2skgbjVXldI9mZJhDwM60BdO SddO8uqA==; Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgqlD-00AW72-23 for linux-arm-kernel@lists.infradead.org; Wed, 12 May 2021 15:26:57 +0000 Received: by mail-wr1-x433.google.com with SMTP id d11so24033072wrw.8 for ; Wed, 12 May 2021 08:26:54 -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=hXAKLlGslSY+StvaTShozecnK56pNk1iaHsdQQqcO3Oq+6ZookK9e21q3ejNQQvBqq RDhHax1vyl5VTyNgLtRs/87oEJGisOF/zGw7VnU0wP2Xli9Vmw1lNM1DP+o1bIMCNZc2 49Wt8OIXmlP0FCA4GETy37IWb6XzuBEsV1YMjfjvHIqMtfiidrWJPN06kSnNPl8G0El+ ejyDjMoNnCe3HFwf1hjDSq/tkolEptYzQzFsogm86a+12K46WgmdmimS0pkSjJdz7Qs1 rZXRl5tgPlAYFLp0FQpP8s37hueBw3hseo+jn1R8u8CpczgMEdOlTFVKdL5IBJcLVRrv wbcw== 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=itzXT6akbeUDxfrXbJxWL233dcKFLmaw26W+aD06q6gm6+KXA1huU94GswdLUKEnNw 0IaB94yZsyOq8kCz1XDkgmY+XzqYrjSOLcF5IsvBTnDSkTXnhxFFi079QPF5kRhUIXzD mNAlsVteW/lGENefmzIaRXDazwqh4QRLVnad6LnrZlKpBlV/wN8Dt87jI1k1K+gaxuOx FUxx4b3TjNLZXbov8TEAIQX3BnrtV3ssiXLzez/eNKn7x2OGGCVpcvEy4mCZcXwhYRnV SJfQtx7jiSCRC0lw92b5Agfnqv2YR0K5oPVUKbJgRhHyuQ3F27gkUTvhERwJ5lUHkctp vpwQ== X-Gm-Message-State: AOAM532Y/joPirx55VBEM8mUSL5qE9TmLyib+HXA+dNgbGmQkYRSWCs8 Tpfj/hhBgJAbFCeWH1q41P3mHw== X-Google-Smtp-Source: ABdhPJypo7Jgc6oAImKUv3gajv3k/NqdipfFKhkHkFZxxCQ1LulKIaO0IIMcNGTIuXb2LioBDAsYuQ== X-Received: by 2002:a05:6000:1549:: with SMTP id 9mr45965246wry.367.1620833213218; Wed, 12 May 2021 08:26:53 -0700 (PDT) Received: from mkorpershoek-XPS-13-9370.home (lfbn-tou-1-1465-169.w90-89.abo.wanadoo.fr. [90.89.34.169]) by smtp.gmail.com with ESMTPSA id b7sm30931256wri.83.2021.05.12.08.26.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 08:26:52 -0700 (PDT) From: Mattijs Korpershoek To: Dmitry Torokhov , Matthias Brugger Cc: Fabien Parent , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Mattijs Korpershoek Subject: [PATCH v2 1/3] Input: mtk-pmic-keys - use get_irq_byname() instead of index Date: Wed, 12 May 2021 17:26:46 +0200 Message-Id: <20210512152648.39961-2-mkorpershoek@baylibre.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210512152648.39961-1-mkorpershoek@baylibre.com> References: <20210512152648.39961-1-mkorpershoek@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210512_082655_106304_1805C39F X-CRM114-Status: GOOD ( 15.27 ) 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 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 Wed May 12 15:26:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattijs Korpershoek X-Patchwork-Id: 12254151 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.4 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=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 25503C43462 for ; Wed, 12 May 2021 15:29:22 +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 8730361CB4 for ; Wed, 12 May 2021 15:29:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8730361CB4 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=ucVZpiXTgxSqOzrtNQ9elu/J2LHfZPQyVg3lLcswpEE=; b=eLatop+iocgoxbHXzxumaFbKb Fmhc07MvVb1qbpZc/myr7uPAHb7SAepNA4IsSbWD/aVA36kv+6iwZN2gwjnWbSvSFUl0cAHMTFCrh NJbgPLNH5R8pJVetyCPLjRwzdTZm6ESM6FhOQcaH72W4lp6JcpH83lm5aOgZmdhSQeSjUXpgRctDB cq7PdQYYl7CBwj1GXzy6bgcXy3lxlBmtgmuqTY++dPqNt6Ckinq2LoE+tXytmjJX26MCbkFnY2r39 eX04XVbt0sfu+tRKo8vPXWDkMGh9XDdlwu+kKZUwQFfmP6xiEcY1mkpxl6VFnBrbsNRdAVI/HOTyQ O9412NwFg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgqm1-003Bxy-RP; Wed, 12 May 2021 15:27:46 +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 1lgqlH-003Bnj-2F for linux-arm-kernel@desiato.infradead.org; Wed, 12 May 2021 15:26:59 +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=lzfTe4NYom6dNO0HLbV+l/ZlHA7iI3yej9+BU8sy+1w=; b=1Sdye6I/TZbMJFbGpbVbonwy3G S+/QmQVfZwAhF3Hri9yNBCU5ewc4KIN01s8c39bx3v3n07DO2/PsGfkNV7veVE/2jQ1NBNkVdp9h+ 1xzkTkip2MkCHKIOTAQWnRFZqI0NSIdxYuwHhXgYcL/5W/9nNoWtd0uiRY0pu9FPf4IsQDk25dYz8 nwp6qytZpd4aFlThKFY08NrqEN1Hj1+ceSJe0zM7DevO7xS/jqzy6AyJicHDSctvgETau9S4nK2u7 SZ00cxDxCbAfvOUpGHkZURq8tgLyEGicu3vGurwf0Vyz84lX8QXdH42/KcAvHlx+9KcAlJw6TIr7f eakyw4rg==; Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgqlE-00AW7g-FS for linux-arm-kernel@lists.infradead.org; Wed, 12 May 2021 15:26:57 +0000 Received: by mail-wr1-x42e.google.com with SMTP id m9so24059349wrx.3 for ; Wed, 12 May 2021 08:26:55 -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=rElwDa8Lrcm2kjcdcnyk3ukxfLOTiThQgebEnFQOeXEdOe3irtXS/3EEKwl1Dh3ar0 aEk4Ciyj4q/bNzRAT9Bx2V44WzDgOR9SkqvieE2ZpPI5Ow1Bc1clLXs8x2G6riAOZ6o+ lGTJhX9LzXyzSyDRYOrGlm9RpGFEscdpCjuXqU+Zfa6WA1NQCuIvHUwoN3v32FJpHk+v hJbeeIjTIfzj9fKTf7LlwHI8l/vumbcMXQcCqYbDBaWfW6d+MeRGwKPPH9BNhfo+3Agd 2iMUa2jqW6N/GAmy+beWKyFvJqos1gKR/nqHlQQ4WnsUBvUM4K5EjIbVCy4boq1xo82s B1pA== 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=tFYhDcXwc0gHSiu6hINQEntYZfefSmVXmpikkJK2vXzlJjWEYK/H+OwsfJTaBlQN9i Ah+ORtlOMW7sWrmWYO7r4ZVWemdw6yQL8YCiqtj3NqiGvJ7SpB0kkIvWDhzCx6Dg/qDl mggNTnNaNXzeZ10g8Zq9LvNAWTWV8jvxDv5Dl+5oDAM6UhvHmTkw45cjI3lzV2lH2sYC X42q0cTWmB0g4/HaIe2dSJK63Zrh6rjjoS2uoJxDSp/o8G9uAm1kG3REt98be/rQPAEr Go9yq4AzbMiYGITm/J+IJPvup7PIHBz2vH89yFXEf2fDmeCjg2pDI7XK5gkyYyipTKn7 FPjg== X-Gm-Message-State: AOAM531dT2ksPCHYXQXwMnjlsAJUKZu1LTcPLTAyh4BNZqtNC1DPRGrz 1HgmqXvX6Oi1N4364ax1ocoCEw== X-Google-Smtp-Source: ABdhPJyvnIsbHX1mOtVgeTVf2klh9fpVHpl9Y27iO4L5BVcpy8cfA9oNsTK0UIGbAHxoGx7lF/DdyQ== X-Received: by 2002:a5d:4947:: with SMTP id r7mr45639060wrs.217.1620833214636; Wed, 12 May 2021 08:26:54 -0700 (PDT) Received: from mkorpershoek-XPS-13-9370.home (lfbn-tou-1-1465-169.w90-89.abo.wanadoo.fr. [90.89.34.169]) by smtp.gmail.com with ESMTPSA id b7sm30931256wri.83.2021.05.12.08.26.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 08:26:54 -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-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Mattijs Korpershoek , Rob Herring Subject: [PATCH v2 2/3] dt-bindings: input: mtk-pmic-keys: add MT6358 binding definition Date: Wed, 12 May 2021 17:26:47 +0200 Message-Id: <20210512152648.39961-3-mkorpershoek@baylibre.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210512152648.39961-1-mkorpershoek@baylibre.com> References: <20210512152648.39961-1-mkorpershoek@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210512_082656_521868_79395FBC X-CRM114-Status: GOOD ( 13.33 ) 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 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 Wed May 12 15:26:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattijs Korpershoek X-Patchwork-Id: 12254153 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.4 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,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 F386CC43600 for ; Wed, 12 May 2021 15:29:31 +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 4932061CD5 for ; Wed, 12 May 2021 15:29:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4932061CD5 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=J48D9/u9aJ5plSaqAJPR9iahshti02Skf0fRyJogOwE=; b=Pj6dCdUV+PA/fTps4Sk+TGu8P Gyuj/at6eP6etBzUeZ83QmneHcYY+DRNH+x7Rwk0bBHRm4gsJDySbl38p70t/TDgUAlxtPN4XBc7E 8vy+IFA8Iad4VXFKnBewsE7fj0xtv4+5yDyu+Y8qfp7R7aYUHaTFPrZT5O+8pi49CI166OttQ7iFv STJT4x18xu27TQnpbR3JF29ry8P3iHOE965eYAJfBCPJWgzlqI2+cU4GrQN6vCt6aqxzSm9Jm2r2D CWfq7YSaZVF7v3XJ/Twq+pnKyuMFhHoI69+M0oUnJXlelCciYpxrSfAp2iZ5R1UKPQDts1pCJkX1q kE2JcAgzw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgqmK-003C2u-F7; Wed, 12 May 2021 15:28:04 +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 1lgqlI-003Bo2-2v for linux-arm-kernel@desiato.infradead.org; Wed, 12 May 2021 15:27:00 +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=IEDSCcz9DuURhhNfs/tK0QYp1lnSjVV5pxew10G8dSk=; b=4XhRqnVzYE9hvhjDojqiGLCJnm 2JlGEsEVYkWd7UsnCD6PjCvLIEReJMrzlZgPNRZ/46WprPteT23grWHfiOqSL4GwwZ6eqDw8kLAW7 yXJFN2U3iCEkEsLurlYhWNxfshOCymkfywAsSSI/ddlQm6wq+Txd3BHqdSp76zzdgW3JgQCx70iJ/ WXyJ6vZhNSfyKdoX/Eei0ml7Pb557zlYfQA/O6E5RKlaMKzUs9x+AaR3hivGfWzd2P1J1LF8KJCh+ Ha9v8DyANHEeT18BR/u5vF12TIYmv3q2b3xqWjNc7eE9oEWFS8F3NuLCJexMcKNpYm7cfEopl3Qn2 u3l5AyZA==; Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgqlF-00AW8U-CM for linux-arm-kernel@lists.infradead.org; Wed, 12 May 2021 15:26:58 +0000 Received: by mail-wr1-x42b.google.com with SMTP id s8so24053335wrw.10 for ; Wed, 12 May 2021 08:26:57 -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=CG7ddyfb3MJ4mflSM2j6jsjXSDK0jc/4+713mBdgzZLahUwj9xU1qBq3tVbUZlOhlF fXUgpuXkILMZbznzaUMp8o+y75a1Pyj76CYD9j6gBYZHUQg+lsrOPSh3QK8JzYMwMSV3 9pgx7uJltO/doD6GJ+GoR2q5skrCbFuebIwR8giwNWAQLLGIRAXKcL2tXNR1/JtcatLt ZM22Qsm/oGAt94hGxt1IFdBqSPLjChptmmcY/O9XoTnSaPf+to8y706uZ5mkjDCtglls iNep62hfW0vRpCpn1+YmTQiaOAMAPsg/FH4N/UgYH5GZNqw6U7OO6VEt2devTqWUK+6f T67A== 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=q429XimlwUELr8TCQnsF3K7cTnVs+ATbY7HzEu8/nTp9jbM+wB9NS0S4d3Ihx67TmK 1qk5DzkBDbPx6faiT9IyByjfjyc1z7R6E9SMsUOpt9vZCDq1PBtTCNFpX77AsPDuo/Eh hA7vOKohvqjrARglHUkPcaKpQvEtZ/eYO0N0uYhOzWTpH2isdXCNjWssXcAQpDOlyEca oVBCwAJvEl20R5naX05KTVJiTWZcyJf1ljFZ4M62I7+FAdxOXWlB16VdXX6RTp5Ru3jG /WjaOcaonsgc39z0muncAtKvqdtR7Cq8beHOlElX0kM/mNqcA9cnW1+Y1niR3FGONPDr DGEg== X-Gm-Message-State: AOAM5324/2rM+donPeDg7FZeZPBB2MPj7mYQcIUoeQTwLNATOJXFT+v3 HwDM2sUl8Zd4N8Tj757lnaST7A== X-Google-Smtp-Source: ABdhPJzkz7qyyf/PvRK8FEXDTG23yu94463YY7AS2T5Ra/L04pD4Rp7Xr9jE4wGckz5kM8vYCbJr3Q== X-Received: by 2002:adf:f3cd:: with SMTP id g13mr39081412wrp.94.1620833216152; Wed, 12 May 2021 08:26:56 -0700 (PDT) Received: from mkorpershoek-XPS-13-9370.home (lfbn-tou-1-1465-169.w90-89.abo.wanadoo.fr. [90.89.34.169]) by smtp.gmail.com with ESMTPSA id b7sm30931256wri.83.2021.05.12.08.26.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 08:26:55 -0700 (PDT) From: Mattijs Korpershoek To: Dmitry Torokhov , Matthias Brugger Cc: Fabien Parent , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Mattijs Korpershoek Subject: [PATCH v2 3/3] Input: mtk-pmic-keys - add support for MT6358 Date: Wed, 12 May 2021 17:26:48 +0200 Message-Id: <20210512152648.39961-4-mkorpershoek@baylibre.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210512152648.39961-1-mkorpershoek@baylibre.com> References: <20210512152648.39961-1-mkorpershoek@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210512_082657_445226_ADF83A2F X-CRM114-Status: GOOD ( 20.68 ) 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 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 --- 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) {