* [PATCH v4 1/4] dt-bindings: toshiba: introduce toshiba,tc9564-clock.yaml
2026-12-01 16:08 [PATCH v4 0/4] clk: tc9564: introduce clock and reset drivers Alex Elder
@ 2026-12-01 16:08 ` Alex Elder
2026-12-01 16:08 ` [PATCH v4 2/4] clk: toshiba: introduce a TC9564 clock driver Alex Elder
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Alex Elder @ 2026-12-01 16:08 UTC (permalink / raw)
To: sboyd, bmasney+clk, jbrunet+clk, robh, krzk+dt, conor+dt, p.zabel,
andersson, konradybcio, abelvesa, arnd, gregkh
Cc: daniel, mohd.anwar, lorenzo.bianconi, fabrice.gasnier,
alexandre.torgue, marex, changhuang.liang, linux-clk, devicetree,
linux-arm-msm, linux-kernel
Define the binding for the clock and reset controller present in the
Toshiba TC9564 SoC.
Reviewed-by: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
Co-developed-by: Daniel Thompson <daniel@riscstar.com>
Signed-off-by: Daniel Thompson <daniel@riscstar.com>
Signed-off-by: Alex Elder <elder@riscstar.com>
---
v4: - Reset IDs are now defined in a separate header file
- Clock and reset ID symbols now have a "TC9564_" prefix.
- A missing space in a guard #endif has been added
.../bindings/clock/toshiba,tc9564-clock.yaml | 74 +++++++++++++++++++
MAINTAINERS | 15 ++++
include/dt-bindings/clock/toshiba,tc9564.h | 26 +++++++
include/dt-bindings/reset/toshiba,tc9564.h | 24 ++++++
4 files changed, 139 insertions(+)
create mode 100644 Documentation/devicetree/bindings/clock/toshiba,tc9564-clock.yaml
create mode 100644 include/dt-bindings/clock/toshiba,tc9564.h
create mode 100644 include/dt-bindings/reset/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..0f55d18c61193
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/toshiba,tc9564-clock.yaml
@@ -0,0 +1,74 @@
+# 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 Controllers
+
+maintainers:
+ - Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
+ - Alex Elder <elder@kernel.org>
+ - Daniel Thompson <danielt@kernel.org>
+
+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 internally into
+ a set of fixed rate, always-on clocks.
+
+ The clock controller exposes a set of simple gated clocks, which are
+ controlled by two registers. Each is 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 IDs are defined <dt-bindings/clock/toshiba,tc9564.h>, and reset
+ IDs are defined <dt-bindings/reset/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 e7652ab2061a2..0a30100222123 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -28723,6 +28723,14 @@ F: Documentation/devicetree/bindings/media/i2c/toshiba,tc358743.yaml
F: drivers/media/i2c/tc358743*
F: include/media/i2c/tc358743.h
+TOSHIBA TC9564 CLOCK 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>
@@ -28730,6 +28738,13 @@ S: Maintained
F: Documentation/devicetree/bindings/misc/pci1179,0220.yaml
F: drivers/misc/tc9564-pci.c
+TOSHIBA TC9564 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: include/dt-bindings/reset/toshiba,tc9564.h
+
TOSHIBA WMI HOTKEYS DRIVER
M: Azael Avalos <coproscefalo@gmail.com>
L: platform-driver-x86@vger.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..540fef71016be
--- /dev/null
+++ b/include/dt-bindings/clock/toshiba,tc9564.h
@@ -0,0 +1,26 @@
+/* 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 TC9564_CLK_I2C 0 /* critical */
+#define TC9564_CLK_PCIE 1 /* critical */
+#define TC9564_CLK_MSIGEN 2
+
+#define TC9564_CLK_MAC0_TX 3
+#define TC9564_CLK_MAC0_RX 4
+#define TC9564_CLK_MAC0_125M 5
+#define TC9564_CLK_MAC0_ALL 6
+
+#define TC9564_CLK_MAC1_TX 7
+#define TC9564_CLK_MAC1_RX 8
+#define TC9564_CLK_MAC1_125M 9
+#define TC9564_CLK_MAC1_ALL 10
+
+#endif /* __CLOCK_TOSHIBA_TC9564_H__ */
diff --git a/include/dt-bindings/reset/toshiba,tc9564.h b/include/dt-bindings/reset/toshiba,tc9564.h
new file mode 100644
index 0000000000000..942a284b0d2f8
--- /dev/null
+++ b/include/dt-bindings/reset/toshiba,tc9564.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+
+/*
+ * Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reserved.
+ */
+
+#ifndef __RESET_TOSHIBA_TC9564_H__
+#define __RESET_TOSHIBA_TC9564_H__
+
+/* Reset IDs */
+
+#define TC9564_RST_I2C 0 /* critical */
+#define TC9564_RST_PCIE 1 /* critical */
+#define TC9564_RST_MSIGEN 2
+
+#define TC9564_RST_MAC0_MAC 3
+#define TC9564_RST_MAC0_PMA 4
+#define TC9564_RST_MAC0_XPCS 5
+
+#define TC9564_RST_MAC1_MAC 6
+#define TC9564_RST_MAC1_PMA 7
+#define TC9564_RST_MAC1_XPCS 8
+
+#endif /* __RESET_TOSHIBA_TC9564_H__ */
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v4 2/4] clk: toshiba: introduce a TC9564 clock driver
2026-12-01 16:08 [PATCH v4 0/4] clk: tc9564: introduce clock and reset drivers Alex Elder
2026-12-01 16:08 ` [PATCH v4 1/4] dt-bindings: toshiba: introduce toshiba,tc9564-clock.yaml Alex Elder
@ 2026-12-01 16:08 ` Alex Elder
2026-12-01 16:21 ` sashiko-bot
2026-12-01 16:08 ` [PATCH v4 3/4] reset: toshiba: introduce a TC9564 reset driver Alex Elder
2026-12-01 16:08 ` [PATCH v4 4/4] arm64: dts: qcom: qcs6490-rb3gen2: add TC9564 clock node Alex Elder
3 siblings, 1 reply; 7+ messages in thread
From: Alex Elder @ 2026-12-01 16:08 UTC (permalink / raw)
To: sboyd, bmasney+clk, jbrunet+clk, robh, krzk+dt, conor+dt, p.zabel,
andersson, konradybcio, abelvesa, arnd, gregkh
Cc: daniel, mohd.anwar, lorenzo.bianconi, fabrice.gasnier,
alexandre.torgue, marex, changhuang.liang, linux-clk, devicetree,
linux-arm-msm, 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. The I2C and PCIE clocks marked
as CRITICAL to prevent their state from ever changing.
Two registers in an MMIO region manage the state of the clocks. The
region is provided via a BAR on one of the PCI functions embedded in
the TC9564 SoC.
This driver creates an auxiliary device responsible for managing the
reset controller implemented within the SoC. Some common definitions
are added to <linux/soc/qcom/tc9563.h> to define the interface between
the clock and the reset driver.
The clock driver should normally be present whenever the TC9564 PCI
driver is enabled, so have TC9564_PCI *imply* the clock driver's config
option, COMMON_CLK_TC9564.
Co-developed-by: Daniel Thompson <daniel@riscstar.com>
Signed-off-by: Daniel Thompson <daniel@riscstar.com>
Signed-off-by: Alex Elder <elder@riscstar.com>
---
v4: - The clocks are now separated by type. A clk_hw pointer is maintained
for the PLL; a hw_onecell_data array holds the clk_hw pointers for
the fixed rate clocks; and a separate hw_onecell_data array holds
clk_hw pointers for the gate clocks.
- The reset controller code has been removed from the clock driver
and placed in a new source file (found in the next patch).
- This clock driver now creates a reset controller auxiliary
device, to bind with the separate reset driver.
- The clock driver and reset device name are now defined in an
existing header file, <linux/soc/qcom/tc9563.h>. This header
is now included by both the clock and reset drivers. A data
structure that describes what is passed from the clock driver
to the reset driver via platform data is defined there as well.
- The function that creates each clock's name is now called
clock_name_alloc() to make it obvious the caller must free
the returned pointer.
- Calls to clock_name_alloc() now all assign the result to a
local variable declared with __free(kfree), so that the
returned pointer gets automatically freed.
- COMMON_CLK_TC9564 no longer depends on TC9564_PCI, and does
not assign a default value. Instead, TC9564_PCI now *implies*
COMMON_CLK_TC9564, meaning no default value is required.
- The driver's probe_type is no set to prefer asynchronous probing.
MAINTAINERS | 1 +
drivers/clk/Kconfig | 8 +
drivers/clk/Makefile | 1 +
drivers/clk/clk-tc9564.c | 401 ++++++++++++++++++++++++++++++++
drivers/misc/Kconfig | 1 +
include/linux/soc/qcom/tc9563.h | 9 +
6 files changed, 421 insertions(+)
create mode 100644 drivers/clk/clk-tc9564.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 0a30100222123..aa52ede9a1aa3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -28729,6 +28729,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..a3d89c55f17a5 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 support"
+ help
+ This enables support for the clock controller embedded in the
+ Toshiba TC9564 SoC. It is also required to support the embedded
+ reset device, which is represented as an auxiliary device created
+ by the clock controller driver.
+
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..ec72a0207fd87
--- /dev/null
+++ b/drivers/clk/clk-tc9564.c
@@ -0,0 +1,401 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+/*
+ * Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reserved.
+ */
+
+#include <linux/auxiliary_bus.h>
+#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 <linux/soc/qcom/tc9563.h>
+
+#include <dt-bindings/clock/toshiba,tc9564.h>
+
+/*
+ * Two registers implement the bits that control whether our clocks are
+ * enabled. These offsets are relative to the address space defined in
+ * devicetree.
+ */
+#define CLOCK0_OFFSET 0x0
+#define CLOCK1_OFFSET 0x8
+
+/* This struct just allows two structures to be allocated/freed together */
+struct reset_aux {
+ struct auxiliary_device adev;
+ struct tc9564_aux_data aux_data;
+};
+
+/*
+ * A PLL driven by a 25 MHz input oscillator provides a clock source to
+ * the chip. A set of fixed rate clocks is derived from the PLL, and a
+ * set of gate clocks are children of the fixed rate clocks.
+ */
+struct tc9564_clock {
+ void __iomem *ioaddr; /* Mapped clock/reset registers */
+ spinlock_t lock; /* Protects reset register updates */
+ struct clk_hw *pll_hw;
+ struct clk_hw_onecell_data *fixed_data;
+ struct clk_hw_onecell_data *gate_data;
+};
+
+/* Indexes into the fixed_init[] array */
+enum fixed_clock {
+ TC9564_CLK_62_5M,
+ TC9564_CLK_125M,
+ TC9564_CLK_250M,
+ TC9564_CLK_312_5M,
+};
+
+struct fixed_init {
+ const char *name;
+ unsigned int div; /* Rate is PLL rate divided by this */
+};
+
+struct gate_init {
+ const char *name;
+ enum fixed_clock parent;
+ u8 offset; /* Control register offset (0x0 or 0x8) */
+ u8 bit; /* Bit in the control register (0-31) */
+ bool critical;
+};
+
+static const struct fixed_init fixed_init[] = {
+ [TC9564_CLK_312_5M] = {
+ .name = "312.5MHz",
+ .div = 4,
+ },
+ [TC9564_CLK_250M] = {
+ .name = "250MHz",
+ .div = 5,
+ },
+ [TC9564_CLK_125M] = {
+ .name = "125MHz",
+ .div = 10,
+ },
+ [TC9564_CLK_62_5M] = {
+ .name = "62.5MHz",
+ .div = 20,
+ },
+};
+#define FIXED_COUNT ARRAY_SIZE(fixed_init)
+
+static const struct gate_init gate_init[] = {
+ [TC9564_CLK_MAC0_TX] = {
+ .name = "MAC0-TX",
+ .parent = TC9564_CLK_312_5M,
+ .offset = CLOCK0_OFFSET,
+ .bit = 7,
+ },
+ [TC9564_CLK_PCIE] = {
+ .name = "PCIe",
+ .parent = TC9564_CLK_250M,
+ .offset = CLOCK0_OFFSET,
+ .bit = 9,
+ .critical = true,
+ },
+ [TC9564_CLK_I2C] = {
+ .name = "i2c",
+ .parent = TC9564_CLK_62_5M,
+ .offset = CLOCK0_OFFSET,
+ .bit = 12,
+ .critical = true,
+ },
+ [TC9564_CLK_MAC0_RX] = {
+ .name = "MAC0-RX",
+ .parent = TC9564_CLK_312_5M,
+ .offset = CLOCK0_OFFSET,
+ .bit = 14,
+ },
+ [TC9564_CLK_MSIGEN] = {
+ .name = "msigen",
+ .parent = TC9564_CLK_125M,
+ .offset = CLOCK0_OFFSET,
+ .bit = 18,
+ },
+ [TC9564_CLK_MAC0_125M] = {
+ .name = "MAC0-125MHz",
+ .parent = TC9564_CLK_125M,
+ .offset = CLOCK0_OFFSET,
+ .bit = 29,
+ },
+ [TC9564_CLK_MAC0_ALL] = {
+ .name = "MAC0-ALL",
+ .parent = TC9564_CLK_250M,
+ .offset = CLOCK0_OFFSET,
+ .bit = 31,
+ },
+ [TC9564_CLK_MAC1_TX] = {
+ .name = "MAC1-TX",
+ .parent = TC9564_CLK_312_5M,
+ .offset = CLOCK1_OFFSET,
+ .bit = 7,
+ },
+ [TC9564_CLK_MAC1_RX] = {
+ .name = "MAC1-RX",
+ .parent = TC9564_CLK_312_5M,
+ .offset = CLOCK1_OFFSET,
+ .bit = 14,
+ },
+ [TC9564_CLK_MAC1_125M] = {
+ .name = "MAC1-125MHz",
+ .parent = TC9564_CLK_125M,
+ .offset = CLOCK1_OFFSET,
+ .bit = 29,
+ },
+ [TC9564_CLK_MAC1_ALL] = {
+ .name = "MAC1-ALL",
+ .parent = TC9564_CLK_250M,
+ .offset = CLOCK1_OFFSET,
+ .bit = 31,
+ },
+};
+#define GATE_COUNT ARRAY_SIZE(gate_init)
+
+/* Caller must free the returned pointer if non-null */
+static const char *clock_name_alloc(struct device *dev, const char *name)
+{
+ return kasprintf(GFP_KERNEL, "%s-%s", dev_name(dev), name);
+}
+
+/* Initialize the PLL (parent is the input oscillator); called from probe */
+static int pll_setup(struct device *dev)
+{
+ const char *name __free(kfree) = clock_name_alloc(dev, "pll");
+ struct tc9564_clock *clock = dev_get_drvdata(dev);
+ struct clk_hw *hw;
+ int ret;
+
+ if (!name)
+ return -ENOMEM;
+
+ hw = devm_clk_hw_register_fixed_factor_index(dev, name, 0, 0, 50, 1);
+ if (IS_ERR(hw))
+ return dev_err_probe(dev, PTR_ERR(hw),
+ "failed to register pll\n");
+
+ ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, hw);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to add pll provider\n");
+
+ clock->pll_hw = hw;
+
+ return 0;
+}
+
+/* Initialize the fixed rate clocks (PLL is parent); called from probe */
+static int fixed_clock_setup(struct device *dev)
+{
+ struct tc9564_clock *clock = dev_get_drvdata(dev);
+ const struct fixed_init *init = &fixed_init[0];
+ struct clk_hw_onecell_data *fixed_data;
+ struct clk_hw *pll_hw = clock->pll_hw;
+ int ret;
+
+ fixed_data = devm_kzalloc_flex(dev, *fixed_data, hws, FIXED_COUNT);
+ if (!fixed_data)
+ return -ENOMEM;
+ fixed_data->num = FIXED_COUNT;
+
+ for (u32 i = 0; i < FIXED_COUNT; i++, init++) {
+ const char *name __free(kfree) = clock_name_alloc(dev, init->name);
+ struct clk_hw *hw;
+
+ if (!name)
+ return -ENOMEM;
+
+ hw = devm_clk_hw_register_fixed_factor_parent_hw(dev, name,
+ pll_hw, 0,
+ 1, init->div);
+ if (IS_ERR(hw))
+ return dev_err_probe(dev, PTR_ERR(hw),
+ "failed to register fixed %s\n",
+ init->name);
+
+ fixed_data->hws[i] = hw;
+ }
+
+ ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
+ fixed_data);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "failed to add fixed clock provider\n");
+
+ clock->fixed_data = fixed_data;
+
+ return 0;
+}
+
+/* Initialize the gate clocks; called from probe */
+static int gate_clock_setup(struct device *dev)
+{
+ struct tc9564_clock *clock = dev_get_drvdata(dev);
+ const struct gate_init *init = &gate_init[0];
+ struct clk_hw_onecell_data *fixed_data;
+ struct clk_hw_onecell_data *gate_data;
+ int ret;
+
+ gate_data = devm_kzalloc_flex(dev, *gate_data, hws, GATE_COUNT);
+ if (!gate_data)
+ return -ENOMEM;
+ gate_data->num = GATE_COUNT;
+
+ fixed_data = clock->fixed_data;
+ for (u32 i = 0; i < GATE_COUNT; i++, init++) {
+ const char *name __free(kfree) = clock_name_alloc(dev, init->name);
+ unsigned long flags = init->critical ? CLK_IS_CRITICAL : 0;
+ void __iomem *reg = clock->ioaddr + init->offset;
+ struct clk_hw *parent_hw;
+ struct clk_hw *hw;
+
+ if (!name)
+ return -ENOMEM;
+
+ /* Each gate clock's parent is a fixed rate clock */
+ parent_hw = fixed_data->hws[init->parent];
+
+ hw = devm_clk_hw_register_gate_parent_hw(dev, name, parent_hw,
+ flags, reg, init->bit,
+ 0, NULL);
+ if (IS_ERR(hw))
+ return dev_err_probe(dev, PTR_ERR(hw),
+ "failed to register gate %s\n",
+ init->name);
+
+ gate_data->hws[i] = hw;
+ }
+
+ ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
+ gate_data);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "failed to add gate clock provider\n");
+
+ clock->gate_data = gate_data;
+
+ return 0;
+}
+
+
+static void reset_dev_release(struct device *dev)
+{
+ of_node_put(dev->of_node);
+}
+
+static struct reset_aux *adev_to_reset_aux(struct auxiliary_device *adev)
+{
+ return container_of(adev, struct reset_aux, adev);
+}
+
+static void reset_adev_remove(void *data)
+{
+ struct auxiliary_device *adev = data;
+
+ auxiliary_device_delete(adev);
+ auxiliary_device_uninit(adev);
+ kfree(adev_to_reset_aux(adev));
+}
+
+/* Create the TC9564 reset auxiliary device */
+static int devm_reset_setup(struct device *dev)
+{
+ struct tc9564_clock *clock = dev_get_drvdata(dev);
+ struct tc9564_aux_data *aux_data;
+ struct auxiliary_device *adev;
+ struct reset_aux *reset_aux;
+ int ret;
+
+ reset_aux = kzalloc_obj(*reset_aux);
+ if (!reset_aux)
+ return -ENOMEM;
+ adev = &reset_aux->adev;
+
+ aux_data = &reset_aux->aux_data;
+ aux_data->reg = clock->ioaddr;
+
+ adev->id = 0;
+ adev->name = TC9564_RESET_DEV_NAME;
+ adev->dev.parent = dev;
+ adev->dev.platform_data = aux_data;
+ adev->dev.release = reset_dev_release;
+ device_set_of_node_from_dev(&adev->dev, dev);
+
+ ret = auxiliary_device_init(adev);
+ if (ret) {
+ of_node_put(adev->dev.of_node);
+ kfree(reset_aux);
+ return ret;
+ }
+
+ ret = auxiliary_device_add(adev);
+ if (ret) {
+ auxiliary_device_uninit(adev);
+ kfree(reset_aux);
+
+ return ret;
+ }
+
+ return devm_add_action_or_reset(dev, reset_adev_remove, adev);
+}
+
+static int tc9564_clk_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct tc9564_clock *clock;
+ struct device_node *np;
+ int ret;
+
+ /* Make sure the reset driver uses the proper module name */
+ BUILD_BUG_ON(__builtin_strcmp(KBUILD_MODNAME, TC9564_CLK_MODNAME));
+
+ np = dev_of_node(dev);
+ if (!np)
+ return dev_err_probe(dev, -EINVAL, "no devicetree node\n");
+
+ clock = devm_kzalloc_obj(dev, *clock);
+ if (!clock)
+ return -ENOMEM;
+
+ clock->ioaddr = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(clock->ioaddr))
+ return dev_err_probe(dev, PTR_ERR(clock->ioaddr),
+ "failed to map registers\n");
+
+ dev_set_drvdata(dev, clock);
+
+ ret = pll_setup(dev);
+ if (ret)
+ return ret;
+
+ ret = fixed_clock_setup(dev);
+ if (ret)
+ return ret;
+
+ ret = gate_clock_setup(dev);
+ if (ret)
+ return ret;
+
+ return devm_reset_setup(dev);
+}
+
+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,
+ },
+};
+module_platform_driver(tc9564_clk_driver);
+
+MODULE_DESCRIPTION("Toshiba TC9564 Clock Driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index c40e89cc57243..391d0ba79c96f 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -574,6 +574,7 @@ config TC9564_PCI
tristate "Toshiba TC9564 PCI function support"
depends on PCI_DYNAMIC_OF_NODES
depends on PCI_QUIRKS
+ imply COMMON_CLK_TC9564
default m
help
This enables support for two PCI functions implemented by the
diff --git a/include/linux/soc/qcom/tc9563.h b/include/linux/soc/qcom/tc9563.h
index 086f37a40d801..2045ffb179133 100644
--- a/include/linux/soc/qcom/tc9563.h
+++ b/include/linux/soc/qcom/tc9563.h
@@ -16,4 +16,13 @@
#define TC9563_GPIO_CONFIG TC9563_GPIO_EN0_OFFSET
#define TC9563_RESET_GPIO TC9563_GPIO_OUT0_OFFSET
+/* Name of the clock driver and the reset auxiliary device it creates */
+#define TC9564_CLK_MODNAME "clk_tc9564"
+#define TC9564_RESET_DEV_NAME "tc9564-reset"
+
+/* Platform data passed by the TC9564 clock driver to its auxiliary device */
+struct tc9564_aux_data {
+ void __iomem *reg;
+};
+
#endif /* __QCOM_TC9563_H */
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v4 3/4] reset: toshiba: introduce a TC9564 reset driver
2026-12-01 16:08 [PATCH v4 0/4] clk: tc9564: introduce clock and reset drivers Alex Elder
2026-12-01 16:08 ` [PATCH v4 1/4] dt-bindings: toshiba: introduce toshiba,tc9564-clock.yaml Alex Elder
2026-12-01 16:08 ` [PATCH v4 2/4] clk: toshiba: introduce a TC9564 clock driver Alex Elder
@ 2026-12-01 16:08 ` Alex Elder
2026-12-01 16:16 ` sashiko-bot
2026-12-01 16:08 ` [PATCH v4 4/4] arm64: dts: qcom: qcs6490-rb3gen2: add TC9564 clock node Alex Elder
3 siblings, 1 reply; 7+ messages in thread
From: Alex Elder @ 2026-12-01 16:08 UTC (permalink / raw)
To: sboyd, bmasney+clk, jbrunet+clk, robh, krzk+dt, conor+dt, p.zabel,
andersson, konradybcio, abelvesa, arnd, gregkh
Cc: daniel, mohd.anwar, lorenzo.bianconi, fabrice.gasnier,
alexandre.torgue, marex, changhuang.liang, linux-clk, devicetree,
linux-arm-msm, linux-kernel
Define a new auxiliary device driver that manages resets implemented
by the Toshiba TC9564 SoC. The TC9564 clock driver creates the reset
device, which will bind to this driver.
The reset controller uses two registers to control a set of 13 resets
that can be asserted or deasserted. Only a subset of the resets can
currently be managed. The I2C and PCIE resets treated as CRITICAL,
meaning their state should never change (and any attempt to do so
results in a warning).
The MMIO region containing the two control registers is mapped by
the clock controller driver, and passed via the auxiliary device's
platform data.
The reset driver should normally be present whenever the TC9564 clock
driver is enabled, so have the COMMON_CLK_TC9564 config option *imply*
the reset driver's config option, RESET_TC9564.
Co-developed-by: Daniel Thompson <daniel@riscstar.com>
Signed-off-by: Daniel Thompson <daniel@riscstar.com>
Signed-off-by: Alex Elder <elder@riscstar.com>
---
v4: - This is a new patch containing a new auxiliary driver for the
reset device. This code was previously included in the clock
driver.
- Checking for attempts to update "critical" resets is no longer
done at assert/deassert time. Instead, the reset controller
defines a new fwnode_xlate callback to check it at "get" time.
- The spinlock used to wrap read/modify/write updates to the
reset control registers is now handled by guard().
MAINTAINERS | 1 +
drivers/clk/Kconfig | 1 +
drivers/reset/Kconfig | 7 ++
drivers/reset/Makefile | 1 +
drivers/reset/reset-tc9564.c | 190 +++++++++++++++++++++++++++++++++++
5 files changed, 200 insertions(+)
create mode 100644 drivers/reset/reset-tc9564.c
diff --git a/MAINTAINERS b/MAINTAINERS
index aa52ede9a1aa3..8fe319f72eace 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -28744,6 +28744,7 @@ M: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
M: Alex Elder <elder@kernel.org>
M: Daniel Thompson <danielt@kernel.org>
S: Maintained
+F: drivers/reset/reset-tc9564.c
F: include/dt-bindings/reset/toshiba,tc9564.h
TOSHIBA WMI HOTKEYS DRIVER
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index a3d89c55f17a5..c78c5a817adec 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -187,6 +187,7 @@ config COMMON_CLK_CDCE706
config COMMON_CLK_TC9564
tristate "Toshiba TC9564 clock support"
+ imply RESET_TC9564
help
This enables support for the clock controller embedded in the
Toshiba TC9564 SoC. It is also required to support the embedded
diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index 673bca1e594e0..fe46877ea1cda 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -369,6 +369,13 @@ config RESET_SUNXI
help
This enables the reset driver for Allwinner SoCs.
+config RESET_TC9564
+ tristate "Toshiba TC9564 reset controller driver"
+ help
+ This enables support for the reset controller embedded in the
+ Toshiba TC9564 SoC. The device is created by the TC9564 clock
+ controller driver as an auxiliary device.
+
config RESET_TENSTORRENT_ATLANTIS
tristate "Tenstorrent atlantis reset driver"
depends on ARCH_TENSTORRENT || COMPILE_TEST
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index 2fe527a7be8e1..2144095c14b3d 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -47,6 +47,7 @@ obj-$(CONFIG_RESET_SKY1_AUDSS) += reset-sky1-audss.o
obj-$(CONFIG_RESET_SOCFPGA) += reset-socfpga.o
obj-$(CONFIG_RESET_SUNPLUS) += reset-sunplus.o
obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o
+obj-$(CONFIG_RESET_TC9564) += reset-tc9564.o
obj-$(CONFIG_RESET_TENSTORRENT_ATLANTIS) += reset-tenstorrent-atlantis.o
obj-$(CONFIG_RESET_TH1520) += reset-th1520.o
obj-$(CONFIG_RESET_TI_SCI) += reset-ti-sci.o
diff --git a/drivers/reset/reset-tc9564.c b/drivers/reset/reset-tc9564.c
new file mode 100644
index 0000000000000..017ea9f962a2b
--- /dev/null
+++ b/drivers/reset/reset-tc9564.c
@@ -0,0 +1,190 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+/*
+ * Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reserved.
+ */
+
+#include <linux/auxiliary_bus.h>
+#include <linux/bits.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/reset-controller.h>
+#include <linux/slab.h>
+#include <linux/soc/qcom/tc9563.h>
+
+#include <dt-bindings/reset/toshiba,tc9564.h>
+
+/*
+ * Two registers implement the bits that control whether our resets are
+ * asserted. These offsets are relative to the mapped memory passed
+ * as platform data from the TC9564 clock driver.
+ */
+#define RESET0_OFFSET 0x4
+#define RESET1_OFFSET 0xc
+
+struct tc9564_reset {
+ void __iomem *reg; /* Mapped register base address */
+ spinlock_t lock; /* Protects register updates */
+ struct reset_controller_dev rcdev;
+};
+
+struct reset_init {
+ u16 offset; /* Control register offset (0x4 or 0xc) */
+ u16 bit; /* Bit in the control register (0-31) */
+};
+
+static const struct reset_init reset_init[] = {
+ [TC9564_RST_MAC0_MAC] = {
+ .offset = RESET0_OFFSET,
+ .bit = 7,
+ },
+ [TC9564_RST_PCIE] = {
+ .offset = RESET0_OFFSET,
+ .bit = 9,
+ },
+ [TC9564_RST_I2C] = {
+ .offset = RESET0_OFFSET,
+ .bit = 12,
+ },
+ [TC9564_RST_MSIGEN] = {
+ .offset = RESET0_OFFSET,
+ .bit = 18,
+ },
+ [TC9564_RST_MAC0_PMA] = {
+ .offset = RESET0_OFFSET,
+ .bit = 30,
+ },
+ [TC9564_RST_MAC0_XPCS] = {
+ .offset = RESET0_OFFSET,
+ .bit = 31,
+ },
+ [TC9564_RST_MAC1_MAC] = {
+ .offset = RESET1_OFFSET,
+ .bit = 7,
+ },
+ [TC9564_RST_MAC1_PMA] = {
+ .offset = RESET1_OFFSET,
+ .bit = 30,
+ },
+ [TC9564_RST_MAC1_XPCS] = {
+ .offset = RESET1_OFFSET,
+ .bit = 31,
+ },
+};
+#define RESET_COUNT ARRAY_SIZE(reset_init)
+
+static int reset_update(struct reset_controller_dev *rcdev,
+ unsigned long id, bool assert)
+{
+ struct tc9564_reset *reset = dev_get_drvdata(rcdev->dev);
+ const struct reset_init *init = &reset_init[id];
+ void __iomem *reg = reset->reg + init->offset;
+ u32 mask = BIT(init->bit);
+ u32 val;
+
+ guard(spinlock_irqsave)(&reset->lock);
+
+ val = readl(reg);
+ if (assert)
+ val |= mask;
+ else
+ val &= ~mask;
+ writel(val, reg);
+
+ return 0;
+}
+
+static int reset_assert(struct reset_controller_dev *rcdev, unsigned long id)
+{
+ return reset_update(rcdev, id, true);
+}
+
+static int reset_deassert(struct reset_controller_dev *rcdev, unsigned long id)
+{
+ return reset_update(rcdev, id, false);
+}
+
+static int reset_status(struct reset_controller_dev *rcdev, unsigned long id)
+{
+ struct tc9564_reset *reset = dev_get_drvdata(rcdev->dev);
+ const struct reset_init *init = &reset_init[id];
+ void __iomem *reg = reset->reg + init->offset;
+
+ return readl(reg) & BIT(init->bit) ? 1 : 0;
+}
+
+static const struct reset_control_ops reset_control_ops = {
+ .assert = reset_assert,
+ .deassert = reset_deassert,
+ .status = reset_status,
+};
+
+static int reset_fwnode_xlate(struct reset_controller_dev *rcdev,
+ const struct fwnode_reference_args *reset_spec)
+{
+ unsigned int id = reset_spec->args[0];
+
+ if (id >= rcdev->nr_resets)
+ return -EINVAL;
+
+ /* Warn on any attempt to get a critical reset */
+ if (WARN_ON(id == TC9564_RST_I2C) || WARN_ON(id == TC9564_RST_PCIE))
+ return -EINVAL;
+
+ return id;
+}
+
+static int tc9564_reset_probe(struct auxiliary_device *adev,
+ const struct auxiliary_device_id *id)
+{
+ struct reset_controller_dev *rcdev;
+ struct tc9564_aux_data *aux_data;
+ struct device *dev = &adev->dev;
+ struct tc9564_reset *reset;
+ int ret;
+
+ aux_data = dev_get_platdata(dev);
+ if (!aux_data)
+ return dev_err_probe(dev, -EINVAL, "no register pointer\n");
+
+ reset = devm_kzalloc_obj(dev, *reset);
+ if (!reset)
+ return -ENOMEM;
+
+ reset->reg = aux_data->reg;
+ spin_lock_init(&reset->lock);
+
+ /* This needs to be set before registering */
+ dev_set_drvdata(dev, reset);
+
+ rcdev = &reset->rcdev;
+ rcdev->ops = &reset_control_ops;
+ rcdev->owner = THIS_MODULE;
+ rcdev->dev = dev;
+ rcdev->of_node = dev_of_node(dev);
+ rcdev->fwnode_reset_n_cells = 1;
+ rcdev->fwnode_xlate = reset_fwnode_xlate;
+ 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 auxiliary_device_id tc9564_reset_ids[] = {
+ { TC9564_CLK_MODNAME "." TC9564_RESET_DEV_NAME },
+ { }
+};
+MODULE_DEVICE_TABLE(auxiliary, tc9564_reset_ids);
+
+static struct auxiliary_driver tc9564_reset_driver = {
+ .name = KBUILD_MODNAME,
+ .probe = tc9564_reset_probe,
+ .id_table = tc9564_reset_ids,
+};
+module_auxiliary_driver(tc9564_reset_driver);
+
+MODULE_DESCRIPTION("Toshiba TC9564 Reset Driver");
+MODULE_LICENSE("GPL");
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread