Merge tag 'pinctrl-v5.11-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw...
[sfrench/cifs-2.6.git] / drivers / pinctrl / pinctrl-amd.c
index 899c16c17b6da4c0c7b42faff86d259603d2ddfe..2d4acf21117cc5ce4fbabab577bf0ded2f4ca35b 100644 (file)
@@ -197,10 +197,16 @@ static int amd_gpio_set_config(struct gpio_chip *gc, unsigned offset,
 static void amd_gpio_dbg_show(struct seq_file *s, struct gpio_chip *gc)
 {
        u32 pin_reg;
+       u32 db_cntrl;
        unsigned long flags;
        unsigned int bank, i, pin_num;
        struct amd_gpio *gpio_dev = gpiochip_get_data(gc);
 
+       bool tmr_out_unit;
+       unsigned int time;
+       unsigned int unit;
+       bool tmr_large;
+
        char *level_trig;
        char *active_level;
        char *interrupt_enable;
@@ -214,6 +220,8 @@ static void amd_gpio_dbg_show(struct seq_file *s, struct gpio_chip *gc)
        char *pull_down_enable;
        char *output_value;
        char *output_enable;
+       char debounce_value[40];
+       char *debounce_enable;
 
        for (bank = 0; bank < gpio_dev->hwbank_num; bank++) {
                seq_printf(s, "GPIO bank%d\t", bank);
@@ -327,13 +335,44 @@ static void amd_gpio_dbg_show(struct seq_file *s, struct gpio_chip *gc)
                                        pin_sts = "input is low|";
                        }
 
+                       db_cntrl = (DB_CNTRl_MASK << DB_CNTRL_OFF) & pin_reg;
+                       if (db_cntrl) {
+                               tmr_out_unit = pin_reg & BIT(DB_TMR_OUT_UNIT_OFF);
+                               tmr_large = pin_reg & BIT(DB_TMR_LARGE_OFF);
+                               time = pin_reg & DB_TMR_OUT_MASK;
+                               if (tmr_large) {
+                                       if (tmr_out_unit)
+                                               unit = 62500;
+                                       else
+                                               unit = 15625;
+                               } else {
+                                       if (tmr_out_unit)
+                                               unit = 244;
+                                       else
+                                               unit = 61;
+                               }
+                               if ((DB_TYPE_REMOVE_GLITCH << DB_CNTRL_OFF) == db_cntrl)
+                                       debounce_enable = "debouncing filter (high and low) enabled|";
+                               else if ((DB_TYPE_PRESERVE_LOW_GLITCH << DB_CNTRL_OFF) == db_cntrl)
+                                       debounce_enable = "debouncing filter (low) enabled|";
+                               else
+                                       debounce_enable = "debouncing filter (high) enabled|";
+
+                               snprintf(debounce_value, sizeof(debounce_value),
+                                        "debouncing timeout is %u (us)|", time * unit);
+                       } else {
+                               debounce_enable = "debouncing filter disabled|";
+                               snprintf(debounce_value, sizeof(debounce_value), " ");
+                       }
+
                        seq_printf(s, "%s %s %s %s %s %s\n"
-                               " %s %s %s %s %s %s %s 0x%x\n",
+                               " %s %s %s %s %s %s %s %s %s 0x%x\n",
                                level_trig, active_level, interrupt_enable,
                                interrupt_mask, wake_cntrl0, wake_cntrl1,
                                wake_cntrl2, pin_sts, pull_up_sel,
                                pull_up_enable, pull_down_enable,
-                               output_value, output_enable, pin_reg);
+                               output_value, output_enable,
+                               debounce_enable, debounce_value, pin_reg);
                }
        }
 }