[PATCH 0/2] add ripple counter dt binding and driver

Rasmus Villemoes
2021-02-26T14:15:22Z

What I'm trying to do:

We have a board with an external watchdog circuit (the kind that is
petted by flipping a gpio). The reset output of that is split in two:
One gives an immediate interrupt, so software knows that a hard reset
is imminent. The other half removes the "reset input" from a ripple
counter, causing that to start counting at 32kHz, and after 64ms, the
SOC's reset pin then gets pulled.

Unfortunately, the board designer overlooked that the 32kHz output
from the RTC can be disabled, which (since no other component uses
it), is just what happens when clk_disable_unused() gets called. When
the watchdog fires, we do get the interrupt, but the board does not
get reset as it should, since the counter doesn't count.

So I'm thinking that the proper way to handle this is to be able to
represent that ripple counter as a clock consumer in DT and have a
driver do the clk_prepare_enable(), even if that driver doesn't and
can't do anything else. But I'm certainly open to other suggestions.

The "clk_ignore_unused" kernel parameter is fine for debugging, but
too big a hammer (since it applies to all "unused" clocks).

Rasmus Villemoes (2):
dt-bindings: misc: add binding for generic ripple counter
drivers: misc: add ripple counter driver

.../devicetree/bindings/misc/ripple-ctr.txt | 8 +++++
drivers/misc/Kconfig | 7 +++++
drivers/misc/Makefile | 1 +
drivers/misc/ripple-ctr.c | 31 +++++++++++++++++++
4 files changed, 47 insertions(+)
create mode 100644 Documentation/devicetree/bindings/misc/ripple-ctr.txt
create mode 100644 drivers/misc/ripple-ctr.c

--
2.29.2