* [PATCH v2 0/2] clk: tc9564: introduce a clock and reset driver
@ 2026-11-20 18:32 Alex Elder
2026-11-20 18:32 ` [PATCH v2 1/2] dt-bindings: toshiba: introduce toshiba,tc9564-clock.yaml Alex Elder
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Alex Elder @ 2026-11-20 18:32 UTC (permalink / raw)
To: sboyd, bmasney+clk, jbrunet+clk, p.zabel, robh, krzk+dt, conor+dt
Cc: daniel, mohd.anwar, lorenzo.bianconi, fabrice.gasnier,
alexandre.torgue, marex, changhuang.liang, devicetree, linux-clk,
linux-kernel
This code has gone around and around in various forms, having been
included most recently in a series that also added a system controller
driver. That system controller has now been removed.
This series introduces a devicetree binding and single driver to support
the clock and reset components present within the Toshiba TC9564 chip.
The Toshiba TC9564 is an SoC that attaches to a host system via PCIe.
It includes a PCIe switch with three downstream ports. To one of
these ports an embedded PCIe endpoint is attached, and that implements
two PCI functions. BAR 4 for both PCI functions provides access to
registers controlling blocks within the SoC, including the clock and
resets controllers supported by this series.
To avoid any confusion I'm only going to refer back to the "syscon"
series", which provides some additional information including links
to earlier versions of this code.
-Alex
The previous version of this code was included in this series:
https://lore.kernel.org/all/20261104004332.2141282-1-elder@riscstar.com/
Between that series (v1) and this one (v2):
- There is no more syscon, so its devicetree binding and driver have
been dropped
- The clock and reset components now have a single devicetree binding
- We no longer use a syscon-generated regmap for accessing the common
range of memory used by multiple drivers; specific sub-ranges are
instead mapped
- The clock and reset drivers have been combined into a single driver
located under drivers/clk
- The config option for the driver includes COMPILE_TEST, as requested
(last month) by Jerome Brunet
- The help text for the config option is simplified, first suggested
by Philipp Zabel
- The driver now names clocks using dev_name() rather than trying to
hand-code a unique name into a fixed-size name array (also suggested
by Jerome)
- Certain functions now always return 0, which simplifies callers
so they can simply return what the called function returns
- As suggested by sashiko, a counted-by field in a flex array is now
assigned explicitly
Alex Elder (2):
dt-bindings: toshiba: introduce toshiba,tc9564-clock.yaml
clk: toshiba: introduce a TC9564 clock/reset driver
.../bindings/clock/toshiba,tc9564-clock.yaml | 73 +++
MAINTAINERS | 9 +
drivers/clk/Kconfig | 8 +
drivers/clk/Makefile | 1 +
drivers/clk/clk-tc9564.c | 501 ++++++++++++++++++
include/dt-bindings/clock/toshiba,tc9564.h | 50 ++
6 files changed, 642 insertions(+)
create mode 100644 Documentation/devicetree/bindings/clock/toshiba,tc9564-clock.yaml
create mode 100644 drivers/clk/clk-tc9564.c
create mode 100644 include/dt-bindings/clock/toshiba,tc9564.h
base-commit: 909ef7a9a30fa139e69e555e3606680f5cca7726
--
2.53.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] dt-bindings: toshiba: introduce toshiba,tc9564-clock.yaml
2026-11-20 18:32 [PATCH v2 0/2] clk: tc9564: introduce a clock and reset driver Alex Elder
@ 2026-11-20 18:32 ` Alex Elder
2026-11-20 18:32 ` [PATCH v2 2/2] clk: toshiba: introduce a TC9564 clock/reset driver Alex Elder
2026-11-20 19:04 ` [PATCH v2 0/2] clk: tc9564: introduce a clock and reset driver Alex Elder
2 siblings, 0 replies; 5+ messages in thread
From: Alex Elder @ 2026-11-20 18:32 UTC (permalink / raw)
To: sboyd, bmasney+clk, jbrunet+clk, p.zabel, robh, krzk+dt, conor+dt
Cc: daniel, mohd.anwar, lorenzo.bianconi, fabrice.gasnier,
alexandre.torgue, marex, changhuang.liang, devicetree, linux-clk,
linux-kernel
Define the binding for the clock and reset controller that present in
the Toshiba TC9564 SoC.
Co-developed-by: Daniel Thompson <daniel@riscstar.com>
Signed-off-by: Daniel Thompson <daniel@riscstar.com>
Signed-off-by: Alex Elder <elder@riscstar.com>
---
v2: - New binding that combines clock and reset under the clock node
.../bindings/clock/toshiba,tc9564-clock.yaml | 73 +++++++++++++++++++
MAINTAINERS | 8 ++
include/dt-bindings/clock/toshiba,tc9564.h | 50 +++++++++++++
3 files changed, 131 insertions(+)
create mode 100644 Documentation/devicetree/bindings/clock/toshiba,tc9564-clock.yaml
create mode 100644 include/dt-bindings/clock/toshiba,tc9564.h
diff --git a/Documentation/devicetree/bindings/clock/toshiba,tc9564-clock.yaml b/Documentation/devicetree/bindings/clock/toshiba,tc9564-clock.yaml
new file mode 100644
index 0000000000000..e789ce8c6a3ac
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/toshiba,tc9564-clock.yaml
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/toshiba,tc9564-clock.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Toshiba TC9564 Clock and Reset Controller
+
+maintainers:
+ - Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
+ - Alex Elder <elder@riscstar.com>
+ - Daniel Thompson <daniel@riscstar.com>
+
+description:
+ The Toshiba TC9564 is an SoC accessed by a host system through the
+ upstream PCIe port on the PCIe switch it implements. The chip includes
+ an embedded PCIe endpoint that provides access to various peripherals
+ within the SoC via its BARs. These peripherals include a simple
+ controller to gate internal clocks, and a reset controller.
+
+ The TC9564 chip has a single input clock. Internally that clock is
+ multiplied by a PLL, and the PLL signal is divided into a set of
+ fixed rate, always-on clocks.
+
+ The clock controller uses two registers to control a set of simple
+ gated clocks, each derived from one of the internal fixed-rate
+ clocks. A total of 21 gated clocks are implemented within the chip,
+ but support for enabling and disabling only a subset of them is
+ provided at this time. Two clocks (I2C and PCIE) are marked critical
+ to make it clear that they should never be disabled.
+
+ The reset controller uses two other registers to control a set of 13
+ resets that can be asserted or deasserted. Here too, only a subset
+ of the resets can currently be managed, and the I2C and PCIE resets
+ are treated as critical.
+
+ Clock and reset IDs are defined <dt-bindings/clock/toshiba,tc9564.h>.
+
+properties:
+ compatible:
+ items:
+ - const: toshiba,tc9564-clock
+
+ reg:
+ maxItems: 1
+
+ clocks:
+ maxItems: 1
+
+ "#clock-cells":
+ const: 1
+
+ "#reset-cells":
+ const: 1
+
+required:
+ - compatible
+ - reg
+ - clocks
+ - "#clock-cells"
+ - "#reset-cells"
+
+additionalProperties: false
+
+examples:
+ - |
+ clock-controller@1004 {
+ compatible = "toshiba,tc9564-clock";
+ reg = <0x1004 0x10>;
+ clocks = <&tc9564_xo_board>;
+ #clock-cells = <1>;
+ #reset-cells = <1>;
+ };
diff --git a/MAINTAINERS b/MAINTAINERS
index c00d3612c9acf..af088e1092e63 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -28683,6 +28683,14 @@ F: Documentation/devicetree/bindings/media/i2c/toshiba,tc358743.yaml
F: drivers/media/i2c/tc358743*
F: include/media/i2c/tc358743.h
+TOSHIBA TC9564 CLOCK/RESET CONTROLLER DRIVER
+M: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
+M: Alex Elder <elder@kernel.org>
+M: Daniel Thompson <danielt@kernel.org>
+S: Maintained
+F: Documentation/devicetree/bindings/clock/toshiba,tc9564-clock.yaml
+F: include/dt-bindings/clock/toshiba,tc9564.h
+
TOSHIBA TC9564 PCI DRIVER
M: Alex Elder <elder@kernel.org>
M: Daniel Thompson <danielt@kernel.org>
diff --git a/include/dt-bindings/clock/toshiba,tc9564.h b/include/dt-bindings/clock/toshiba,tc9564.h
new file mode 100644
index 0000000000000..a0325b10b6c36
--- /dev/null
+++ b/include/dt-bindings/clock/toshiba,tc9564.h
@@ -0,0 +1,50 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+
+/*
+ * Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reserved.
+ */
+
+#ifndef __CLOCK_TOSHIBA_TC9564_H__
+#define __CLOCK_TOSHIBA_TC9564_H__
+
+/* Clock IDs */
+
+#define CLOCK_PLL 0
+
+#define CLOCK_62_5M 1
+#define CLOCK_100M 2
+#define CLOCK_125M 3
+#define CLOCK_250M 4
+#define CLOCK_312_5M 5
+
+#define CLOCK_I2C 6 /* critical */
+#define CLOCK_PCIE 7 /* critical */
+#define CLOCK_MSIGEN 8
+
+#define CLOCK_MAC0_TX 9
+#define CLOCK_MAC0_RX 10
+#define CLOCK_MAC0_125M 11
+#define CLOCK_MAC0_312_5M 12
+#define CLOCK_MAC0_ALL 13
+
+#define CLOCK_MAC1_TX 14
+#define CLOCK_MAC1_RX 15
+#define CLOCK_MAC1_125M 16
+#define CLOCK_MAC1_312_5M 17
+#define CLOCK_MAC1_ALL 18
+
+/* Reset IDs */
+
+#define RESET_I2C 0 /* critical */
+#define RESET_PCIE 1 /* critical */
+#define RESET_MSIGEN 2
+
+#define RESET_MAC0_MAC 3
+#define RESET_MAC0_PMA 4
+#define RESET_MAC0_XPCS 5
+
+#define RESET_MAC1_MAC 6
+#define RESET_MAC1_PMA 7
+#define RESET_MAC1_XPCS 8
+
+#endif /* __CLOCK_TOSHIBA_TC9564_H__*/
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] clk: toshiba: introduce a TC9564 clock/reset driver
2026-11-20 18:32 [PATCH v2 0/2] clk: tc9564: introduce a clock and reset driver Alex Elder
2026-11-20 18:32 ` [PATCH v2 1/2] dt-bindings: toshiba: introduce toshiba,tc9564-clock.yaml Alex Elder
@ 2026-11-20 18:32 ` Alex Elder
2026-11-20 18:42 ` sashiko-bot
2026-11-20 19:04 ` [PATCH v2 0/2] clk: tc9564: introduce a clock and reset driver Alex Elder
2 siblings, 1 reply; 5+ messages in thread
From: Alex Elder @ 2026-11-20 18:32 UTC (permalink / raw)
To: sboyd, bmasney+clk, jbrunet+clk, p.zabel, robh, krzk+dt, conor+dt
Cc: daniel, mohd.anwar, lorenzo.bianconi, fabrice.gasnier,
alexandre.torgue, marex, changhuang.liang, devicetree, linux-clk,
linux-kernel
Define a new platform driver that manages clocks 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.
Two registers manage the state of the clocks. The registers are
accessed via a regmap supplied by a system controller. Access to
the memory region is provided via a BAR on a PCIe endpoint function
embedded in the TC9564 SoC.
Define the binding for the clock and reset controller that present in
the Toshiba TC9564 SoC.
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 some of these won't be used any time soon by software,
so they are omitted.
There are also 13 resets that can be asserted or deasserted, but support
for some of these is omitted as well.
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@riscstar.com>
Signed-off-by: Daniel Thompson <daniel@riscstar.com>
Signed-off-by: Alex Elder <elder@riscstar.com>
---
v2: - New driver that combines clock and reset functionality
- Map the platform memory resource rather than using a regmap
- Kconfig adds COMPILE_TEST, and its help text is simplified
- Clock names now defined based on dev_name()
- gate_clk_manage() and reset_manage() return 0, so their
callers can be made a little simpler
- Flex array counted-by field is now explicitly assigned
MAINTAINERS | 1 +
drivers/clk/Kconfig | 8 +
drivers/clk/Makefile | 1 +
drivers/clk/clk-tc9564.c | 501 +++++++++++++++++++++++++++++++++++++++
4 files changed, 511 insertions(+)
create mode 100644 drivers/clk/clk-tc9564.c
diff --git a/MAINTAINERS b/MAINTAINERS
index af088e1092e63..9503c304c35ed 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -28689,6 +28689,7 @@ M: Alex Elder <elder@kernel.org>
M: Daniel Thompson <danielt@kernel.org>
S: Maintained
F: Documentation/devicetree/bindings/clock/toshiba,tc9564-clock.yaml
+F: drivers/clk/clk-tc9564.c
F: include/dt-bindings/clock/toshiba,tc9564.h
TOSHIBA TC9564 PCI DRIVER
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 6bfa2c8fffe1b..b27807ee93863 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -185,6 +185,14 @@ config COMMON_CLK_CDCE706
help
This driver supports TI CDCE706 programmable 3-PLL clock synthesizer.
+config COMMON_CLK_TC9564
+ tristate "Toshiba TC9564 clock and reset support"
+ depends on TC9564_PCI || COMPILE_TEST
+ default TC9564_PCI
+ help
+ This enables support for the clock and reset controllers embedded
+ in the Toshiba TC9564 SoC.
+
config COMMON_CLK_TPS68470
tristate "Clock Driver for TI TPS68470 PMIC"
depends on I2C
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 99377a13ebc57..d67cfb6d623d3 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -111,6 +111,7 @@ obj-$(CONFIG_COMMON_CLK_SI570) += clk-si570.o
obj-$(CONFIG_COMMON_CLK_SP7021) += clk-sp7021.o
obj-$(CONFIG_COMMON_CLK_STM32F) += clk-stm32f4.o
obj-$(CONFIG_COMMON_CLK_STM32H7) += clk-stm32h7.o
+obj-$(CONFIG_COMMON_CLK_TC9564) += clk-tc9564.o
obj-$(CONFIG_COMMON_CLK_TPS68470) += clk-tps68470.o
obj-$(CONFIG_CLK_TWL6040) += clk-twl6040.o
obj-$(CONFIG_CLK_TWL) += clk-twl.o
diff --git a/drivers/clk/clk-tc9564.c b/drivers/clk/clk-tc9564.c
new file mode 100644
index 0000000000000..65ed524bf2ee7
--- /dev/null
+++ b/drivers/clk/clk-tc9564.c
@@ -0,0 +1,501 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+/*
+ * Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reserved.
+ */
+
+#include <linux/bits.h>
+#include <linux/clk-provider.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/reset-controller.h>
+#include <linux/slab.h>
+
+#include <dt-bindings/clock/toshiba,tc9564.h>
+
+/*
+ * Two registers implement clock enable/disable bits for all gated clocks.
+ * And two registers implement reset assertion bits for all resets.
+ * These offsets are relative to the address space defined in devicetree.
+ */
+#define CLOCK0_OFFSET 0x0
+#define CLOCK1_OFFSET 0x8
+#define RESET0_OFFSET 0x4
+#define RESET1_OFFSET 0xc
+
+struct tc9564_clock {
+ void __iomem *ioaddr; /* Mapped clock/reset registers */
+ struct clk_hw_onecell_data *clk_data;
+ struct reset_controller_dev rcdev;
+};
+
+struct gate_clock {
+ const struct clock_init *init;
+ struct clk_hw hw;
+};
+
+enum clock_type { PLL, FIXED, GATE, CRITICAL_GATE };
+
+struct clock_init {
+ const char *name;
+ enum clock_type type;
+ union {
+ u32 mult; /* PLL rate multiplier */
+
+ struct { /* Fixed rate clock; parent is PLL */
+ u32 numerator; /* 0 is treated as 1 */
+ u32 denominator;
+ };
+
+ struct { /* Gated clock; parent is a fixed rate clock */
+ u16 parent; /* Parent clock ID, e.g. CLOCK_100M */
+ u16 offset; /* Register offset */
+ u32 mask; /* Value is 2^n (only one bit set) */
+ };
+ };
+};
+
+struct reset_init {
+ u32 offset; /* Register offset */
+ u32 mask; /* Value is 2^n (only one bit set) */
+};
+
+/*
+ * Clocks are initialized and registered in the order of their IDs.
+ * There is one PLL, and it is initialized first. Fixed clocks are
+ * initialized after that, and the gated clocks are initialized last
+ * (after their parent clocks have been registered).
+ */
+static const struct clock_init clock_init[] = {
+ [CLOCK_PLL] = {
+ .name = "pll",
+ .type = PLL,
+ .mult = 50,
+ },
+
+ [CLOCK_62_5M] = {
+ .name = "62.5MHz",
+ .type = FIXED,
+ .denominator = 20,
+ },
+ [CLOCK_100M] = {
+ .name = "100MHz",
+ .type = FIXED,
+ .numerator = 2,
+ .denominator = 25,
+ },
+ [CLOCK_125M] = {
+ .name = "125MHz",
+ .type = FIXED,
+ .denominator = 10,
+ },
+ [CLOCK_250M] = {
+ .name = "250MHz",
+ .type = FIXED,
+ .denominator = 5,
+ },
+ [CLOCK_312_5M] = {
+ .name = "312.5MHz",
+ .type = FIXED,
+ .denominator = 4,
+ },
+
+ [CLOCK_I2C] = {
+ .name = "i2c",
+ .type = CRITICAL_GATE,
+ .parent = CLOCK_100M,
+ .offset = CLOCK0_OFFSET,
+ .mask = BIT(12),
+ },
+ [CLOCK_PCIE] = {
+ .name = "PCIe",
+ .type = CRITICAL_GATE,
+ .parent = CLOCK_100M,
+ .offset = CLOCK0_OFFSET,
+ .mask = BIT(9),
+ },
+ [CLOCK_MSIGEN] = {
+ .name = "msigen",
+ .type = GATE,
+ .parent = CLOCK_62_5M,
+ .offset = CLOCK0_OFFSET,
+ .mask = BIT(18),
+ },
+
+ [CLOCK_MAC0_TX] = {
+ .name = "MAC0-TX",
+ .type = GATE,
+ .parent = CLOCK_250M,
+ .offset = CLOCK0_OFFSET,
+ .mask = BIT(7),
+ },
+ [CLOCK_MAC0_RX] = {
+ .name = "MAC0-RX",
+ .type = GATE,
+ .parent = CLOCK_250M,
+ .offset = CLOCK0_OFFSET,
+ .mask = BIT(14),
+ },
+ [CLOCK_MAC0_125M] = {
+ .name = "MAC0-125MHz",
+ .type = GATE,
+ .parent = CLOCK_125M,
+ .offset = CLOCK0_OFFSET,
+ .mask = BIT(29),
+ },
+ [CLOCK_MAC0_312_5M] = {
+ .name = "MAC0-312.5MHz",
+ .type = GATE,
+ .parent = CLOCK_312_5M,
+ .offset = CLOCK0_OFFSET,
+ .mask = BIT(30),
+ },
+ [CLOCK_MAC0_ALL] = {
+ .name = "MAC0-ALL",
+ .type = GATE,
+ .parent = CLOCK_250M,
+ .offset = CLOCK0_OFFSET,
+ .mask = BIT(31),
+ },
+
+ [CLOCK_MAC1_TX] = {
+ .name = "MAC1-TX",
+ .type = GATE,
+ .parent = CLOCK_250M,
+ .offset = CLOCK1_OFFSET,
+ .mask = BIT(7),
+ },
+ [CLOCK_MAC1_RX] = {
+ .name = "MAC1-RX",
+ .type = GATE,
+ .parent = CLOCK_250M,
+ .offset = CLOCK1_OFFSET,
+ .mask = BIT(14),
+ },
+ [CLOCK_MAC1_125M] = {
+ .name = "MAC1-125MHz",
+ .type = GATE,
+ .parent = CLOCK_125M,
+ .offset = CLOCK1_OFFSET,
+ .mask = BIT(29),
+ },
+ [CLOCK_MAC1_312_5M] = {
+ .name = "MAC1-312.5MHz",
+ .type = GATE,
+ .parent = CLOCK_312_5M,
+ .offset = CLOCK1_OFFSET,
+ .mask = BIT(30),
+ },
+ [CLOCK_MAC1_ALL] = {
+ .name = "MAC1-ALL",
+ .type = GATE,
+ .parent = CLOCK_250M,
+ .offset = CLOCK1_OFFSET,
+ .mask = BIT(31),
+ },
+};
+#define CLOCK_COUNT ARRAY_SIZE(clock_init)
+
+static const struct reset_init reset_init[] = {
+ [RESET_I2C] = {
+ .offset = RESET0_OFFSET,
+ .mask = BIT(12),
+ },
+ [RESET_PCIE] = {
+ .offset = RESET0_OFFSET,
+ .mask = BIT(9),
+ },
+ [RESET_MSIGEN] = {
+ .offset = RESET0_OFFSET,
+ .mask = BIT(18),
+ },
+
+ [RESET_MAC0_MAC] = {
+ .offset = RESET0_OFFSET,
+ .mask = BIT(7),
+ },
+ [RESET_MAC0_PMA] = {
+ .offset = RESET0_OFFSET,
+ .mask = BIT(30),
+ },
+ [RESET_MAC0_XPCS] = {
+ .offset = RESET0_OFFSET,
+ .mask = BIT(31),
+ },
+
+ [RESET_MAC1_MAC] = {
+ .offset = RESET1_OFFSET,
+ .mask = BIT(7),
+ },
+ [RESET_MAC1_PMA] = {
+ .offset = RESET1_OFFSET,
+ .mask = BIT(30),
+ },
+ [RESET_MAC1_XPCS] = {
+ .offset = RESET1_OFFSET,
+ .mask = BIT(31),
+ },
+};
+#define RESET_COUNT ARRAY_SIZE(reset_init)
+
+/* Parent is the input oscillator running at 25 MHz; PLL runs at 1250 MHz */
+static struct clk_hw *pll_register(struct device *dev, const char *name,
+ const struct clock_init *init)
+{
+ return devm_clk_hw_register_fixed_factor_index(dev, name, 0, 0,
+ init->mult, 1);
+}
+
+/* The PLL is the parent of all fixed clocks */
+static struct clk_hw *fixed_register(struct device *dev, const char *name,
+ const struct clock_init *init)
+{
+ struct tc9564_clock *tc9564_clock = dev_get_drvdata(dev);
+ u32 numerator = init->numerator ? : 1;
+ struct clk_hw *pll_hw;
+
+ pll_hw = tc9564_clock->clk_data->hws[CLOCK_PLL];
+
+ return devm_clk_hw_register_fixed_factor_parent_hw(dev, name, pll_hw,
+ 0, numerator,
+ init->denominator);
+}
+
+static const struct gate_clock *hw_to_gate_clock(struct clk_hw *hw)
+{
+ return container_of_const(hw, struct gate_clock, hw);
+}
+
+static int gate_clk_manage(struct clk_hw *hw, bool enable)
+{
+ struct tc9564_clock *tc9564_clock = dev_get_drvdata(clk_hw_get_dev(hw));
+ const struct gate_clock *clock = hw_to_gate_clock(hw);
+ u32 mask = clock->init->mask;
+ void __iomem *ioaddr;
+ u32 val;
+
+ ioaddr = tc9564_clock->ioaddr + clock->init->offset;
+
+ val = readl(ioaddr);
+ if (enable)
+ val |= mask;
+ else
+ val &= ~mask;
+ writel(val, ioaddr);
+
+ return 0;
+}
+
+static int gate_clk_enable(struct clk_hw *hw)
+{
+ return gate_clk_manage(hw, true);
+}
+
+static void gate_clk_disable(struct clk_hw *hw)
+{
+ (void)gate_clk_manage(hw, false);
+}
+
+static int gate_clk_is_enabled(struct clk_hw *hw)
+{
+ struct tc9564_clock *tc9564_clock = dev_get_drvdata(clk_hw_get_dev(hw));
+ const struct gate_clock *clock = hw_to_gate_clock(hw);
+ void __iomem *ioaddr;
+
+ ioaddr = tc9564_clock->ioaddr + clock->init->offset;
+
+ return readl(ioaddr) & clock->init->mask ? 1 : 0;
+}
+
+static const struct clk_ops gate_clk_ops = {
+ .enable = gate_clk_enable,
+ .disable = gate_clk_disable,
+ .is_enabled = gate_clk_is_enabled,
+};
+
+static struct clk_hw *gate_register(struct device *dev, const char *name,
+ const struct clock_init *init)
+{
+ struct tc9564_clock *tc9564_clock = dev_get_drvdata(dev);
+ struct clk_init_data clk_init = { };
+ const struct clk_hw *parent_hw;
+ struct gate_clock *clock;
+ int ret;
+
+ clock = devm_kzalloc_obj(dev, *clock);
+ if (!clock)
+ return ERR_PTR(-ENOMEM);
+
+ parent_hw = tc9564_clock->clk_data->hws[init->parent];
+
+ clk_init.name = name;
+ clk_init.ops = &gate_clk_ops;
+ clk_init.parent_hws = &parent_hw;
+ clk_init.num_parents = 1;
+ if (init->type == CRITICAL_GATE)
+ clk_init.flags = CLK_IS_CRITICAL;
+
+ clock->hw.init = &clk_init;
+ clock->init = init;
+
+ ret = devm_clk_hw_register(dev, &clock->hw);
+ if (ret)
+ return ERR_PTR(ret);
+
+ return &clock->hw;
+}
+
+/* Warn on requests to assert or deassert critical resets */
+static bool reset_is_critical(unsigned long id)
+{
+ return WARN_ON(id == RESET_I2C) || WARN_ON(id == RESET_PCIE);
+}
+
+static int reset_manage(struct reset_controller_dev *rcdev,
+ unsigned long id, bool assert)
+{
+ struct tc9564_clock *tc9564_clock = dev_get_drvdata(rcdev->dev);
+ const struct reset_init *reset = &reset_init[id];
+ u32 mask = reset->mask;
+ void __iomem *ioaddr;
+ u32 val;
+
+ if (reset_is_critical(id))
+ return 0; /* Just ignore the request */
+
+ ioaddr = tc9564_clock->ioaddr + reset->offset;
+
+ val = readl(ioaddr);
+ if (assert)
+ val |= mask;
+ else
+ val &= ~mask;
+ writel(val, ioaddr);
+
+ return 0;
+}
+
+static int reset_assert(struct reset_controller_dev *rcdev, unsigned long id)
+{
+ return reset_manage(rcdev, id, true);
+}
+
+static int reset_deassert(struct reset_controller_dev *rcdev, unsigned long id)
+{
+ return reset_manage(rcdev, id, false);
+}
+
+static int reset_status(struct reset_controller_dev *rcdev, unsigned long id)
+{
+ struct tc9564_clock *tc9564_clock = dev_get_drvdata(rcdev->dev);
+ const struct reset_init *reset = &reset_init[id];
+ void __iomem *ioaddr;
+
+ ioaddr = tc9564_clock->ioaddr + reset->offset;
+
+ return readl(ioaddr) & reset->mask ? 1 : 0;
+}
+
+static const struct reset_control_ops reset_control_ops = {
+ .assert = reset_assert,
+ .deassert = reset_deassert,
+ .status = reset_status,
+};
+
+static int tc9564_clk_probe(struct platform_device *pdev)
+{
+ struct clk_hw_onecell_data *clk_data;
+ struct reset_controller_dev *rcdev;
+ struct tc9564_clock *tc9564_clock;
+ struct device *dev = &pdev->dev;
+ struct device_node *np;
+ int ret;
+
+ np = dev_of_node(dev);
+ if (!np)
+ return dev_err_probe(dev, -EINVAL, "no devicetree node\n");
+
+ tc9564_clock = devm_kzalloc_obj(dev, *tc9564_clock);
+ if (!tc9564_clock)
+ return -ENOMEM;
+
+ tc9564_clock->ioaddr = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(tc9564_clock->ioaddr))
+ return dev_err_probe(dev, PTR_ERR(tc9564_clock->ioaddr),
+ "failed to map registers\n");
+
+ clk_data = devm_kzalloc_flex(dev, *tc9564_clock->clk_data, hws,
+ CLOCK_COUNT);
+ if (!clk_data)
+ return -ENOMEM;
+ clk_data->num = CLOCK_COUNT;
+
+ tc9564_clock->clk_data = clk_data;
+
+ /* Record the driver data pointer before we register anything */
+ dev_set_drvdata(dev, tc9564_clock);
+
+ /* Initialize all the clocks, then register the provider */
+ for (u32 i = 0; i < clk_data->num; i++) {
+ const struct clock_init *init = &clock_init[i];
+ struct clk_hw *hw;
+ char *name;
+
+ name = kasprintf(GFP_KERNEL, "%s-%s", dev_name(dev), init->name);
+ if (!name)
+ return -ENOMEM;
+
+ if (init->type == PLL)
+ hw = pll_register(dev, name, init);
+ else if (init->type == FIXED)
+ hw = fixed_register(dev, name, init);
+ else
+ hw = gate_register(dev, name, init);
+ kfree(name);
+
+ if (IS_ERR(hw))
+ return dev_err_probe(dev, PTR_ERR(hw),
+ "failed to register %s\n",
+ init->name);
+ clk_data->hws[i] = hw;
+ }
+
+ ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to add clock provider\n");
+
+ /* Set up and register the reset controller */
+ rcdev = &tc9564_clock->rcdev;
+ rcdev->ops = &reset_control_ops;
+ rcdev->owner = THIS_MODULE;
+ rcdev->dev = dev;
+ rcdev->of_node = np;
+ rcdev->nr_resets = RESET_COUNT;
+
+ ret = devm_reset_controller_register(dev, rcdev);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "failed to register reset controller\n");
+
+ return 0;
+}
+
+static const struct of_device_id tc9564_clock_match[] = {
+ { .compatible = "toshiba,tc9564-clock", },
+ { }
+};
+MODULE_DEVICE_TABLE(of, tc9564_clock_match);
+
+static struct platform_driver tc9564_clk_driver = {
+ .probe = tc9564_clk_probe,
+ .driver = {
+ .name = KBUILD_MODNAME,
+ .of_match_table = tc9564_clock_match,
+ .probe_type = PROBE_PREFER_ASYNCHRONOUS,
+ },
+};
+module_platform_driver(tc9564_clk_driver);
+
+MODULE_DESCRIPTION("Toshiba TC9564 Clock Driver");
+MODULE_LICENSE("GPL");
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] clk: toshiba: introduce a TC9564 clock/reset driver
2026-11-20 18:32 ` [PATCH v2 2/2] clk: toshiba: introduce a TC9564 clock/reset driver Alex Elder
@ 2026-11-20 18:42 ` sashiko-bot
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-11-20 18:42 UTC (permalink / raw)
To: Alex Elder; +Cc: devicetree, linux-clk, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] clk: tc9564: unlocked register read-modify-write in
reset_manage()
- [Medium] clk: tc9564: missing select RESET_CONTROLLER in
COMMON_CLK_TC9564
- [Low] clk: tc9564: stale v1 and dt-binding text in commit message
- [Low] clk: tc9564: duplicate clk_gate implementation in
gate_register()
--
commit c8a057c6e9911108f130ae1447d0fae1c9ba8eff
Author: Alex Elder <elder@kernel.org>
clk: toshiba: introduce a TC9564 clock/reset driver
This commit adds a platform driver for the clock and reset controllers on
the Toshiba TC9564 SoC.
> Define a new platform driver that manages clocks 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.
>
> Two registers manage the state of the clocks. The registers are
> accessed via a regmap supplied by a system controller. Access to
> the memory region is provided via a BAR on a PCIe endpoint function
> embedded in the TC9564 SoC.
>
> Define the binding for the clock and reset controller that present in
> the Toshiba TC9564 SoC.
[Severity: Low]
These first three paragraphs appear to be leftover text from v1 and the
devicetree binding patch: the driver now maps the platform MMIO resource
directly via devm_platform_ioremap_resource() instead of using a syscon
regmap, and the description restarts in the fourth paragraph.
> diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
> index 6bfa2c8fffe1b..b27807ee93863 100644
> --- a/drivers/clk/Kconfig
> +++ b/drivers/clk/Kconfig
> @@ -185,6 +185,14 @@ config COMMON_CLK_CDCE706
> help
> This driver supports TI CDCE706 programmable 3-PLL clock synthesizer.
>
> +config COMMON_CLK_TC9564
> + tristate "Toshiba TC9564 clock and reset support"
> + depends on TC9564_PCI || COMPILE_TEST
> + default TC9564_PCI
> + help
> + This enables support for the clock and reset controllers embedded
> + in the Toshiba TC9564 SoC.
[Severity: Medium]
Should COMMON_CLK_TC9564 select RESET_CONTROLLER? Because TC9564 is a
PCIe endpoint device, this driver can be enabled on host architectures
that do not select ARCH_HAS_RESET_CONTROLLER. When
CONFIG_RESET_CONTROLLER is disabled, devm_reset_controller_register()
compiles to a no-op stub returning 0, silently omitting the reset
controller functionality and causing non-optional reset consumers to fail
with -ENOTSUPP.
> diff --git a/drivers/clk/clk-tc9564.c b/drivers/clk/clk-tc9564.c
> new file mode 100644
> index 0000000000000..65ed524bf2ee7
> --- /dev/null
> +++ b/drivers/clk/clk-tc9564.c
[ ... ]
> +static const struct reset_init reset_init[] = {
> + [RESET_I2C] = {
> + .offset = RESET0_OFFSET,
> + .mask = BIT(12),
> + },
> + [RESET_PCIE] = {
> + .offset = RESET0_OFFSET,
> + .mask = BIT(9),
> + },
> + [RESET_MSIGEN] = {
> + .offset = RESET0_OFFSET,
> + .mask = BIT(18),
> + },
> +
> + [RESET_MAC0_MAC] = {
> + .offset = RESET0_OFFSET,
> + .mask = BIT(7),
> + },
> + [RESET_MAC0_PMA] = {
> + .offset = RESET0_OFFSET,
> + .mask = BIT(30),
> + },
> + [RESET_MAC0_XPCS] = {
> + .offset = RESET0_OFFSET,
> + .mask = BIT(31),
> + },
> +
> + [RESET_MAC1_MAC] = {
> + .offset = RESET1_OFFSET,
> + .mask = BIT(7),
> + },
> + [RESET_MAC1_PMA] = {
> + .offset = RESET1_OFFSET,
> + .mask = BIT(30),
> + },
> + [RESET_MAC1_XPCS] = {
> + .offset = RESET1_OFFSET,
> + .mask = BIT(31),
> + },
> +};
> +#define RESET_COUNT ARRAY_SIZE(reset_init)
[ ... ]
> +static const struct gate_clock *hw_to_gate_clock(struct clk_hw *hw)
> +{
> + return container_of_const(hw, struct gate_clock, hw);
> +}
> +
> +static int gate_clk_manage(struct clk_hw *hw, bool enable)
> +{
> + struct tc9564_clock *tc9564_clock = dev_get_drvdata(clk_hw_get_dev(hw));
> + const struct gate_clock *clock = hw_to_gate_clock(hw);
> + u32 mask = clock->init->mask;
> + void __iomem *ioaddr;
> + u32 val;
> +
> + ioaddr = tc9564_clock->ioaddr + clock->init->offset;
> +
> + val = readl(ioaddr);
> + if (enable)
> + val |= mask;
> + else
> + val &= ~mask;
> + writel(val, ioaddr);
> +
> + return 0;
> +}
> +
> +static int gate_clk_enable(struct clk_hw *hw)
> +{
> + return gate_clk_manage(hw, true);
> +}
> +
> +static void gate_clk_disable(struct clk_hw *hw)
> +{
> + (void)gate_clk_manage(hw, false);
> +}
> +
> +static int gate_clk_is_enabled(struct clk_hw *hw)
> +{
> + struct tc9564_clock *tc9564_clock = dev_get_drvdata(clk_hw_get_dev(hw));
> + const struct gate_clock *clock = hw_to_gate_clock(hw);
> + void __iomem *ioaddr;
> +
> + ioaddr = tc9564_clock->ioaddr + clock->init->offset;
> +
> + return readl(ioaddr) & clock->init->mask ? 1 : 0;
> +}
> +
> +static const struct clk_ops gate_clk_ops = {
> + .enable = gate_clk_enable,
> + .disable = gate_clk_disable,
> + .is_enabled = gate_clk_is_enabled,
> +};
> +
> +static struct clk_hw *gate_register(struct device *dev, const char *name,
> + const struct clock_init *init)
> +{
> + struct tc9564_clock *tc9564_clock = dev_get_drvdata(dev);
> + struct clk_init_data clk_init = { };
> + const struct clk_hw *parent_hw;
> + struct gate_clock *clock;
> + int ret;
> +
> + clock = devm_kzalloc_obj(dev, *clock);
> + if (!clock)
> + return ERR_PTR(-ENOMEM);
> +
> + parent_hw = tc9564_clock->clk_data->hws[init->parent];
> +
> + clk_init.name = name;
> + clk_init.ops = &gate_clk_ops;
> + clk_init.parent_hws = &parent_hw;
> + clk_init.num_parents = 1;
> + if (init->type == CRITICAL_GATE)
> + clk_init.flags = CLK_IS_CRITICAL;
> +
> + clock->hw.init = &clk_init;
> + clock->init = init;
> +
> + ret = devm_clk_hw_register(dev, &clock->hw);
> + if (ret)
> + return ERR_PTR(ret);
> +
> + return &clock->hw;
> +}
[Severity: Low]
This isn't a bug, but now that the driver accesses MMIO registers directly
rather than through regmap, gate_register() and gate_clk_ops duplicate the
standard single-bit MMIO gate implementation. Using
devm_clk_hw_register_gate_parent_hw() (as pll_register() and
fixed_register() do with the fixed-factor helpers) would allow dropping
struct gate_clock and the custom gate callbacks.
> +
> +/* Warn on requests to assert or deassert critical resets */
> +static bool reset_is_critical(unsigned long id)
> +{
> + return WARN_ON(id == RESET_I2C) || WARN_ON(id == RESET_PCIE);
> +}
> +
> +static int reset_manage(struct reset_controller_dev *rcdev,
> + unsigned long id, bool assert)
> +{
> + struct tc9564_clock *tc9564_clock = dev_get_drvdata(rcdev->dev);
> + const struct reset_init *reset = &reset_init[id];
> + u32 mask = reset->mask;
> + void __iomem *ioaddr;
> + u32 val;
> +
> + if (reset_is_critical(id))
> + return 0; /* Just ignore the request */
> +
> + ioaddr = tc9564_clock->ioaddr + reset->offset;
> +
> + val = readl(ioaddr);
> + if (assert)
> + val |= mask;
> + else
> + val &= ~mask;
> + writel(val, ioaddr);
> +
> + return 0;
> +}
[Severity: Medium]
Can concurrent reset operations on lines sharing RESET0_OFFSET or
RESET1_OFFSET race in reset_manage()?
Unlike the clock framework (which holds enable_lock across enable and
disable callbacks), the reset controller core only acquires a
per-reset-control SRCU read lock in reset_control_assert() and
reset_control_deassert(). Two consumers asserting or deasserting
different resets in the same register (such as RESET_MSIGEN and
RESET_MAC0_MAC in RESET0_OFFSET) can perform concurrent read-modify-write
sequences and overwrite each other's bit changes. A spinlock in struct
tc9564_clock around the readl()/writel() sequence in reset_manage() would
prevent this.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120183212.1264522-1-elder@riscstar.com?part=2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/2] clk: tc9564: introduce a clock and reset driver
2026-11-20 18:32 [PATCH v2 0/2] clk: tc9564: introduce a clock and reset driver Alex Elder
2026-11-20 18:32 ` [PATCH v2 1/2] dt-bindings: toshiba: introduce toshiba,tc9564-clock.yaml Alex Elder
2026-11-20 18:32 ` [PATCH v2 2/2] clk: toshiba: introduce a TC9564 clock/reset driver Alex Elder
@ 2026-11-20 19:04 ` Alex Elder
2 siblings, 0 replies; 5+ messages in thread
From: Alex Elder @ 2026-11-20 19:04 UTC (permalink / raw)
To: sboyd, bmasney+clk, jbrunet+clk, p.zabel, robh, krzk+dt, conor+dt
Cc: daniel, mohd.anwar, lorenzo.bianconi, fabrice.gasnier,
alexandre.torgue, marex, changhuang.liang, devicetree, linux-clk,
linux-kernel
On 11/20/26 12:32 PM, Alex Elder wrote:
> This code has gone around and around in various forms, having been
> included most recently in a series that also added a system controller
> driver. That system controller has now been removed.
>
> This series introduces a devicetree binding and single driver to support
> the clock and reset components present within the Toshiba TC9564 chip.
>
> The Toshiba TC9564 is an SoC that attaches to a host system via PCIe.
> It includes a PCIe switch with three downstream ports. To one of
> these ports an embedded PCIe endpoint is attached, and that implements
> two PCI functions. BAR 4 for both PCI functions provides access to
> registers controlling blocks within the SoC, including the clock and
> resets controllers supported by this series.
>
> To avoid any confusion I'm only going to refer back to the "syscon"
> series", which provides some additional information including links
> to earlier versions of this code.
>
> -Alex
If anyone would like to see the DTS file that uses this clock
and reset functionality, it's available here:
https://github.com/riscstar/linux/commit/de0515ee2967d8ff7753cc179a8e05283ee62829
-Alex
>
> The previous version of this code was included in this series:
> https://lore.kernel.org/all/20261104004332.2141282-1-elder@riscstar.com/
>
> Between that series (v1) and this one (v2):
> - There is no more syscon, so its devicetree binding and driver have
> been dropped
> - The clock and reset components now have a single devicetree binding
> - We no longer use a syscon-generated regmap for accessing the common
> range of memory used by multiple drivers; specific sub-ranges are
> instead mapped
> - The clock and reset drivers have been combined into a single driver
> located under drivers/clk
> - The config option for the driver includes COMPILE_TEST, as requested
> (last month) by Jerome Brunet
> - The help text for the config option is simplified, first suggested
> by Philipp Zabel
> - The driver now names clocks using dev_name() rather than trying to
> hand-code a unique name into a fixed-size name array (also suggested
> by Jerome)
> - Certain functions now always return 0, which simplifies callers
> so they can simply return what the called function returns
> - As suggested by sashiko, a counted-by field in a flex array is now
> assigned explicitly
>
> Alex Elder (2):
> dt-bindings: toshiba: introduce toshiba,tc9564-clock.yaml
> clk: toshiba: introduce a TC9564 clock/reset driver
>
> .../bindings/clock/toshiba,tc9564-clock.yaml | 73 +++
> MAINTAINERS | 9 +
> drivers/clk/Kconfig | 8 +
> drivers/clk/Makefile | 1 +
> drivers/clk/clk-tc9564.c | 501 ++++++++++++++++++
> include/dt-bindings/clock/toshiba,tc9564.h | 50 ++
> 6 files changed, 642 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/clock/toshiba,tc9564-clock.yaml
> create mode 100644 drivers/clk/clk-tc9564.c
> create mode 100644 include/dt-bindings/clock/toshiba,tc9564.h
>
>
> base-commit: 909ef7a9a30fa139e69e555e3606680f5cca7726
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-20 19:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 18:32 [PATCH v2 0/2] clk: tc9564: introduce a clock and reset driver Alex Elder
2026-11-20 18:32 ` [PATCH v2 1/2] dt-bindings: toshiba: introduce toshiba,tc9564-clock.yaml Alex Elder
2026-11-20 18:32 ` [PATCH v2 2/2] clk: toshiba: introduce a TC9564 clock/reset driver Alex Elder
2026-11-20 18:42 ` sashiko-bot
2026-11-20 19:04 ` [PATCH v2 0/2] clk: tc9564: introduce a clock and reset driver Alex Elder
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.