diff mbox

[v1,3/3] pinctrl: baytrail: Add debounce to debug output

Message ID 20170126172409.132136-4-andriy.shevchenko@linux.intel.com
State New
Headers show

Commit Message

Andy Shevchenko Jan. 26, 2017, 5:24 p.m. UTC
When debug pin configuration is printed out debounce setting is missed.
Add it here.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pinctrl/intel/pinctrl-baytrail.c | 46 ++++++++++++++++++++++++++++++--
 1 file changed, 44 insertions(+), 2 deletions(-)

Comments

Mika Westerberg Jan. 27, 2017, 9:40 a.m. UTC | #1
On Thu, Jan 26, 2017 at 07:24:09PM +0200, Andy Shevchenko wrote:
> When debug pin configuration is printed out debounce setting is missed.
> Add it here.

That information is already made available in pinctrl debugfs files so I
don't see any reason to duplicate it.
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jean Delvare Jan. 27, 2017, 10:07 a.m. UTC | #2
Hi Andy,

On Thu, 26 Jan 2017 19:24:09 +0200, Andy Shevchenko wrote:
> When debug pin configuration is printed out debounce setting is missed.
> Add it here.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/pinctrl/intel/pinctrl-baytrail.c | 46 ++++++++++++++++++++++++++++++--
>  1 file changed, 44 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c
> index a1f85a79f186..6bdb6e5879f8 100644
> --- a/drivers/pinctrl/intel/pinctrl-baytrail.c
> +++ b/drivers/pinctrl/intel/pinctrl-baytrail.c
> @@ -1391,11 +1391,12 @@ static int byt_gpio_direction_output(struct gpio_chip *chip,
>  static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
>  {
>  	struct byt_gpio *vg = gpiochip_get_data(chip);
> +	u32 conf0, debounce, val;
>  	int i;
> -	u32 conf0, val;
>  
>  	for (i = 0; i < vg->soc_data->npins; i++) {
>  		const struct byt_community *comm;
> +		const char *db_str = NULL;
>  		const char *pull_str = NULL;
>  		const char *pull = NULL;
>  		void __iomem *reg;
> @@ -1415,6 +1416,16 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
>  		}
>  		conf0 = readl(reg);
>  
> +		reg = byt_gpio_reg(vg, pin, BYT_DEBOUNCE_REG);
> +		if (!reg) {
> +			seq_printf(s,
> +				   "Could not retrieve pin %i debounce reg\n",
> +				   pin);
> +			raw_spin_unlock_irqrestore(&vg->lock, flags);
> +			continue;
> +		}
> +		debounce = readl(reg);
> +
>  		reg = byt_gpio_reg(vg, pin, BYT_VAL_REG);
>  		if (!reg) {
>  			seq_printf(s,
> @@ -1459,6 +1470,32 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
>  			break;
>  		}
>  
> +		if (conf0 & BYT_DEBOUNCE_EN) {
> +			switch (debounce & BYT_DEBOUNCE_PULSE_MASK) {
> +			case BYT_DEBOUNCE_PULSE_375US:
> +				db_str = "375us";
> +				break;
> +			case BYT_DEBOUNCE_PULSE_750US:
> +				db_str = "750us";
> +				break;
> +			case BYT_DEBOUNCE_PULSE_1500US:
> +				db_str = "1500us";
> +				break;
> +			case BYT_DEBOUNCE_PULSE_3MS:
> +				db_str = "3ms";
> +				break;
> +			case BYT_DEBOUNCE_PULSE_6MS:
> +				db_str = "6ms";
> +				break;
> +			case BYT_DEBOUNCE_PULSE_12MS:
> +				db_str = "12ms";
> +				break;
> +			case BYT_DEBOUNCE_PULSE_24MS:
> +				db_str = "24ms";
> +				break;
> +			}
> +		}
> +
>  		seq_printf(s,
>  			   " gpio-%-3d (%-20.20s) %s %s %s pad-%-3d offset:0x%03x mux:%d %s%s%s",
>  			   pin,
> @@ -1475,7 +1512,12 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
>  		if (pull && pull_str)
>  			seq_printf(s, " %-4s %-3s", pull, pull_str);
>  		else
> -			seq_puts(s, "          ");
> +			seq_puts(s, "         ");
> +
> +		if (db_str)
> +			seq_printf(s, " %-6s", db_str);
> +		else
> +			seq_puts(s, "        ");

Isn't that one space too many?

>  
>  		if (conf0 & BYT_IODEN)
>  			seq_puts(s, " open-drain");

Looks good to me.

Reviewed-by: Jean Delvare <jdelvare@suse.de>
Linus Walleij Jan. 30, 2017, 2:51 p.m. UTC | #3
On Thu, Jan 26, 2017 at 6:24 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> When debug pin configuration is printed out debounce setting is missed.
> Add it here.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

I have dropped this patch for now due to Mika's skepticism.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andy Shevchenko Jan. 30, 2017, 3:13 p.m. UTC | #4
On Mon, 2017-01-30 at 15:51 +0100, Linus Walleij wrote:
> On Thu, Jan 26, 2017 at 6:24 PM, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> 
> > When debug pin configuration is printed out debounce setting is
> > missed.
> > Add it here.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> I have dropped this patch for now due to Mika's skepticism.

Thank you, that what I was expecting.
diff mbox

Patch

diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c
index a1f85a79f186..6bdb6e5879f8 100644
--- a/drivers/pinctrl/intel/pinctrl-baytrail.c
+++ b/drivers/pinctrl/intel/pinctrl-baytrail.c
@@ -1391,11 +1391,12 @@  static int byt_gpio_direction_output(struct gpio_chip *chip,
 static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
 {
 	struct byt_gpio *vg = gpiochip_get_data(chip);
+	u32 conf0, debounce, val;
 	int i;
-	u32 conf0, val;
 
 	for (i = 0; i < vg->soc_data->npins; i++) {
 		const struct byt_community *comm;
+		const char *db_str = NULL;
 		const char *pull_str = NULL;
 		const char *pull = NULL;
 		void __iomem *reg;
@@ -1415,6 +1416,16 @@  static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
 		}
 		conf0 = readl(reg);
 
+		reg = byt_gpio_reg(vg, pin, BYT_DEBOUNCE_REG);
+		if (!reg) {
+			seq_printf(s,
+				   "Could not retrieve pin %i debounce reg\n",
+				   pin);
+			raw_spin_unlock_irqrestore(&vg->lock, flags);
+			continue;
+		}
+		debounce = readl(reg);
+
 		reg = byt_gpio_reg(vg, pin, BYT_VAL_REG);
 		if (!reg) {
 			seq_printf(s,
@@ -1459,6 +1470,32 @@  static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
 			break;
 		}
 
+		if (conf0 & BYT_DEBOUNCE_EN) {
+			switch (debounce & BYT_DEBOUNCE_PULSE_MASK) {
+			case BYT_DEBOUNCE_PULSE_375US:
+				db_str = "375us";
+				break;
+			case BYT_DEBOUNCE_PULSE_750US:
+				db_str = "750us";
+				break;
+			case BYT_DEBOUNCE_PULSE_1500US:
+				db_str = "1500us";
+				break;
+			case BYT_DEBOUNCE_PULSE_3MS:
+				db_str = "3ms";
+				break;
+			case BYT_DEBOUNCE_PULSE_6MS:
+				db_str = "6ms";
+				break;
+			case BYT_DEBOUNCE_PULSE_12MS:
+				db_str = "12ms";
+				break;
+			case BYT_DEBOUNCE_PULSE_24MS:
+				db_str = "24ms";
+				break;
+			}
+		}
+
 		seq_printf(s,
 			   " gpio-%-3d (%-20.20s) %s %s %s pad-%-3d offset:0x%03x mux:%d %s%s%s",
 			   pin,
@@ -1475,7 +1512,12 @@  static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
 		if (pull && pull_str)
 			seq_printf(s, " %-4s %-3s", pull, pull_str);
 		else
-			seq_puts(s, "          ");
+			seq_puts(s, "         ");
+
+		if (db_str)
+			seq_printf(s, " %-6s", db_str);
+		else
+			seq_puts(s, "        ");
 
 		if (conf0 & BYT_IODEN)
 			seq_puts(s, " open-drain");