public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [RESEND PATCH 0/3] pinctrl: renesas: trivial fixes and enhancements
@ 2020-11-04 17:27 Lad Prabhakar
  2020-11-04 17:27 ` [RESEND PATCH 1/3] pinctrl: renesas: Drop unused members from struct sh_pfc_pinctrl Lad Prabhakar
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Lad Prabhakar @ 2020-11-04 17:27 UTC (permalink / raw)
  To: u-boot

Hi All,

This patch series includes trivial fixes and enhancements to
renesas pfc driver.


This is exactly the same series posted earlier [1].
[1] https://patchwork.ozlabs.org/project/uboot/list/?series=203651

Cheers,
Prabhakar

Lad Prabhakar (3):
  pinctrl: renesas: Drop unused members from struct sh_pfc_pinctrl
  pinctrl: renesas: Make sure the pin type is updated after setting the
    MUX
  pinctrl: renesas: Implement get_pin_muxing() callback

 drivers/pinctrl/renesas/pfc.c | 54 ++++++++++++++++++++++++++++++-----
 1 file changed, 47 insertions(+), 7 deletions(-)

-- 
2.17.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [RESEND PATCH 1/3] pinctrl: renesas: Drop unused members from struct sh_pfc_pinctrl
  2020-11-04 17:27 [RESEND PATCH 0/3] pinctrl: renesas: trivial fixes and enhancements Lad Prabhakar
@ 2020-11-04 17:27 ` Lad Prabhakar
  2020-11-04 19:22   ` Marek Vasut
  2020-11-04 17:27 ` [RESEND PATCH 2/3] pinctrl: renesas: Make sure the pin type is updated after setting the MUX Lad Prabhakar
  2020-11-04 17:27 ` [RESEND PATCH 3/3] pinctrl: renesas: Implement get_pin_muxing() callback Lad Prabhakar
  2 siblings, 1 reply; 7+ messages in thread
From: Lad Prabhakar @ 2020-11-04 17:27 UTC (permalink / raw)
  To: u-boot

Drop unused members from struct sh_pfc_pinctrl.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/pinctrl/renesas/pfc.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/pinctrl/renesas/pfc.c b/drivers/pinctrl/renesas/pfc.c
index db0fa9b728..fb811a95bc 100644
--- a/drivers/pinctrl/renesas/pfc.c
+++ b/drivers/pinctrl/renesas/pfc.c
@@ -50,10 +50,6 @@ struct sh_pfc_pinctrl {
 	struct sh_pfc *pfc;
 
 	struct sh_pfc_pin_config *configs;
-
-	const char *func_prop_name;
-	const char *groups_prop_name;
-	const char *pins_prop_name;
 };
 
 struct sh_pfc_pin_range {
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [RESEND PATCH 2/3] pinctrl: renesas: Make sure the pin type is updated after setting the MUX
  2020-11-04 17:27 [RESEND PATCH 0/3] pinctrl: renesas: trivial fixes and enhancements Lad Prabhakar
  2020-11-04 17:27 ` [RESEND PATCH 1/3] pinctrl: renesas: Drop unused members from struct sh_pfc_pinctrl Lad Prabhakar
@ 2020-11-04 17:27 ` Lad Prabhakar
  2020-11-04 19:22   ` Marek Vasut
  2020-11-04 17:27 ` [RESEND PATCH 3/3] pinctrl: renesas: Implement get_pin_muxing() callback Lad Prabhakar
  2 siblings, 1 reply; 7+ messages in thread
From: Lad Prabhakar @ 2020-11-04 17:27 UTC (permalink / raw)
  To: u-boot

Update pin type after every successful call to sh_pfc_config_mux().

This fixes pin functionality from being overwritten.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/pinctrl/renesas/pfc.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/renesas/pfc.c b/drivers/pinctrl/renesas/pfc.c
index fb811a95bc..275702d13a 100644
--- a/drivers/pinctrl/renesas/pfc.c
+++ b/drivers/pinctrl/renesas/pfc.c
@@ -537,11 +537,18 @@ static int sh_pfc_pinctrl_pin_set(struct udevice *dev, unsigned pin_selector,
 	const struct sh_pfc_pin *pin = &priv->pfc.info->pins[pin_selector];
 	int idx = sh_pfc_get_pin_index(pfc, pin->pin);
 	struct sh_pfc_pin_config *cfg = &pmx->configs[idx];
+	int ret;
 
 	if (cfg->type != PINMUX_TYPE_NONE)
 		return -EBUSY;
 
-	return sh_pfc_config_mux(pfc, pin->enum_id, PINMUX_TYPE_FUNCTION);
+	ret = sh_pfc_config_mux(pfc, pin->enum_id, PINMUX_TYPE_FUNCTION);
+	if (ret)
+		return ret;
+
+	cfg->type = PINMUX_TYPE_FUNCTION;
+
+	return 0;
 }
 
 static int sh_pfc_pinctrl_group_set(struct udevice *dev, unsigned group_selector,
@@ -551,12 +558,14 @@ static int sh_pfc_pinctrl_group_set(struct udevice *dev, unsigned group_selector
 	struct sh_pfc_pinctrl *pmx = &priv->pmx;
 	struct sh_pfc *pfc = &priv->pfc;
 	const struct sh_pfc_pin_group *grp = &priv->pfc.info->groups[group_selector];
+	struct sh_pfc_pin_config *cfg;
 	unsigned int i;
 	int ret = 0;
+	int idx;
 
 	for (i = 0; i < grp->nr_pins; ++i) {
-		int idx = sh_pfc_get_pin_index(pfc, grp->pins[i]);
-		struct sh_pfc_pin_config *cfg = &pmx->configs[idx];
+		idx = sh_pfc_get_pin_index(pfc, grp->pins[i]);
+		cfg = &pmx->configs[idx];
 
 		if (cfg->type != PINMUX_TYPE_NONE) {
 			ret = -EBUSY;
@@ -568,6 +577,10 @@ static int sh_pfc_pinctrl_group_set(struct udevice *dev, unsigned group_selector
 		ret = sh_pfc_config_mux(pfc, grp->mux[i], PINMUX_TYPE_FUNCTION);
 		if (ret < 0)
 			break;
+
+		idx = sh_pfc_get_pin_index(pfc, grp->pins[i]);
+		cfg = &pmx->configs[idx];
+		cfg->type = PINMUX_TYPE_FUNCTION;
 	}
 
 done:
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [RESEND PATCH 3/3] pinctrl: renesas: Implement get_pin_muxing() callback
  2020-11-04 17:27 [RESEND PATCH 0/3] pinctrl: renesas: trivial fixes and enhancements Lad Prabhakar
  2020-11-04 17:27 ` [RESEND PATCH 1/3] pinctrl: renesas: Drop unused members from struct sh_pfc_pinctrl Lad Prabhakar
  2020-11-04 17:27 ` [RESEND PATCH 2/3] pinctrl: renesas: Make sure the pin type is updated after setting the MUX Lad Prabhakar
@ 2020-11-04 17:27 ` Lad Prabhakar
  2 siblings, 0 replies; 7+ messages in thread
From: Lad Prabhakar @ 2020-11-04 17:27 UTC (permalink / raw)
  To: u-boot

Implement get_pin_muxing() callback so that pinmux status
command can be used on Renesas platforms.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/pinctrl/renesas/pfc.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/pinctrl/renesas/pfc.c b/drivers/pinctrl/renesas/pfc.c
index 275702d13a..a1da45db2e 100644
--- a/drivers/pinctrl/renesas/pfc.c
+++ b/drivers/pinctrl/renesas/pfc.c
@@ -44,6 +44,7 @@ enum sh_pfc_model {
 
 struct sh_pfc_pin_config {
 	u32 type;
+	const char *function_name;
 };
 
 struct sh_pfc_pinctrl {
@@ -448,6 +449,30 @@ static const char *sh_pfc_pinctrl_get_group_name(struct udevice *dev,
 	return priv->pfc.info->groups[selector].name;
 }
 
+static int sh_pfc_pinctrl_get_pin_muxing(struct udevice *dev,
+					 unsigned int selector,
+					 char *buf, int size)
+{
+	struct sh_pfc_pinctrl_priv *priv = dev_get_priv(dev);
+	struct sh_pfc_pinctrl *pmx = &priv->pmx;
+	struct sh_pfc *pfc = &priv->pfc;
+	struct sh_pfc_pin_config *cfg;
+	const struct sh_pfc_pin *pin;
+	int idx;
+
+	pin = &priv->pfc.info->pins[selector];
+	if (!pin) {
+		snprintf(buf, size, "Unknown");
+		return -EINVAL;
+	}
+
+	idx = sh_pfc_get_pin_index(pfc, pin->pin);
+	cfg = &pmx->configs[idx];
+	snprintf(buf, size, "%s", cfg->function_name);
+
+	return 0;
+}
+
 static int sh_pfc_pinctrl_get_functions_count(struct udevice *dev)
 {
 	struct sh_pfc_pinctrl_priv *priv = dev_get_priv(dev);
@@ -495,6 +520,7 @@ static int sh_pfc_gpio_request_enable(struct udevice *dev,
 		return ret;
 
 	cfg->type = PINMUX_TYPE_GPIO;
+	cfg->function_name = "gpio";
 
 	return 0;
 }
@@ -524,6 +550,7 @@ static int sh_pfc_gpio_disable_free(struct udevice *dev,
 	cfg = &pmx->configs[idx];
 
 	cfg->type = PINMUX_TYPE_NONE;
+	cfg->function_name = "none";
 
 	return 0;
 }
@@ -547,6 +574,7 @@ static int sh_pfc_pinctrl_pin_set(struct udevice *dev, unsigned pin_selector,
 		return ret;
 
 	cfg->type = PINMUX_TYPE_FUNCTION;
+	cfg->function_name = "function";
 
 	return 0;
 }
@@ -581,6 +609,7 @@ static int sh_pfc_pinctrl_group_set(struct udevice *dev, unsigned group_selector
 		idx = sh_pfc_get_pin_index(pfc, grp->pins[i]);
 		cfg = &pmx->configs[idx];
 		cfg->type = PINMUX_TYPE_FUNCTION;
+		cfg->function_name = priv->pfc.info->groups[group_selector].name;
 	}
 
 done:
@@ -787,6 +816,7 @@ static struct pinctrl_ops sh_pfc_pinctrl_ops = {
 	.get_pin_name		= sh_pfc_pinctrl_get_pin_name,
 	.get_groups_count	= sh_pfc_pinctrl_get_groups_count,
 	.get_group_name		= sh_pfc_pinctrl_get_group_name,
+	.get_pin_muxing		= sh_pfc_pinctrl_get_pin_muxing,
 	.get_functions_count	= sh_pfc_pinctrl_get_functions_count,
 	.get_function_name	= sh_pfc_pinctrl_get_function_name,
 
@@ -817,6 +847,7 @@ static int sh_pfc_map_pins(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx)
 	for (i = 0; i < pfc->info->nr_pins; ++i) {
 		struct sh_pfc_pin_config *cfg = &pmx->configs[i];
 		cfg->type = PINMUX_TYPE_NONE;
+		cfg->function_name = "none";
 	}
 
 	return 0;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [RESEND PATCH 2/3] pinctrl: renesas: Make sure the pin type is updated after setting the MUX
  2020-11-04 17:27 ` [RESEND PATCH 2/3] pinctrl: renesas: Make sure the pin type is updated after setting the MUX Lad Prabhakar
@ 2020-11-04 19:22   ` Marek Vasut
  2020-11-05 10:09     ` Lad, Prabhakar
  0 siblings, 1 reply; 7+ messages in thread
From: Marek Vasut @ 2020-11-04 19:22 UTC (permalink / raw)
  To: u-boot

On 11/4/20 6:27 PM, Lad Prabhakar wrote:
> Update pin type after every successful call to sh_pfc_config_mux().
> 
> This fixes pin functionality from being overwritten.

Can you please provide more details about the problem you are fixing 
here ? What is the problem ? What triggers it ?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [RESEND PATCH 1/3] pinctrl: renesas: Drop unused members from struct sh_pfc_pinctrl
  2020-11-04 17:27 ` [RESEND PATCH 1/3] pinctrl: renesas: Drop unused members from struct sh_pfc_pinctrl Lad Prabhakar
@ 2020-11-04 19:22   ` Marek Vasut
  0 siblings, 0 replies; 7+ messages in thread
From: Marek Vasut @ 2020-11-04 19:22 UTC (permalink / raw)
  To: u-boot

On 11/4/20 6:27 PM, Lad Prabhakar wrote:
> Drop unused members from struct sh_pfc_pinctrl.

Applied, thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [RESEND PATCH 2/3] pinctrl: renesas: Make sure the pin type is updated after setting the MUX
  2020-11-04 19:22   ` Marek Vasut
@ 2020-11-05 10:09     ` Lad, Prabhakar
  0 siblings, 0 replies; 7+ messages in thread
From: Lad, Prabhakar @ 2020-11-05 10:09 UTC (permalink / raw)
  To: u-boot

Hi Marek,

Thank you for the review.

On Wed, Nov 4, 2020 at 7:29 PM Marek Vasut <marek.vasut@gmail.com> wrote:
>
> On 11/4/20 6:27 PM, Lad Prabhakar wrote:
> > Update pin type after every successful call to sh_pfc_config_mux().
> >
> > This fixes pin functionality from being overwritten.
>
> Can you please provide more details about the problem you are fixing
> here ? What is the problem ? What triggers it ?
>
By default on startup all the pin types are configured to
PINMUX_TYPE_NONE (in sh_pfc_map_pins()), when pin is set as GPIO the
pin type is updated to PINMUX_TYPE_GPIO. But the type is not updated
when the pin is set as a function in
sh_pfc_pinctrl_pin_set()/sh_pfc_pinctrl_group_set() calls (although
these calls have a check if pin type is not PINMUX_TYPE_NONE). So with
the current implementation suppose initially the pin is configured as
USB function and later as SPI function this driver does not complain
and makes USB unusable.

With this patch on every successful call to
sh_pfc_pinctrl_pin_set()/sh_pfc_pinctrl_group_set()  the pin type is
updated so that the functionality of the pin is not overwritten as
these functions already have the below check,

if (cfg->type != PINMUX_TYPE_NONE) {
  ret = -EBUSY;

Cheers,
Prabhakar

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-11-05 10:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-04 17:27 [RESEND PATCH 0/3] pinctrl: renesas: trivial fixes and enhancements Lad Prabhakar
2020-11-04 17:27 ` [RESEND PATCH 1/3] pinctrl: renesas: Drop unused members from struct sh_pfc_pinctrl Lad Prabhakar
2020-11-04 19:22   ` Marek Vasut
2020-11-04 17:27 ` [RESEND PATCH 2/3] pinctrl: renesas: Make sure the pin type is updated after setting the MUX Lad Prabhakar
2020-11-04 19:22   ` Marek Vasut
2020-11-05 10:09     ` Lad, Prabhakar
2020-11-04 17:27 ` [RESEND PATCH 3/3] pinctrl: renesas: Implement get_pin_muxing() callback Lad Prabhakar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox