From: Philipp Zabel <p.zabel@pengutronix.de>
To: filipp.dunsky@gmail.com, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>
Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org
Subject: Re: [PATCH 2/3] clk: cs7542: Add global PCIe controls and network engine reset
Date: Tue, 24 Nov 2026 10:48:03 +0100 [thread overview]
Message-ID: <9facd8eabb9d0c2bbe816117481dd624aa8c1f04.camel@pengutronix.de> (raw)
In-Reply-To: <20261124-b4-cs7542-global-controls-v1-2-12548785df2c@gmail.com>
On Di, 2026-11-24 at 00:50 +0300, Fil Dunsky via B4 Relay wrote:
> From: Fil Dunsky <filipp.dunsky@gmail.com>
>
> Register PCIe gates and controller resets through the early global
> provider. Add the network engine composite reset using the same syscon
> regmap, with the existing 1 us/1000 us readback polling and partial-domain
> status error from the posted NE reset driver. Keep the PCIe reset pulse
> delays and all provider-registration failure cleanup. NE pulse reset
> remains unsupported; the Ethernet consumer needs assert/deassert/status.
>
> Both independent consumers can use this common provider without a
> PCIe-host dependency or a resource-less network reset child.
>
> AI assistance: Codex prepared this draft from the posted CS7542 series.
>
> Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com>
> ---
> drivers/clk/Kconfig | 7 +-
> drivers/clk/clk-cs7542.c | 211 ++++++++++++++++++++++++++++++++++++++++++-----
> 2 files changed, 195 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
> index 47b5265fe..cba07bed3 100644
> --- a/drivers/clk/Kconfig
> +++ b/drivers/clk/Kconfig
> @@ -59,13 +59,16 @@ config LMK04832
> Low-Noise JESD204B Compliant Clock Jitter Cleaner With Dual Loop PLLs
>
> config COMMON_CLK_CS7542
> - bool "Cortina Systems CS7542 strap-selected clocks"
> + bool "Cortina Systems CS7542 global clocks and resets"
> depends on OF && HAS_IOMEM
> select MFD_SYSCON
> + select RESET_CONTROLLER
> help
> Read the boot straps of the CS7542 global control block to provide
> its APB, CPU and AXI clocks. This driver does not change PLLs or
> - dividers. It is built in because the APB clock is needed by timers.
> + dividers. It also provides the three PCIe clock gates and resets,
> + and the exclusive network engine and DMA-LSO/SSP reset domain.
> + It is built in because the APB clock is needed by timers.
>
> config COMMON_CLK_APPLE_NCO
> tristate "Clock driver for Apple SoC NCOs"
> diff --git a/drivers/clk/clk-cs7542.c b/drivers/clk/clk-cs7542.c
> index 4e6c1e98a..17b7109a9 100644
> --- a/drivers/clk/clk-cs7542.c
> +++ b/drivers/clk/clk-cs7542.c
[...]
> @@ -33,14 +38,142 @@ static const char * const cs7542_clock_names[] = {
> [CS7542_CLK_APB] = "cs7542-apb",
> [CS7542_CLK_CPU] = "cs7542-cpu",
> [CS7542_CLK_AXI] = "cs7542-axi",
> + [CS7542_CLK_PCIE0] = "cs7542-pcie0",
> + [CS7542_CLK_PCIE1] = "cs7542-pcie1",
> + [CS7542_CLK_PCIE2] = "cs7542-pcie2",
> +};
> +
> +#define CS7542_PORTS 3
> +#define CS7542_NUM_RESETS 4
> +/* NI, FE, TM, SCH, QM, DMA-LSO/SSP, NI XRAM; never reset SDRAM (bit 4). */
> +#define CS7542_NE_RESET_MASK (GENMASK(3, 0) | BIT(5) | BIT(16) | BIT(17))
So these are multiple separate resets merged into one logical reset
control? Does the hardware require them to be set with the same write
access?
> +#define GLOBAL_RESET 0x04
> +#define GLOBAL_CONFIG 0x10
> +
[...]
> +static int cs7542_gate_is_prepared(struct clk_hw *hw)
> +{
> + struct cs7542_gate *gate = container_of(hw, struct cs7542_gate, hw);
> + unsigned int value;
> + int ret;
> +
> + ret = regmap_read(gate->map, GLOBAL_CONFIG, &value);
> + return ret ? ret : !!(value & gate->mask);
Consider using regmap_test_bits() here.
> +}
> +
> +static const struct clk_ops cs7542_gate_ops = {
> + .prepare = cs7542_gate_prepare,
> + .unprepare = cs7542_gate_unprepare,
> + .is_prepared = cs7542_gate_is_prepared,
> +};
> +
> +static int cs7542_reset_update(struct reset_controller_dev *rcdev,
> + unsigned long id, bool assert)
> +{
> + struct cs7542_control *ctl = container_of(rcdev, struct cs7542_control, rcdev);
> + unsigned int value;
> + u32 mask, target;
> + int ret;
> +
> + if (id >= CS7542_NUM_RESETS)
> + return -EINVAL;
This is superfluous, fwnode_reset_simple_xlate() already checked this
before creating the reset control.
> + mask = id == CS7542_RESET_NE ? CS7542_NE_RESET_MASK : BIT(6 + id);
> + target = assert ? mask : 0;
> + ret = regmap_update_bits(ctl->map, GLOBAL_RESET, mask, target);
> + if (ret || id != CS7542_RESET_NE)
> + return ret;
> + return regmap_read_poll_timeout(ctl->map, 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_control *ctl = container_of(rcdev, struct cs7542_control, rcdev);
> + unsigned int value;
> + u32 mask;
> + int ret;
> +
> + if (id >= CS7542_NUM_RESETS)
> + return -EINVAL;
> + mask = id == CS7542_RESET_NE ? CS7542_NE_RESET_MASK : BIT(6 + id);
> + ret = regmap_read(ctl->map, GLOBAL_RESET, &value);
> + if (ret)
> + return ret;
> + value &= mask;
> + if (id == CS7542_RESET_NE && value && value != mask)
> + return -EIO;
Is this a sign that maybe these should be separate controls?
> + return !!value;
> +}
> +
> +static int cs7542_reset_pulse(struct reset_controller_dev *rcdev, unsigned long id)
> +{
> + int ret;
> +
> + if (id >= CS7542_NUM_RESETS)
> + return -EINVAL;
> + if (id == CS7542_RESET_NE)
> + return -EOPNOTSUPP;
> +
> + ret = cs7542_reset_assert(rcdev, id);
> + if (ret)
> + return ret;
> + usleep_range(10000, 12000);
> + ret = cs7542_reset_deassert(rcdev, id);
> + if (ret)
> + return ret;
> + usleep_range(10000, 12000);
> + return 0;
> +}
Please drop this and let the PCIe driver call
reset_control_assert/deassert() itself.
reset_control_reset() is for (compatibilty with) self-clearing resets.
regards
Philipp
next prev parent reply other threads:[~2026-11-24 9:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 21:50 [PATCH 0/3] soc: cortina: Add CS7542 shared gates and reset domains Fil Dunsky via B4 Relay
2026-11-23 21:50 ` [PATCH 1/3] dt-bindings: soc: Describe CS7542 global " Fil Dunsky via B4 Relay
2026-11-23 21:50 ` [PATCH 2/3] clk: cs7542: Add global PCIe controls and network engine reset Fil Dunsky via B4 Relay
2026-11-24 9:48 ` Philipp Zabel [this message]
2026-11-24 10:05 ` Fil Dunsky
2026-11-23 21:51 ` [PATCH 3/3] MAINTAINERS: Track CS7542 global reset specifiers 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=9facd8eabb9d0c2bbe816117481dd624aa8c1f04.camel@pengutronix.de \
--to=p.zabel@pengutronix.de \
--cc=bmasney+clk@redhat.com \
--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=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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®