From: Changhuang Liang <changhuang.liang@starfivetech.com>
To: Brian Masney <bmasney@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
Emil Renner Berthing <kernel@esmil.dk>
Cc: Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-riscv@lists.infradead.org,
Hal Feng <hal.feng@starfivetech.com>,
Changhuang Liang <changhuang.liang@starfivetech.com>
Subject: [PATCH v2 5/6] reset: starfive: jh71x0: Support discontiguous reset IDs
Date: Wed, 18 Nov 2026 02:05:22 -0800 [thread overview]
Message-ID: <20261118100523.11395-6-changhuang.liang@starfivetech.com> (raw)
In-Reply-To: <20261118100523.11395-1-changhuang.liang@starfivetech.com>
The reset IDs exposed to consumers of the StarFive JHB100 reset
controllers do not map one-to-one to the hardware reset bits.
Add struct jh71x0_reset_info, which describes the number of resets, the
assert/status register offsets and, for such controllers, a table of
hardware reset lines indexed by reset ID. Add
reset_starfive_jh71x0_register_with_info() to register a controller
described this way.
If a map is provided, install a custom fwnode_xlate callback that
translates the reset ID of the reset specifier to the hardware reset
line. The translation is thus done once when a reset control is
requested, and the reset operations are left untouched since they only
ever see hardware reset lines.
Existing users of reset_starfive_jh71x0_register() are unaffected.
Signed-off-by: Changhuang Liang <changhuang.liang@starfivetech.com>
---
.../reset/starfive/reset-starfive-jh71x0.c | 60 +++++++++++++++++++
.../reset/starfive/reset-starfive-jh71x0.h | 24 ++++++++
2 files changed, 84 insertions(+)
diff --git a/drivers/reset/starfive/reset-starfive-jh71x0.c b/drivers/reset/starfive/reset-starfive-jh71x0.c
index d410a5a0ded4..5c64d47fb530 100644
--- a/drivers/reset/starfive/reset-starfive-jh71x0.c
+++ b/drivers/reset/starfive/reset-starfive-jh71x0.c
@@ -7,6 +7,7 @@
#include <linux/bitmap.h>
#include <linux/device.h>
+#include <linux/fwnode.h>
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/reset-controller.h>
@@ -21,6 +22,8 @@ struct jh71x0_reset {
void __iomem *assert;
void __iomem *status;
const u32 *asserted;
+ /* optional hardware reset lines indexed by reset ID, rcdev.nr_resets entries */
+ const unsigned int *map;
};
static inline struct jh71x0_reset *
@@ -29,6 +32,23 @@ jh71x0_reset_from(struct reset_controller_dev *rcdev)
return container_of(rcdev, struct jh71x0_reset, rcdev);
}
+/*
+ * Translate the reset ID of a reset specifier to the hardware reset line once,
+ * when the reset control is requested, so that the reset operations only ever
+ * see hardware reset lines.
+ */
+static int jh71x0_reset_fwnode_xlate(struct reset_controller_dev *rcdev,
+ const struct fwnode_reference_args *reset_spec)
+{
+ struct jh71x0_reset *data = jh71x0_reset_from(rcdev);
+ unsigned int id = reset_spec->args[0];
+
+ if (id >= rcdev->nr_resets)
+ return -EINVAL;
+
+ return data->map[id];
+}
+
static int jh71x0_reset_update(struct reset_controller_dev *rcdev,
unsigned long id, bool assert)
{
@@ -132,3 +152,43 @@ int reset_starfive_jh71x0_register(struct device *dev, struct device_node *of_no
return devm_reset_controller_register(dev, &data->rcdev);
}
EXPORT_SYMBOL_GPL(reset_starfive_jh71x0_register);
+
+int reset_starfive_jh71x0_register_with_info(struct device *dev, struct device_node *of_node,
+ void __iomem *assert, void __iomem *status,
+ const u32 *asserted,
+ const struct jh71x0_reset_info *info,
+ struct module *owner)
+{
+ struct jh71x0_reset *data;
+ int ret;
+
+ data = devm_kzalloc_obj(dev, *data);
+ if (!data)
+ return -ENOMEM;
+
+ data->rcdev.ops = &jh71x0_reset_ops;
+ data->rcdev.owner = owner;
+ data->rcdev.nr_resets = info->nr_resets;
+ data->rcdev.dev = dev;
+ data->rcdev.of_node = of_node;
+
+ if (info->map) {
+ data->map = info->map;
+ data->rcdev.fwnode_xlate = jh71x0_reset_fwnode_xlate;
+ data->rcdev.fwnode_reset_n_cells = 1;
+ }
+
+ spin_lock_init(&data->lock);
+ data->assert = assert;
+ data->status = status;
+ data->asserted = asserted;
+
+ ret = devm_reset_controller_register(dev, &data->rcdev);
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "Failed to register reset controller\n");
+
+ dev_info(dev, "Registered %u resets\n", data->rcdev.nr_resets);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(reset_starfive_jh71x0_register_with_info);
diff --git a/drivers/reset/starfive/reset-starfive-jh71x0.h b/drivers/reset/starfive/reset-starfive-jh71x0.h
index db7d39a87f87..918ecec3975e 100644
--- a/drivers/reset/starfive/reset-starfive-jh71x0.h
+++ b/drivers/reset/starfive/reset-starfive-jh71x0.h
@@ -6,9 +6,33 @@
#ifndef __RESET_STARFIVE_JH71X0_H
#define __RESET_STARFIVE_JH71X0_H
+/**
+ * struct jh71x0_reset_info - description of a reset controller
+ * @nr_resets: number of resets, which is the number of @map entries if @map
+ * is set
+ * @assert_offset: offset of the first assert register
+ * @status_offset: offset of the first status register
+ * @map: optional table of hardware reset lines, i.e. bit numbers in the
+ * assert/status registers, indexed by reset ID, for controllers whose
+ * reset IDs do not map one-to-one to the hardware reset lines; NULL if
+ * the reset ID is the hardware reset line
+ */
+struct jh71x0_reset_info {
+ unsigned int nr_resets;
+ unsigned int assert_offset;
+ unsigned int status_offset;
+ const unsigned int *map;
+};
+
int reset_starfive_jh71x0_register(struct device *dev, struct device_node *of_node,
void __iomem *assert, void __iomem *status,
const u32 *asserted, unsigned int nr_resets,
struct module *owner);
+int reset_starfive_jh71x0_register_with_info(struct device *dev, struct device_node *of_node,
+ void __iomem *assert, void __iomem *status,
+ const u32 *asserted,
+ const struct jh71x0_reset_info *info,
+ struct module *owner);
+
#endif /* __RESET_STARFIVE_JH71X0_H */
--
2.25.1
next prev parent reply other threads:[~2026-11-18 10:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 10:05 [PATCH v2 0/6] Add System-0 CRG for JHB100 SoC Changhuang Liang
2026-11-18 10:05 ` [PATCH v2 1/6] clk: starfive: jh7110-sys: Fix memory leak in reset controller register Changhuang Liang
2026-11-18 10:05 ` [PATCH v2 2/6] clk: starfive: jh71x0: Move reset controller registration to jh71x0 common code Changhuang Liang
2026-11-18 10:05 ` [PATCH v2 3/6] clk: starfive: jh71x0: Add generic CRG probe helper Changhuang Liang
2026-11-18 10:05 ` [PATCH v2 4/6] clk: starfive: Add JHB100 System-0 clock generator driver Changhuang Liang
2026-11-18 10:05 ` Changhuang Liang [this message]
2026-11-18 10:39 ` [PATCH v2 5/6] reset: starfive: jh71x0: Support discontiguous reset IDs Philipp Zabel
2026-11-18 10:05 ` [PATCH v2 6/6] reset: starfive: Add StarFive JHB100 System-0 reset driver Changhuang Liang
2026-11-18 10:39 ` Philipp Zabel
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=20261118100523.11395-6-changhuang.liang@starfivetech.com \
--to=changhuang.liang@starfivetech.com \
--cc=bmasney@redhat.com \
--cc=conor+dt@kernel.org \
--cc=hal.feng@starfivetech.com \
--cc=jbrunet+clk@baylibre.com \
--cc=kernel@esmil.dk \
--cc=krzk+dt@kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--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
all inboxes | Powered by JetHome®