From patchwork Mon Apr 25 14:19:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattijs Korpershoek X-Patchwork-Id: 12825823 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E4F75C433EF for ; Mon, 25 Apr 2022 14:21:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=B876Xl4m9DECyq4I1FeK2hLQLTWDzW7GUg94nnWxPKo=; b=L17MQxj5kHaVVt WE5I+XWaGzagFBUs9uQER65WjbJ7stc8PpuIhbo/MoyqSCQakl08xcw/GMFlXUevNsnRnOF/AH+kW uW6l8KVmyChR/n6dbHrT/jzVMHFRfgVZoP+5gby3TsZ2REZ5lLazr6MlFQPf7aweteF9Gdm/NuaEU 7zSs+EyYxC9KubZmvPFaIopYjDLgf340Gt65OKY8A7XfrqVIecJctUtPKV/sUQvPuCzhsHYdKSbZD X7hPfbIZFg76/ZcfnhRMrZIN7ZVKHStM8ntMehKcAtU1oiRFr1JKrvix1aYeiXz2JBuSkBGZauFvb 0SBH8yRiqQuRyNkP42oQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nizYv-009tD4-W7; Mon, 25 Apr 2022 14:19:39 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nizYe-009t5W-Rg for linux-arm-kernel@lists.infradead.org; Mon, 25 Apr 2022 14:19:23 +0000 Received: by mail-wr1-x42b.google.com with SMTP id q23so8210869wra.1 for ; Mon, 25 Apr 2022 07:19:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f2ty6Kirg+4vRs3TX4nTiMefjQ+ct09dXtXeTw7jYik=; b=1sB7e3bdedA9AmRsfGnyCiarRfssvnjB14wg3RY5vuJjV8MlDlAG4m3750y3L4EI6B VCreeEhx06bcRLFb3DUHAYJvjqkhhjWZ5wEsdtvd0iyChuQyufYvQz/rFgbcBNXFkta5 oZ364bmnxUDmoMo5PKJYxul44ORkdDIAdkjhG7RD7z3xVe48qqIIxETG2j+dSi9L5Pxi 451O8ITGyPjGK/bRn2zi7whFR2olqTX68D+YTPvymtepHOVTUjCHRAG4eiBUy0hkofDD QV83KEgXbzukq11DA/dsG46j5gmqyPahC8HpJjhHATw13Xy4EH6GtVSWueTVkutXrcyB H+Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f2ty6Kirg+4vRs3TX4nTiMefjQ+ct09dXtXeTw7jYik=; b=PdvCt0JPBmOi/KwfOlDrKCFYEnqfP45HSYxMyOZ33M6zD4wlhgAvwe6F0Xm55pOGOz asPpXtHCPrpzj+fCcyZJ0MTpSLWZOVoZ33CIzLx9ekLkfCRXS6Ndf4H2CJGFA7N2dz96 q6kT2uzxc/5Rj+/NV7P9TsCvOjocSRhkUad1oL4oAD6+0LkdJGWVYTzh0l3FJ+G8PLYd 7Rdn0uHEqtYruVPDBikIfIcLhbE28nKsnZyzQdWxtOyvdsEsPE0t7H+q343bCW61DJMa 8PdPwKTX0EkDoXZRGMpotricU+oVsCci+vnBaVoTi/7eGyqSY5rO2ZQS3NZG5PG49D3h FlFw== X-Gm-Message-State: AOAM5311wAVEfFiemQeRG+AfvrPCJVZdllLmlS/PdrSqmalGIzyVIXoI jXBO7l74QLuMfbpCvcgzxsma6A== X-Google-Smtp-Source: ABdhPJyz4lwM9SSlgEubsE2+9MARuzk/2+T+ZiKJb/BBzhW4+LWq+OpWxYNbBON2beZCu62KJb+UqQ== X-Received: by 2002:a05:6000:1a86:b0:20a:a933:ba16 with SMTP id f6-20020a0560001a8600b0020aa933ba16mr14279412wry.583.1650896359277; Mon, 25 Apr 2022 07:19:19 -0700 (PDT) Received: from groot.home ([2a01:cb19:85e6:1900:ce86:3a65:67d7:726d]) by smtp.gmail.com with ESMTPSA id f10-20020a5d64ca000000b0020aa97b0383sm9144592wri.113.2022.04.25.07.19.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Apr 2022 07:19:19 -0700 (PDT) From: Mattijs Korpershoek To: Dmitry Torokhov Cc: Matthias Brugger , AngeloGioacchino Del Regno , Kevin Hilman , Fabien Parent , linux-input@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mattijs Korpershoek Subject: [PATCH 2/2] Input: mt6779-keypad - implement row/column selection Date: Mon, 25 Apr 2022 16:19:14 +0200 Message-Id: <20220425141914.158959-3-mkorpershoek@baylibre.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220425141914.158959-1-mkorpershoek@baylibre.com> References: <20220425141914.158959-1-mkorpershoek@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220425_071921_261529_58ECF9D0 X-CRM114-Status: GOOD ( 13.12 ) 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 The MediaTek keypad has a total of 6 input rows and 6 input columns. By default, rows/columns 0-2 are enabled. This is controlled by the KP_SEL register: - bits[9:4] control row selection - bits[15:10] control column selection Each bit enables the corresponding row/column number (e.g KP_SEL[4] enables ROW0) Depending on how the keypad is wired, this may result in wrong readings of the keypad state. Program the KP_SEL register to limit the key detection to n_rows, n_cols we retrieve from the device tree. Signed-off-by: Mattijs Korpershoek --- drivers/input/keyboard/mt6779-keypad.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/input/keyboard/mt6779-keypad.c b/drivers/input/keyboard/mt6779-keypad.c index 23360de20da5..653dfc619696 100644 --- a/drivers/input/keyboard/mt6779-keypad.c +++ b/drivers/input/keyboard/mt6779-keypad.c @@ -17,6 +17,11 @@ #define MTK_KPD_DEBOUNCE 0x0018 #define MTK_KPD_DEBOUNCE_MASK GENMASK(13, 0) #define MTK_KPD_DEBOUNCE_MAX_MS 256 +#define MTK_KPD_SEL 0x0020 +#define MTK_KPD_SEL_COL GENMASK(15, 10) +#define MTK_KPD_SEL_ROW GENMASK(9, 4) +#define MTK_KPD_SEL_COLMASK(c) (MTK_KPD_SEL_COL >> (6 - (c))) +#define MTK_KPD_SEL_ROWMASK(r) (MTK_KPD_SEL_ROW >> (6 - (r))) #define MTK_KPD_NUM_MEMS 5 #define MTK_KPD_NUM_BITS 136 /* 4*32+8 MEM5 only use 8 BITS */ @@ -171,6 +176,11 @@ static int mt6779_keypad_pdrv_probe(struct platform_device *pdev) regmap_write(keypad->regmap, MTK_KPD_DEBOUNCE, (debounce * (1 << 5)) & MTK_KPD_DEBOUNCE_MASK); + regmap_update_bits(keypad->regmap, MTK_KPD_SEL, MTK_KPD_SEL_ROW, + MTK_KPD_SEL_ROWMASK(keypad->n_rows)); + regmap_update_bits(keypad->regmap, MTK_KPD_SEL, MTK_KPD_SEL_COL, + MTK_KPD_SEL_COLMASK(keypad->n_cols)); + keypad->clk = devm_clk_get(&pdev->dev, "kpd"); if (IS_ERR(keypad->clk)) return PTR_ERR(keypad->clk);