From: Alex Elder <elder@riscstar.com>
To: sboyd@kernel.org, bmasney+clk@redhat.com,
jbrunet+clk@baylibre.com, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, p.zabel@pengutronix.de,
andersson@kernel.org, konradybcio@kernel.org,
abelvesa@kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org
Cc: daniel@riscstar.com, mohd.anwar@oss.qualcomm.com,
lorenzo.bianconi@oss.qualcomm.com, fabrice.gasnier@foss.st.com,
alexandre.torgue@foss.st.com, marex@nabladev.com,
changhuang.liang@starfivetech.com, linux-clk@vger.kernel.org,
devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v4 3/4] reset: toshiba: introduce a TC9564 reset driver
Date: Tue, 1 Dec 2026 10:08:08 -0600 [thread overview]
Message-ID: <20261201160810.2422466-4-elder@riscstar.com> (raw)
In-Reply-To: <20261201160810.2422466-1-elder@riscstar.com>
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
next prev parent reply other threads:[~2026-12-01 16:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2026-12-01 16:16 ` [PATCH v4 3/4] reset: toshiba: introduce a TC9564 reset driver sashiko-bot
2026-12-01 16:08 ` [PATCH v4 4/4] arm64: dts: qcom: qcs6490-rb3gen2: add TC9564 clock node Alex Elder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201160810.2422466-4-elder@riscstar.com \
--to=elder@riscstar.com \
--cc=abelvesa@kernel.org \
--cc=alexandre.torgue@foss.st.com \
--cc=andersson@kernel.org \
--cc=arnd@arndb.de \
--cc=bmasney+clk@redhat.com \
--cc=changhuang.liang@starfivetech.com \
--cc=conor+dt@kernel.org \
--cc=daniel@riscstar.com \
--cc=devicetree@vger.kernel.org \
--cc=fabrice.gasnier@foss.st.com \
--cc=gregkh@linuxfoundation.org \
--cc=jbrunet+clk@baylibre.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo.bianconi@oss.qualcomm.com \
--cc=marex@nabladev.com \
--cc=mohd.anwar@oss.qualcomm.com \
--cc=p.zabel@pengutronix.de \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox