Commit dcb5dbc3 authored by Dong Aisheng's avatar Dong Aisheng Committed by Linus Walleij

pinctrl: show pin name for pingroups in sysfs

Pin name is more useful to users.

After change, when cat pingroups in sysfs, it becomes:
root@freescale /sys/kernel/debug/pinctrl/20e0000.iomuxc$ cat pingroups
registered pin groups:
group: uart4grp-1
pin 219 (MX6Q_PAD_KEY_ROW0)
pin 218 (MX6Q_PAD_KEY_COL0)

group: usdhc4grp-1
pin 305 (MX6Q_PAD_SD4_CMD)
pin 306 (MX6Q_PAD_SD4_CLK)
pin 315 (MX6Q_PAD_SD4_DAT0)
pin 316 (MX6Q_PAD_SD4_DAT1)
pin 317 (MX6Q_PAD_SD4_DAT2)
pin 318 (MX6Q_PAD_SD4_DAT3)
pin 319 (MX6Q_PAD_SD4_DAT4)
pin 320 (MX6Q_PAD_SD4_DAT5)
pin 321 (MX6Q_PAD_SD4_DAT6)
pin 322 (MX6Q_PAD_SD4_DAT7)
Acked-by: default avatarStephen Warren <swarren@wwwdotorg.org>
Signed-off-by: default avatarDong Aisheng <dong.aisheng@linaro.org>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent d0bd8df5
...@@ -125,6 +125,25 @@ int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name) ...@@ -125,6 +125,25 @@ int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name)
return -EINVAL; return -EINVAL;
} }
/**
* pin_get_name_from_id() - look up a pin name from a pin id
* @pctldev: the pin control device to lookup the pin on
* @name: the name of the pin to look up
*/
const char *pin_get_name(struct pinctrl_dev *pctldev, const unsigned pin)
{
const struct pin_desc *desc;
desc = pin_desc_get(pctldev, pin);
if (desc == NULL) {
dev_err(pctldev->dev, "failed to get pin(%d) name\n",
pin);
return NULL;
}
return desc->name;
}
/** /**
* pin_is_valid() - check if pin exists on controller * pin_is_valid() - check if pin exists on controller
* @pctldev: the pin control device to check the pin on * @pctldev: the pin control device to check the pin on
...@@ -1011,6 +1030,7 @@ static int pinctrl_groups_show(struct seq_file *s, void *what) ...@@ -1011,6 +1030,7 @@ static int pinctrl_groups_show(struct seq_file *s, void *what)
const unsigned *pins; const unsigned *pins;
unsigned num_pins; unsigned num_pins;
const char *gname = ops->get_group_name(pctldev, selector); const char *gname = ops->get_group_name(pctldev, selector);
const char *pname;
int ret; int ret;
int i; int i;
...@@ -1020,10 +1040,14 @@ static int pinctrl_groups_show(struct seq_file *s, void *what) ...@@ -1020,10 +1040,14 @@ static int pinctrl_groups_show(struct seq_file *s, void *what)
seq_printf(s, "%s [ERROR GETTING PINS]\n", seq_printf(s, "%s [ERROR GETTING PINS]\n",
gname); gname);
else { else {
seq_printf(s, "group: %s, pins = [ ", gname); seq_printf(s, "group: %s\n", gname);
for (i = 0; i < num_pins; i++) for (i = 0; i < num_pins; i++) {
seq_printf(s, "%d ", pins[i]); pname = pin_get_name(pctldev, pins[i]);
seq_puts(s, "]\n"); if (WARN_ON(!pname))
return -EINVAL;
seq_printf(s, "pin %d (%s)\n", pins[i], pname);
}
seq_puts(s, "\n");
} }
selector++; selector++;
} }
......
...@@ -148,6 +148,7 @@ struct pin_desc { ...@@ -148,6 +148,7 @@ struct pin_desc {
struct pinctrl_dev *get_pinctrl_dev_from_devname(const char *dev_name); struct pinctrl_dev *get_pinctrl_dev_from_devname(const char *dev_name);
int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name); int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name);
const char *pin_get_name(struct pinctrl_dev *pctldev, const unsigned pin);
int pinctrl_get_group_selector(struct pinctrl_dev *pctldev, int pinctrl_get_group_selector(struct pinctrl_dev *pctldev,
const char *pin_group); const char *pin_group);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment