Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35432144rwd; Mon, 10 Jul 2023 07:22:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlE/ippinAwlM8+fQk4+HZg4dyJSG0GHQkxpNOcDv1vYYDEXSDxNseqTCCLlRJ8CttJmk3TV X-Received: by 2002:a17:906:1d0:b0:98f:8481:24b3 with SMTP id 16-20020a17090601d000b0098f848124b3mr14432684ejj.37.1688998976605; Mon, 10 Jul 2023 07:22:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688998976; cv=none; d=google.com; s=arc-20160816; b=tUrcpSmq4rlw8q1zqN0FR/MyeZXScbOn0zpF5cGpAuAsl0D4ATLsDIg4u2yRGAnHcb yn3D3aCUA9Cbm4Ed+2+ht9CicuogYIBhRTl/qVM+YuJDkIGnYbm7cjtx5/sx56Cyos+b 87SXUheb+eJ1hLIlZDgJtRtoAJmKtM/2xi429rfVEyoATBtmugnamGAp7xQAR96Sitkp h8xFg/VytlbXNrvERKbQa1x7A9ezGbVnxzONslMJ/VD866cxHbVAOy3ofBoZ0yLqJfQy EEsE4weOnt3e3nFy/9hJk+KCENt9p3ZX6Tghi6nXcdUCC7djz+9jZjakw5ndWqG5XNCY o1Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=65lrvutxjv1LGSMFc5GRPKY9ig7UCggBJs0eH4YUNiU=; fh=TKy3wWT8/HCYAJbJVi47XgMOE1BpQN9k4PUXVNTlLak=; b=tZbdlPjYUnwn37Cl4p7yz/fVirrpb6Ja+W2lS3+bbub/sLc8cdRplcyOoMXpH/KvCu jpa2ScAYMF5XIdCa74Zcj59lPOzCtQQ/MKr21e/emfyhHP/CysChDBJV5a0EQQVV0pN+ X8IC35gI82KcW1X2OMKoHgTxUj3UFOHkv9R6/wtWoQa/sQhSvOezQMWBQv7/owUQJs1k c8IAKwt+CCqG041clr363dlOg2j3jnNVJMHXy7LvOZeTHLaA4DxCXJPdL/47J6nlPpkb cG3H6JZnXLpWzOyG2gs49Pf7BPBTc7ggRSlyDOeIjQ5W3rjYYtc5DQe1Cu4kugjSllDA L+Tg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s6-20020a170906454600b00987a0569370si8764729ejq.703.2023.07.10.07.22.32; Mon, 10 Jul 2023 07:22:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233085AbjGJOOZ convert rfc822-to-8bit (ORCPT + 99 others); Mon, 10 Jul 2023 10:14:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233024AbjGJOOX (ORCPT ); Mon, 10 Jul 2023 10:14:23 -0400 Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A56D9DF; Mon, 10 Jul 2023 07:14:22 -0700 (PDT) Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-579ef51428eso58731147b3.2; Mon, 10 Jul 2023 07:14:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688998462; x=1691590462; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F1SoVYt/eXkCUju2ZrXSBXhCNBA/PkoSDQudNUVgxBk=; b=c1z2zbn3OBnf/1vczT/XxCqWvTdV6D1lr+28xgEtUglq/HWORcK3Ay5Glgz3kZmc7u AMZhwSFZDTwA5ffhDrq/wTSkKnQBM2mjdhGzKoqFeCWgWBmnoxgTt8s2fB6cwUHfeEMM q7RREyFthliodB429vnFOFQQdCGNEr8MlFColV9u6Flj1oXAigJ1YCNBR1Ct7n5iyEvs 2zFZsf39owNxjQnFUui12hapvNKI+ssX1h9tXwnu3RCwJFGxBfNmwYnAdJSFvlbFf3t6 KcOs7vR+S2K///gCf9KNJKFCVfo91tUePGm+BhobVzoomoO6IENn/kntdHCMrs2579Xi B72A== X-Gm-Message-State: ABy/qLZVvHZXedcftpeeIb3nf9ArFNJs9k98/rngljj79Oz+8smn9WlJ pxns3OJwblka1s16/OVBGlL1rxCUVxLnTA== X-Received: by 2002:a0d:e884:0:b0:56f:ff55:2b7d with SMTP id r126-20020a0de884000000b0056fff552b7dmr15566918ywe.17.1688998461736; Mon, 10 Jul 2023 07:14:21 -0700 (PDT) Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com. [209.85.128.173]) by smtp.gmail.com with ESMTPSA id p135-20020a0de68d000000b005707d7686ddsm3078088ywe.76.2023.07.10.07.14.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 Jul 2023 07:14:21 -0700 (PDT) Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-57a6df91b1eso27582177b3.1; Mon, 10 Jul 2023 07:14:21 -0700 (PDT) X-Received: by 2002:a25:68ca:0:b0:c85:a84:d87e with SMTP id d193-20020a2568ca000000b00c850a84d87emr2850225ybc.10.1688998461286; Mon, 10 Jul 2023 07:14:21 -0700 (PDT) MIME-Version: 1.0 References: <20230630120433.49529-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20230630120433.49529-2-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: From: Geert Uytterhoeven Date: Mon, 10 Jul 2023 16:14:10 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 1/4] pinctrl: renesas: rzg2l: Include pinmap in RZG2L_GPIO_PORT_PACK() macro To: Biju Das Cc: "Lad, Prabhakar" , Magnus Damm , Rob Herring , Krzysztof Kozlowski , Linus Walleij , "linux-renesas-soc@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "linux-gpio@vger.kernel.org" , Prabhakar Mahadev Lad Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Biju, On Mon, Jul 3, 2023 at 4:13 PM Biju Das wrote: > > -----Original Message----- > > From: Lad, Prabhakar > > Sent: Monday, July 3, 2023 1:43 PM > > To: Biju Das > > Cc: Geert Uytterhoeven ; Magnus Damm > > ; Rob Herring ; Krzysztof > > Kozlowski ; Linus Walleij > > ; linux-renesas-soc@vger.kernel.org; > > devicetree@vger.kernel.org; linux-riscv@lists.infradead.org; linux- > > kernel@vger.kernel.org; linux-gpio@vger.kernel.org; Prabhakar Mahadev > > Lad > > Subject: Re: [RFC PATCH 1/4] pinctrl: renesas: rzg2l: Include pinmap in > > RZG2L_GPIO_PORT_PACK() macro > > > > On Mon, Jul 3, 2023 at 12:42 PM Biju Das > > wrote: > > > > -----Original Message----- > > > > From: Prabhakar > > > > Sent: Friday, June 30, 2023 1:05 PM > > > > To: Geert Uytterhoeven ; Magnus Damm > > > > > > > > Cc: Rob Herring ; Krzysztof Kozlowski > > > > ; Linus Walleij > > > > ; linux-renesas-soc@vger.kernel.org; > > > > devicetree@vger.kernel.org; linux-riscv@lists.infradead.org; linux- > > > > kernel@vger.kernel.org; linux-gpio@vger.kernel.org; Biju Das > > > > ; Prabhakar > > > > ; Prabhakar Mahadev Lad > > > > > > > > Subject: [RFC PATCH 1/4] pinctrl: renesas: rzg2l: Include pinmap in > > > > RZG2L_GPIO_PORT_PACK() macro > > > > > > > > From: Lad Prabhakar > > > > > > > > Currently we assume all the port pins are sequential ie always PX_0 > > > > to PX_n (n=1..7) exist, but on RZ/Five SoC we have additional pins > > > > P19_1 to > > > > P28_5 which have holes in them, for example only one pin on port19 > > > > is available and that is P19_1 and not P19_0. > > > > > > > > So to handle such cases include pinmap for each port which would > > > > indicate the pin availability on each port. With this we also get > > > > additional pin validation, for example on the RZ/G2L SOC P0 has two > > > > pins > > > > P0_1 and P0_0 but with DT/SYSFS could use the P0_2-P0_7. > > > > > > > > While at it, update rzg2l_validate_gpio_pin() to use the port pinmap > > > > to validate the gpio pin. > > > > > > > > Signed-off-by: Lad Prabhakar > > > > > > > > --- > > > > drivers/pinctrl/renesas/pinctrl-rzg2l.c | 167 > > > > ++++++++++++------------ > > > > 1 file changed, 86 insertions(+), 81 deletions(-) > > > > > > > > diff --git a/drivers/pinctrl/renesas/pinctrl-rzg2l.c > > > > b/drivers/pinctrl/renesas/pinctrl-rzg2l.c > > > > index 9511d920565e..a0c2e585e765 100644 > > > > --- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c > > > > +++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c > > > > @@ -67,10 +67,12 @@ > > > > PIN_CFG_FILCLKSEL) > > > > > > > > /* > > > > - * n indicates number of pins in the port, a is the register index > > > > - * and f is pin configuration capabilities supported. > > > > + * m indicates the bitmap of supported pins, n indicates number > > > > + * of pins in the port, a is the register index and f is pin > > > > + * configuration capabilities supported. > > > > */ > > > > -#define RZG2L_GPIO_PORT_PACK(n, a, f) (((n) << 28) | ((a) << > > 20) | > > > > (f)) > > > > +#define RZG2L_GPIO_PORT_PACK(m, n, a, f) ((UL(m) << 32) | > > (UL(n) << 28) > > > > | ((a) << 20) | (f)) > > > > > > I guess, you can still achieve RZG2L_GPIO_PORT_PACK(n, a, f) with > > > ((UL(PINMAP(n)) << 32) | (UL(n) << 28) | ((a) << 20) | (f)) > > > > > > #define PINMAP(n) GENMASK(n,0) ?? Then you don't need to modify > > rzg2l_gpio_configs. > > > > > Good point, but this would work if port pins didn't have any holes. > > For example on RZ/Five port P19 we have P19_1 pin only and P19_0 is not > > available (and similarly for port P25 we have P25_1). > > Maybe introduce a helper macro to address this case. > > #define RZG2L_GPIO_PORT_PACK_WITH_HOLES(m, n, a, f) for these 2 cases "sparse" is the terse term. #define RZG2L_GPIO_PORT_PACK_SPARSE(m, a, f) as "n" can be derived from "m" > and use RZG2L_GPIO_PORT_PACK(n, a, f) for the one without holes. Exactly. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds