From: Fil Dunsky via B4 Relay <devnull+filipp.dunsky.gmail.com@kernel.org>
To: Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
Linus Walleij <linusw@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
linux-gpio@vger.kernel.org
Subject: [PATCH v4 4/6] reset: Add Cortina Systems CS7542 global reset controller
Date: Wed, 25 Nov 2026 13:34:12 +0300 [thread overview]
Message-ID: <20261125-cs7542-syscon-v4-4-3337bb0d3b48@gmail.com> (raw)
In-Reply-To: <20261125-cs7542-syscon-v4-0-3337bb0d3b48@gmail.com>
From: Fil Dunsky <filipp.dunsky@gmail.com>
Use the shared syscon regmap to control three PCIe and seven network
engine reset signals. PCIe consumers supply their own assert and
recovery timing. Verify level transitions of the network resets before
the consumer releases DMA buffers. Reject the unassigned group ID to
preserve exclusive ownership of the underlying lines.
The clock provider registers early for timers. Match the platform
device for the same syscon when reset consumers can probe.
Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com>
---
drivers/reset/Kconfig | 10 ++++
drivers/reset/Makefile | 1 +
drivers/reset/reset-cs7542.c | 134 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 145 insertions(+)
diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index eda9c698a..544cb79fa 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -73,6 +73,16 @@ config RESET_BRCMSTB_RESCAL
This enables the RESCAL reset controller for SATA, PCIe0, or PCIe1 on
BCM7216 or the BCM2712.
+config RESET_CS7542
+ tristate "Cortina Systems CS7542 reset controller"
+ depends on OF && HAS_IOMEM
+ select MFD_SYSCON
+ help
+ Control the individual PCIe and network engine reset signals in
+ the CS7542 global register block.
+ The PCIe controllers have independent level resets. The network
+ engine uses seven reset lines, including the shared DMA block.
+
config RESET_DR1V90
tristate "Anlogic DR1V90 reset controller"
depends on ARCH_ANLOGIC || COMPILE_TEST
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index 489fafd6b..df183fc0a 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_RESET_BCM6345) += reset-bcm6345.o
obj-$(CONFIG_RESET_BERLIN) += reset-berlin.o
obj-$(CONFIG_RESET_BRCMSTB) += reset-brcmstb.o
obj-$(CONFIG_RESET_BRCMSTB_RESCAL) += reset-brcmstb-rescal.o
+obj-$(CONFIG_RESET_CS7542) += reset-cs7542.o
obj-$(CONFIG_RESET_DR1V90) += reset-dr1v90.o
obj-$(CONFIG_RESET_EIC7700) += reset-eic7700.o
obj-$(CONFIG_RESET_EIC7700_HSP) += reset-eic7700-hsp.o
diff --git a/drivers/reset/reset-cs7542.c b/drivers/reset/reset-cs7542.c
new file mode 100644
index 000000000..b86c82554
--- /dev/null
+++ b/drivers/reset/reset-cs7542.c
@@ -0,0 +1,134 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* Cortina Systems CS7542 global reset controller */
+
+#include <linux/bits.h>
+#include <linux/mfd/syscon.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/reset-controller.h>
+#include <linux/slab.h>
+
+#include <dt-bindings/reset/cortina,cs7542-reset.h>
+
+#define CS7542_GLOBAL_RESET 0x04
+
+static const u32 cs7542_reset_masks[] = {
+ [CS7542_RESET_PCIE0] = BIT(6),
+ [CS7542_RESET_PCIE1] = BIT(7),
+ [CS7542_RESET_PCIE2] = BIT(8),
+ [CS7542_RESET_NI] = BIT(0),
+ [CS7542_RESET_FE] = BIT(1),
+ [CS7542_RESET_TM] = BIT(2),
+ [CS7542_RESET_SCH] = BIT(3),
+ [CS7542_RESET_QM] = BIT(5),
+ [CS7542_RESET_DMA] = BIT(16),
+ [CS7542_RESET_NI_XRAM] = BIT(17),
+};
+
+struct cs7542_reset {
+ struct reset_controller_dev rcdev;
+ struct regmap *map;
+};
+
+static int cs7542_reset_update(struct reset_controller_dev *rcdev,
+ unsigned long id, bool assert)
+{
+ struct cs7542_reset *rst = container_of(rcdev, struct cs7542_reset, rcdev);
+ u32 mask = cs7542_reset_masks[id];
+ u32 target = assert ? mask : 0;
+ unsigned int value;
+ int ret;
+
+ ret = regmap_update_bits(rst->map, CS7542_GLOBAL_RESET, mask, target);
+ if (ret || id < CS7542_RESET_NI)
+ return ret;
+
+ return regmap_read_poll_timeout(rst->map, CS7542_GLOBAL_RESET, value,
+ (value & mask) == target, 1, 1000);
+}
+
+static int cs7542_reset_assert(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ return cs7542_reset_update(rcdev, id, true);
+}
+
+static int cs7542_reset_deassert(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ return cs7542_reset_update(rcdev, id, false);
+}
+
+static int cs7542_reset_status(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ struct cs7542_reset *rst = container_of(rcdev, struct cs7542_reset, rcdev);
+
+ return regmap_test_bits(rst->map, CS7542_GLOBAL_RESET, cs7542_reset_masks[id]);
+}
+
+static int cs7542_reset_xlate(struct reset_controller_dev *rcdev,
+ const struct of_phandle_args *spec)
+{
+ unsigned int id = spec->args[0];
+
+ if (id >= rcdev->nr_resets || !cs7542_reset_masks[id])
+ return -EINVAL;
+
+ return id;
+}
+
+static const struct reset_control_ops cs7542_reset_ops = {
+ .assert = cs7542_reset_assert,
+ .deassert = cs7542_reset_deassert,
+ .status = cs7542_reset_status,
+};
+
+static int cs7542_reset_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct cs7542_reset *rst;
+
+ /* Clock-only descriptions also use this syscon. */
+ if (!of_property_present(dev->of_node, "#reset-cells"))
+ return 0;
+
+ rst = devm_kzalloc(dev, sizeof(*rst), GFP_KERNEL);
+ if (!rst)
+ return -ENOMEM;
+
+ rst->map = syscon_node_to_regmap(dev->of_node);
+ if (IS_ERR(rst->map))
+ return dev_err_probe(dev, PTR_ERR(rst->map), "cannot get global regmap\n");
+
+ rst->rcdev.owner = THIS_MODULE;
+ rst->rcdev.dev = dev;
+ rst->rcdev.of_node = dev->of_node;
+ rst->rcdev.ops = &cs7542_reset_ops;
+ rst->rcdev.nr_resets = ARRAY_SIZE(cs7542_reset_masks);
+ rst->rcdev.of_reset_n_cells = 1;
+ rst->rcdev.of_xlate = cs7542_reset_xlate;
+
+ return devm_reset_controller_register(dev, &rst->rcdev);
+}
+
+static const struct of_device_id cs7542_reset_of_match[] = {
+ { .compatible = "cortina,cs7542-syscon" },
+ { }
+};
+MODULE_DEVICE_TABLE(of, cs7542_reset_of_match);
+
+static struct platform_driver cs7542_reset_driver = {
+ .probe = cs7542_reset_probe,
+ .driver = {
+ .name = "cs7542-reset",
+ .of_match_table = cs7542_reset_of_match,
+ .suppress_bind_attrs = true,
+ },
+};
+module_platform_driver(cs7542_reset_driver);
+
+MODULE_DESCRIPTION("Cortina Systems CS7542 global reset controller");
+MODULE_LICENSE("GPL");
--
2.53.0
next prev parent reply other threads:[~2026-11-25 10:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 10:34 [PATCH v4 0/6] soc: cortina: Add CS7542 global clocks, reset controller and pinctrl Fil Dunsky via B4 Relay
2026-11-25 10:34 ` [PATCH v4 1/6] dt-bindings: soc: Add Cortina Systems CS7542 global controls Fil Dunsky via B4 Relay
2026-11-25 10:34 ` [PATCH v4 2/6] dt-bindings: pinctrl: Add Cortina Systems CS7542 pin mux Fil Dunsky via B4 Relay
2026-11-25 10:34 ` [PATCH v4 3/6] clk: Add Cortina Systems CS7542 clocks Fil Dunsky via B4 Relay
2026-11-25 10:46 ` sashiko-bot
2026-11-25 10:34 ` Fil Dunsky via B4 Relay [this message]
2026-11-25 10:34 ` [PATCH v4 5/6] pinctrl: Add Cortina Systems CS7542 pin multiplexer Fil Dunsky via B4 Relay
2026-11-25 10:34 ` [PATCH v4 6/6] MAINTAINERS: Add CS7542 global control support Fil Dunsky via B4 Relay
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=20261125-cs7542-syscon-v4-4-3337bb0d3b48@gmail.com \
--to=devnull+filipp.dunsky.gmail.com@kernel.org \
--cc=bmasney+clk@redhat.com \
--cc=brgl@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=filipp.dunsky@gmail.com \
--cc=jbrunet+clk@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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