From patchwork Sat Nov 5 18:59:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=2E_Neusch=C3=A4fer?= X-Patchwork-Id: 622215 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10FD9C46467 for ; Sat, 5 Nov 2022 18:59:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229980AbiKES7f (ORCPT ); Sat, 5 Nov 2022 14:59:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229916AbiKES7b (ORCPT ); Sat, 5 Nov 2022 14:59:31 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37B172BFF; Sat, 5 Nov 2022 11:59:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1667674761; bh=Qpw8OKKBbZVVfzRq9A/GSiYS3wmIwpXxBurfIN6x05I=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=SlDnVSwIFHrbJ4TPSLdlFuzAXHC+bhydtVpb9WMVZB0v6f01S4F78lyUg/+J+C6Tt CMQ8PLC1PWyN6BpBAtQjO0NmP4h4SvP7s7uDegygqsYg0BguryUfEytGL4RH0zMfht 65Rkb8r0evwqpBLKV6LSQhqNBb/ybRZS4oJLDrWdR9Dj2BeeSbS2rOMBzZSxsw4Mz6 kdl9PMtD7MK6sdgM0iIoilyTg/2XyGMx/nZDziyeKE+j2Y5n7Lh7JZu0ona21wuYkS XKvb3IEJwPLoeaIQYNe8pvDquFEfcBna05w9Bbz+8md0+p7JgQRxuXMWjaiRCuCOgy JIPDD+uQ3LSfQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from probook ([87.78.44.193]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N1fmq-1p2ITJ2h5M-011x00; Sat, 05 Nov 2022 19:59:21 +0100 From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= To: linux-spi@vger.kernel.org, openbmc@lists.ozlabs.org Cc: Lee Jones , Rob Herring , Krzysztof Kozlowski , =?utf-8?q?Jonathan?= =?utf-8?q?_Neusch=C3=A4fer?= , Mark Brown , Linus Walleij , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Subject: [PATCH 2/8] pinctrl: nuvoton: wpcm450: Fix handling of inverted MFSEL bits Date: Sat, 5 Nov 2022 19:59:05 +0100 Message-Id: <20221105185911.1547847-3-j.neuschaefer@gmx.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221105185911.1547847-1-j.neuschaefer@gmx.net> References: <20221105185911.1547847-1-j.neuschaefer@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:Vfta1KKuPXfyTJlokrlUIHqVt+wLZz8l/XAP30d+cEfJqL6A2LA g5LjfJosVcXeoCtrvPlJNvI6ZX5ynJxH721gUnKyGVOj9SLpUA29/I2PBZtdDVOB+d6EqT2 Dh6Q2yAtBCAYQK1V7mhtYOqApao/igkZ0ZQvTwRlIP8pwqLrQKJpVLYaZ/fzXTl17AwqWjx bR+w2fkM/sYjgaVQBMYHw== UI-OutboundReport: notjunk:1;M01:P0:n3cR5LUqolI=;cP+fOJOaOTtw9hjNLch1t/06EwK N+vvEtSrqWPHeYoWb6HLd+ym+5ej+kC0F1ErWt8n+MfZU3Xs8uP1kuhkMllSbQyTmEXLC7WIL SFdwcTVxNV4oAbP9q/GUqnedEiLtEpH+rTsm9XYG+9QMkLt6GjXh/4k0dHvgxI8XqIDwRaaUM Nln9YkmS4awqNp4Eq5ZKIQSh5nwLWf/q5ecC+rIe6S9ztCMUuZOJxTtWUj2ZKBf8GwfL5W3rd Ni5Vu5vU3NbID+p83WYl/HT2tYHQhu5Ktsmuw8nIuF2YLq9sGt9yqy1NL+V+jwxFnemoqnKm0 tAM+Sp6GXELpvq/Gw8azuUNZhkvg6wd9Ow2sMkIX4M5ovoSX4zMUb6Xa4knAr4qNAIX6NTmk8 gO7Hls5ZE8hvkxmOXdOX/bblzEv/Ln81ClPvOr9g7XGegpVSAFy6ucYqbXE2wndzbSxYfZIRU iZyh0l+K4yJdFAGlkUHaVi7+5oIBCp2TSOzG08oFVQkVRzLW45RhSniQ+8fRIrQ/nGsiwI7T4 wE3IHqoC5kIQiEkMqEWLk2vgiG+xFAzv1jnMB10JKkMuJ2YcDjTiYf8kEmMxonkv1Vb+JMYa9 GoNSL/aFidXyb3dyw53BmX0FhY+WbwUMrOxXMAzA11SND6QaJWQx6OwaYmOElCdhCyTagHj8C rIsNmb3ssRcgmZJSyIWh8w+i8VyIIXB2E2tLNAsHoPphMs6sMe+XfvspRfaFqZz64AKeaTNle JCBj9KboCuv6gq80WVNRc3jTLDOfKf+Mstx1KF+j7UgcJ8SE2hXf4SlBWg8VVURz3w7QC5zmo 6A2Bqn3ZNXPPoeqyoA5LSd8YotnUU9ixrjdHXejGoqEDV6alcWbB2WxXWaix2f5ByAfGHZbKN QyYUnlB2DqFsQXiMNJlF8tvNV1iQ326GUUEZWlGfbu4GW8DVU9WRdf4c+LBbFBhJE7mZvZBR5 wD5J/CG787cp2GsgKDZbeo7U+UQ= Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org SCS3SEL and KBCCSEL use inverted logic: Whereas in other fields 0 selects the GPIO function and 1 selects the special function, in these two fields, 0 selects the special function and 1 selects the GPIO function. Adjust the code to handle this quirk. Signed-off-by: Jonathan Neuschäfer --- drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) -- 2.35.1 diff --git a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c index 49b2177af17b2..2d1c1652cfd9d 100644 --- a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c +++ b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c @@ -628,6 +628,9 @@ struct wpcm450_pincfg { int fn1, reg1, bit1; }; +/* Add this value to bit0 or bit1 to indicate that the MFSEL bit is inverted */ +#define INV BIT(5) + static const struct wpcm450_pincfg pincfg[] = { /* PIN FUNCTION 1 FUNCTION 2 */ WPCM450_PINCFG(0, none, NONE, 0, none, NONE, 0), @@ -665,7 +668,7 @@ static const struct wpcm450_pincfg pincfg[] = { WPCM450_PINCFG(32, scs1, MFSEL1, 3, none, NONE, 0), WPCM450_PINCFG(33, scs2, MFSEL1, 4, none, NONE, 0), - WPCM450_PINCFG(34, scs3, MFSEL1, 5, none, NONE, 0), + WPCM450_PINCFG(34, scs3, MFSEL1, 5 | INV, none, NONE, 0), WPCM450_PINCFG(35, xcs1, MFSEL1, 29, none, NONE, 0), WPCM450_PINCFG(36, xcs2, MFSEL1, 28, none, NONE, 0), WPCM450_PINCFG(37, none, NONE, 0, none, NONE, 0), /* DVO */ @@ -725,8 +728,8 @@ static const struct wpcm450_pincfg pincfg[] = { WPCM450_PINCFG(90, r2err, MFSEL1, 15, none, NONE, 0), WPCM450_PINCFG(91, r2md, MFSEL1, 16, none, NONE, 0), WPCM450_PINCFG(92, r2md, MFSEL1, 16, none, NONE, 0), - WPCM450_PINCFG(93, kbcc, MFSEL1, 17, none, NONE, 0), - WPCM450_PINCFG(94, kbcc, MFSEL1, 17, none, NONE, 0), + WPCM450_PINCFG(93, kbcc, MFSEL1, 17 | INV, none, NONE, 0), + WPCM450_PINCFG(94, kbcc, MFSEL1, 17 | INV, none, NONE, 0), WPCM450_PINCFG(95, none, NONE, 0, none, NONE, 0), WPCM450_PINCFG(96, none, NONE, 0, none, NONE, 0), @@ -805,6 +808,11 @@ static void wpcm450_update_mfsel(struct regmap *gcr_regmap, int reg, int bit, in { bool value = (fn == fn_selected); + if (bit & INV) { + value = !value; + bit &= ~INV; + } + regmap_update_bits(gcr_regmap, reg, BIT(bit), value ? BIT(bit) : 0); }