From: Steen Hegelund <steen.hegelund@microchip.com>
To: Herve Codina <herve.codina@bootlin.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
"Simon Horman" <horms@kernel.org>, Lee Jones <lee@kernel.org>,
Arnd Bergmann <arnd@arndb.de>,
Derek Kiernan <derek.kiernan@amd.com>,
Dragan Cvetic <dragan.cvetic@amd.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Bjorn Helgaas <bhelgaas@google.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
Lars Povlsen <lars.povlsen@microchip.com>,
Daniel Machon <daniel.machon@microchip.com>,
<UNGLinuxDriver@microchip.com>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Saravana Kannan <saravanak@google.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Horatiu Vultur <horatiu.vultur@microchip.com>,
"Andrew Lunn" <andrew@lunn.ch>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
<linux-pci@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
"Allan Nielsen" <allan.nielsen@microchip.com>,
Luca Ceresoli <luca.ceresoli@bootlin.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH v7 3/6] reset: mchp: sparx5: Map cpu-syscon locally in case of LAN966x
Date: Wed, 9 Oct 2024 09:29:52 +0200 [thread overview]
Message-ID: <71fb65a929e5d5be86f95ab76591beb77e641c14.camel@microchip.com> (raw)
In-Reply-To: <20241003081647.642468-4-herve.codina@bootlin.com>
Hi Herve,
On Thu, 2024-10-03 at 10:16 +0200, Herve Codina wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
>
> In the LAN966x PCI device use case, the syscon API cannot be used as
> it does not support device removal [1]. A syscon device is a core
> "system" device and not a device available in some addon boards and
> so,
> it is not supposed to be removed. The syscon API follows this
> assumption
> but this assumption is no longer valid in the LAN966x use case.
>
> In order to avoid the use of the syscon API and so, support for
> removal,
> use a local mapping of the syscon device.
>
> Link:
> https://lore.kernel.org/all/20240923100741.11277439@bootlin.com/ [1]
> Signed-off-by: Herve Codina <herve.codina@bootlin.com>
> ---
> drivers/reset/reset-microchip-sparx5.c | 35
> +++++++++++++++++++++++++-
> 1 file changed, 34 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/reset/reset-microchip-sparx5.c
> b/drivers/reset/reset-microchip-sparx5.c
> index 636e85c388b0..48a62d5da78d 100644
> --- a/drivers/reset/reset-microchip-sparx5.c
> +++ b/drivers/reset/reset-microchip-sparx5.c
> @@ -62,6 +62,28 @@ static const struct reset_control_ops
> sparx5_reset_ops = {
> .reset = sparx5_reset_noop,
> };
>
> +static const struct regmap_config mchp_lan966x_syscon_regmap_config
> = {
> + .reg_bits = 32,
> + .val_bits = 32,
> + .reg_stride = 4,
> +};
> +
> +static struct regmap *mchp_lan966x_syscon_to_regmap(struct device
> *dev,
> + struct
> device_node *syscon_np)
> +{
> + struct regmap_config regmap_config =
> mchp_lan966x_syscon_regmap_config;
> + resource_size_t size;
> + void __iomem *base;
> +
> + base = devm_of_iomap(dev, syscon_np, 0, &size);
> + if (IS_ERR(base))
> + return ERR_CAST(base);
> +
> + regmap_config.max_register = size - 4;
> +
> + return devm_regmap_init_mmio(dev, base, ®map_config);
> +}
> +
> static int mchp_sparx5_map_syscon(struct platform_device *pdev, char
> *name,
> struct regmap **target)
> {
> @@ -72,7 +94,18 @@ static int mchp_sparx5_map_syscon(struct
> platform_device *pdev, char *name,
> syscon_np = of_parse_phandle(pdev->dev.of_node, name, 0);
> if (!syscon_np)
> return -ENODEV;
> - regmap = syscon_node_to_regmap(syscon_np);
> +
> + /*
> + * The syscon API doesn't support syscon device removal.
> + * When used in LAN966x PCI device, the cpu-syscon device
> needs to be
> + * removed when the PCI device is removed.
> + * In case of LAN966x, map the syscon device locally to
> support the
> + * device removal.
> + */
> + if (of_device_is_compatible(pdev->dev.of_node,
> "microchip,lan966x-switch-reset"))
> + regmap = mchp_lan966x_syscon_to_regmap(&pdev->dev,
> syscon_np);
> + else
> + regmap = syscon_node_to_regmap(syscon_np);
> of_node_put(syscon_np);
> if (IS_ERR(regmap)) {
> err = PTR_ERR(regmap);
> --
> 2.46.1
>
This looks good to me.
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
BR
Steen
next prev parent reply other threads:[~2024-10-09 7:30 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-03 8:16 [PATCH v7 0/6] Add support for the LAN966x PCI device using a DT overlay Herve Codina
2024-10-03 8:16 ` [PATCH v7 1/6] misc: Add support for LAN966x PCI device Herve Codina
2024-10-03 9:13 ` Geert Uytterhoeven
2024-10-03 8:16 ` [PATCH v7 2/6] MAINTAINERS: Add the Microchip LAN966x PCI driver entry Herve Codina
2024-10-03 8:16 ` [PATCH v7 3/6] reset: mchp: sparx5: Map cpu-syscon locally in case of LAN966x Herve Codina
2024-10-09 7:29 ` Steen Hegelund [this message]
2024-10-09 10:20 ` Geert Uytterhoeven
2024-10-09 10:58 ` Conor Dooley
2024-10-09 10:15 ` Philipp Zabel
2024-10-03 8:16 ` [PATCH v7 4/6] reset: mchp: sparx5: Add MCHP_LAN966X_PCI dependency Herve Codina
2024-10-09 10:15 ` Philipp Zabel
2024-10-03 8:16 ` [PATCH v7 5/6] reset: mchp: sparx5: Allow building as a module Herve Codina
2024-10-09 10:15 ` Philipp Zabel
2024-10-03 8:16 ` [PATCH v7 6/6] reset: mchp: sparx5: set the dev member of the reset controller Herve Codina
2024-10-09 10:16 ` 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=71fb65a929e5d5be86f95ab76591beb77e641c14.camel@microchip.com \
--to=steen.hegelund@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=allan.nielsen@microchip.com \
--cc=andrew@lunn.ch \
--cc=andy.shevchenko@gmail.com \
--cc=arnd@arndb.de \
--cc=bhelgaas@google.com \
--cc=conor+dt@kernel.org \
--cc=daniel.machon@microchip.com \
--cc=davem@davemloft.net \
--cc=derek.kiernan@amd.com \
--cc=devicetree@vger.kernel.org \
--cc=dragan.cvetic@amd.com \
--cc=edumazet@google.com \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=herve.codina@bootlin.com \
--cc=horatiu.vultur@microchip.com \
--cc=horms@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=lars.povlsen@microchip.com \
--cc=lee@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=luca.ceresoli@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
--cc=saravanak@google.com \
--cc=thomas.petazzoni@bootlin.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;
as well as URLs for NNTP newsgroup(s).