Skip to contentSkip to conversation

Minor fixes for MediaTek pinctrl driver

PATCH New Weijie Gao 2 participants 9 messages Mar 5, 2021 – Mar 20, 2021

Subsystems (3)
lore
Share & tools
lore

Weijie Gao

author
#0 lore raw

cover Minor fixes for MediaTek pinctrl driver

This patch series provides fixes for MediaTek pinctrl driver common parts and mt7629.

Sam Shih (2):
pinctrl: mediatek: fix wrong assignment in mtk_get_pin_name
pinctrl: mediatek: add get_pin_muxing ops for mediatek pinctrl

Weijie Gao (2):
pinctrl: mediatek: do not probe gpio driver if not enabled
pinctrl: mt7629: add jtag function and pin group

 drivers/pinctrl/mediatek/pinctrl-mt7629.c     |  7 +++++
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 28 +++++++++++++++----
 2 files changed, 30 insertions(+), 5 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/4 pinctrl: mediatek: fix wrong assignment in mtk_get_pin_name

From: Sam Shih <[email protected]>

This is a bug fix for mtk pinctrl common part. Appearently pins should be used instead of grps in mtk_get_pin_name().

---
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/mediatek/pinctrl-mtk-common.c +1 -1
index 4dd3f73ead..b700dd98bf 100644
@@ -219,7 +219,7 @@ static const char *mtk_get_pin_name(struct udevice *dev,
 {
 	struct mtk_pinctrl_priv *priv = dev_get_priv(dev);
 
-	if (!priv->soc->grps[selector].name)
+	if (!priv->soc->pins[selector].name)
 		return mtk_pinctrl_dummy_name;
 
 	return priv->soc->pins[selector].name;
Signature · 1 line
2.17.1
author
#3 lore raw

PATCH 2/4 pinctrl: mediatek: add get_pin_muxing ops for mediatek pinctrl

In reply to Weijie Gao

From: Sam Shih <[email protected]>

This patch add get_pin_muxing support for mediatek pinctrl drivers

---
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/pinctrl/mediatek/pinctrl-mtk-common.c +14 -0
index b700dd98bf..b2212c2559 100644
@@ -232,6 +232,19 @@ static int mtk_get_pins_count(struct udevice *dev)
 	return priv->soc->npins;
 }
 
+static int mtk_get_pin_muxing(struct udevice *dev, unsigned int selector,
+			      char *buf, int size)
+{
+	int val, err;
+
+	err = mtk_hw_get_value(dev, selector, PINCTRL_PIN_REG_MODE, &val);
+	if (err)
+		return err;
+
+	snprintf(buf, size, "Aux Func.%d", val);
+	return 0;
+}
+
 static const char *mtk_get_group_name(struct udevice *dev,
 				      unsigned int selector)
 {
@@ -512,6 +525,7 @@ static int mtk_pinconf_group_set(struct udevice *dev,
 const struct pinctrl_ops mtk_pinctrl_ops = {
 	.get_pins_count = mtk_get_pins_count,
 	.get_pin_name = mtk_get_pin_name,
+	.get_pin_muxing = mtk_get_pin_muxing,
 	.get_groups_count = mtk_get_groups_count,
 	.get_group_name = mtk_get_group_name,
 	.get_functions_count = mtk_get_functions_count,
Signature · 1 line
2.17.1
author
#5 lore raw

PATCH 3/4 pinctrl: mediatek: do not probe gpio driver if not enabled

In reply to Weijie Gao

The mtk pinctrl driver is a combination driver with support for both pinctrl and gpio. When this driver is used in SPL, gpio support may not be enabled, and this will result in a compilation error.

To fix this, macros are added to make sure gpio related code will only be compiled when gpio support is enabled.

---
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/pinctrl/mediatek/pinctrl-mtk-common.c +8 -4
index b2212c2559..264c6458c9 100644
@@ -540,6 +540,8 @@ const struct pinctrl_ops mtk_pinctrl_ops = {
 	.set_state = pinctrl_generic_set_state,
 };
 
+#if CONFIG_IS_ENABLED(DM_GPIO) || \
+    (defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_GPIO_SUPPORT))
 static int mtk_gpio_get(struct udevice *dev, unsigned int off)
 {
 	int val, err;
@@ -647,12 +649,13 @@ static int mtk_gpiochip_register(struct udevice *parent)
 
 	return 0;
 }
+#endif
 
 int mtk_pinctrl_common_probe(struct udevice *dev,
 			     struct mtk_pinctrl_soc *soc)
 {
 	struct mtk_pinctrl_priv *priv = dev_get_priv(dev);
-	int ret;
+	int ret = 0;
 
 	priv->base = dev_read_addr_ptr(dev);
 	if (!priv->base)
@@ -660,9 +663,10 @@ int mtk_pinctrl_common_probe(struct udevice *dev,
 
 	priv->soc = soc;
 
+#if CONFIG_IS_ENABLED(DM_GPIO) || \
+    (defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_GPIO_SUPPORT))
 	ret = mtk_gpiochip_register(dev);
-	if (ret)
-		return ret;
+#endif
 
-	return 0;
+	return ret;
 }
Signature · 1 line
2.17.1
author
#7 lore raw

PATCH 4/4 pinctrl: mt7629: add jtag function and pin group

In reply to Weijie Gao

The EPHY LEDs of mt7629 can be used as JTAG. This patch adds the jtag pin group to the pinctrl driver.

---
 drivers/pinctrl/mediatek/pinctrl-mt7629.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/pinctrl/mediatek/pinctrl-mt7629.c +7 -0
index 7ce64fde25..5d4bec2234 100644
@@ -201,6 +201,10 @@ static int mt7629_wf2g_led_funcs[] = { 1, };
 static int mt7629_wf5g_led_pins[] = { 18, };
 static int mt7629_wf5g_led_funcs[] = { 1, };
 
+/* LED for EPHY used as JTAG */
+static int mt7629_ephy_leds_jtag_pins[] = { 12, 13, 14, 15, 16, };
+static int mt7629_ephy_leds_jtag_funcs[] = { 7, 7, 7, 7, 7, };
+
 /* Watchdog */
 static int mt7629_watchdog_pins[] = { 11, };
 static int mt7629_watchdog_funcs[] = { 1, };
@@ -297,6 +301,7 @@ static const struct mtk_group_desc mt7629_groups[] = {
 	PINCTRL_PIN_GROUP("ephy_led2", mt7629_ephy_led2),
 	PINCTRL_PIN_GROUP("ephy_led3", mt7629_ephy_led3),
 	PINCTRL_PIN_GROUP("ephy_led4", mt7629_ephy_led4),
+	PINCTRL_PIN_GROUP("ephy_leds_jtag", mt7629_ephy_leds_jtag),
 	PINCTRL_PIN_GROUP("wf2g_led", mt7629_wf2g_led),
 	PINCTRL_PIN_GROUP("wf5g_led", mt7629_wf5g_led),
 	PINCTRL_PIN_GROUP("watchdog", mt7629_watchdog),
@@ -364,6 +369,7 @@ static const char *const mt7629_uart_groups[] = { "uart1_0_txd_rxd",
 static const char *const mt7629_wdt_groups[] = { "watchdog", };
 static const char *const mt7629_wifi_groups[] = { "wf0_5g", "wf0_2g", };
 static const char *const mt7629_flash_groups[] = { "snfi", "spi_nor" };
+static const char *const mt7629_jtag_groups[] = { "ephy_leds_jtag" };
 
 static const struct mtk_function_desc mt7629_functions[] = {
 	{"eth",	mt7629_ethernet_groups, ARRAY_SIZE(mt7629_ethernet_groups)},
@@ -376,6 +382,7 @@ static const struct mtk_function_desc mt7629_functions[] = {
 	{"watchdog", mt7629_wdt_groups, ARRAY_SIZE(mt7629_wdt_groups)},
 	{"wifi", mt7629_wifi_groups, ARRAY_SIZE(mt7629_wifi_groups)},
 	{"flash", mt7629_flash_groups, ARRAY_SIZE(mt7629_flash_groups)},
+	{"jtag", mt7629_jtag_groups, ARRAY_SIZE(mt7629_jtag_groups)},
 };
 
 static struct mtk_pinctrl_soc mt7629_data = {
Signature · 1 line
2.17.1
#2 lore raw

PATCH 1/4 pinctrl: mediatek: fix wrong assignment in mtk_get_pin_name

In reply to Weijie Gao
Quoted 6 lines · Weijie Gao

From: Sam Shih <[email protected]>

This is a bug fix for mtk pinctrl common part. Appearently pins should be used instead of grps in mtk_get_pin_name().

Applied to u-boot/next, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210320/53870e9a/attachment.sig>
#4 lore raw

PATCH 2/4 pinctrl: mediatek: add get_pin_muxing ops for mediatek pinctrl

In reply to Weijie Gao
Quoted 5 lines · Weijie Gao

From: Sam Shih <[email protected]>

This patch add get_pin_muxing support for mediatek pinctrl drivers

Applied to u-boot/next, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210320/a9c103ce/attachment.sig>
#6 lore raw

PATCH 3/4 pinctrl: mediatek: do not probe gpio driver if not enabled

In reply to Weijie Gao
Quoted 8 lines · Weijie Gao

The mtk pinctrl driver is a combination driver with support for both pinctrl and gpio. When this driver is used in SPL, gpio support may not be enabled, and this will result in a compilation error.

To fix this, macros are added to make sure gpio related code will only be compiled when gpio support is enabled.

Applied to u-boot/next, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210320/7060dfbf/attachment.sig>
#8 lore raw

PATCH 4/4 pinctrl: mt7629: add jtag function and pin group

In reply to Weijie Gao
Quoted 4 lines · Weijie Gao

The EPHY LEDs of mt7629 can be used as JTAG. This patch adds the jtag pin group to the pinctrl driver.

Applied to u-boot/next, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210320/51f2f5a6/attachment.sig>