From: Steven Price <steven.price@arm.com>
To: Nicolas Boichat <drinkcat@chromium.org>,
Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <Mark.Rutland@arm.com>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"ulf.hansson@linaro.org" <ulf.hansson@linaro.org>,
Tomeu Vizoso <tomeu.vizoso@collabora.com>,
David Airlie <airlied@linux.ie>,
Liam Girdwood <lgirdwood@gmail.com>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Mark Brown <broonie@kernel.org>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>,
Daniel Vetter <daniel@ffwll.ch>,
"hsinyi@chromium.org" <hsinyi@chromium.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v4 4/7] drm/panfrost: Add support for multiple regulators
Date: Mon, 10 Feb 2020 11:31:29 +0000 [thread overview]
Message-ID: <df99cedb-4c2c-b8b8-14e6-d7b8d8fe351a@arm.com> (raw)
In-Reply-To: <20200207052627.130118-5-drinkcat@chromium.org>
On 07/02/2020 05:26, Nicolas Boichat wrote:
> Some GPUs, namely, the bifrost/g72 part on MT8183, have a second
> regulator for their SRAM, let's add support for that.
>
> We extend the framework in a generic manner so that we could
> support more than 2 regulators, if required.
>
> Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Steven Price <steven.price@arm.com>
Thanks,
Steve
>
> ---
>
> v4:
> - nits: Run through latest version of checkpatch:
> - Use WARN instead of BUG_ON.
> - Drop braces in single expression for loop.
> - *comp not * comp
> v3:
> - Make this more generic, by allowing any number of regulators
> (in practice we fix the maximum number of regulators to 2, but
> this could be increased easily).
> - We only probe the second regulator if the device tree matching
> data asks for it.
> - I couldn't find a way to detect the number of regulators in the
> device tree, if we wanted to refuse to probe the device if there
> are too many regulators, which might be required for safety, see
> the thread on v2 [1].
> - The discussion also included the idea of a separate device tree
> entry for a "soft PDC", or at least a separate driver. I'm not
> sure to understand the full picture, and how different vendors
> implement this, so I'm still integrating everything in the main
> driver. I'd be happy to try to make mt8183 fit into such a
> framework after it's created, but I don't think I'm best placed
> to implement (and again, the main purpose of this was to test
> if the binding is correct).
>
> [1] https://patchwork.kernel.org/patch/11322839/
>
> drivers/gpu/drm/panfrost/panfrost_device.c | 26 +++++++++++++-------
> drivers/gpu/drm/panfrost/panfrost_device.h | 15 +++++++++++-
> drivers/gpu/drm/panfrost/panfrost_drv.c | 28 +++++++++++++++-------
> 3 files changed, 51 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c
> index 238fb6d54df4732..3720d50f6d9f965 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_device.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_device.c
> @@ -87,18 +87,27 @@ static void panfrost_clk_fini(struct panfrost_device *pfdev)
>
> static int panfrost_regulator_init(struct panfrost_device *pfdev)
> {
> - int ret;
> + int ret, i;
>
> - pfdev->regulator = devm_regulator_get(pfdev->dev, "mali");
> - if (IS_ERR(pfdev->regulator)) {
> - ret = PTR_ERR(pfdev->regulator);
> - dev_err(pfdev->dev, "failed to get regulator: %d\n", ret);
> + if (WARN(pfdev->comp->num_supplies > ARRAY_SIZE(pfdev->regulators),
> + "Too many supplies in compatible structure.\n"))
> + return -EINVAL;
> +
> + for (i = 0; i < pfdev->comp->num_supplies; i++)
> + pfdev->regulators[i].supply = pfdev->comp->supply_names[i];
> +
> + ret = devm_regulator_bulk_get(pfdev->dev,
> + pfdev->comp->num_supplies,
> + pfdev->regulators);
> + if (ret < 0) {
> + dev_err(pfdev->dev, "failed to get regulators: %d\n", ret);
> return ret;
> }
>
> - ret = regulator_enable(pfdev->regulator);
> + ret = regulator_bulk_enable(pfdev->comp->num_supplies,
> + pfdev->regulators);
> if (ret < 0) {
> - dev_err(pfdev->dev, "failed to enable regulator: %d\n", ret);
> + dev_err(pfdev->dev, "failed to enable regulators: %d\n", ret);
> return ret;
> }
>
> @@ -107,7 +116,8 @@ static int panfrost_regulator_init(struct panfrost_device *pfdev)
>
> static void panfrost_regulator_fini(struct panfrost_device *pfdev)
> {
> - regulator_disable(pfdev->regulator);
> + regulator_bulk_disable(pfdev->comp->num_supplies,
> + pfdev->regulators);
> }
>
> int panfrost_device_init(struct panfrost_device *pfdev)
> diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h
> index 06713811b92cdf7..c9468bc5573ac9d 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_device.h
> +++ b/drivers/gpu/drm/panfrost/panfrost_device.h
> @@ -7,6 +7,7 @@
>
> #include <linux/atomic.h>
> #include <linux/io-pgtable.h>
> +#include <linux/regulator/consumer.h>
> #include <linux/spinlock.h>
> #include <drm/drm_device.h>
> #include <drm/drm_mm.h>
> @@ -19,6 +20,7 @@ struct panfrost_job;
> struct panfrost_perfcnt;
>
> #define NUM_JOB_SLOTS 3
> +#define MAX_REGULATORS 2
>
> struct panfrost_features {
> u16 id;
> @@ -51,6 +53,16 @@ struct panfrost_features {
> unsigned long hw_issues[64 / BITS_PER_LONG];
> };
>
> +/*
> + * Features that cannot be automatically detected and need matching using the
> + * compatible string, typically SoC-specific.
> + */
> +struct panfrost_compatible {
> + /* Supplies count and names. */
> + int num_supplies;
> + const char * const *supply_names;
> +};
> +
> struct panfrost_device {
> struct device *dev;
> struct drm_device *ddev;
> @@ -59,10 +71,11 @@ struct panfrost_device {
> void __iomem *iomem;
> struct clk *clock;
> struct clk *bus_clock;
> - struct regulator *regulator;
> + struct regulator_bulk_data regulators[MAX_REGULATORS];
> struct reset_control *rstc;
>
> struct panfrost_features features;
> + const struct panfrost_compatible *comp;
>
> spinlock_t as_lock;
> unsigned long as_in_use_mask;
> diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c
> index b7a618db3ee223e..4d08507526239f2 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_drv.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c
> @@ -584,6 +584,10 @@ static int panfrost_probe(struct platform_device *pdev)
>
> platform_set_drvdata(pdev, pfdev);
>
> + pfdev->comp = of_device_get_match_data(&pdev->dev);
> + if (!pfdev->comp)
> + return -ENODEV;
> +
> /* Allocate and initialze the DRM device. */
> ddev = drm_dev_alloc(&panfrost_drm_driver, &pdev->dev);
> if (IS_ERR(ddev))
> @@ -655,16 +659,22 @@ static int panfrost_remove(struct platform_device *pdev)
> return 0;
> }
>
> +const char * const default_supplies[] = { "mali" };
> +static const struct panfrost_compatible default_data = {
> + .num_supplies = ARRAY_SIZE(default_supplies),
> + .supply_names = default_supplies,
> +};
> +
> static const struct of_device_id dt_match[] = {
> - { .compatible = "arm,mali-t604" },
> - { .compatible = "arm,mali-t624" },
> - { .compatible = "arm,mali-t628" },
> - { .compatible = "arm,mali-t720" },
> - { .compatible = "arm,mali-t760" },
> - { .compatible = "arm,mali-t820" },
> - { .compatible = "arm,mali-t830" },
> - { .compatible = "arm,mali-t860" },
> - { .compatible = "arm,mali-t880" },
> + { .compatible = "arm,mali-t604", .data = &default_data, },
> + { .compatible = "arm,mali-t624", .data = &default_data, },
> + { .compatible = "arm,mali-t628", .data = &default_data, },
> + { .compatible = "arm,mali-t720", .data = &default_data, },
> + { .compatible = "arm,mali-t760", .data = &default_data, },
> + { .compatible = "arm,mali-t820", .data = &default_data, },
> + { .compatible = "arm,mali-t830", .data = &default_data, },
> + { .compatible = "arm,mali-t860", .data = &default_data, },
> + { .compatible = "arm,mali-t880", .data = &default_data, },
> {}
> };
> MODULE_DEVICE_TABLE(of, dt_match);
>
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
next prev parent reply other threads:[~2020-02-10 11:31 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-07 5:26 [PATCH v4 0/7] Add dts for mt8183 GPU (and misc panfrost patches) Nicolas Boichat
2020-02-07 5:26 ` [PATCH v4 1/7] dt-bindings: gpu: mali-bifrost: Add Mediatek MT8183 Nicolas Boichat
2020-02-25 17:16 ` Rob Herring
2020-02-26 0:55 ` Nicolas Boichat
2020-03-06 2:34 ` Nick Fan
2020-03-06 2:43 ` Nicolas Boichat
2020-03-06 14:13 ` Rob Herring
2020-03-06 14:43 ` Steven Price
2020-03-09 7:55 ` Nick Fan
2020-02-07 5:26 ` [PATCH v4 2/7] arm64: dts: mt8183: Add node for the Mali GPU Nicolas Boichat
2020-02-07 5:26 ` [PATCH v4 3/7] drm/panfrost: Improve error reporting in panfrost_gpu_power_on Nicolas Boichat
2020-02-12 10:38 ` Matthias Brugger
2020-02-07 5:26 ` [PATCH v4 4/7] drm/panfrost: Add support for multiple regulators Nicolas Boichat
2020-02-10 11:31 ` Steven Price [this message]
2020-02-10 14:00 ` Mark Brown
2020-02-07 5:26 ` [PATCH v4 5/7] drm/panfrost: Add support for multiple power domains Nicolas Boichat
2020-02-07 13:52 ` Alyssa Rosenzweig
2020-02-09 12:43 ` Nicolas Boichat
2020-02-07 14:25 ` Ulf Hansson
2020-02-09 12:50 ` Nicolas Boichat
2020-02-10 7:50 ` Ulf Hansson
2020-02-10 11:39 ` Steven Price
2020-02-11 19:43 ` Rob Herring
2020-02-11 20:08 ` Saravana Kannan
2020-02-12 1:58 ` Rob Herring
2020-02-12 2:10 ` Saravana Kannan
2020-02-12 2:08 ` Nicolas Boichat
2020-02-07 5:26 ` [PATCH v4 6/7] RFC: drm/panfrost: Add mt8183-mali compatible string Nicolas Boichat
2020-02-07 5:26 ` [PATCH v4 7/7] RFC: drm/panfrost: devfreq: Add support for 2 regulators Nicolas Boichat
2020-02-12 8:49 ` Nicolas Boichat
2020-02-12 9:06 ` Viresh Kumar
2020-02-12 18:14 ` Rob Herring
2020-02-13 7:57 ` Nicolas Boichat
2020-02-13 8:24 ` Nicolas Boichat
[not found] ` <e4e95aa7713344e8b43fe5fad05de3ee@mtkmbs01n1.mediatek.inc>
2020-03-09 1:53 ` Nicolas Boichat
2020-02-07 6:17 ` [PATCH v4 0/7] Add dts for mt8183 GPU (and misc panfrost patches) Tomeu Vizoso
2020-02-07 7:42 ` Nicolas Boichat
2020-02-07 8:13 ` Tomeu Vizoso
2020-02-10 3:39 ` Nicolas Boichat
2020-02-10 8:17 ` Tomeu Vizoso
2020-02-25 20:35 ` Rob Herring
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=df99cedb-4c2c-b8b8-14e6-d7b8d8fe351a@arm.com \
--to=steven.price@arm.com \
--cc=Mark.Rutland@arm.com \
--cc=airlied@linux.ie \
--cc=alyssa.rosenzweig@collabora.com \
--cc=broonie@kernel.org \
--cc=daniel@ffwll.ch \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=drinkcat@chromium.org \
--cc=hsinyi@chromium.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=robh+dt@kernel.org \
--cc=tomeu.vizoso@collabora.com \
--cc=ulf.hansson@linaro.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;
as well as URLs for NNTP newsgroup(s).