Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp963593rdb; Wed, 6 Dec 2023 05:13:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IHEv5iJ3Ow+AMTbunr0kFm9Q/OMW9sOiEdQqtgmc8o3IVncrwk1bNzrwNvkJfjiEcGDpl2b X-Received: by 2002:a05:6a20:4424:b0:18c:111e:bd7b with SMTP id ce36-20020a056a20442400b0018c111ebd7bmr1318292pzb.20.1701868422844; Wed, 06 Dec 2023 05:13:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701868422; cv=none; d=google.com; s=arc-20160816; b=aE9XRtSPcK3ZOTna2rSrhYJgT81UA62tdrM/glyU7sSrzeb/TIXwpb9YPP8CS7ggbv cIj93vXTBOX3l0pt5Hx4Tx2rDOZChXHOmFQEBkY2uoEC9AFkhc0MqLgMss6hLIGVZ5hL ZJWVYQ7MCaYBq7fSGMCrz2bi+3ClkGN5aCE7F+iihDofGA7cFybih/YczRVyZVVq7qAa u4HvH4Yjzf/ywb+6CBM4ZOBqF8bxsw/P6THN0y/Bn6BTXkzlosIqcXWfxl82Ngw843pr 8Mr3BzH2A8EDvWeXDNslolm6T65TxD5MWN7OTriiItIa39EXErvoDO3YEAU95e+2DWLV wReQ== 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=KKDjZklvS4+KTRVL+77Pcm+uRsOktISe/SHH68IUgoI=; fh=NuMIl5JYnFtDs4JUW+lYUL0RScygYS1RsnN9Jb908TY=; b=rF9qAVp7HB/+BKg29CGRXRexK2mkXXbOVsDoeXCxQULhB78H3DiD9U+3A3VJL7XfDM PYJEtZUUrWQSInHQ11Yh2TTL4GObSw/O7tLLXJAbUKZxZ9gshDDKVy5cB97ynZsGCMtp 8xThqB6lBAQuc6u187vr3qw5szlcvAcVg8Nh9U4mbekStjyToQPfKbtIEUDn3ls7H6xL UH+B5IyiEECDqxv3OWvOYbHgsHYmfQUe4idFnSeIsqMn5llb1G2KSpcn8mXEjgDku0Gt Ek1X2cWd72iOSEaWHpHXj5rQzQW2IV9ueABeWdRB9bKvEhZSLOXdKUMbIdsWCMRo6CLO nRuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id k37-20020a63ff25000000b005ad8009e304si11626700pgi.784.2023.12.06.05.13.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 05:13:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 97EE4802A6DC; Wed, 6 Dec 2023 05:13:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378432AbjLFNNU convert rfc822-to-8bit (ORCPT + 99 others); Wed, 6 Dec 2023 08:13:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378416AbjLFNNT (ORCPT ); Wed, 6 Dec 2023 08:13:19 -0500 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 725C0122; Wed, 6 Dec 2023 05:13:25 -0800 (PST) Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-5d400779f16so7643657b3.0; Wed, 06 Dec 2023 05:13:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701868404; x=1702473204; 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=QpA0ectE+0fOxvKG7PAumxgR/vsxQ2Vp0KirOSeTgT4=; b=VCg5QEuSkjpVPQ9S5NNQB0Yi+fFG8AY8/prZKKKHayfYBf/vXR9n3hFzhemy8BaVx8 Lr/mg+CQwx/EGwv6PetCU/x/gHNWCZgmBOeI6WfdD3RuGRbEg1zWLeqmsjzZJyVsN1fr nC7ASNLRS+SXcb3pfpTTk6bHw4+HfgOwpRhDFKinQtMMhiD+We3nnUA4Z5j/CKuzqmf7 aC2rkmcsFaklxlyAtneTAERj68O/9Zljb+Dg72izWkOvI0aebWs5z8fAb44Sy5hJzz6i it+Xt+4ZEQIJF+At2iZMYVnqmyz4HsjFSBfg3hZqtinBk7K6A13T63jW0BV0TYPi7CM5 RBcQ== X-Gm-Message-State: AOJu0Yx/0qeqIlrLiQnuUXXJ0L99uvDRDX26nj1+fWEyzNKdDiN6C6ar jpCOB6mSRb8QKITx32H89EvJ173NlOso6Q== X-Received: by 2002:a81:b646:0:b0:5cd:ef57:ce3a with SMTP id h6-20020a81b646000000b005cdef57ce3amr506826ywk.0.1701868404480; Wed, 06 Dec 2023 05:13:24 -0800 (PST) Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com. [209.85.219.181]) by smtp.gmail.com with ESMTPSA id p67-20020a819846000000b005d379110c89sm4792304ywg.8.2023.12.06.05.13.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Dec 2023 05:13:22 -0800 (PST) Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-db548da6e3bso762757276.0; Wed, 06 Dec 2023 05:13:22 -0800 (PST) X-Received: by 2002:a25:d289:0:b0:db3:523f:2351 with SMTP id j131-20020a25d289000000b00db3523f2351mr2026647ybg.10.1701868402141; Wed, 06 Dec 2023 05:13:22 -0800 (PST) MIME-Version: 1.0 References: <20231201131551.201503-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20231201131551.201503-2-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: <20231201131551.201503-2-prabhakar.mahadev-lad.rj@bp.renesas.com> From: Geert Uytterhoeven Date: Wed, 6 Dec 2023 14:13:10 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 1/3] pinctrl: renesas: rzg2l: Include pinmap in RZG2L_GPIO_PORT_PACK() macro To: Prabhakar Cc: Magnus Damm , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Paul Walmsley , Palmer Dabbelt , Albert Ou , Linus Walleij , linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-gpio@vger.kernel.org, Biju Das , Lad Prabhakar 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 06 Dec 2023 05:13:29 -0800 (PST) Hi Prabhakar, On Fri, Dec 1, 2023 at 2:16 PM Prabhakar wrote: > 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. As the pincount can be calculated based on pinmap drop this > from RZG2L_GPIO_PORT_PACK() macro and update RZG2L_GPIO_PORT_GET_PINCNT() > macro. > > Previously we had a max of 7 pins on each port but on RZ/Five Port-20 > has 8 pins, so move the single pin configuration to BIT(63). > > Signed-off-by: Lad Prabhakar Thanks for your patch! > --- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c > +++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c > @@ -80,15 +80,17 @@ > * 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_GET_PINCNT(x) (((x) & GENMASK(30, 28)) >> 28) > +#define RZG2L_GPIO_PORT_PACK(n, a, f) (((n) > 0 ? ((u64)(GENMASK_ULL(((n) - 1 + 28), 28))) : 0) | \ The mask creation can be simplified to ((1ULL << (n)) - 1) << 28 but see below... > + ((a) << 20) | (f)) > +#define RZG2L_GPIO_PORT_GET_PINMAP(x) (((x) & GENMASK_ULL(35, 28)) >> 28) > +#define RZG2L_GPIO_PORT_GET_PINCNT(x) (hweight8(RZG2L_GPIO_PORT_GET_PINMAP((x)))) I think we've reached the point where it would be easier for the casual reviewer to #define PIN_CFG_*_MASK for all fields, and use FIELD_{PREP,GET}() to pack resp. extract values. That would also make it more obvious which bits are in use, and how many bits are still available for future use. > > /* > - * BIT(31) indicates dedicated pin, p is the register index while > + * BIT(63) indicates dedicated pin, p is the register index while > * referencing to SR/IEN/IOLH/FILxx registers, b is the register bits > * (b * 8) and f is the pin configuration capabilities supported. > */ > -#define RZG2L_SINGLE_PIN BIT(31) > +#define RZG2L_SINGLE_PIN BIT_ULL(63) > #define RZG2L_SINGLE_PIN_PACK(p, b, f) (RZG2L_SINGLE_PIN | \ > ((p) << 24) | ((b) << 20) | (f)) > #define RZG2L_SINGLE_PIN_GET_BIT(x) (((x) & GENMASK(22, 20)) >> 20) Likewise. > @@ -180,12 +182,12 @@ struct rzg2l_hwcfg { > > struct rzg2l_dedicated_configs { > const char *name; > - u32 config; > + u64 config; > }; The rest LGTM. It's a pity we have to switch to 64 bits, but I'm afraid there is not much we can do about that... 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