Commit 512f2122 authored by Clément Péron's avatar Clément Péron Committed by Rob Herring

drm/panfrost: dynamically alloc regulators

We will later introduce regulators managed by OPP.

Only alloc regulators when it's needed. This also help use
to release the regulators only when they are allocated.
Reviewed-by: default avatarSteven Price <steven.price@arm.com>
Reviewed-by: default avatarAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Signed-off-by: default avatarClément Péron <peron.clem@gmail.com>
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20200710095409.407087-10-peron.clem@gmail.com
parent 25e247bb
...@@ -90,9 +90,11 @@ static int panfrost_regulator_init(struct panfrost_device *pfdev) ...@@ -90,9 +90,11 @@ static int panfrost_regulator_init(struct panfrost_device *pfdev)
{ {
int ret, i; int ret, i;
if (WARN(pfdev->comp->num_supplies > ARRAY_SIZE(pfdev->regulators), pfdev->regulators = devm_kcalloc(pfdev->dev, pfdev->comp->num_supplies,
"Too many supplies in compatible structure.\n")) sizeof(*pfdev->regulators),
return -EINVAL; GFP_KERNEL);
if (!pfdev->regulators)
return -ENOMEM;
for (i = 0; i < pfdev->comp->num_supplies; i++) for (i = 0; i < pfdev->comp->num_supplies; i++)
pfdev->regulators[i].supply = pfdev->comp->supply_names[i]; pfdev->regulators[i].supply = pfdev->comp->supply_names[i];
...@@ -119,8 +121,10 @@ static int panfrost_regulator_init(struct panfrost_device *pfdev) ...@@ -119,8 +121,10 @@ static int panfrost_regulator_init(struct panfrost_device *pfdev)
static void panfrost_regulator_fini(struct panfrost_device *pfdev) static void panfrost_regulator_fini(struct panfrost_device *pfdev)
{ {
regulator_bulk_disable(pfdev->comp->num_supplies, if (!pfdev->regulators)
pfdev->regulators); return;
regulator_bulk_disable(pfdev->comp->num_supplies, pfdev->regulators);
} }
static void panfrost_pm_domain_fini(struct panfrost_device *pfdev) static void panfrost_pm_domain_fini(struct panfrost_device *pfdev)
......
...@@ -22,7 +22,6 @@ struct panfrost_job; ...@@ -22,7 +22,6 @@ struct panfrost_job;
struct panfrost_perfcnt; struct panfrost_perfcnt;
#define NUM_JOB_SLOTS 3 #define NUM_JOB_SLOTS 3
#define MAX_REGULATORS 2
#define MAX_PM_DOMAINS 3 #define MAX_PM_DOMAINS 3
struct panfrost_features { struct panfrost_features {
...@@ -81,7 +80,7 @@ struct panfrost_device { ...@@ -81,7 +80,7 @@ struct panfrost_device {
void __iomem *iomem; void __iomem *iomem;
struct clk *clock; struct clk *clock;
struct clk *bus_clock; struct clk *bus_clock;
struct regulator_bulk_data regulators[MAX_REGULATORS]; struct regulator_bulk_data *regulators;
struct reset_control *rstc; struct reset_control *rstc;
/* pm_domains for devices with more than one. */ /* pm_domains for devices with more than one. */
struct device *pm_domain_devs[MAX_PM_DOMAINS]; struct device *pm_domain_devs[MAX_PM_DOMAINS];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment