Re: [PATCH v3 2/3] clk: toshiba: introduce a TC9564 clock/reset driver

From: Alex Elder

Date: Thu Nov 26 2026 - 08:00:06 EST


On 11/26/26 3:42 AM, Philipp Zabel wrote:
On Mi, 2026-11-25 at 14:21 -0600, Alex Elder wrote:
Define a new platform driver that manages clocks and resets implemented
by the Toshiba TC9564 SoC. There are 21 gate clocks that can be enabled
and disabled, but currently only the clocks that are (or will soon be)
used are defined to be controllable. There are also 13 resets that can
be asserted or deasserted, but support for some of these is omitted as
well.

Two registers manage the state of the clocks, and two others manage
the state of the resets. All four registers are found in a region
mapped for MMIO. The region is provided via a BAR on one of the PCI
functions embedded in the TC9564 SoC.

The I2C and PCIE clocks and resets are treated as CRITICAL, meaning their
state should never be changed (and a warning is issued if changing their
state is attempted).

Co-developed-by: Daniel Thompson <daniel@xxxxxxxxxxxx>
Signed-off-by: Daniel Thompson <daniel@xxxxxxxxxxxx>
Signed-off-by: Alex Elder <elder@xxxxxxxxxxxx>
---
v3: - Fixed problems/garbage in the patch header
- The Kconfig option now depends on RESET_CONTROLLER, and can now
be enabled if COMPILE_TEST is enabled
- The generic gate clock controller code is now used rather than
implementing a custom one
- The PLL and internal fixed clocks IDs are no longer available
outside "clk-tc9564.c"
- The PLL is initialialized, followed by all fixed rate clocks,
followed by the gate clocks, to ensure each clock's parent is
initialized before the clock is
- Updating the reset registers (read/modify/write) is now protected
by a spinlock
- "Unnecessary newlines" have been removed

MAINTAINERS | 1 +
drivers/clk/Kconfig | 9 +
drivers/clk/Makefile | 1 +
drivers/clk/clk-tc9564.c | 456 +++++++++++++++++++++++++++++++++++++++
4 files changed, 467 insertions(+)
create mode 100644 drivers/clk/clk-tc9564.c

[...]
diff --git a/drivers/clk/clk-tc9564.c b/drivers/clk/clk-tc9564.c
new file mode 100644
index 0000000000000..306781e2f7b4f
--- /dev/null
+++ b/drivers/clk/clk-tc9564.c
@@ -0,0 +1,456 @@
[...]
+
+static int reset_update(struct reset_controller_dev *rcdev,
+ unsigned long id, bool assert)
+{
+ const struct reset_init *reset;
+ struct tc9564_clock *clock;
+ unsigned long flags;
+ void __iomem *reg;
+ u32 mask;
+ u32 val;
+
+ /* Warn on any attempt to change state of a critical reset */
+ if (WARN_ON(id == RESET_I2C) || WARN_ON(id == RESET_PCIE))
+ return 0;

Can't this be checked at reset_control_get() time (in fwnode_xlate) so
that critical reset controls aren't given out to consumers in the first
place?

So I'd pass in a slightly modified fwnode_reset_simple_xlate()
as the fwnode_xlate pointer? I hadn't thought about that, but
it's a good suggestion.

+ clock = dev_get_drvdata(rcdev->dev);
+ reset = &reset_init[id];
+ reg = clock->ioaddr + reset->offset;
+ mask = BIT(reset->bit);
+
+ spin_lock_irqsave(&clock->lock, flags);

Consider using guard(spinlock).

OK I'll do that. This will be the first time I've used this...

Thanks.

-Alex

regards
Philipp