> Define a new auxiliary device driver that manages resets implemented > by the Toshiba TC9564 SoC. The TC9564 clock driver will create 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 MMIO region containing the two control registers is mapped by > the clock controller driver, and passed via the auxiliary device's > platform data. > > Some common definitions are added to to > specify the interface between the clock and reset drivers. > > Reviewed-by: Philipp Zabel > Reviewed-by: Lorenzo Bianconi > Co-developed-by: Daniel Thompson > Signed-off-by: Daniel Thompson > Signed-off-by: Alex Elder > --- > v5: - Code related to the I2C and PCIE resets (including code that > warned if they were used) has been removed. > - The Kconfig now selects AUXILIARY_BUS > - Philipp's Reviewed-by tag has been added. > > MAINTAINERS | 1 + > drivers/reset/Kconfig | 8 ++ > drivers/reset/Makefile | 1 + > drivers/reset/reset-tc9564.c | 165 ++++++++++++++++++++++++++++++++ > include/linux/soc/qcom/tc9563.h | 9 ++ > 5 files changed, 184 insertions(+) > create mode 100644 drivers/reset/reset-tc9564.c > > diff --git a/MAINTAINERS b/MAINTAINERS > index 5d9fc5c5fbcd8..936d60a27dd3c 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -28812,6 +28812,7 @@ M: Lorenzo Bianconi > M: Alex Elder > M: Daniel Thompson > S: Maintained > +F: drivers/reset/reset-tc9564.c > F: include/dt-bindings/reset/toshiba,tc9564.h > > TOSHIBA WMI HOTKEYS DRIVER > diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig > index 673bca1e594e0..f8ef663ac5b79 100644 > --- a/drivers/reset/Kconfig > +++ b/drivers/reset/Kconfig > @@ -369,6 +369,14 @@ config RESET_SUNXI > help > This enables the reset driver for Allwinner SoCs. > > +config RESET_TC9564 > + tristate "Toshiba TC9564 reset controller driver" > + select AUXILIARY_BUS > + 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..218be6dbbb2a3 > --- /dev/null > +++ b/drivers/reset/reset-tc9564.c > @@ -0,0 +1,165 @@ > +// SPDX-License-Identifier: GPL-2.0-only > + > +/* > + * Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reserved. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > + > +/* > + * 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 *regs; /* Mapped registers 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_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->regs + 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->regs + 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 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->regs = aux_data->regs; > + 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->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"); > diff --git a/include/linux/soc/qcom/tc9563.h b/include/linux/soc/qcom/tc9563.h > index 086f37a40d801..f778ce9ae2e7c 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 to the TC9564 reset auxiliary driver */ > +struct tc9564_aux_data { > + void __iomem *regs; nit: I guess we do not really need it. Regards, Lorenzo > +}; > + > #endif /* __QCOM_TC9563_H */ > -- > 2.53.0 >