Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp417237rdb; Thu, 21 Dec 2023 13:05:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IED0kK4cP3vcopp60E4gISL4GhoVzjvuUD5FzRuXZ6ca3OQGf2OAYx7FZliyOoEa66MMYki X-Received: by 2002:a17:902:ec81:b0:1d0:b693:ae15 with SMTP id x1-20020a170902ec8100b001d0b693ae15mr326804plg.43.1703192703713; Thu, 21 Dec 2023 13:05:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703192703; cv=none; d=google.com; s=arc-20160816; b=fSaZHUaE5LRYjXJndY+GgJ1eSeMPJuayiULTc9CWbWPjxteJwxn9JO6Sqz4q+gF9MG /XdlJCMTAKdLqWcbyjXjajMWhh2srcjoUhLSW76orfvNryS5W8kBep8oUAbsAzV9EY4e UxaVx5H6676TfCXiUrTl1s4GPjW/uFtTkr72YLSYgq9bHx1zpd+0ueSfzfNN1BmY8yMZ FF1pVkw82yAua5CSknUeSKELkUh/v3T5NV+f1M+Uh7ImKtTYQ8diubix41x66U1vDmda Ety9GmLa5Kqg1/xHp6LCiWERAJ4WrKscJ+6HEkbxRzzFRuAGvpDrwF4PlLS/ICJjm6uQ 5/wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=a3iK+XCFKHi89cS9qJf066rKv09q1lojAXsmMshz01Y=; fh=0WgGgTkT9PEbgUxul6kkm0x3MN1t+62wt6LteXOg5vA=; b=X431W/qSG7rDzMo0TqPkgUi7AvKeFMijEL8UwzktnVVox/M+WBNfQ/57sTFImBW5Ca kDWV4ff2uo6Utovvjb6f0eoNIJJ8at/mVw/0W8OoGyJOi1+KpqSFe2vf1P77Gnq+3TX9 KCKFY3PVq5H9H4GhKcXdT0zXS5vYV2LhX9RjvcJ0oBNXZ8YdVRKCOMVlYu7pXczYIICj WL+Po0U6EVRfdKHvsOm5v0GcKDcMUfBnNuF7zfi1yJEfieJUThPR57C1NEEDtXW8M9za ksIlEqPYTWbm7+KpvXxpwvVb8ekIMYubMhVTaGJ3n//HY77mp6/xnE1jwEFj93IKmCIl Vuuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Eh2YgSCb; spf=pass (google.com: domain of linux-kernel+bounces-9071-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9071-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c6-20020a170902c1c600b001d351aad192si2026428plc.598.2023.12.21.13.05.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 13:05:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9071-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Eh2YgSCb; spf=pass (google.com: domain of linux-kernel+bounces-9071-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9071-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CE7A1288978 for ; Thu, 21 Dec 2023 21:05:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1B8676DAE; Thu, 21 Dec 2023 21:04:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Eh2YgSCb" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A2347690B; Thu, 21 Dec 2023 21:04:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-3b9f8c9307dso1006523b6e.0; Thu, 21 Dec 2023 13:04:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703192692; x=1703797492; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=a3iK+XCFKHi89cS9qJf066rKv09q1lojAXsmMshz01Y=; b=Eh2YgSCbF9rWIrYAmUeVg1hMg7FRx7oW5XWCD0ynvWxsy7INwMHK6w2fwxmJGXjImA 849zrLUY3Tit8+sV714A6aVZPyehOvRLUu+tvlUik0aUkQWUb54SD4/auYdwIASJM9gM ikwjAYNsN1+HiMB/wIcm0QM9z363h6avn/P/pfN9jzWkCuMRIn5MviC1rF+L2TheDTkG TdLSou6CqJ+nAO5hUwn+O2yxbS6sC1CMaenO928c3340ilDUSv/INRoCZqgSISfIlFDi 5EJ7gjb3hqnCGSsNaHBOxo1shEfp4bnXKTdvTBZqtqUpmWQUPYY8KMr7RFbPe/dWlIAv Jbbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703192692; x=1703797492; 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=a3iK+XCFKHi89cS9qJf066rKv09q1lojAXsmMshz01Y=; b=KsSbpvPjDknVL58zlK+XFHZL88Tlu4zLjIIt/iiRz46v9n/R1948bGvws3FtCh3scJ mkz+/stt535GRm1L5E4xZ00kjRR5MfYGNXoboRp9itLSPBh1UoeLlZ7OKuU/RB7hQsrO R+NMfM8YFPBFhpWzcOpVchlVX5Qsls9loYSTTiuRgYQqkhrRg5x1FsRfabmbJOJegvy8 cslvgxCcePpzJQ5lbIEhH062dqKlNbMSDdoCEGogT/7zrJq+/b4DLxFS/WBZFhbHft1x 95+izei1yyFBQFhN+npnhb8gS5RDutvDcbHpohz8vXjAV1ZAul+Trmnwce7hLU3CFuSc t48g== X-Gm-Message-State: AOJu0YzPHFahowdLNgaCscn2byWfRtNaHG7IU5hGNSQccoDKoWIZNS2C xfn5ZRE1Cb7UktuvFoo27ymKcMyRoWQlCpPIhsg= X-Received: by 2002:a05:6870:b150:b0:203:a833:237e with SMTP id a16-20020a056870b15000b00203a833237emr553136oal.9.1703192692341; Thu, 21 Dec 2023 13:04:52 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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: From: "Lad, Prabhakar" Date: Thu, 21 Dec 2023 21:04:12 +0000 Message-ID: Subject: Re: [PATCH v3 1/3] pinctrl: renesas: rzg2l: Include pinmap in RZG2L_GPIO_PORT_PACK() macro To: Geert Uytterhoeven 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: quoted-printable Hi Geert, Thank you for the review. On Wed, Dec 6, 2023 at 1:13=E2=80=AFPM Geert Uytterhoeven wrote: > > Hi Prabhakar, > > On Fri, Dec 1, 2023 at 2:16=E2=80=AFPM Prabhakar wrote: > > From: Lad Prabhakar > > > > Currently we assume all the port pins are sequential ie always PX_0 to > > PX_n (n=3D1..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 th= is > > 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 > OK. > 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_P= INMAP((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. > If I use the FIELD_PREP() macro like below I get build issues as below: #define RZG2L_GPIO_PORT_PIN_CNT_MASK GENMASK(31, 28) #define RZG2L_GPIO_PORT_PIN_REG_MASK GENMASK(27, 20) #define RZG2L_GPIO_PORT_PIN_CFG_MASK GENMASK(19, 0) #define RZG2L_GPIO_PORT_PACK(n, a, f) FIELD_PREP(RZG2L_GPIO_PORT_PIN_CNT_MASK, n) | \ FIELD_PREP(RZG2L_GPIO_PORT_PIN_REG_MASK, a) | \ FIELD_PREP(RZG2L_GPIO_PORT_PIN_CFG_MASK, f) drivers/pinctrl/renesas/pinctrl-rzg2l.c:91:41: note: in expansion of macro 'FIELD_PREP' 91 | FIELD_PREP(RZG2L_GPIO_PORT_PIN_CFG_MASK, f) | ^~~~~~~~~~ drivers/pinctrl/renesas/pinctrl-rzg2l.c:1486:9: note: in expansion of macro 'RZG2L_GPIO_PORT_PACK' 1486 | RZG2L_GPIO_PORT_PACK(6, 0x2a, RZG3S_MPXED_PIN_FUNCS(A)), /* P18 */ | ^~~~~~~~~~~~~~~~~~~~ Do you have any pointers? Cheers, Prabhakar > > > > /* > > - * 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-m6= 8k.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