Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp3127590lqt; Tue, 23 Apr 2024 11:01:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUtgRi7aszBP52Ttefo6XgHB7eBPttZVkZI+pxM39j9y3NKx9hamsiAVXaf4pFCOiSiPuraebpg9Fsc7OAiED81XfBVlQwxwRdQlEZFLg== X-Google-Smtp-Source: AGHT+IFXGcNB7U1ARXqJ19sAnFjPylRmOKxFwItT/6tJ4SPIQirQ+hCDU4JvwkBJD7+Rr9/fk0jv X-Received: by 2002:a50:8d0b:0:b0:56e:f64:aaf6 with SMTP id s11-20020a508d0b000000b0056e0f64aaf6mr91319eds.5.1713895302541; Tue, 23 Apr 2024 11:01:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713895302; cv=pass; d=google.com; s=arc-20160816; b=jcoeJhXl0UYum4kiU18oLKZ9ZO+qz5BteLXC0rB6h9CX+m5LTOgdEhJifmaEtm++ff NPmZM++tbEHSkxR3aQkBUqxWEriTMWrgL5tXRGnyTNHrVEvbvAd3W0j+E8wRspAs1Py1 rcpH35gO7VfebR3NtKH1nVplfnNE6iexp+YR0HBmAiU+IiAw8QpCJjFterecKSWILU5f LigLa1KUQFp+tizu8wch0V1znlekYgG4ZH1BjtBs7lqhfPiRRos+3/2KHZlH4j30XEn0 HCYj7ojJX8Jn75Cxq9jqlGeX+ljkQ1tWbf56aieMXtF0wnCqmyBWn01r0EixxIt90dIx ftMg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=fjO/zSIrfOCV8FlsmQ6h2ESV4mTTgyPIjLpSsgo714E=; fh=c1dCoInd0+dLcx/UrFic0i0JNXnY76E8cxrqocE94CU=; b=kNafhK2rl/gHctW48weKe0ez0Q3Qx+H/Yl5LJVuph3JVpaUudRjJAbFRzpz5oQbcm9 M5KGg2XIFgpcfa6gkhhtSUWSrmuqzu/Ga9ceH9d0fW1q+SNRZBfwm1XDLUVDGR/Ack+K FV+3V9Uy6S8W8WgoinfgKjGtcedN0da+wn4bWo/OKaGCbhLE7kF8x+/HTwEKp6I6VjU1 mp87a1Zd/aunnw/ekresQ6LIDJ0mcBUsAnHkrCCUVpsISQl8Vstrm2kFIsGjjM7Psgsd nsbBb2pWDLXmQ0fBUBg6pWN7mZpiyeNbEx4PKqRFl0bxOQiDYh5R4CxCozaglnsV+ERH pf9A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lsODWg13; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-155717-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155717-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id x14-20020aa7d38e000000b0057224cae773si653848edq.220.2024.04.23.11.01.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 11:01:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155717-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lsODWg13; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-155717-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155717-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 2083E1F24D82 for ; Tue, 23 Apr 2024 18:01:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BFA5A13E889; Tue, 23 Apr 2024 17:59:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lsODWg13" Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 0422B142E77; Tue, 23 Apr 2024 17:59:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713895169; cv=none; b=OMb9WZpKp/1wXkCNrdHy5kIW746OhU9/qGw8P970hAJPOvsfGmYp3jYa+twPaAHXXTSsrt4FmzNMg2uuAUWN2paQl963ST35sLRiwQp9/hdgnenAHFsjBpp2kkiajLc05WofHy1lCNeJBUP2X8Em5PNj+WYeeMHvliOWahCoXB8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713895169; c=relaxed/simple; bh=HcbsyG+Tvga8urvYrCDOXy5hy5ESWVMOxCwdjcLP2bo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cbJep38NoiOur1TltQYWdBnSJla4YZeqsqQx8vg+jr0C9L2ftlb5odlFLRnmo2NHbKRDh8Y6NGfO0UhzQtQMnMIEBRGHXonrHnrYn9dVkTC9qtrJRo1Rk4jxz7t/WgPXoZIVp+jk/5w8/v4HdQCH3PeXnLE10c9uUREaX6gqnOE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lsODWg13; arc=none smtp.client-ip=209.85.128.43 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-wm1-f43.google.com with SMTP id 5b1f17b1804b1-41a1d88723bso20336915e9.0; Tue, 23 Apr 2024 10:59:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713895166; x=1714499966; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fjO/zSIrfOCV8FlsmQ6h2ESV4mTTgyPIjLpSsgo714E=; b=lsODWg13N+pP3Tm8y17rPS4ig6EpH33cN+Vf1fWkSn/9qC0TIOlkKT3VTpBKAFYHqY uuYMZ35jymWbUvg2L0EwhDV2U0x1dajfY26pwEQcZ9fHclaMVpSVnoHexIfJrpFXubWs jQjtthF3vkTgjAKwP2Ixl5A5UJgH65xH917T29BfGrWayJH0LeyRuqqcdwNaN1CZbh+W YZNOUlnDCCm2zP8jPhXmVnOpL5QlsPAjxlSUxtgVncsuUD404d3Fbk2b0Fi3g0pwjWH7 GS+GKPc/qL6qoMuINpOS5Lgoev+G9+4g77tQwaVbViJs+P5jCk+b4B2eYtdQrpm59p21 uaQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713895166; x=1714499966; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fjO/zSIrfOCV8FlsmQ6h2ESV4mTTgyPIjLpSsgo714E=; b=HiHtByHy3YhrA7CRbuj9obvyrBSI3WJxZiKrqoCDZZuukzjLnTeRFOZBS2bfFpDT0T uTw9bx5aibHFC9B1G+hNNiy5EhBgi3m+P3ImCxIyCVQy6rDu0QTL21d5Q3HB9sPhDFQV HtqAFSXwMUCQ8Icf6wIyyVxzH4m78NtaavgEZV0uacNwV7MoauWGujnpki9h4t/w8vqo pTLfLNRasVorgrmhhRQBeZf5FmKeZs+qB3FKiMHjCi0IOGIRlPXqNrvGQ59g6Rm7DwRW qqBAbxdIXfJB696yLo24RFxDWa1Xe6I0LJ0q3cZFncd6vJNxm1qXMO+KXgvE6nNniVkR iLpw== X-Forwarded-Encrypted: i=1; AJvYcCVAG7+hsq3JzDGqupoYxZcAbaMPs3QMad9HqPkn4XCvKBhXYrQUeRtCKRO2gJvc7tEk2TFrRao5QQTgOW3tfb+AyWw4B7Y6R1mGO5qHmL8pesHl1mnwJDdX8lu+128sK3xmrye7xCXRexXniqQLsHZJN6kYGjGPbYJcAhWocs/RQoNAkrv3g42OyTvC X-Gm-Message-State: AOJu0YxULLpVM6cwauYGvOQSv9/RbanM5/tpQvtZpIl3DjJNQBl3QVXN Jq0YJ7x5LojrSRj8MaRl3JXRP2ntbASWLI1GTQdKiMlmoUlWMeYd X-Received: by 2002:a05:600c:3108:b0:41a:ac28:1fc8 with SMTP id g8-20020a05600c310800b0041aac281fc8mr6347wmo.33.1713895166435; Tue, 23 Apr 2024 10:59:26 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:cef0:9ed3:1428:f85f]) by smtp.gmail.com with ESMTPSA id fl5-20020a05600c0b8500b0041abeaaf7f0sm2808145wmb.28.2024.04.23.10.59.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 10:59:25 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Geert Uytterhoeven , Linus Walleij , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Magnus Damm , linux-renesas-soc@vger.kernel.org Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v2 10/13] pinctrl: renesas: pinctrl-rzg2l: Add support to set pulling up/down the pins Date: Tue, 23 Apr 2024 18:58:57 +0100 Message-Id: <20240423175900.702640-11-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240423175900.702640-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240423175900.702640-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Lad Prabhakar Add support to configure bias-disable, bias-pull-up and bias-pull-down properties of the pin. Two new function pointers get_bias_param() and get_bias_val() are introduced as the values in PUPD register differ when compared to RZ/G2L family and RZ/V2H(P) SoC, Value | RZ/G2L | RZ/V2H --------------------------------- 00b: | Bias Disabled | Pull up/down disabled 01b: | Pull-up | Pull up/down disabled 10b: | Pull-down | Pull-down 11b: | Prohibited | Pull-up Signed-off-by: Lad Prabhakar --- RFC->v2 - New patch --- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 73 +++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/drivers/pinctrl/renesas/pinctrl-rzg2l.c b/drivers/pinctrl/renesas/pinctrl-rzg2l.c index 102fa75c71d3..c144bf43522b 100644 --- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c +++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c @@ -122,6 +122,7 @@ #define IOLH(off) (0x1000 + (off) * 8) #define SR(off) (0x1400 + (off) * 8) #define IEN(off) (0x1800 + (off) * 8) +#define PUPD(off) (0x1C00 + (off) * 8) #define ISEL(off) (0x2C00 + (off) * 8) #define SD_CH(off, ch) ((off) + (ch) * 4) #define ETH_POC(off, ch) ((off) + (ch) * 4) @@ -140,6 +141,7 @@ #define IEN_MASK 0x01 #define IOLH_MASK 0x03 #define SR_MASK 0x01 +#define PUPD_MASK 0x03 #define PM_INPUT 0x1 #define PM_OUTPUT 0x2 @@ -265,6 +267,8 @@ struct rzg2l_pinctrl_data { void (*pmc_writeb)(struct rzg2l_pinctrl *pctrl, u8 val, void __iomem *addr); u32 (*read_oen)(struct rzg2l_pinctrl *pctrl, u32 caps, u32 offset, u8 pin); int (*write_oen)(struct rzg2l_pinctrl *pctrl, u32 caps, u32 offset, u8 pin, u8 oen); + int (*get_bias_param)(u8 val); + int (*get_bias_val)(enum pin_config_param param); }; /** @@ -1081,6 +1085,38 @@ static int rzg2l_write_oen(struct rzg2l_pinctrl *pctrl, u32 caps, u32 offset, u8 return 0; } +static int rzg2l_get_bias_param(u8 val) +{ + switch (val) { + case 0: + return PIN_CONFIG_BIAS_DISABLE; + case 1: + return PIN_CONFIG_BIAS_PULL_UP; + case 2: + return PIN_CONFIG_BIAS_PULL_DOWN; + default: + break; + } + + return -EINVAL; +} + +static int rzg2l_get_bias_val(enum pin_config_param param) +{ + switch (param) { + case PIN_CONFIG_BIAS_DISABLE: + return 0; + case PIN_CONFIG_BIAS_PULL_UP: + return 1; + case PIN_CONFIG_BIAS_PULL_DOWN: + return 2; + default: + break; + } + + return -EINVAL; +} + static int rzg2l_pinctrl_pinconf_get(struct pinctrl_dev *pctldev, unsigned int _pin, unsigned long *config) @@ -1139,6 +1175,25 @@ static int rzg2l_pinctrl_pinconf_get(struct pinctrl_dev *pctldev, arg = rzg2l_read_pin_config(pctrl, SR(off), bit, SR_MASK); break; + case PIN_CONFIG_BIAS_DISABLE: + case PIN_CONFIG_BIAS_PULL_UP: + case PIN_CONFIG_BIAS_PULL_DOWN: { + if (!(cfg & PIN_CFG_PUPD)) + return -EINVAL; + + ret = pctrl->data->get_bias_param(rzg2l_read_pin_config(pctrl, + PUPD(off), + bit, PUPD_MASK)); + if (ret < 0) + return ret; + + if (ret != param) + return -EINVAL; + /* for PIN_CONFIG_BIAS_PULL_UP/DOWN when enabled we just return 1 */ + arg = 1; + break; + } + case PIN_CONFIG_DRIVE_STRENGTH: { unsigned int index; @@ -1254,6 +1309,20 @@ static int rzg2l_pinctrl_pinconf_set(struct pinctrl_dev *pctldev, rzg2l_rmw_pin_config(pctrl, SR(off), bit, SR_MASK, arg); break; + case PIN_CONFIG_BIAS_DISABLE: + case PIN_CONFIG_BIAS_PULL_UP: + case PIN_CONFIG_BIAS_PULL_DOWN: { + if (!(cfg & PIN_CFG_PUPD)) + return -EINVAL; + + ret = pctrl->data->get_bias_val(param); + if (ret < 0) + return ret; + + rzg2l_rmw_pin_config(pctrl, PUPD(off), bit, PUPD_MASK, ret); + break; + } + case PIN_CONFIG_DRIVE_STRENGTH: arg = pinconf_to_config_argument(_configs[i]); @@ -2746,6 +2815,8 @@ static struct rzg2l_pinctrl_data r9a07g044_data = { .pmc_writeb = &rzg2l_pmc_writeb, .read_oen = &rzg2l_read_oen, .write_oen = &rzg2l_write_oen, + .get_bias_param = &rzg2l_get_bias_param, + .get_bias_val = &rzg2l_get_bias_val, }; static struct rzg2l_pinctrl_data r9a08g045_data = { @@ -2761,6 +2832,8 @@ static struct rzg2l_pinctrl_data r9a08g045_data = { .pmc_writeb = &rzg2l_pmc_writeb, .read_oen = &rzg2l_read_oen, .write_oen = &rzg2l_write_oen, + .get_bias_param = &rzg2l_get_bias_param, + .get_bias_val = &rzg2l_get_bias_val, }; static const struct of_device_id rzg2l_pinctrl_of_table[] = { -- 2.34.1