linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: Andreas Feldner <pelzi@flying-snail.de>
Cc: Maxime Ripard <maxime@cerno.tech>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Chen-Yu Tsai <wens@csie.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Samuel Holland <samuel@sholland.org>,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pinctrl: sunxi: set minimal debounce on input-debounce 0
Date: Sat, 11 Feb 2023 19:59:31 +0000	[thread overview]
Message-ID: <20230211195931.5f1b2abb@slackpad.lan> (raw)
In-Reply-To: <200d4457-9801-c862-0e86-850e3188f765@flying-snail.de>

On Sat, 11 Feb 2023 19:08:32 +0100
Andreas Feldner <pelzi@flying-snail.de> wrote:

Hi Andreas,

thanks for putting this together!

> sunxi-h3-h5 based boards have no support for switching
> off IRQ debouncing filter. This would be the expected
> behaviour of value 0 for the general pinctl parameter
> input-debounce.
> The current driver implementation ignores value 0
> for input-debounce, leaving the chip's default. This
> default, however, is not minimal, but equivalent to
> value 31 (microseconds).
> 
> This patch does not ignore value 0 but instead makes
> sure the corresponding IRQ debounce filter is set
> to the shortest time selectable, i. e. the fast
> oscillator with a divider of 1 == (2 ^ 0).
> 
> The current default behaviour is explicitly ensured
> by including input-debounce=<31 31> in the relevant
> part of the devicetree.

The actual change looks alright to me, just some general comments:
- Please don't post new patches as replies to existing threads. Even a
  new revision of a previously posted series is a new thread.
- Your patch is whitespace deformed (no tabs, just spaces). This makes
  it impossible to apply without doing it manually. Your original patch
  was fine in this regard, not sure what you changed. In general it's
  recommended to use git send-email. For a simple patch it might be
  feasible to craft the email in a client (ideally by using an
  external editor), but make sure that it still applies. Sending to
  yourself first helps.
- You cannot mix DT changes and code changes in one patch, they have to
  be in separate patches. The DT change also brings up the question why
  this would be specific to H3/H5, I think this applies to virtually
  every Allwinner SoC.

Cheers,
Andre

> 
> Fixes: 7c926492d38a ("pinctrl: sunxi: Add support for interrupt debouncing")
> 
> Signed-off-by: Andreas Feldner <pelzi@flying-snail.de>
> ---
>   arch/arm/boot/dts/sunxi-h3-h5.dtsi    |  1 +
>   drivers/pinctrl/sunxi/pinctrl-sunxi.c | 40 +++++++++++++++------------
>   2 files changed, 24 insertions(+), 17 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/sunxi-h3-h5.dtsi 
> b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
> index 686193bd6bd9..e9ed4948134d 100644
> --- a/arch/arm/boot/dts/sunxi-h3-h5.dtsi
> +++ b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
> @@ -410,6 +410,7 @@ pio: pinctrl@1c20800 {
>               #gpio-cells = <3>;
>               interrupt-controller;
>               #interrupt-cells = <3>;
> +            input-debounce = <31 31>;
> 
>               csi_pins: csi-pins {
>                   pins = "PE0", "PE2", "PE3", "PE4", "PE5",
> diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c 
> b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> index f35179eceb4e..6798c8f4067e 100644
> --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> @@ -1444,29 +1444,35 @@ static int sunxi_pinctrl_setup_debounce(struct 
> sunxi_pinctrl *pctl,
>           if (ret)
>               return ret;
> 
> -        if (!debounce)
> -            continue;
> -
> -        debounce_freq = DIV_ROUND_CLOSEST(USEC_PER_SEC, debounce);
> -        losc_div = sunxi_pinctrl_get_debounce_div(losc,
> -                              debounce_freq,
> -                              &losc_diff);
> -
> -        hosc_div = sunxi_pinctrl_get_debounce_div(hosc,
> -                              debounce_freq,
> -                              &hosc_diff);
> -
> -        if (hosc_diff < losc_diff) {
> -            div = hosc_div;
> -            src = 1;
> +        if (debounce) {
> +            debounce_freq = DIV_ROUND_CLOSEST(USEC_PER_SEC, debounce);
> +            losc_div = sunxi_pinctrl_get_debounce_div(losc,
> +                                  debounce_freq,
> +                                  &losc_diff);
> +
> +            hosc_div = sunxi_pinctrl_get_debounce_div(hosc,
> +                                  debounce_freq,
> +                                  &hosc_diff);
> +
> +            if (hosc_diff < losc_diff) {
> +                div = hosc_div;
> +                src = 1;
> +            } else {
> +                div = losc_div;
> +                src = 0;
> +            }
>           } else {
> -            div = losc_div;
> -            src = 0;
> +            /* lowest time as best approximation to "off" */
> +            div = 0;
> +            src = 1;
>           }
> 
>           writel(src | div << 4,
>                  pctl->membase +
>                  sunxi_irq_debounce_reg_from_bank(pctl->desc, i));
> +
> +        pr_info("Debounce filter for IRQ bank %d configured to %d us 
> (reg %x)\n",
> +            i, debounce, src | div << 4);
>       }
> 
>       return 0;


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-02-11 20:03 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-06 19:51 [PATCH] ARM: dts: allwinner: minimize irq debounce filter per default Andreas Feldner
2023-02-07  1:16 ` Andre Przywara
2023-02-08 12:50   ` Andreas Feldner
2023-02-09 20:29     ` Andre Przywara
2023-02-10  8:29       ` Maxime Ripard
2023-02-10  9:44         ` Andre Przywara
2023-02-10 10:06           ` Maxime Ripard
2023-02-10 10:18             ` Andre Przywara
2023-02-11 12:50               ` pelzi
2023-02-11 15:13                 ` Andre Przywara
2023-02-11 18:08                   ` [PATCH] pinctrl: sunxi: set minimal debounce on input-debounce 0 Andreas Feldner
2023-02-11 19:59                     ` Andre Przywara [this message]
2023-02-13  8:43               ` [PATCH] ARM: dts: allwinner: minimize irq debounce filter per default Maxime Ripard
2023-02-13  8:49                 ` pelzi
2023-02-13  9:18                   ` Maxime Ripard
2023-02-13 11:56                     ` Andre Przywara
2023-02-14 18:49                       ` pelzi
2023-02-15  8:36                       ` Maxime Ripard
2023-02-11 19:45       ` Samuel Holland
2023-02-13  1:51         ` Andre Przywara

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=20230211195931.5f1b2abb@slackpad.lan \
    --to=andre.przywara@arm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=maxime@cerno.tech \
    --cc=pelzi@flying-snail.de \
    --cc=robh+dt@kernel.org \
    --cc=samuel@sholland.org \
    --cc=wens@csie.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).