Re: [PATCH v5 6/6] reset: Add Siflower SF19A2890 peripheral reset driver

From: Philipp Zabel

Date: Tue Nov 24 2026 - 05:30:21 EST


On Mo, 2026-11-23 at 23:41 -0500, Joseph Telaak via B4 Relay wrote:
> From: Joseph Telaak <joseph@xxxxxxxxxx>
>
> Add a driver for the resets of the Siflower SF19A2890 peripheral clock
> and reset managers. It binds to the auxiliary device that their clock
> driver creates and uses the registers that driver has mapped. Where an
> IP has a reset line for each of its clock domains, as the PL011 UARTs
> and the PL022 SPI controller do, one reset drives all of them, since
> they have to be asserted together.
>
> Based on the reset part of the driver in Chuanhong Guo's SF19A2890
> branch.
>
> Link: https://github.com/981213/linux/commit/37c81bebaf54
> Co-developed-by: Chuanhong Guo <gch981213@xxxxxxxxx>
> Signed-off-by: Chuanhong Guo <gch981213@xxxxxxxxx>
> Signed-off-by: Joseph Telaak <joseph@xxxxxxxxxx>
> ---
> MAINTAINERS | 1 +
> drivers/reset/Kconfig | 11 ++
> drivers/reset/Makefile | 1 +
> drivers/reset/reset-sf19a2890-periphcrm.c | 194 ++++++++++++++++++++++++++++++
> 4 files changed, 207 insertions(+)
>
[...]
> diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
> index 489fafd6bbe3..d4b707505c3d 100644
> --- a/drivers/reset/Makefile
> +++ b/drivers/reset/Makefile
> @@ -39,6 +39,7 @@ obj-$(CONFIG_RESET_RASPBERRYPI) += reset-raspberrypi.o
> obj-$(CONFIG_RESET_RZG2L_USBPHY_CTRL) += reset-rzg2l-usbphy-ctrl.o
> obj-$(CONFIG_RESET_RZV2H_USB2PHY) += reset-rzv2h-usb2phy.o
> obj-$(CONFIG_RESET_SCMI) += reset-scmi.o
> +obj-$(CONFIG_RESET_SF19A2890_PERIPHCRM) += reset-sf19a2890-periphcrm.o
> obj-$(CONFIG_RESET_SIMPLE) += reset-simple.o
> obj-$(CONFIG_RESET_SKY1) += reset-sky1.o
> obj-$(CONFIG_RESET_SKY1_AUDSS) += reset-sky1-audss.o
> diff --git a/drivers/reset/reset-sf19a2890-periphcrm.c b/drivers/reset/reset-sf19a2890-periphcrm.c
> new file mode 100644
> index 000000000000..54b476237bd4
> --- /dev/null
> +++ b/drivers/reset/reset-sf19a2890-periphcrm.c
> @@ -0,0 +1,194 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Siflower SF19A2890 peripheral reset driver
> + *
> + * The peripheral clock and reset managers keep their resets in the first
> + * register of the block. Their clock driver creates an auxiliary device for
> + * them and passes the mapped registers in its platform data.
> + */
> +
> +#include <linux/auxiliary_bus.h>
> +#include <linux/bits.h>
> +#include <linux/device.h>
> +#include <linux/io.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/reset-controller.h>
> +#include <linux/spinlock.h>
> +
> +#include <dt-bindings/clock/siflower,sf19a2890-periph-crm.h>
> +
> +#define REG_RESET 0x0
> +
> +struct sf19a2890_periphrst_data {
> + const u32 *masks;
> + unsigned int num_resets;
> +};
> +
> +struct sf19a2890_periphrst {
> + struct reset_controller_dev rcdev;
> + void __iomem *base;
> + spinlock_t lock; /* serializes reset register updates */
> + const u32 *masks;
> +};
> +
> +static inline struct sf19a2890_periphrst *
> +rcdev_to_periphrst(struct reset_controller_dev *rcdev)
> +{
> + return container_of(rcdev, struct sf19a2890_periphrst, rcdev);
> +}
> +
> +static int sf19a2890_periphrst_update(struct reset_controller_dev *rcdev,
> + unsigned long id, bool assert)
> +{
> + struct sf19a2890_periphrst *rst = rcdev_to_periphrst(rcdev);
> + u32 reg;
> +
> + guard(spinlock_irqsave)(&rst->lock);
> + reg = readl(rst->base + REG_RESET);
> + if (assert)
> + reg |= rst->masks[id];
> + else
> + reg &= ~rst->masks[id];
> + writel(reg, rst->base + REG_RESET);
> + return 0;
> +}
> +
> +static int sf19a2890_periphrst_assert(struct reset_controller_dev *rcdev,
> + unsigned long id)
> +{
> + return sf19a2890_periphrst_update(rcdev, id, true);
> +}
> +
> +static int sf19a2890_periphrst_deassert(struct reset_controller_dev *rcdev,
> + unsigned long id)
> +{
> + return sf19a2890_periphrst_update(rcdev, id, false);
> +}
> +
> +static int sf19a2890_periphrst_status(struct reset_controller_dev *rcdev,
> + unsigned long id)
> +{
> + struct sf19a2890_periphrst *rst = rcdev_to_periphrst(rcdev);
> +
> + return !!(readl(rst->base + REG_RESET) & rst->masks[id]);
> +}
> +
> +static const struct reset_control_ops sf19a2890_periphrst_ops = {
> + .assert = sf19a2890_periphrst_assert,
> + .deassert = sf19a2890_periphrst_deassert,
> + .status = sf19a2890_periphrst_status,
> +};
> +
> +#define RST_DATA(_name) \
> + static const struct sf19a2890_periphrst_data sf19a2890_##_name##_rst = { \
> + .masks = sf19a2890_##_name##_masks, \
> + .num_resets = ARRAY_SIZE(sf19a2890_##_name##_masks), \
> + }
> +
> +/*
> + * A reset that covers several bits drives the reset lines of all the clock
> + * domains of one IP, which have to be asserted together.
> + */

This comment seems misplaced. I suggest you move it up to the masks
field in the sf19a2890_periphrst_data definition or down to where
multiple bits are actually set. Also, s/reset/reset mask/ ?

> +static const u32 sf19a2890_single_masks[] = { BIT(0) };
> +
> +RST_DATA(single);
> +
> +/* The two sides of an asynchronous AXI bridge */
> +static const u32 sf19a2890_gmac_masks[] = { [RST_GMAC] = GENMASK(1, 0) };
> +
> +RST_DATA(gmac);
[...]
> +static int sf19a2890_periphrst_probe(struct auxiliary_device *adev,
> + const struct auxiliary_device_id *id)
> +{
> + const struct sf19a2890_periphrst_data *data;
> + struct device *dev = &adev->dev;
> + const struct of_device_id *match;
> + struct sf19a2890_periphrst *rst;
> +
> + /* The OF node is the parent's, so device_get_match_data() cannot be used */
> + match = of_match_node(sf19a2890_periphrst_ids, dev->of_node);
> + if (!match)
> + return -ENODEV;
> + data = match->data;
> +
> + rst = devm_kzalloc(dev, sizeof(*rst), GFP_KERNEL);

devm_kzalloc_obj()

regards
Philipp