Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7792953rdb; Thu, 4 Jan 2024 07:55:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IE/FQ9WzZS+Jfk896+tmwEuDxL8lpT8P9bTESjUvi2aUr+LETH9FwrXNQetdVhZ4ZjMXo+P X-Received: by 2002:a05:620a:c06:b0:781:16b1:86b1 with SMTP id l6-20020a05620a0c0600b0078116b186b1mr744676qki.34.1704383737461; Thu, 04 Jan 2024 07:55:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704383737; cv=none; d=google.com; s=arc-20160816; b=MQLoI2Gbw/UMMt5IpT/EDKE+NSilh8Wuiy7ijl+WOGgTpS7vxHjEy37lyX/1sDtoT4 S9zIrb+ogQZpM4HkzLiKmxaWU2dj0O3o+Iq+GPV1FxquChk2tNeuQAahTbc4swGrZDqi Duh+It+bQ9RcOI/8FlbZSP4dcFhWB5M/FMPz7X5RvBAng6nB+a4znQzTXzewAxNnEWa7 MZH0pg7Y4WHSwa4uAcUgHFY7WoO5C4P5/oVtUua+49Ob6wAx5Poqa+0yWVyt0kE7dCO0 YJWRNcEHgQrANbfnbaADN9KFM9SmrvC0xmuKQqZOH5NIzQUj0WEl2x5g9L4hndti5Ek/ AFnQ== 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=UPeDIiQjNkPvl4Ik1+JkTjR4o2Soc24WzRcdY8DaVYo=; fh=0WgGgTkT9PEbgUxul6kkm0x3MN1t+62wt6LteXOg5vA=; b=KdADfmRw/Nt2oYVfBc8sf438+OSmNqKV/ILnY7/UEm7yEvDrfa76AxXUkS2SKj4ob1 dWnae8bwXlVbggguhqmN2BeHh/PLQolVGQfwgrjjRqDsPt2jNOdnMiT2JOG4+5fqsHbG Ffiwa23r6u5xb+2O1Dmg6ZnOKNW0GzrI4ql1HYksDJ7ruGL8Sf4SBRwnVlg0QoHJJVzu hwpSUU2QKJixCMRzRbTdYMcTNo4CS2kVRfzCPB5/UQo/xL9ICdjNuPbok6rtK7QLVkAY hHiM8fy3yKtv72rSOnI+YQ4EsZR4oYHDHk/R0SIl42Pai83xz+0xM4EPpyvWds0/Ke4Z Qycg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fvZjdmoW; spf=pass (google.com: domain of linux-kernel+bounces-16890-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16890-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id x17-20020a05620a449100b00781ebb79d6bsi2986850qkp.169.2024.01.04.07.55.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 07:55:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16890-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fvZjdmoW; spf=pass (google.com: domain of linux-kernel+bounces-16890-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16890-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 29EAA1C21411 for ; Thu, 4 Jan 2024 15:55:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E23924A06; Thu, 4 Jan 2024 15:55:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fvZjdmoW" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-vk1-f173.google.com (mail-vk1-f173.google.com [209.85.221.173]) (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 D8EF3249EC; Thu, 4 Jan 2024 15:55:24 +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-vk1-f173.google.com with SMTP id 71dfb90a1353d-4b732dfa6e4so187303e0c.1; Thu, 04 Jan 2024 07:55:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704383723; x=1704988523; 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=UPeDIiQjNkPvl4Ik1+JkTjR4o2Soc24WzRcdY8DaVYo=; b=fvZjdmoWk6wPXVGe4F4nqa57sn02xom6y1xg+NPAKOfxSccOkMRO16bTL4JTuEmvEX xr+Gp8vIkZ68Izwg9cLZRFDwof56nQnzGHIFAYPbe7+bZD+2FrV3Eq5EEy2DYTBBv7/n +exlCiyRXPfHIX2Qnu4q8cxY1G8zxzZd97aTbwPrVE0qqGrbU5/biAn8xBQnMMQNfo0s 50rwuEMRZcTCCbwnPHDY692OPm2PBPtSb+nRzYUom9EK4+waflic7yy0DcW6HlhFb4j1 lqrtcVbGOlbpjTqhJ967GYCoVdYeVeAqZ36M6T19s0AvM9NZHuBG0LlBjAxKse3/zOTQ Mhvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704383723; x=1704988523; 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=UPeDIiQjNkPvl4Ik1+JkTjR4o2Soc24WzRcdY8DaVYo=; b=HktXfpQdbaE+58/YoWKl04lYDqYF7lrv7sEzQd0IVGV+OAe1y4qFzgQ9linNmPkzoB MECYfACkKk9qpUswnlCJnooHySOcfbAj2d5cOplfijZMEt4k4llIVxvHCtCNCPAmxrpi 0GD6BKKHW3DCUKHAtPD5eT0mr+pYsReWP9KDqQq+U5XRL9D3G7xLCtX+sOhapkk5dHmw fZOG+o0MfwQlf6XRq1/n+O4OmobY1Sbr20TjI2vxRwkRgQw6l1M0bhRkDkc1L8NQP/dk N/sF5gXLoy3HWzGyVPzqYfYEhj0mYPS6vNgsY9/vJ7dqSPyD0GxeaZcKX9Zeab2FUZXX WTvw== X-Gm-Message-State: AOJu0YyWNTyrE0DU4l7pTEe6JPs3hvYlU2flCtNFtZLFbkJUkWTN0nEh w8jOoJnwgNwPqIIvB9dQfTPsfwM/MP86vlE6MPU= X-Received: by 2002:a05:6122:12d3:b0:4b7:3d44:9b05 with SMTP id d19-20020a05612212d300b004b73d449b05mr664953vkp.4.1704383723681; Thu, 04 Jan 2024 07:55:23 -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, 4 Jan 2024 15:54:29 +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, On Tue, Jan 2, 2024 at 10:18=E2=80=AFAM Geert Uytterhoeven wrote: > > Hi Prabhakar, > > On Thu, Dec 21, 2023 at 10:04=E2=80=AFPM Lad, Prabhakar > wrote: > > On Wed, Dec 6, 2023 at 1:13=E2=80=AFPM Geert Uytterhoeven wrote: > > > 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 P= 19_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 availabil= ity > > > > on each port. As the pincount can be calculated based on pinmap dro= p this > > > > from RZG2L_GPIO_PORT_PACK() macro and update RZG2L_GPIO_PORT_GET_PI= NCNT() > > > > 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_G= ET_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. > > > > > 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? > > You left out the actual error :-( > Oops sorry. > include/linux/bitfield.h:113:9: error: braced-group within expression > allowed only inside a function > 113 | ({ > \ > | ^ > drivers/pinctrl/renesas/pinctrl-rzg2l.c:93:39: note: in expansion of > macro =E2=80=98FIELD_PREP=E2=80=99 > 93 | #define RZG2L_GPIO_PORT_PACK(n, a, f) > FIELD_PREP(RZG2L_GPIO_PORT_PIN_CNT_MASK, n) | \ > | ^~~~~~~~~~ > drivers/pinctrl/renesas/pinctrl-rzg2l.c:1555:9: note: in expansion of > macro =E2=80=98RZG2L_GPIO_PORT_PACK=E2=80=99 > 1555 | RZG2L_GPIO_PORT_PACK(2, 0x10, RZG2L_MPXED_PIN_FUNCS), > | ^~~~~~~~~~~~~~~~~~~~ > > Using FIELD_PREP_CONST() instead makes it build. > Thanks for the pointer, that did the trick. > 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. To clarify, you mean to define PIN_CFG_*_MASK for all PIN_CFG_IOLH_A..PIN_CFG_OEN macros? I ask because we dont extract the respective CFG flags in the code. Cheers, Prabhakar