From: Philipp Zabel <p.zabel@pengutronix.de>
To: joseph@telaak.dev, Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: "Paul Burton" <paulburton@kernel.org>,
"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
"Chuanhong Guo" <gch981213@gmail.com>, "Yao Zi" <me@ziyao.cc>,
"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
linux-mips@vger.kernel.org, linux-clk@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 6/6] reset: Add Siflower SF19A2890 peripheral reset driver
Date: Tue, 24 Nov 2026 11:30:03 +0100 [thread overview]
Message-ID: <bfa7cff359bf346981be355d0429f4743a58dbc4.camel@pengutronix.de> (raw)
In-Reply-To: <20261123-sf19a2890-sysm-v5-6-4ba44a0db17d@telaak.dev>
On Mo, 2026-11-23 at 23:41 -0500, Joseph Telaak via B4 Relay wrote:
> From: Joseph Telaak <joseph@telaak.dev>
>
> 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@gmail.com>
> Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
> Signed-off-by: Joseph Telaak <joseph@telaak.dev>
> ---
> 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
prev parent reply other threads:[~2026-11-24 10:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 4:41 [PATCH v5 0/6] clk: Add the Siflower SF19A2890 clock manager and peripheral clock and reset managers Joseph Telaak via B4 Relay
2026-11-24 4:41 ` [PATCH v5 1/6] MIPS: Add support for Siflower MIPS SoCs Joseph Telaak via B4 Relay
2026-11-24 4:41 ` [PATCH v5 2/6] dt-bindings: clock: Add Siflower SF19A2890 clock manager Joseph Telaak via B4 Relay
2026-11-24 4:41 ` [PATCH v5 3/6] clk: siflower: Add SF19A2890 clock manager driver Joseph Telaak via B4 Relay
2026-11-24 4:41 ` [PATCH v5 4/6] dt-bindings: clock: Add Siflower SF19A2890 peripheral clock/reset managers Joseph Telaak via B4 Relay
2026-11-24 4:41 ` [PATCH v5 5/6] clk: siflower: Add SF19A2890 peripheral clock driver Joseph Telaak via B4 Relay
2026-11-24 4:41 ` [PATCH v5 6/6] reset: Add Siflower SF19A2890 peripheral reset driver Joseph Telaak via B4 Relay
2026-11-24 10:30 ` Philipp Zabel [this message]
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=bfa7cff359bf346981be355d0429f4743a58dbc4.camel@pengutronix.de \
--to=p.zabel@pengutronix.de \
--cc=bmasney+clk@redhat.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gch981213@gmail.com \
--cc=jbrunet+clk@baylibre.com \
--cc=jiaxun.yang@flygoat.com \
--cc=joseph@telaak.dev \
--cc=krzk+dt@kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=me@ziyao.cc \
--cc=paulburton@kernel.org \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=tsbogend@alpha.franken.de \
--cc=u.kleine-koenig@baylibre.com \
/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
all inboxes | Powered by JetHome®