linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Coiby Xu <coiby.xu@gmail.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Hans de Goede <hdegoede@redhat.com>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] pinctrl: amd: print debounce filter info in debugfs
Date: Tue, 27 Oct 2020 07:16:31 +0800	[thread overview]
Message-ID: <20201026231631.6l6kei3z45cunzmx@Rk> (raw)
In-Reply-To: <CAHp75VfZ+-rJFWVpowXyViA99_9tA5VaFLfJGH1WF4W=kQHr8w@mail.gmail.com>

On Mon, Oct 26, 2020 at 05:22:45PM +0200, Andy Shevchenko wrote:
>On Mon, Oct 26, 2020 at 5:16 PM Coiby Xu <coiby.xu@gmail.com> wrote:
>>
>> Print the status of debounce filter as follows,
>> $ cat /sys/kernel/debug/gpio
>> pin129          interrupt is disabled| interrupt is masked| disable wakeup in S0i3 state| disable wakeup in S3 state|
>>  disable wakeup in S4/S5 state| input is high|   pull-up is disabled| Pull-down is disabled|   output is disabled| debouncing filter disabled|   0x50000
>> pin130          interrupt is disabled| interrupt is masked| disable wakeup in S0i3 state| disable wakeup in S3 state|
>>  disable wakeup in S4/S5 state| input is high|   pull-up is disabled| Pull-down is disabled|   output is disabled| debouncing filter (high) enabled| debouncing timeout is 124800 (us)| 0x503c8
>>                                                                                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>Thanks for an update!
>In general looks good, one nit below (sorry, missed it in v1 round)
>
Thank you for the feedbacks!
>...
>
>> +       char debounce_value[40];
>
>(1)
>
>...
>
>> +                               if (tmr_large) {
>> +                                       if (tmr_out_unit)
>> +                                               unit = 62500;
>> +                                       else
>
>> +                                               unit = 15600;
>
>Side note: Hmm... Shouldn't be 15625? As 1/4.

Thank you for discovering the inconsistency! I wrote these code based on
amd_gpio_set_debounce. I'll send an email to the original author to
confirm it.

static int amd_gpio_set_debounce(struct gpio_chip *gc, unsigned offset,
		unsigned debounce)
{
     ...
	if (debounce) {
		pin_reg |= DB_TYPE_REMOVE_GLITCH << DB_CNTRL_OFF;
		pin_reg &= ~DB_TMR_OUT_MASK;
		/*
		Debounce	Debounce	Timer	Max
		TmrLarge	TmrOutUnit	Unit	Debounce
							Time
		0	0	61 usec (2 RtcClk)	976 usec
		0	1	244 usec (8 RtcClk)	3.9 msec
		1	0	15.6 msec (512 RtcClk)	250 msec
		1	1	62.5 msec (2048 RtcClk)	1 sec
		*/

		if (debounce < 61) {
			pin_reg |= 1;
			pin_reg &= ~BIT(DB_TMR_OUT_UNIT_OFF);
			pin_reg &= ~BIT(DB_TMR_LARGE_OFF);
		} else if (debounce < 976) {
			time = debounce / 61;
			pin_reg |= time & DB_TMR_OUT_MASK;
			pin_reg &= ~BIT(DB_TMR_OUT_UNIT_OFF);
			pin_reg &= ~BIT(DB_TMR_LARGE_OFF);
         ...
>
>> +                               } else {
>> +                                       if (tmr_out_unit)
>> +                                               unit = 244;
>> +                                       else
>> +                                               unit = 61;
>
>...
>
>
>> +                               snprintf(debounce_value, 40,
>> +                                        "debouncing timeout is %u (us)|", time * unit);
>
>(2)
>
>...
>
>> +                               snprintf(debounce_value, 40, " ");
>
>(3)
>
>Because of definition (1) can you in (2) and (3) use sizeof() ?
>
I've considered defining a constant. Obviously sizeof is a better
idea:)

>--
>With Best Regards,
>Andy Shevchenko

--
Best regards,
Coiby

  reply	other threads:[~2020-10-26 23:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-26 15:16 [PATCH v2] pinctrl: amd: print debounce filter info in debugfs Coiby Xu
2020-10-26 15:22 ` Andy Shevchenko
2020-10-26 23:16   ` Coiby Xu [this message]
2020-10-27  9:42     ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201026231631.6l6kei3z45cunzmx@Rk \
    --to=coiby.xu@gmail.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).