From: Marjan Pascolo <marjan.pascolo@trexom.it>
To: Maxime Ripard <maxime@cerno.tech>,
wens@csie.org, Jernej Skrabec <jernej.skrabec@siol.net>
Cc: linux-arm-kernel@lists.infradead.org,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [PATCH] pinctrl/sunxi: adding input-debounce-ns property
Date: Wed, 10 Feb 2021 17:22:37 +0100 [thread overview]
Message-ID: <c3bc06e3-4193-dc0b-b2b3-d54636481e28@trexom.it> (raw)
In-Reply-To: <20210114114219.faulkwww3dhdqwmc@gilmour>
On Allwinner SoC interrupt debounce can be controlled by two oscillator
(32KHz and 24MHz) and a prescale divider.
Oscillator and prescale divider are set through
device tree property "input-debounce" which have 1uS accuracy.
For acheive nS precision a new device tree poperty is made
named "input-debounce-ns".
"input-debounce-ns" is checked only if "input-debounce"
property is not defined.
Suggested-by: Maxime Ripard <maxime@cerno.tech>
Signed-off-by: Marjan Pascolo <marjan.pascolo@trexom.it>
---
---
.../pinctrl/allwinner,sun4i-a10-pinctrl.yaml | 9 +++++++
drivers/pinctrl/sunxi/pinctrl-sunxi.c | 25 ++++++++++++++++---
2 files changed, 30 insertions(+), 4 deletions(-)
diff --git
a/Documentation/devicetree/bindings/pinctrl/allwinner,sun4i-a10-pinctrl.yaml
b/Documentation/devicetree/bindings/pinctrl/allwinner,sun4i-a10-pinctrl.yaml
index 5240487dfe50..346776de3a44 100644
---
a/Documentation/devicetree/bindings/pinctrl/allwinner,sun4i-a10-pinctrl.yaml
+++
b/Documentation/devicetree/bindings/pinctrl/allwinner,sun4i-a10-pinctrl.yaml
@@ -93,6 +93,15 @@ properties:
minItems: 1
maxItems: 5
+ input-debounce-ns:
+ description:
+ Debouncing periods in nanoseconds, one period per interrupt
+ bank found in the controller.
+ Only checked if input-debounce is not present
+ $ref: /schemas/types.yaml#/definitions/uint32-array
+ minItems: 1
+ maxItems: 5
+
patternProperties:
# It's pretty scary, but the basic idea is that:
# - One node name can start with either s- or r- for PRCM nodes,
diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
index dc8d39ae045b..869b6d5743ba 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
@@ -1335,14 +1335,31 @@ static int sunxi_pinctrl_setup_debounce(struct
sunxi_pinctrl *pctl,
struct clk *hosc, *losc;
u8 div, src;
int i, ret;
+ /* Keeping for loop below clean */
+ const char* debounce_prop_name;
+ unsigned long debounce_dividend;
/* Deal with old DTs that didn't have the oscillators */
if (of_clk_get_parent_count(node) != 3)
return 0;
+ /*
+ * Distinguish between simple input-debounce
+ * and new input-debounce-ns
+ */
+
/* If we don't have any setup, bail out */
- if (!of_find_property(node, "input-debounce", NULL))
- return 0;
+ if (!of_find_property(node, "input-debounce", NULL)) {
+ if(!of_find_property(node, "input-debounce-ns", NULL)) {
+ return 0;
+ } else {
+ debounce_prop_name="input-debounce-ns";
+ debounce_dividend=NSEC_PER_SEC;
+ }
+ } else {
+ debounce_prop_name="input-debounce";
+ debounce_dividend=USEC_PER_SEC;
+ }
losc = devm_clk_get(pctl->dev, "losc");
if (IS_ERR(losc))
@@ -1356,7 +1373,7 @@ static int sunxi_pinctrl_setup_debounce(struct
sunxi_pinctrl *pctl,
unsigned long debounce_freq;
u32 debounce;
- ret = of_property_read_u32_index(node, "input-debounce",
+ ret = of_property_read_u32_index(node, debounce_prop_name,
i, &debounce);
if (ret)
return ret;
@@ -1364,7 +1381,7 @@ static int sunxi_pinctrl_setup_debounce(struct
sunxi_pinctrl *pctl,
if (!debounce)
continue;
- debounce_freq = DIV_ROUND_CLOSEST(USEC_PER_SEC, debounce);
+ debounce_freq = DIV_ROUND_CLOSEST(debounce_dividend, debounce);
losc_div = sunxi_pinctrl_get_debounce_div(losc,
debounce_freq,
&losc_diff);
--
2.22.0.windows.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2021-02-10 16:27 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-06 19:27 [PATCH 0/2] drm/sun4i: fix DCLK and improve its handling Giulio Benetti
2021-01-06 19:27 ` [PATCH 1/2] drm/sun4i: tcon: fix inverted DCLK polarity Giulio Benetti
2021-01-06 21:00 ` Jernej Škrabec
2021-01-07 2:30 ` [PATCH v2 0/2] drm/sun4i: fix DCLK and improve its handling Giulio Benetti
2021-01-07 2:30 ` [PATCH v2 1/2] drm/sun4i: tcon: fix inverted DCLK polarity Giulio Benetti
2021-01-07 2:30 ` [PATCH v2 2/2] drm/sun4i: tcon: improve DCLK polarity handling Giulio Benetti
2021-01-08 9:23 ` Maxime Ripard
2021-01-08 9:32 ` Marjan Pascolo
2021-01-08 14:46 ` Giulio Benetti
2021-01-08 14:34 ` Giulio Benetti
2021-01-11 17:20 ` Maxime Ripard
2021-01-11 17:37 ` Giulio Benetti
2021-01-11 17:46 ` [PATCH v3] drm/sun4i: tcon: fix inverted DCLK polarity Giulio Benetti
2021-01-13 9:42 ` Maxime Ripard
2021-01-13 10:47 ` [PATCH v4] " Giulio Benetti
2021-01-13 16:05 ` [PATCH v5] " Giulio Benetti
2021-01-14 1:32 ` kernel test robot
2021-01-14 7:58 ` Marjan Pascolo
2021-01-14 8:12 ` Giulio Benetti
2021-01-14 8:17 ` [PATCH v6] " Giulio Benetti
2021-01-14 11:40 ` Marjan Pascolo
2021-01-14 11:42 ` Maxime Ripard
2021-02-10 16:22 ` Marjan Pascolo [this message]
2021-02-17 11:03 ` [PATCH] pinctrl/sunxi: adding input-debounce-ns property Maxime Ripard
2021-02-26 12:53 ` Marjan Pascolo
2021-03-04 15:51 ` Maxime Ripard
2021-01-13 10:48 ` [PATCH v3] drm/sun4i: tcon: fix inverted DCLK polarity Giulio Benetti
2021-01-06 19:28 ` [PATCH 2/2] drm/sun4i: tcon: improve DCLK polarity handling Giulio Benetti
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=c3bc06e3-4193-dc0b-b2b3-d54636481e28@trexom.it \
--to=marjan.pascolo@trexom.it \
--cc=dri-devel@lists.freedesktop.org \
--cc=jernej.skrabec@siol.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maxime@cerno.tech \
--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).