mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/7] pinctrl: rockchip: make use of pinconf-generic.h
Date: Mon,  1 Jul 2024 09:32:15 +0200	[thread overview]
Message-ID: <20240701073220.165946-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240701073220.165946-1-a.fatoum@pengutronix.de>

So far we defined our own enum to record what bias was indicated by the
device tree properties. Now that we have imported the upstream enum
definition, make use of it to make syncs with Linux easier.

While at it, we replace one usage of RK_BIAS_PULL_UP with `1'. That they
were equal before was a coincidence and now that we use the Linux
definitions, this is no longer the case.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/pinctrl/pinctrl-rockchip.c | 38 +++++++++++++-----------------
 1 file changed, 16 insertions(+), 22 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index ca9939c9e91d..d80ac7d5dc04 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -20,6 +20,7 @@
 #include <of.h>
 #include <of_address.h>
 #include <pinctrl.h>
+#include <linux/pinctrl/pinconf-generic.h>
 #include <dt-bindings/pinctrl/rockchip.h>
 
 #include <linux/basic_mmio_gpio.h>
@@ -222,30 +223,23 @@
 #define RK3588_PIN_BANK_FLAGS(ID, PIN, LABEL, M, P)			\
 	PIN_BANK_IOMUX_FLAGS_PULL_FLAGS(ID, PIN, LABEL, M, M, M, M, P, P, P, P)
 
-enum {
-	RK_BIAS_DISABLE = 0,
-	RK_BIAS_PULL_UP,
-	RK_BIAS_PULL_DOWN,
-	RK_BIAS_BUS_HOLD,
-};
-
 static struct rockchip_pinctrl *to_rockchip_pinctrl(struct pinctrl_device *pdev)
 {
 	return container_of(pdev, struct rockchip_pinctrl, pctl_dev);
 }
 
-static int parse_bias_config(struct device_node *np)
+static enum pin_config_param parse_bias_config(struct device_node *np)
 {
 	u32 val;
  
 	if (of_property_read_u32(np, "bias-pull-up", &val) != -EINVAL)
-		return RK_BIAS_PULL_UP;
+		return PIN_CONFIG_BIAS_PULL_UP;
 	else if (of_property_read_u32(np, "bias-pull-down", &val) != -EINVAL)
-		return RK_BIAS_PULL_DOWN;
+		return PIN_CONFIG_BIAS_PULL_DOWN;
 	else if (of_property_read_u32(np, "bias-bus-hold", &val) != -EINVAL)
-		return RK_BIAS_BUS_HOLD;
+		return PIN_CONFIG_BIAS_BUS_HOLD;
 	else
-		return RK_BIAS_DISABLE;
+		return PIN_CONFIG_BIAS_DISABLE;
 }
 
 static struct rockchip_pin_bank *bank_num_to_bank(
@@ -2104,16 +2098,16 @@ static int rockchip_set_drive_perpin(struct rockchip_pin_bank *bank,
 
 static int rockchip_pull_list[PULL_TYPE_MAX][4] = {
 	{
-		RK_BIAS_DISABLE,
-		RK_BIAS_PULL_UP,
-		RK_BIAS_PULL_DOWN,
-		RK_BIAS_BUS_HOLD
+		PIN_CONFIG_BIAS_DISABLE,
+		PIN_CONFIG_BIAS_PULL_UP,
+		PIN_CONFIG_BIAS_PULL_DOWN,
+		PIN_CONFIG_BIAS_BUS_HOLD
 	},
 	{
-		RK_BIAS_DISABLE,
-		RK_BIAS_PULL_DOWN,
-		RK_BIAS_DISABLE,
-		RK_BIAS_PULL_UP
+		PIN_CONFIG_BIAS_DISABLE,
+		PIN_CONFIG_BIAS_PULL_DOWN,
+		PIN_CONFIG_BIAS_DISABLE,
+		PIN_CONFIG_BIAS_PULL_UP
 	},
 };
 
@@ -2142,7 +2136,7 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank,
 	case RK2928:
 	case RK3128:
 		data = BIT(bit + 16);
-		if (pull == RK_BIAS_DISABLE)
+		if (pull == PIN_CONFIG_BIAS_DISABLE)
 			data |= BIT(bit);
 		ret = regmap_write(regmap, reg, data);
 		break;
@@ -2169,7 +2163,7 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank,
 		 * where that pull up value becomes 3.
 		 */
 		if (ctrl->type == RK3568 && bank->bank_num == 0 && pin_num >= 27 && pin_num <= 30) {
-			if (ret == RK_BIAS_PULL_UP)
+			if (ret == 1)
 				ret = 3;
 		}
 
-- 
2.39.2




  parent reply	other threads:[~2024-07-01  7:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-01  7:32 [PATCH 0/7] pinctrl: rockchip: support &pcfg_input/output Ahmad Fatoum
2024-07-01  7:32 ` [PATCH 1/7] pinctrl: import <linux/pinctrl/pinconf-generic.h> header Ahmad Fatoum
2024-07-01  7:32 ` Ahmad Fatoum [this message]
2024-07-01  7:32 ` [PATCH 3/7] pinctrl: rockchip: use of_property_read_bool() Ahmad Fatoum
2024-07-01  7:32 ` [PATCH 4/7] pinctrl: rockchip: add support for configuring schmitt trigger Ahmad Fatoum
2024-07-01  7:32 ` [PATCH 5/7] pinctrl: rockchip: add support for bias-pull-pin-default Ahmad Fatoum
2024-07-01  7:32 ` [PATCH 6/7] gpiolib: implement of_gpio_get_chip_by_alias Ahmad Fatoum
2024-07-01  7:32 ` [PATCH 7/7] pinctrl: rockchip: add support for configuring GPIO direction Ahmad Fatoum
2024-07-01  9:45 ` [PATCH 0/7] pinctrl: rockchip: support &pcfg_input/output Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240701073220.165946-3-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox