Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp56572pxb; Fri, 29 Oct 2021 05:47:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNzgtGGsUzvmKjpnOoRaLEzOYiMnVRCputv7Arp6PrOew9i+Z6+YrTzuNiKeycXXPn3QlS X-Received: by 2002:a05:6402:50c7:: with SMTP id h7mr14954757edb.191.1635511658545; Fri, 29 Oct 2021 05:47:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635511658; cv=none; d=google.com; s=arc-20160816; b=NnQRuv1thEPVYh8//+VTrad05qKFWEadb6F+bLc2YovOHyZc6OtpMdbSsuSklpWjqA 5xLcxF7fB1g3pZBQO2WLYwCS3WKHddvJ3sAniu6U5PxIfIdC6d1AnfZTLSUYWqp/M8/V Nfh1RpnHjBymA4bQrAdhUMntOHF6qQicwYsDV1cGNuvM5xaUmvk+bFhE1Bbr1wDQyEGY 8mdclagMDfqM4h5a5oGreEln9GG3ge7JX2XaHzTz1HrDe9urpOM4xT8RlDQBOPqZMbU4 v49cAhyexbtI6XjjMc0IHyQ5vQYraPTgTbm7Dma2YX2SmtARVePxv7s73RNoY2lSqzZ/ jNlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=use5DQdjY6K9MBQ0xGMqdxa9v8WiifWRW96cV6Z/Iec=; b=OpARVcnwJnAs9CjfufWENeNfVrRUK+4zpyMQPuviIPkgZJOZ7Mzh8iiHii8HFFDCwf vaqJh1YUSIejxfhrt9E4/UQeHyw5wjliOt2Oog+EnRMyJSCLAKoOanTicsG8XRzFYHjN 8PEFSxyYg+8Q1Te0VA1knp0g4LSU0dMFrbbQcf+c5XC+n/0Q0FRw386RBoXw8kDgqX5t Xu8+1VinCb3k0VlpGuHXANOA9ogO87wukGlzPrHW9xoUvUR5wQ/9IOs2zT/6PFN4pt2T kwNGqvMZHJmd3VmdYTS8BkdGlD2wPiiX6l+E6WqbGK6dpH5BLEydOyCa764VXqNpXpp9 ceHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a18si7864675edx.592.2021.10.29.05.47.14; Fri, 29 Oct 2021 05:47:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231761AbhJ2MrY (ORCPT + 99 others); Fri, 29 Oct 2021 08:47:24 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:14605 "EHLO relmlie6.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231695AbhJ2MrU (ORCPT ); Fri, 29 Oct 2021 08:47:20 -0400 X-IronPort-AV: E=Sophos;i="5.87,192,1631545200"; d="scan'208";a="98894441" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 29 Oct 2021 21:44:51 +0900 Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 5FC39438EE72; Fri, 29 Oct 2021 21:44:49 +0900 (JST) From: Lad Prabhakar To: Geert Uytterhoeven , Linus Walleij , Rob Herring , linux-gpio@vger.kernel.org, devicetree@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das , Lad Prabhakar Subject: [PATCH v2 3/5] pinctrl: renesas: pinctrl-rzg2l: Add support to get/set pin config for GPIO port pins Date: Fri, 29 Oct 2021 13:44:35 +0100 Message-Id: <20211029124437.20721-4-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211029124437.20721-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20211029124437.20721-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support to get/set pin config for GPIO port pins. Signed-off-by: Lad Prabhakar Reviewed-by: Biju Das --- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/pinctrl/renesas/pinctrl-rzg2l.c b/drivers/pinctrl/renesas/pinctrl-rzg2l.c index f294ae7b8b5a..bc34c63bbb36 100644 --- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c +++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c @@ -426,6 +426,23 @@ static int rzg2l_dt_node_to_map(struct pinctrl_dev *pctldev, return ret; } +static int rzg2l_validate_gpio_pin(struct rzg2l_pinctrl *pctrl, + u32 cfg, u32 port, u8 bit) +{ + u8 pincount = RZG2L_GPIO_PORT_GET_PINCNT(cfg); + u32 port_index = RZG2L_GPIO_PORT_GET_INDEX(cfg); + u32 data; + + if (bit >= pincount || port >= pctrl->data->n_port_pins) + return -EINVAL; + + data = pctrl->data->port_pin_configs[port]; + if (port_index != RZG2L_GPIO_PORT_GET_INDEX(data)) + return -EINVAL; + + return 0; +} + static u32 rzg2l_read_pin_config(struct rzg2l_pinctrl *pctrl, bool port_pin, u32 offset, u8 bit, u32 mask) { @@ -495,6 +512,14 @@ static int rzg2l_pinctrl_pinconf_get(struct pinctrl_dev *pctldev, port = RZG2L_SINGLE_PIN_GET_PORT(*pin_data); cfg = RZG2L_SINGLE_PIN_GET_CFGS(*pin_data); bit = RZG2L_SINGLE_PIN_GET_BIT(*pin_data); + } else { + cfg = RZG2L_GPIO_PORT_GET_CFGS(*pin_data); + port = RZG2L_PIN_ID_TO_PORT(_pin); + bit = RZG2L_PIN_ID_TO_PIN(_pin); + port_pin = true; + + if (rzg2l_validate_gpio_pin(pctrl, *pin_data, port, bit)) + return -EINVAL; } switch (param) { @@ -557,6 +582,14 @@ static int rzg2l_pinctrl_pinconf_set(struct pinctrl_dev *pctldev, port = RZG2L_SINGLE_PIN_GET_PORT(*pin_data); cfg = RZG2L_SINGLE_PIN_GET_CFGS(*pin_data); bit = RZG2L_SINGLE_PIN_GET_BIT(*pin_data); + } else { + cfg = RZG2L_GPIO_PORT_GET_CFGS(*pin_data); + port = RZG2L_PIN_ID_TO_PORT(_pin); + bit = RZG2L_PIN_ID_TO_PIN(_pin); + port_pin = true; + + if (rzg2l_validate_gpio_pin(pctrl, *pin_data, port, bit)) + return -EINVAL; } for (i = 0; i < num_configs; i++) { -- 2.17.1