Skip to content

Commit ce4b8f5

Browse files
paligregkh
authored andcommitted
cpufreq: armada-37xx: Fix the AVS value for load L1
[ Upstream commit d118ac2 ] The original CPU voltage value for load L1 is too low for Armada 37xx SoC when base CPU frequency is 1000 or 1200 MHz. It leads to instabilities where CPU gets stuck soon after dynamic voltage scaling from load L1 to L0. Update the CPU voltage value for load L1 accordingly when base frequency is 1000 or 1200 MHz. The minimal L1 value for base CPU frequency 1000 MHz is updated from the original 1.05V to 1.108V and for 1200 MHz is updated to 1.155V. This minimal L1 value is used only in the case when it is lower than value for L0. This change fixes CPU instability issues on 1 GHz and 1.2 GHz variants of Espressobin and 1 GHz Turris Mox. Marvell previously for 1 GHz variant of Espressobin provided a patch [1] suitable only for their Marvell Linux kernel 4.4 fork which workarounded this issue. Patch forced CPU voltage value to 1.108V in all loads. But such change does not fix CPU instability issues on 1.2 GHz variants of Armada 3720 SoC. During testing we come to the conclusion that using 1.108V as minimal value for L1 load makes 1 GHz variants of Espressobin and Turris Mox boards stable. And similarly 1.155V for 1.2 GHz variant of Espressobin. These two values 1.108V and 1.155V are documented in Armada 3700 Hardware Specifications as typical initial CPU voltage values. Discussion about this issue is also at the Armbian forum [2]. [1] - MarvellEmbeddedProcessors/linux-marvell@dc33b62 [2] - https://forum.armbian.com/topic/10429-how-to-make-espressobin-v7-stable/ Signed-off-by: Pali Rohár <pali@kernel.org> Acked-by: Gregory CLEMENT <gregory.clement@bootlin.com> Tested-by: Tomasz Maciej Nowak <tmn505@gmail.com> Tested-by: Anders Trier Olesen <anders.trier.olesen@gmail.com> Tested-by: Philip Soares <philips@netisense.com> Fixes: 1c35282 ("cpufreq: armada-37xx: Add AVS support") Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent cccc3f1 commit ce4b8f5

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

‎drivers/cpufreq/armada-37xx-cpufreq.c‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@
7373
#define LOAD_LEVEL_NR 4
7474

7575
#define MIN_VOLT_MV 1000
76+
#define MIN_VOLT_MV_FOR_L1_1000MHZ 1108
77+
#define MIN_VOLT_MV_FOR_L1_1200MHZ 1155
7678

7779
/* AVS value for the corresponding voltage (in mV) */
7880
static int avs_map[] = {
@@ -208,6 +210,8 @@ static u32 armada_37xx_avs_val_match(int target_vm)
208210
* - L2 & L3 voltage should be about 150mv smaller than L0 voltage.
209211
* This function calculates L1 & L2 & L3 AVS values dynamically based
210212
* on L0 voltage and fill all AVS values to the AVS value table.
213+
* When base CPU frequency is 1000 or 1200 MHz then there is additional
214+
* minimal avs value for load L1.
211215
*/
212216
static void __init armada37xx_cpufreq_avs_configure(struct regmap *base,
213217
struct armada_37xx_dvfs *dvfs)
@@ -239,6 +243,19 @@ static void __init armada37xx_cpufreq_avs_configure(struct regmap *base,
239243
for (load_level = 1; load_level < LOAD_LEVEL_NR; load_level++)
240244
dvfs->avs[load_level] = avs_min;
241245

246+
/*
247+
* Set the avs values for load L0 and L1 when base CPU frequency
248+
* is 1000/1200 MHz to its typical initial values according to
249+
* the Armada 3700 Hardware Specifications.
250+
*/
251+
if (dvfs->cpu_freq_max >= 1000*1000*1000) {
252+
if (dvfs->cpu_freq_max >= 1200*1000*1000)
253+
avs_min = armada_37xx_avs_val_match(MIN_VOLT_MV_FOR_L1_1200MHZ);
254+
else
255+
avs_min = armada_37xx_avs_val_match(MIN_VOLT_MV_FOR_L1_1000MHZ);
256+
dvfs->avs[0] = dvfs->avs[1] = avs_min;
257+
}
258+
242259
return;
243260
}
244261

@@ -258,6 +275,26 @@ static void __init armada37xx_cpufreq_avs_configure(struct regmap *base,
258275
target_vm = avs_map[l0_vdd_min] - 150;
259276
target_vm = target_vm > MIN_VOLT_MV ? target_vm : MIN_VOLT_MV;
260277
dvfs->avs[2] = dvfs->avs[3] = armada_37xx_avs_val_match(target_vm);
278+
279+
/*
280+
* Fix the avs value for load L1 when base CPU frequency is 1000/1200 MHz,
281+
* otherwise the CPU gets stuck when switching from load L1 to load L0.
282+
* Also ensure that avs value for load L1 is not higher than for L0.
283+
*/
284+
if (dvfs->cpu_freq_max >= 1000*1000*1000) {
285+
u32 avs_min_l1;
286+
287+
if (dvfs->cpu_freq_max >= 1200*1000*1000)
288+
avs_min_l1 = armada_37xx_avs_val_match(MIN_VOLT_MV_FOR_L1_1200MHZ);
289+
else
290+
avs_min_l1 = armada_37xx_avs_val_match(MIN_VOLT_MV_FOR_L1_1000MHZ);
291+
292+
if (avs_min_l1 > dvfs->avs[0])
293+
avs_min_l1 = dvfs->avs[0];
294+
295+
if (dvfs->avs[1] < avs_min_l1)
296+
dvfs->avs[1] = avs_min_l1;
297+
}
261298
}
262299

263300
static void __init armada37xx_cpufreq_avs_setup(struct regmap *base,

0 commit comments

Comments
 (0)