Skip to content

Commit ba60189

Browse files
webgeek1234vireshk
authored andcommitted
cpufreq: tegra186: Initialize all cores to max frequencies
During initialization, the EDVD_COREx_VOLT_FREQ registers for some cores are still at reset values and not reflecting the actual frequency. This causes get calls to fail. Set all cores to their respective max frequency during probe to initialize the registers to working values. Suggested-by: Mikko Perttunen <mperttunen@nvidia.com> Signed-off-by: Aaron Kling <webgeek1234@gmail.com> Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
1 parent 0b1bb98 commit ba60189

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

drivers/cpufreq/tegra186-cpufreq.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,14 @@ static struct cpufreq_driver tegra186_cpufreq_driver = {
136136

137137
static struct cpufreq_frequency_table *init_vhint_table(
138138
struct platform_device *pdev, struct tegra_bpmp *bpmp,
139-
struct tegra186_cpufreq_cluster *cluster, unsigned int cluster_id)
139+
struct tegra186_cpufreq_cluster *cluster, unsigned int cluster_id,
140+
int *num_rates)
140141
{
141142
struct cpufreq_frequency_table *table;
142143
struct mrq_cpu_vhint_request req;
143144
struct tegra_bpmp_message msg;
144145
struct cpu_vhint_data *data;
145-
int err, i, j, num_rates = 0;
146+
int err, i, j;
146147
dma_addr_t phys;
147148
void *virt;
148149

@@ -172,6 +173,7 @@ static struct cpufreq_frequency_table *init_vhint_table(
172173
goto free;
173174
}
174175

176+
*num_rates = 0;
175177
for (i = data->vfloor; i <= data->vceil; i++) {
176178
u16 ndiv = data->ndiv[i];
177179

@@ -182,10 +184,10 @@ static struct cpufreq_frequency_table *init_vhint_table(
182184
if (i > 0 && ndiv == data->ndiv[i - 1])
183185
continue;
184186

185-
num_rates++;
187+
(*num_rates)++;
186188
}
187189

188-
table = devm_kcalloc(&pdev->dev, num_rates + 1, sizeof(*table),
190+
table = devm_kcalloc(&pdev->dev, *num_rates + 1, sizeof(*table),
189191
GFP_KERNEL);
190192
if (!table) {
191193
table = ERR_PTR(-ENOMEM);
@@ -227,7 +229,9 @@ static int tegra186_cpufreq_probe(struct platform_device *pdev)
227229
{
228230
struct tegra186_cpufreq_data *data;
229231
struct tegra_bpmp *bpmp;
230-
unsigned int i = 0, err;
232+
unsigned int i = 0, err, edvd_offset;
233+
int num_rates = 0;
234+
u32 edvd_val, cpu;
231235

232236
data = devm_kzalloc(&pdev->dev,
233237
struct_size(data, clusters, TEGRA186_NUM_CLUSTERS),
@@ -250,10 +254,21 @@ static int tegra186_cpufreq_probe(struct platform_device *pdev)
250254
for (i = 0; i < TEGRA186_NUM_CLUSTERS; i++) {
251255
struct tegra186_cpufreq_cluster *cluster = &data->clusters[i];
252256

253-
cluster->table = init_vhint_table(pdev, bpmp, cluster, i);
257+
cluster->table = init_vhint_table(pdev, bpmp, cluster, i, &num_rates);
254258
if (IS_ERR(cluster->table)) {
255259
err = PTR_ERR(cluster->table);
256260
goto put_bpmp;
261+
} else if (!num_rates) {
262+
err = -EINVAL;
263+
goto put_bpmp;
264+
}
265+
266+
for (cpu = 0; cpu < ARRAY_SIZE(tegra186_cpus); cpu++) {
267+
if (data->cpus[cpu].bpmp_cluster_id == i) {
268+
edvd_val = cluster->table[num_rates - 1].driver_data;
269+
edvd_offset = data->cpus[cpu].edvd_offset;
270+
writel(edvd_val, data->regs + edvd_offset);
271+
}
257272
}
258273
}
259274

0 commit comments

Comments
 (0)