summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/panfrost/panfrost_device.c
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2020-02-07 13:26:24 +0800
committerRob Herring <robh@kernel.org>2020-02-25 14:35:31 -0600
commit3e1399bccf5163c59f41298b4faf768e199f4322 (patch)
treea82c8b0107ca8156aa65372f3549f3ceda86bd77 /drivers/gpu/drm/panfrost/panfrost_device.c
parenta9d73b30bb46afb2da40257d680249dc029702d4 (diff)
downloadlinux-stable-3e1399bccf5163c59f41298b4faf768e199f4322.tar.gz
linux-stable-3e1399bccf5163c59f41298b4faf768e199f4322.tar.bz2
linux-stable-3e1399bccf5163c59f41298b4faf768e199f4322.zip
drm/panfrost: Add support for multiple regulators
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> Reviwed-by: Mark Brown <broonie@kernel.org> Signed-off-by: Rob Herring <robh@kernel.org> Link: https://patchwork.freedesktop.org/patch/msgid/20200207052627.130118-5-drinkcat@chromium.org
Diffstat (limited to 'drivers/gpu/drm/panfrost/panfrost_device.c')
-rw-r--r--drivers/gpu/drm/panfrost/panfrost_device.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c
index 238fb6d54df4..3720d50f6d9f 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)