Skip to content

Commit 8f1774a

Browse files
author
Linus Walleij
committed
pinctrl: nomadik: improve GPIO debug prints
The debugfs file would only define if the line was "pulled" and not which direction (pull up or pull down). Improve this by taking two print paths depending on whether the pin is set as input or output and use the data register directly to figure out whether the pin is set for pull up or pull down. Signed-off-by: Linus Walleij <[email protected]>
1 parent 259145f commit 8f1774a

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

drivers/pinctrl/nomadik/pinctrl-nomadik.c

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,7 @@ static void nmk_gpio_dbg_show_one(struct seq_file *s,
986986
container_of(chip, struct nmk_gpio_chip, chip);
987987
int mode;
988988
bool is_out;
989+
bool data_out;
989990
bool pull;
990991
u32 bit = 1 << offset;
991992
const char *modes[] = {
@@ -998,28 +999,41 @@ static void nmk_gpio_dbg_show_one(struct seq_file *s,
998999
[NMK_GPIO_ALT_C+3] = "altC3",
9991000
[NMK_GPIO_ALT_C+4] = "altC4",
10001001
};
1002+
const char *pulls[] = {
1003+
"none ",
1004+
"pull down",
1005+
"pull up ",
1006+
};
10011007

10021008
clk_enable(nmk_chip->clk);
10031009
is_out = !!(readl(nmk_chip->addr + NMK_GPIO_DIR) & bit);
10041010
pull = !(readl(nmk_chip->addr + NMK_GPIO_PDIS) & bit);
1011+
data_out = !!(readl(nmk_chip->addr + NMK_GPIO_DAT) & bit);
10051012
mode = nmk_gpio_get_mode(gpio);
10061013
if ((mode == NMK_GPIO_ALT_C) && pctldev)
10071014
mode = nmk_prcm_gpiocr_get_mode(pctldev, gpio);
10081015

1009-
seq_printf(s, " gpio-%-3d (%-20.20s) %s %s %s %s",
1010-
gpio, label ?: "(none)",
1011-
is_out ? "out" : "in ",
1012-
chip->get
1013-
? (chip->get(chip, offset) ? "hi" : "lo")
1014-
: "? ",
1015-
(mode < 0) ? "unknown" : modes[mode],
1016-
pull ? "pull" : "none");
1017-
1018-
if (!is_out) {
1016+
if (is_out) {
1017+
seq_printf(s, " gpio-%-3d (%-20.20s) out %s %s",
1018+
gpio,
1019+
label ?: "(none)",
1020+
data_out ? "hi" : "lo",
1021+
(mode < 0) ? "unknown" : modes[mode]);
1022+
} else {
10191023
int irq = gpio_to_irq(gpio);
10201024
struct irq_desc *desc = irq_to_desc(irq);
1025+
int pullidx = 0;
10211026

1022-
/* This races with request_irq(), set_irq_type(),
1027+
if (pull)
1028+
pullidx = data_out ? 1 : 2;
1029+
1030+
seq_printf(s, " gpio-%-3d (%-20.20s) in %s %s",
1031+
gpio,
1032+
label ?: "(none)",
1033+
pulls[pullidx],
1034+
(mode < 0) ? "unknown" : modes[mode]);
1035+
/*
1036+
* This races with request_irq(), set_irq_type(),
10231037
* and set_irq_wake() ... but those are "rare".
10241038
*/
10251039
if (irq > 0 && desc && desc->action) {

0 commit comments

Comments
 (0)