From: Lee Jones <lee.jones@linaro.org>
To: Stefan Wahren <stefan.wahren@i2se.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
Ray Jui <rjui@broadcom.com>,
Scott Branden <sbranden@broadcom.com>,
Peter Robinson <pbrobinson@gmail.com>,
Melissa Wen <melissa.srw@gmail.com>,
Phil Elwell <phil@raspberrypi.com>,
bcm-kernel-feedback-list@broadcom.com,
Maxime Ripard <maxime@cerno.tech>,
devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Subject: Re: [PATCH V3 06/11] mfd: bcm2835-pm: Use 'reg-names' to get resources
Date: Thu, 23 Jun 2022 09:27:45 +0100 [thread overview]
Message-ID: <YrQkAYS0U5PyBLJb@google.com> (raw)
In-Reply-To: <20220607204226.8703-7-stefan.wahren@i2se.com>
On Tue, 07 Jun 2022, Stefan Wahren wrote:
> From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
>
> If available in firmware, find resources by their 'reg-names' position
> instead of relying on hardcoded offsets. Care is taken to support old
> firmware nonetheless.
>
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
> ---
> drivers/mfd/bcm2835-pm.c | 59 +++++++++++++++++++++++++++-------------
> 1 file changed, 40 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/mfd/bcm2835-pm.c b/drivers/mfd/bcm2835-pm.c
> index 42fe67f1538e..ff0dae5a026d 100644
> --- a/drivers/mfd/bcm2835-pm.c
> +++ b/drivers/mfd/bcm2835-pm.c
> @@ -25,9 +25,41 @@ static const struct mfd_cell bcm2835_power_devs[] = {
> { .name = "bcm2835-power" },
> };
>
> +static int bcm2835_pm_get_pdata(struct platform_device *pdev,
> + struct bcm2835_pm *pm)
> +{
> + /* If no 'reg-names' property is found we can assume we're using old
> + * firmware.
> + */
Please use the correct format for multi-line comments.
Better still, convert this to a single line comment.
> + if (!of_find_property(pm->dev->of_node, "reg-names", NULL)) {
> + dev_warn(pm->dev, "reg-names are missing, please update your DTB.\n");
> +
> + pm->base = devm_platform_ioremap_resource(pdev, 0);
> + if (IS_ERR(pm->base))
> + return PTR_ERR(pm->base);
> +
> + pm->asb = devm_platform_ioremap_resource(pdev, 1);
Might be nicer to return here and remove the else.
> + } else {
> + struct resource *res;
> +
> + pm->base = devm_platform_ioremap_resource_byname(pdev, "pm");
> + if (IS_ERR(pm->base))
> + return PTR_ERR(pm->base);
> +
> + res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
> + "asb");
While you're at it, might as well make this single line too.
> + if (res)
> + pm->asb = devm_ioremap_resource(&pdev->dev, res);
> + }
> +
> + if (IS_ERR(pm->asb))
> + pm->asb = NULL;
> +
> + return 0;
> +}
> +
> static int bcm2835_pm_probe(struct platform_device *pdev)
> {
> - struct resource *res;
> struct device *dev = &pdev->dev;
> struct bcm2835_pm *pm;
> int ret;
> @@ -39,10 +71,9 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
>
> pm->dev = dev;
>
> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - pm->base = devm_ioremap_resource(dev, res);
> - if (IS_ERR(pm->base))
> - return PTR_ERR(pm->base);
> + ret = bcm2835_pm_get_pdata(pdev, pm);
> + if (ret)
> + return ret;
>
> ret = devm_mfd_add_devices(dev, -1,
> bcm2835_pm_devs, ARRAY_SIZE(bcm2835_pm_devs),
> @@ -54,20 +85,10 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
> * bcm2835-pm binding as the key for whether we can reference
> * the full PM register range and support power domains.
> */
> - res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> - if (res) {
> - pm->asb = devm_ioremap_resource(dev, res);
> - if (IS_ERR(pm->asb))
> - return PTR_ERR(pm->asb);
> -
> - ret = devm_mfd_add_devices(dev, -1,
> - bcm2835_power_devs,
> - ARRAY_SIZE(bcm2835_power_devs),
> - NULL, 0, NULL);
> - if (ret)
> - return ret;
> - }
> -
> + if (pm->asb)
> + return devm_mfd_add_devices(dev, -1, bcm2835_power_devs,
> + ARRAY_SIZE(bcm2835_power_devs),
> + NULL, 0, NULL);
> return 0;
> }
>
--
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
next prev parent reply other threads:[~2022-06-23 8:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-07 20:42 [PATCH V3 00/11] soc: bcm2835-power: Prepare BCM2711 V3D support Stefan Wahren
2022-06-07 20:42 ` [PATCH V3 01/11] dt-bindings: soc: bcm: bcm2835-pm: Convert bindings to DT schema Stefan Wahren
2022-06-07 20:42 ` [PATCH V3 02/11] dt-bindings: soc: bcm: bcm2835-pm: Introduce reg-names Stefan Wahren
2022-06-07 20:42 ` [PATCH V3 03/11] dt-bindings: soc: bcm: bcm2835-pm: Add support for bcm2711 Stefan Wahren
2022-06-09 20:42 ` Rob Herring
2022-06-07 20:42 ` [PATCH V3 04/11] ARM: dts: bcm2835/bcm2711: Introduce reg-names in watchdog node Stefan Wahren
2022-06-07 20:42 ` [PATCH V3 05/11] ARM: dts: bcm2711: Use proper compatible in PM/Watchdog node Stefan Wahren
2022-06-07 20:42 ` [PATCH V3 06/11] mfd: bcm2835-pm: Use 'reg-names' to get resources Stefan Wahren
2022-06-23 8:27 ` Lee Jones [this message]
2022-06-07 20:42 ` [PATCH V3 07/11] mfd: bcm2835-pm: Add support for BCM2711 Stefan Wahren
2022-06-23 8:41 ` Lee Jones
2022-06-07 20:42 ` [PATCH V3 08/11] soc: bcm: bcm2835-power: Refactor ASB control Stefan Wahren
2022-06-07 20:42 ` [PATCH V3 09/11] soc: bcm: bcm2835-power: Resolve ASB register macros Stefan Wahren
2022-06-07 20:42 ` [PATCH V3 10/11] soc: bcm: bcm2835-power: Add support for BCM2711's RPiVid ASB Stefan Wahren
2022-06-07 20:42 ` [PATCH V3 11/11] soc: bcm: bcm2835-power: Bypass power_on/off() calls Stefan Wahren
2022-06-08 9:27 ` [PATCH V3 00/11] soc: bcm2835-power: Prepare BCM2711 V3D support Florian Fainelli
2022-06-15 17:38 ` Florian Fainelli
2022-06-23 2:02 ` Florian Fainelli
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=YrQkAYS0U5PyBLJb@google.com \
--to=lee.jones@linaro.org \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=devicetree@vger.kernel.org \
--cc=f.fainelli@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maxime@cerno.tech \
--cc=melissa.srw@gmail.com \
--cc=nsaenzjulienne@suse.de \
--cc=pbrobinson@gmail.com \
--cc=phil@raspberrypi.com \
--cc=rjui@broadcom.com \
--cc=sbranden@broadcom.com \
--cc=stefan.wahren@i2se.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).