Commit 75358cf3 authored by Mario Limonciello's avatar Mario Limonciello Committed by Linus Walleij
Browse files

pinctrl: amd: Adjust debugfs output



More fields are to be added, so to keep the display from being
too busy, adjust it.

1) Add a header to all columns
2) Except for interrupt, when fields have no data show empty
3) Remove otherwise blank whitespace

Signed-off-by: default avatarMario Limonciello <mario.limonciello@amd.com>
Link: https://lore.kernel.org/r/20230328174231.8924-2-mario.limonciello@amd.com


Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent c4582907
Loading
Loading
Loading
Loading
+30 −46
Original line number Diff line number Diff line
@@ -206,15 +206,12 @@ static void amd_gpio_dbg_show(struct seq_file *s, struct gpio_chip *gc)

	char *level_trig;
	char *active_level;
	char *interrupt_enable;
	char *interrupt_mask;
	char *wake_cntrl0;
	char *wake_cntrl1;
	char *wake_cntrl2;
	char *pin_sts;
	char *pull_up_sel;
	char *pull_up_enable;
	char *pull_down_enable;
	char *orientation;
	char debounce_value[40];
	char *debounce_enable;
@@ -246,6 +243,7 @@ static void amd_gpio_dbg_show(struct seq_file *s, struct gpio_chip *gc)
			continue;
		}
		seq_printf(s, "GPIO bank%d\n", bank);
		seq_puts(s, "gpio\tint|active|trigger|S0i3| S3|S4/S5| Z|wake|pull|  orient|       debounce|reg\n");
		for (; i < pin_num; i++) {
			seq_printf(s, "#%d\t", i);
			raw_spin_lock_irqsave(&gpio_dev->lock, flags);
@@ -255,7 +253,6 @@ static void amd_gpio_dbg_show(struct seq_file *s, struct gpio_chip *gc)
			if (pin_reg & BIT(INTERRUPT_ENABLE_OFF)) {
				u8 level = (pin_reg >> ACTIVE_LEVEL_OFF) &
						ACTIVE_LEVEL_MASK;
				interrupt_enable = "+";

				if (level == ACTIVE_LEVEL_HIGH)
					active_level = "↑";
@@ -272,65 +269,54 @@ static void amd_gpio_dbg_show(struct seq_file *s, struct gpio_chip *gc)
				else
					level_trig = " edge";

			} else {
				interrupt_enable = "∅";
				active_level = "∅";
				level_trig = "    ∅";
			}

				if (pin_reg & BIT(INTERRUPT_MASK_OFF))
					interrupt_mask = "😛";
				else
					interrupt_mask = "😷";
			seq_printf(s, "int %s (%s)| active-%s| %s-⚡| ",
				   interrupt_enable,

				seq_printf(s, "%s|     %s|  %s|",
				   interrupt_mask,
				   active_level,
				   level_trig);
			} else
				seq_puts(s, "  ∅|      |       |");

			if (pin_reg & BIT(WAKE_CNTRL_OFF_S0I3))
				wake_cntrl0 = "⏰";
			else
				wake_cntrl0 = " ";
			seq_printf(s, "S0i3 %s| ", wake_cntrl0);
				wake_cntrl0 = "  ";
			seq_printf(s, "  %s| ", wake_cntrl0);

			if (pin_reg & BIT(WAKE_CNTRL_OFF_S3))
				wake_cntrl1 = "⏰";
			else
				wake_cntrl1 = " ";
			seq_printf(s, "S3 %s| ", wake_cntrl1);
				wake_cntrl1 = "  ";
			seq_printf(s, "%s|", wake_cntrl1);

			if (pin_reg & BIT(WAKE_CNTRL_OFF_S4))
				wake_cntrl2 = "⏰";
			else
				wake_cntrl2 = " ";
			seq_printf(s, "S4/S5 %s| ", wake_cntrl2);
				wake_cntrl2 = "  ";
			seq_printf(s, "   %s|", wake_cntrl2);

			if (pin_reg & BIT(WAKECNTRL_Z_OFF))
				wake_cntrlz = "⏰";
			else
				wake_cntrlz = " ";
			seq_printf(s, "Z %s| ", wake_cntrlz);
				wake_cntrlz = "  ";
			seq_printf(s, "%s|", wake_cntrlz);

			if (pin_reg & BIT(PULL_UP_ENABLE_OFF)) {
				pull_up_enable = "+";
				if (pin_reg & BIT(PULL_UP_SEL_OFF))
					pull_up_sel = "8k";
				else
					pull_up_sel = "4k";
				seq_printf(s, "%s ↑|",
					   pull_up_sel);
			} else if (pin_reg & BIT(PULL_DOWN_ENABLE_OFF)) {
				seq_puts(s, "   ↓|");
			} else  {
				pull_up_enable = "∅";
				pull_up_sel = "  ";
				seq_puts(s, "    |");
			}
			seq_printf(s, "pull-↑ %s (%s)| ",
				   pull_up_enable,
				   pull_up_sel);

			if (pin_reg & BIT(PULL_DOWN_ENABLE_OFF))
				pull_down_enable = "+";
			else
				pull_down_enable = "∅";
			seq_printf(s, "pull-↓ %s| ", pull_down_enable);

			if (pin_reg & BIT(OUTPUT_ENABLE_OFF)) {
				pin_sts = "output";
@@ -364,18 +350,16 @@ static void amd_gpio_dbg_show(struct seq_file *s, struct gpio_chip *gc)
						unit = 61;
				}
				if ((DB_TYPE_REMOVE_GLITCH << DB_CNTRL_OFF) == db_cntrl)
					debounce_enable = "b +";
					debounce_enable = "b";
				else if ((DB_TYPE_PRESERVE_LOW_GLITCH << DB_CNTRL_OFF) == db_cntrl)
					debounce_enable = "↓ +";
					debounce_enable = "↓";
				else
					debounce_enable = "↑ +";

					debounce_enable = "↑";
				snprintf(debounce_value, sizeof(debounce_value), "%06u", time * unit);
				seq_printf(s, "%s (🕑 %sus)|", debounce_enable, debounce_value);
			} else {
				debounce_enable = "  ∅";
				time = 0;
				seq_puts(s, "               |");
			}
			snprintf(debounce_value, sizeof(debounce_value), "%u", time * unit);
			seq_printf(s, "debounce %s (🕑 %sus)| ", debounce_enable, debounce_value);
			seq_printf(s, "0x%x\n", pin_reg);
		}
	}