[PATCH v4 3/4] reset: toshiba: introduce a TC9564 reset driver

From: Alex Elder

Date: Tue Dec 01 2026 - 11:08:40 EST


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@xxxxxxxxxxxx>
Signed-off-by: Daniel Thompson <daniel@xxxxxxxxxxxx>
Signed-off-by: Alex Elder <elder@xxxxxxxxxxxx>
---
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@xxxxxxxxxxxxxxxx>
M: Alex Elder <elder@xxxxxxxxxx>
M: Daniel Thompson <danielt@xxxxxxxxxx>
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