Skip to content

Commit c8343e8

Browse files
dgerlachrafaeljw
authored andcommitted
cpufreq: ti-cpufreq: Add support for multiple regulators
Some platforms, like those in the DRA7 and AM57 families, require the scaling of multiple regulators in order to properly support higher OPPs. Let the ti-cpufreq driver determine when this is required and pass the appropriate regulator names to the OPP core so that they can be properly managed. Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Dave Gerlach <d-gerlach@ti.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent db410b2 commit c8343e8

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

drivers/cpufreq/ti-cpufreq.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,15 @@ struct ti_cpufreq_soc_data {
5151
unsigned long efuse_mask;
5252
unsigned long efuse_shift;
5353
unsigned long rev_offset;
54+
bool multi_regulator;
5455
};
5556

5657
struct ti_cpufreq_data {
5758
struct device *cpu_dev;
5859
struct device_node *opp_node;
5960
struct regmap *syscon;
6061
const struct ti_cpufreq_soc_data *soc_data;
62+
struct opp_table *opp_table;
6163
};
6264

6365
static unsigned long amx3_efuse_xlate(struct ti_cpufreq_data *opp_data,
@@ -96,6 +98,7 @@ static struct ti_cpufreq_soc_data am3x_soc_data = {
9698
.efuse_offset = 0x07fc,
9799
.efuse_mask = 0x1fff,
98100
.rev_offset = 0x600,
101+
.multi_regulator = false,
99102
};
100103

101104
static struct ti_cpufreq_soc_data am4x_soc_data = {
@@ -104,6 +107,7 @@ static struct ti_cpufreq_soc_data am4x_soc_data = {
104107
.efuse_offset = 0x0610,
105108
.efuse_mask = 0x3f,
106109
.rev_offset = 0x600,
110+
.multi_regulator = false,
107111
};
108112

109113
static struct ti_cpufreq_soc_data dra7_soc_data = {
@@ -112,6 +116,7 @@ static struct ti_cpufreq_soc_data dra7_soc_data = {
112116
.efuse_mask = 0xf80000,
113117
.efuse_shift = 19,
114118
.rev_offset = 0x204,
119+
.multi_regulator = true,
115120
};
116121

117122
/**
@@ -201,7 +206,9 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
201206
u32 version[VERSION_COUNT];
202207
struct device_node *np;
203208
const struct of_device_id *match;
209+
struct opp_table *ti_opp_table;
204210
struct ti_cpufreq_data *opp_data;
211+
const char * const reg_names[] = {"vdd", "vbb"};
205212
int ret;
206213

207214
np = of_find_node_by_path("/");
@@ -248,16 +255,29 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
248255
if (ret)
249256
goto fail_put_node;
250257

251-
ret = PTR_ERR_OR_ZERO(dev_pm_opp_set_supported_hw(opp_data->cpu_dev,
252-
version, VERSION_COUNT));
253-
if (ret) {
258+
ti_opp_table = dev_pm_opp_set_supported_hw(opp_data->cpu_dev,
259+
version, VERSION_COUNT);
260+
if (IS_ERR(ti_opp_table)) {
254261
dev_err(opp_data->cpu_dev,
255262
"Failed to set supported hardware\n");
263+
ret = PTR_ERR(ti_opp_table);
256264
goto fail_put_node;
257265
}
258266

259-
of_node_put(opp_data->opp_node);
267+
opp_data->opp_table = ti_opp_table;
268+
269+
if (opp_data->soc_data->multi_regulator) {
270+
ti_opp_table = dev_pm_opp_set_regulators(opp_data->cpu_dev,
271+
reg_names,
272+
ARRAY_SIZE(reg_names));
273+
if (IS_ERR(ti_opp_table)) {
274+
dev_pm_opp_put_supported_hw(opp_data->opp_table);
275+
ret = PTR_ERR(ti_opp_table);
276+
goto fail_put_node;
277+
}
278+
}
260279

280+
of_node_put(opp_data->opp_node);
261281
register_cpufreq_dt:
262282
platform_device_register_simple("cpufreq-dt", -1, NULL, 0);
263283

0 commit comments

Comments
 (0)