Skip to contentSkip to conversation

pinctrl: meson: add support for pinmux status

PATCH New Neil Armstrong 2 participants 7 messages Jun 4, 2019 – Jun 5, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover pinctrl: meson: add support for pinmux status

In order to support the "pinmux status" command, fix the GX pinctrl drivers and add the necessary functions callbacks.

Neil Armstrong (4):
pinctrl: meson-gx: fix GPIO_TEST_N and GPIOCLK_ groups
pinctrl: meson: add common function to get pins name
pinctrl: meson-gx: add support for getting pinmux status
pinctrl: meson-axg: add support for getting pinmux status

 drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c | 48 +++++++++++++++++++
 drivers/pinctrl/meson/pinctrl-meson-gx-pmx.c  | 44 +++++++++++++++++
 drivers/pinctrl/meson/pinctrl-meson-gxbb.c    |  7 ++-
 drivers/pinctrl/meson/pinctrl-meson-gxl.c     |  6 ++-
 drivers/pinctrl/meson/pinctrl-meson.c         | 24 ++++++++++
 drivers/pinctrl/meson/pinctrl-meson.h         |  3 ++
 6 files changed, 128 insertions(+), 4 deletions(-)
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/4 pinctrl: meson-gx: fix GPIO_TEST_N and GPIOCLK_ groups

The GPIO_TEST_N was in the wrong pmx group table, move it back with the AO groups, GPIODV_18 was missing, add it back, and finally the GPIOCLK_* group names were missing.

---
 drivers/pinctrl/meson/pinctrl-meson-gxbb.c | 7 +++++--
 drivers/pinctrl/meson/pinctrl-meson-gxl.c  | 6 ++++--
 2 files changed, 9 insertions(+), 4 deletions(-)
drivers/pinctrl/meson/pinctrl-meson-gxbb.c +5 -2
index 22e8b055d7..59b5be6211 100644
@@ -144,6 +144,7 @@ static struct meson_pmx_group meson_gxbb_periphs_groups[] = {
 	GPIO_GROUP(GPIODV_15, EE_OFF),
 	GPIO_GROUP(GPIODV_16, EE_OFF),
 	GPIO_GROUP(GPIODV_17, EE_OFF),
+	GPIO_GROUP(GPIODV_18, EE_OFF),
 	GPIO_GROUP(GPIODV_19, EE_OFF),
 	GPIO_GROUP(GPIODV_20, EE_OFF),
 	GPIO_GROUP(GPIODV_21, EE_OFF),
@@ -203,8 +204,6 @@ static struct meson_pmx_group meson_gxbb_periphs_groups[] = {
 	GPIO_GROUP(GPIOCLK_2, EE_OFF),
 	GPIO_GROUP(GPIOCLK_3, EE_OFF),
 
-	GPIO_GROUP(GPIO_TEST_N, EE_OFF),
-
 	/* Bank X */
 	GROUP(uart_tx_a,	4,	13),
 	GROUP(uart_rx_a,	4,	12),
@@ -270,6 +269,8 @@ static struct meson_pmx_group meson_gxbb_aobus_groups[] = {
 	GPIO_GROUP(GPIOAO_12, 0),
 	GPIO_GROUP(GPIOAO_13, 0),
 
+	GPIO_GROUP(GPIO_TEST_N, 0),
+
 	/* bank AO */
 	GROUP(uart_tx_ao_b,	0,	26),
 	GROUP(uart_rx_ao_b,	0,	25),
@@ -318,6 +319,8 @@ static const char * const gpio_periphs_groups[] = {
 	"GPIOX_10", "GPIOX_11", "GPIOX_12", "GPIOX_13", "GPIOX_14",
 	"GPIOX_15", "GPIOX_16", "GPIOX_17", "GPIOX_18", "GPIOX_19",
 	"GPIOX_20", "GPIOX_21", "GPIOX_22",
+
+	"GPIOCLK_0", "GPIOCLK_1", "GPIOCLK_2", "GPIOCLK_3",
 };
 
 static const char * const emmc_groups[] = {
drivers/pinctrl/meson/pinctrl-meson-gxl.c +4 -2
index 1819eee4d0..5acc21b9c2 100644
@@ -254,6 +254,7 @@ static struct meson_pmx_group meson_gxl_periphs_groups[] = {
 	GPIO_GROUP(GPIODV_15, EE_OFF),
 	GPIO_GROUP(GPIODV_16, EE_OFF),
 	GPIO_GROUP(GPIODV_17, EE_OFF),
+	GPIO_GROUP(GPIODV_18, EE_OFF),
 	GPIO_GROUP(GPIODV_19, EE_OFF),
 	GPIO_GROUP(GPIODV_20, EE_OFF),
 	GPIO_GROUP(GPIODV_21, EE_OFF),
@@ -289,8 +290,6 @@ static struct meson_pmx_group meson_gxl_periphs_groups[] = {
 	GPIO_GROUP(GPIOCLK_0, EE_OFF),
 	GPIO_GROUP(GPIOCLK_1, EE_OFF),
 
-	GPIO_GROUP(GPIO_TEST_N, 0),
-
 	/* Bank X */
 	GROUP(sdio_d0,		5,	31),
 	GROUP(sdio_d1,		5,	30),
@@ -415,6 +414,8 @@ static struct meson_pmx_group meson_gxl_aobus_groups[] = {
 	GPIO_GROUP(GPIOAO_8, 0),
 	GPIO_GROUP(GPIOAO_9, 0),
 
+	GPIO_GROUP(GPIO_TEST_N, 0),
+
 	/* bank AO */
 	GROUP(uart_tx_ao_b_0,	0,	26),
 	GROUP(uart_rx_ao_b_1,	0,	25),
@@ -471,6 +472,7 @@ static const char * const gpio_periphs_groups[] = {
 	"GPIOX_5", "GPIOX_6", "GPIOX_7", "GPIOX_8", "GPIOX_9",
 	"GPIOX_10", "GPIOX_11", "GPIOX_12", "GPIOX_13", "GPIOX_14",
 	"GPIOX_15", "GPIOX_16", "GPIOX_17", "GPIOX_18",
+	"GPIOCLK_0", "GPIOCLK_1",
 };
 
 static const char * const emmc_groups[] = {
Signature · 1 line
2.21.0
#2 lore raw

PATCH 2/4 pinctrl: meson: add common function to get pins name

In reply to Neil Armstrong

In order to support the "pinmux status" command, add common function to get pins count and pin name.

---
 drivers/pinctrl/meson/pinctrl-meson.c | 24 ++++++++++++++++++++++++
 drivers/pinctrl/meson/pinctrl-meson.h |  3 +++
 2 files changed, 27 insertions(+)
drivers/pinctrl/meson/pinctrl-meson.c +24 -0
index 8735418c5b..eb40a84ed1 100644
@@ -20,6 +20,8 @@ DECLARE_GLOBAL_DATA_PTR;
 
 static const char *meson_pinctrl_dummy_name = "_dummy";
 
+static char pin_name[PINNAME_SIZE];
+
 int meson_pinctrl_get_groups_count(struct udevice *dev)
 {
 	struct meson_pinctrl *priv = dev_get_priv(dev);
@@ -38,6 +40,28 @@ const char *meson_pinctrl_get_group_name(struct udevice *dev,
 	return priv->data->groups[selector].name;
 }
 
+int meson_pinctrl_get_pins_count(struct udevice *dev)
+{
+	struct meson_pinctrl *priv = dev_get_priv(dev);
+
+	return priv->data->num_pins;
+}
+
+const char *meson_pinctrl_get_pin_name(struct udevice *dev,
+				       unsigned int selector)
+{
+	struct meson_pinctrl *priv = dev_get_priv(dev);
+
+	if (selector > priv->data->num_pins ||
+	    selector > priv->data->funcs[0].num_groups)
+		snprintf(pin_name, PINNAME_SIZE, "Error");
+	else
+		snprintf(pin_name, PINNAME_SIZE, "%s",
+			 priv->data->funcs[0].groups[selector]);
+
+	return pin_name;
+}
+
 int meson_pinmux_get_functions_count(struct udevice *dev)
 {
 	struct meson_pinctrl *priv = dev_get_priv(dev);
drivers/pinctrl/meson/pinctrl-meson.h +3 -0
index b3683e2073..0882dfe713 100644
@@ -120,6 +120,9 @@ extern const struct pinctrl_ops meson_pinctrl_ops;
 int meson_pinctrl_get_groups_count(struct udevice *dev);
 const char *meson_pinctrl_get_group_name(struct udevice *dev,
 					 unsigned int selector);
+int meson_pinctrl_get_pins_count(struct udevice *dev);
+const char *meson_pinctrl_get_pin_name(struct udevice *dev,
+				       unsigned int selector);
 int meson_pinmux_get_functions_count(struct udevice *dev);
 const char *meson_pinmux_get_function_name(struct udevice *dev,
 					   unsigned int selector);
Signature · 1 line
2.21.0
#3 lore raw

PATCH 3/4 pinctrl: meson-gx: add support for getting pinmux status

In reply to Neil Armstrong

In order to support the "pinmux status" command, use the common functions to get the pins count and names, and add the GX specific function to get the current function from registers.

---
 drivers/pinctrl/meson/pinctrl-meson-gx-pmx.c | 44 ++++++++++++++++++++
 1 file changed, 44 insertions(+)
drivers/pinctrl/meson/pinctrl-meson-gx-pmx.c +44 -0
index cf72576b6c..b37b517fe5 100644
@@ -72,6 +72,47 @@ static int meson_gx_pinmux_group_set(struct udevice *dev,
 	return 0;
 }
 
+static int meson_gx_pinmux_get(struct udevice *dev,
+				      unsigned int selector,
+				      char *buf, int size)
+{
+	struct meson_pinctrl *priv = dev_get_priv(dev);
+	struct meson_pmx_group *group;
+	struct meson_gx_pmx_data *pmx_data;
+	void __iomem *addr;
+	int i, j, pos = 0;
+	unsigned int pin;
+	u32 reg;
+
+	pin = selector + priv->data->pin_base;
+
+	for (i = 0; i < priv->data->num_groups; i++) {
+		group = &priv->data->groups[i];
+		pmx_data = (struct meson_gx_pmx_data *)group->data;
+		if (pmx_data->is_gpio)
+			continue;
+
+		for (j = 0; j < group->num_pins; j++) {
+			if (group->pins[j] == pin) {
+				/* We have found a group using the pin */
+				addr = priv->reg_mux + pmx_data->reg * 4;
+				reg = readl(addr) & BIT(pmx_data->bit);
+				if (reg) {
+					pos += snprintf(buf + pos, size - pos,
+							"%s ", group->name) - 1;
+					return 0;
+				}
+			}
+		}
+	}
+
+	/* Fallback, must be used as GPIO */
+	snprintf(buf, size, "%s or Unknown",
+		 priv->data->groups[selector].name);
+
+	return 0;
+}
+
 const struct pinconf_param meson_gx_pinconf_params[] = {
 	{ "bias-disable", PIN_CONFIG_BIAS_DISABLE, 0 },
 	{ "bias-pull-up", PIN_CONFIG_BIAS_PULL_UP, 1 },
@@ -89,6 +130,9 @@ const struct pinctrl_ops meson_gx_pinctrl_ops = {
 	.pinconf_num_params = ARRAY_SIZE(meson_gx_pinconf_params),
 	.pinconf_set = meson_pinconf_set,
 	.pinconf_group_set = meson_pinconf_group_set,
+	.get_pin_name = meson_pinctrl_get_pin_name,
+	.get_pins_count = meson_pinctrl_get_pins_count,
+	.get_pin_muxing	= meson_gx_pinmux_get,
 };
 
 static const struct dm_gpio_ops meson_gx_gpio_ops = {
Signature · 1 line
2.21.0
#4 lore raw

PATCH 3/4 pinctrl: meson-gx: add support for getting pinmux status

Quoted 63 lines · Neil Armstrong

In order to support the "pinmux status" command, use the common functions to get the pins count and names, and add the GX specific function to get the current function from registers.

---
  drivers/pinctrl/meson/pinctrl-meson-gx-pmx.c | 44 ++++++++++++++++++++
  1 file changed, 44 insertions(+)
drivers/pinctrl/meson/pinctrl-meson-gx-pmx.c +41 -0
index cf72576b6c..b37b517fe5 100644
@@ -72,6 +72,47 @@ static int meson_gx_pinmux_group_set(struct udevice *dev,
  	return 0;
  }
 
+static int meson_gx_pinmux_get(struct udevice *dev,
+				      unsigned int selector,
+				      char *buf, int size)
+{
+	struct meson_pinctrl *priv = dev_get_priv(dev);
+	struct meson_pmx_group *group;
+	struct meson_gx_pmx_data *pmx_data;
+	void __iomem *addr;
+	int i, j, pos = 0;
+	unsigned int pin;
+	u32 reg;
+
+	pin = selector + priv->data->pin_base;
+
+	for (i = 0; i < priv->data->num_groups; i++) {
+		group = &priv->data->groups[i];
+		pmx_data = (struct meson_gx_pmx_data *)group->data;
+		if (pmx_data->is_gpio)
+			continue;
+
+		for (j = 0; j < group->num_pins; j++) {
+			if (group->pins[j] == pin) {
+				/* We have found a group using the pin */
+				addr = priv->reg_mux + pmx_data->reg * 4;
+				reg = readl(addr) & BIT(pmx_data->bit);
+				if (reg) {
+					pos += snprintf(buf + pos, size - pos,
+							"%s ", group->name) - 1;
+					return 0;
+				}
+			}
+		}
+	}
+
+	/* Fallback, must be used as GPIO */
+	snprintf(buf, size, "%s or Unknown",
+		 priv->data->groups[selector].name);
+
+	return 0;
+}
+
  const struct pinconf_param meson_gx_pinconf_params[] = {
  	{ "bias-disable", PIN_CONFIG_BIAS_DISABLE, 0 },
  	{ "bias-pull-up", PIN_CONFIG_BIAS_PULL_UP, 1 },

drivers/pinctrl/meson/pinctrl-meson-gx-pmx.c const struct pinctrl_ops meson_gx_pinctrl_ops = { · line 138

Quoted 9 lines
drivers/pinctrl/meson/pinctrl-meson-gx-pmx.c +3 -0
@@ -89,6 +130,9 @@ const struct pinctrl_ops meson_gx_pinctrl_ops = {
  	.pinconf_num_params = ARRAY_SIZE(meson_gx_pinconf_params),
  	.pinconf_set = meson_pinconf_set,
  	.pinconf_group_set = meson_pinconf_group_set,
+	.get_pin_name = meson_pinctrl_get_pin_name,
+	.get_pins_count = meson_pinctrl_get_pins_count,
+	.get_pin_muxing	= meson_gx_pinmux_get,
  };
 
  static const struct dm_gpio_ops meson_gx_gpio_ops = {

Tested on a ODROID-C2 (gxbb) using the command 'pinmux status -a'

#5 lore raw

PATCH 4/4 pinctrl: meson-axg: add support for getting pinmux status

In reply to Neil Armstrong

In order to support the "pinmux status" command, use the common functions to get the pins count and names, and add the AXG specific function to get the current function from registers.

---
 drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c | 48 +++++++++++++++++++
 1 file changed, 48 insertions(+)
drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c +48 -0
index f23b188f2f..10b070ea06 100644
@@ -93,6 +93,51 @@ static int meson_axg_pinmux_group_set(struct udevice *dev,
 	return 0;
 }
 
+static int meson_axg_pinmux_get(struct udevice *dev, unsigned int selector,
+				char *buf, int size)
+{
+	struct meson_pinctrl *priv = dev_get_priv(dev);
+	struct meson_pmx_axg_data *pmx_data;
+	struct meson_pmx_group *group;
+	struct meson_pmx_bank *bank;
+	unsigned int offset;
+	unsigned int func;
+	unsigned int reg;
+	int ret, i, j;
+
+	selector += priv->data->pin_base;
+
+	ret = meson_axg_pmx_get_bank(dev, selector, &bank);
+	if (ret) {
+		snprintf(buf, size, "Unhandled");
+		return 0;
+	}
+
+	meson_axg_pmx_calc_reg_and_offset(bank, selector, &reg, &offset);
+
+	func = (readl(priv->reg_mux + (reg << 2)) >> offset) & 0xf;
+
+	for (i = 0; i < priv->data->num_groups; i++) {
+		group = &priv->data->groups[i];
+		pmx_data = (struct meson_pmx_axg_data *)group->data;
+
+		if (pmx_data->func != func)
+			continue;
+
+		for (j = 0; j < group->num_pins; j++) {
+			if (group->pins[j] == selector) {
+				snprintf(buf, size, "%s (%x)",
+					 group->name, func);
+				return 0;
+			}
+		}
+	}
+
+	snprintf(buf, size, "Unknown (%x)", func);
+
+	return 0;
+}
+
 const struct pinconf_param meson_axg_pinconf_params[] = {
 	{ "bias-disable", PIN_CONFIG_BIAS_DISABLE, 0 },
 	{ "bias-pull-up", PIN_CONFIG_BIAS_PULL_UP, 1 },
@@ -110,6 +155,9 @@ const struct pinctrl_ops meson_axg_pinctrl_ops = {
 	.pinconf_num_params = ARRAY_SIZE(meson_axg_pinconf_params),
 	.pinconf_set = meson_pinconf_set,
 	.pinconf_group_set = meson_pinconf_group_set,
+	.get_pin_name = meson_pinctrl_get_pin_name,
+	.get_pins_count = meson_pinctrl_get_pins_count,
+	.get_pin_muxing	= meson_axg_pinmux_get,
 };
 
 static int meson_axg_gpio_request(struct udevice *dev,
Signature · 1 line
2.21.0
#6 lore raw

cover pinctrl: meson: add support for pinmux status

In reply to Neil Armstrong
Quoted 9 lines · Neil Armstrong

In order to support the "pinmux status" command, fix the GX pinctrl drivers and add the necessary functions callbacks.

Neil Armstrong (4):
pinctrl: meson-gx: fix GPIO_TEST_N and GPIOCLK_ groups
pinctrl: meson: add common function to get pins name
pinctrl: meson-gx: add support for getting pinmux status
pinctrl: meson-axg: add support for getting pinmux status

Quoted 8 lines
 drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c | 48 +++++++++++++++++++
 drivers/pinctrl/meson/pinctrl-meson-gx-pmx.c  | 44 +++++++++++++++++
 drivers/pinctrl/meson/pinctrl-meson-gxbb.c    |  7 ++-
 drivers/pinctrl/meson/pinctrl-meson-gxl.c     |  6 ++-
 drivers/pinctrl/meson/pinctrl-meson.c         | 24 ++++++++++
 drivers/pinctrl/meson/pinctrl-meson.h         |  3 ++
 6 files changed, 128 insertions(+), 4 deletions(-)

Applied to u-boot-amlogic