Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp27366877rwd; Tue, 4 Jul 2023 01:49:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5dlMp+dXOPUUJD7Jof6uAOCic2N9wxdOCMkzECz5+nzVH4ToZABXMRpK6aieJ3Q0bmfRaQ X-Received: by 2002:a9d:69c5:0:b0:6b7:4b0e:6d48 with SMTP id v5-20020a9d69c5000000b006b74b0e6d48mr11573500oto.24.1688460577035; Tue, 04 Jul 2023 01:49:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688460577; cv=none; d=google.com; s=arc-20160816; b=Hl8OzJHCL9ntvw2SOGTzgV9LOL6L25CUB/ksDiv+MM5FU5tVgx9TU5knxmeYTxhhuX UF3j6I9sHPP5WHcc/uKu/O5YRa5ETk9Vk4IAM5aUJoqFE2ttMMGHjVKTT11X258OYYco +0N8a4xOq2OByd1gLgTP5IPLyNTOPyEmYoNq80EelYx0v5KFGQlrLXuIFiJNZr+t6Lbz Q/P6YuPfVel1fRVS3vUmxBJ1eliVJ4tisTg6Pc+Am61PEVyWWY6MMszlxkDu5MW2w25i HQkag53vEEP9Eo1X//y9geGJlGZiyApg4M2jGQpJEH2vK6/TfCSmxQiyrNejbUJrcDOn hMMA== 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 :dkim-signature; bh=VDbe9ViOonNjf+BBw3JuRqHmgJYIIlBwInsX6f0IRLM=; fh=Lfb1xLtDS7GmnVb/I4ejrQfEYVIhLJCzWJ3AYTR+mRg=; b=TiGzQLZKGFxjy1zDYsow7tFRH3R9AtcULwK5+gwnwngTqxb/ozIXZ218UUj5ZFwupa ENj/vZdSRWDQPzW819wQVDcmGudlD6PJkZ4SwxDMKFJXYZQpVHi80+qA/PWdEu8VA0IJ pF4WqWJUZKoMSURgHn6BJZK2JatQErmFHDPuzf3jfkF+nfKPJGVofKKNHSV8zt1P27nt ggDZFYGBq2jZGij8aaJysYGFtRSNMDhgVquyccCmcDsp4+pUDjo+4VynhlQec+ZjZfnL VOprgf4R+yseh76RnFTThA7yPKBzO1YXGKcqAJx7TluYWjgDLIMXT2kaRcee62EbnjBH GRHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=TQLyOlk0; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t62-20020a638141000000b005481915c0cfsi20067305pgd.1.2023.07.04.01.49.24; Tue, 04 Jul 2023 01:49:36 -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; dkim=pass header.i=@gmail.com header.s=20221208 header.b=TQLyOlk0; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231695AbjGDIg2 (ORCPT + 99 others); Tue, 4 Jul 2023 04:36:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231679AbjGDIgG (ORCPT ); Tue, 4 Jul 2023 04:36:06 -0400 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EF44E62; Tue, 4 Jul 2023 01:36:05 -0700 (PDT) Received: by mail-io1-xd33.google.com with SMTP id ca18e2360f4ac-7866189cff1so162631639f.0; Tue, 04 Jul 2023 01:36:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688459764; x=1691051764; 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=VDbe9ViOonNjf+BBw3JuRqHmgJYIIlBwInsX6f0IRLM=; b=TQLyOlk0eahcefxNZxdEkYY4uoaj3wt4Qz+GBpYpx7x3IdFzZCLTbG9qi/rgajUFE1 VOE3tHXIgM7MDq1HkgQNVl1ATHv8v5ybVbYlgVRcWzDpzp9YMFLf2e9rcPgkTHbfPaEE jG5pvryseieVu7Xh9BeTzC/WOO7QZX1fZW0cenBpiA9nFcgzDpWWFEa6Jy/hjW0PmRh3 NpVCJo+lH5PFzZ35VhHXODIKwPh5vipGjWDrnCcNF6YhFdfXV3sefUGOyFJV35d8n7vx NRzg891eJ1pskGFhdhqeqJIeRR4DSoMykSz3NhZLnGckrmZdWMNuX79VIHlkAV1+9hW1 Sk5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688459764; x=1691051764; 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=VDbe9ViOonNjf+BBw3JuRqHmgJYIIlBwInsX6f0IRLM=; b=BKgIdPFFx/1JTYy/5Djl0EFAhx6s4fE44B7HdZeajcuM2Cp8Vcu/EzVArvcQ711jfP 3hj+FYvCI3kosjhaXYkXPDdawyIPIEHKHBpFfnSkpIg68WAt+2AXoV5gZfrVUDkS9xWW I1AeL0gM0Mi4Qvdxh5RzydNxCwukkoKwk5ZJ9Rmf0Z3RF2X4FMbjkIOG6/fRlw+NPY3K 8oCr2KrwZH/F7RnuIrGR0DYhoc4ApW8XDf2rvV2DyqU6qMQddqZjkHNGVvbKLyd654H1 Ym6WMu6ud3LoNYgnSUiantxXnvczUXE+7at+bmAQs4+V0I9cGu5QOi49eBzd4QxuHj1E GlAA== X-Gm-Message-State: ABy/qLYk2FXttr1DZpG9fqvZQyKPHlK0plHoa2aNuy5iu7qL2b9cBtSU l22cWa6ijua9qDgEAURb3rlQvoCaI8RAfv0F7qE= X-Received: by 2002:a6b:6f10:0:b0:786:7389:51d7 with SMTP id k16-20020a6b6f10000000b00786738951d7mr7180271ioc.5.1688459764550; Tue, 04 Jul 2023 01:36:04 -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: "Lad, Prabhakar" Date: Tue, 4 Jul 2023 09:35:38 +0100 Message-ID: Subject: Re: [RFC PATCH 1/4] pinctrl: renesas: rzg2l: Include pinmap in RZG2L_GPIO_PORT_PACK() macro 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Tue, Jul 4, 2023 at 9:30=E2=80=AFAM Biju Das wrote: > > Hi Prabhakar, > > > -----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=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. With this we also get > > additional pin validation, for example on the RZ/G2L SOC P0 has two pin= s > > 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)) > > +#define RZG2L_GPIO_PORT_GET_PINMAP(x) (((x) & GENMASK(39, 32)) = >> 32) > > #define RZG2L_GPIO_PORT_GET_PINCNT(x) (((x) & GENMASK(30, 28)) = >> 28) > > #define RZG2L_GPIO_PORT_GET_INDEX(x) (((x) & GENMASK(26, 20)) >> 20) > > #define RZG2L_GPIO_PORT_GET_CFGS(x) ((x) & GENMASK(19, 0)) > > @@ -129,7 +131,7 @@ struct rzg2l_dedicated_configs { > > > > struct rzg2l_pinctrl_data { > > const char * const *port_pins; > > - const u32 *port_pin_configs; > > + const u64 *port_pin_configs; > > Can this be SoC specific? Only for RZ/Five you need this changes. > Others SoCs like RZ/{G2L,G2LC,V2L and G2UL) still work with u32* as there > is no holes. With this change memory usage is doubled as we change from > u32->u64. > This is to avoid writing to undocumented registers so I have added for all the SoCs. For example on the RZ/G2L SOC P0 has two pins P0_1 and P0_0 but DT/SYSFS could use the P0_2-P0_7. This patch restricts users to use only available GPIO pins. Cheers, Prabhakar