Re: [PATCH 2/2] pinctrl: renesas: rzg2l: Enable noise filter for GPIO interrupt input

From: Linus Walleij
Date: Wed Sep 20 2023 - 09:54:45 EST


On Wed, Sep 20, 2023 at 2:37 PM Biju Das <biju.das.jz@xxxxxxxxxxxxxx> wrote:

> 2) Digital Noise Filter Clock Selection Register (FILCLKSEL):
>
> The FILCLKSEL register selects the divided clock to be input to digital noise filters.
>
> 00b: Not divided (initial value)
> 01b: Divided by 9000 (41.666 ns x 9000 = 375,000 ns)
> 10b: Divided by 18000 (41.666 ns x 18000 = 750,000 ns)
> 11b: Divided by 36000 (41.666 ns x 36000 = 1,500,000 ns)
> Note: This value is the value when the external clock is 24MHz.
>
> Q1) What is the recommended way to associate the above values with
> PIN_CONFIG_INPUT_DEBOUNCE?
>
> Eg: I need to configure filter on, 8 stage filter , a divisor of 18000 for a mechanical button bounce noise.

As per the generic pin config and DT bindings:

* @PIN_CONFIG_INPUT_DEBOUNCE: this will configure the pin to debounce mode,
* which means it will wait for signals to settle when reading inputs. The
* argument gives the debounce time in usecs. Setting the
* argument to zero turns debouncing off.

input-debounce:
$ref: /schemas/types.yaml#/definitions/uint32
description: Takes the debounce time in usec as argument or 0 to disable
debouncing

The recommended way is to pass the desired clock cycle in microseconds as the
argument to the pin config.

Yours,
Linus Walleij