clk: meson-g12a: fix bit range for fixed sys and hifi pll
PATCH v2 1/1 clk: meson-g12a: fix bit range for fixed sys and hifi pll
The bit range 17:0 does not match the datasheet for A311D / S905D3. Change the bit range to 18:0 for FIX and HIFI PLLs to match datasheet.
The frac field is missing for sys pll so add that as well.
Patched:
+ sudo cat /sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq \/sys/devices/system/cpu/cpufreq/policy2/cpuinfo_cur_freq 996999
500000
+ sudo cat /sys/kernel/debug/meson-clk-msr/measure_summary
+ grep -i '\(sys_\|hifi_\|fixed_\)pll'
hifi_pll 0 +/-1562Hz
sys_pll_div16 0 +/-1562Hz
sys_pll_cpub_div16 0 +/-1562Hz
+ sudo cat /sys/kernel/debug/clk/clk_summary
+ grep -i '\(sys_\|hifi_\|fixed_\)pll'
hifi_pll_dco 0 0 0 0
hifi_pll 0 0 0 0
sys_pll_dco 1 1 0 3999999985
sys_pll 0 0 0 499999999
sys_pll_div16_en 0 0 0 499999999
sys_pll_div16 0 0 0 31249999
fixed_pll_dco 1 1 1 3987999985
fixed_pll 3 3 1 1993999993Unpatch:
+ sudo cat /sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq \/sys/devices/system/cpu/cpufreq/policy2/cpuinfo_cur_freq 1000000
500000
+ sudo cat /sys/kernel/debug/meson-clk-msr/measure_summary
+ grep -i '\(sys_\|hifi_\|fixed_\)pll'
hifi_pll 0 +/-1562Hz
sys_pll_div16 0 +/-1562Hz
sys_pll_cpub_div16 0 +/-1562Hz
+ sudo cat /sys/kernel/debug/clk/clk_summary
+ grep -i '\(sys_\|hifi_\|fixed_\)pll'
hifi_pll_dco 0 0 0 0
hifi_pll 0 0 0 0
sys_pll_dco 1 1 0 4800000000
sys_pll 0 0 0 1200000000
sys_pll_div16_en 0 0 0 1200000000
sys_pll_div16 0 0 0 75000000
fixed_pll_dco 1 1 1 3999999939
fixed_pll 3 3 1 1999999970--- drivers/clk/meson/g12a.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/clk/meson/g12a.c +7 -2
@@ -157,7 +157,7 @@ static struct clk_regmap g12a_fixed_pll_dco = { .frac = { .reg_off = HHI_FIX_PLL_CNTL1, .shift = 0, - .width = 17, + .width = 19, }, .l = { .reg_off = HHI_FIX_PLL_CNTL0,
@@ -223,6 +223,11 @@ static struct clk_regmap g12a_sys_pll_dco = { .shift = 10, .width = 5, }, + .frac = { + .reg_off = HHI_SYS_PLL_CNTL1, + .shift = 0, + .width = 19, + }, .l = { .reg_off = HHI_SYS_PLL_CNTL0, .shift = 31,
@@ -1901,7 +1906,7 @@ static struct clk_regmap g12a_hifi_pll_dco = { .frac = { .reg_off = HHI_HIFI_PLL_CNTL1, .shift = 0, - .width = 17, + .width = 19, }, .l = { .reg_off = HHI_HIFI_PLL_CNTL0,
Signature · 1 line
2.47.2
Jerome Brunet
maintainerQuoted 81 lines · Da Xue
The bit range 17:0 does not match the datasheet for A311D / S905D3. Change the bit range to 18:0 for FIX and HIFI PLLs to match datasheet.
The frac field is missing for sys pll so add that as well.
Patched:
+ sudo cat
/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq\/sys/devices/system/cpu/cpufreq/policy2/cpuinfo_cur_freq996999
500000
+ sudo cat/sys/kernel/debug/meson-clk-msr/measure_summary
+ grep -i '\(sys_\|hifi_\|fixed_\)pll'hifi_pll 0 +/-1562Hz sys_pll_div16 0 +/-1562Hz sys_pll_cpub_div16 0 +/-1562Hz + sudo cat /sys/kernel/debug/clk/clk_summary + grep -i '\(sys_\|hifi_\|fixed_\)pll' hifi_pll_dco 0 0 0 0 hifi_pll 0 0 0 0 sys_pll_dco 1 1 0 3999999985 sys_pll 0 0 0 499999999 sys_pll_div16_en 0 0 0 499999999 sys_pll_div16 0 0 0 31249999 fixed_pll_dco 1 1 1 3987999985 fixed_pll 3 3 1 1993999993Unpatch:
+ sudo cat
/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq\/sys/devices/system/cpu/cpufreq/policy2/cpuinfo_cur_freq1000000
500000
+ sudo cat/sys/kernel/debug/meson-clk-msr/measure_summary
+ grep -i '\(sys_\|hifi_\|fixed_\)pll'hifi_pll 0 +/-1562Hz sys_pll_div16 0 +/-1562Hz sys_pll_cpub_div16 0 +/-1562Hz + sudo cat /sys/kernel/debug/clk/clk_summary + grep -i '\(sys_\|hifi_\|fixed_\)pll' hifi_pll_dco 0 0 0 0 hifi_pll 0 0 0 0 sys_pll_dco 1 1 0 4800000000 sys_pll 0 0 0 1200000000 sys_pll_div16_en 0 0 0 1200000000 sys_pll_div16 0 0 0 75000000 fixed_pll_dco 1 1 1 3999999939 fixed_pll 3 3 1 1999999970Fixes 085a4ea93d54 ("clk: meson: g12a: add peripheral clock controller")Signed-off-by Da Xue <[email protected]>--- drivers/clk/meson/g12a.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/clk/meson/g12a.c +6
-1@@ -157,7 +157,7 @@ static struct clk_regmap g12a_fixed_pll_dco = { .frac = { .reg_off = HHI_FIX_PLL_CNTL1, .shift = 0, - .width = 17, + .width = 19, }, .l = { .reg_off = HHI_FIX_PLL_CNTL0,@@ -223,6 +223,11 @@ static struct clk_regmap g12a_sys_pll_dco = { .shift = 10, .width = 5, }, + .frac = { + .reg_off = HHI_SYS_PLL_CNTL1, + .shift = 0, + .width = 19, + }, .l = { .reg_off = HHI_SYS_PLL_CNTL0, .shift = 31,
drivers/clk/meson/g12a.c static struct clk_regmap g12a_hifi_pll_dco = { · line 1912
Quoted 8 lines
drivers/clk/meson/g12a.c +1
-1@@ -1901,7 +1906,7 @@ static struct clk_regmap g12a_hifi_pll_dco = { .frac = { .reg_off = HHI_HIFI_PLL_CNTL1, .shift = 0, - .width = 17, + .width = 19, }, .l = { .reg_off = HHI_HIFI_PLL_CNTL0,
Thanks for this.
While this is indeed the same topic, this is doing 2 things at once. Could you please split this, fixup in one change, adding the missing frac in another ?
It is much easier to handle in case something needs to be reverted.
Signature · 1 line
Jerome
Hi Da:
Thanks for your feedback. but this patch is wrong.
Quoted 4 lines · Da Xue
[ EXTERNAL EMAIL ]
The bit range 17:0 does not match the datasheet for A311D / S905D3. Change the bit range to 18:0 for FIX and HIFI PLLs to match datasheet.
The upper 2 bits (bit18, bit17) of the frac were deprecated long ago. The actual effective bit field for frac is bit[16:0]. However, the corresponding datasheet has not been updated. I will provide feedback and update the datasheet accordingly.
Quoted 2 lines
The frac field is missing for sys pll so add that as well.
PLLs with frac support are used in scenarios requiring a wide range of output frequencies (e.g., audio/video applications).
Since sys_pll is dedicated to clocking the CPU and does not require such frequency versatility, it does not support fractional frequency multiplication.
Quoted 93 lines
Patched:
+ sudo cat
/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq\/sys/devices/system/cpu/cpufreq/policy2/cpuinfo_cur_freq996999
500000
+ sudo cat/sys/kernel/debug/meson-clk-msr/measure_summary
+ grep -i '\(sys_\|hifi_\|fixed_\)pll'hifi_pll 0 +/-1562Hz sys_pll_div16 0 +/-1562Hz sys_pll_cpub_div16 0 +/-1562Hz + sudo cat /sys/kernel/debug/clk/clk_summary + grep -i '\(sys_\|hifi_\|fixed_\)pll' hifi_pll_dco 0 0 0 0 hifi_pll 0 0 0 0 sys_pll_dco 1 1 0 3999999985 sys_pll 0 0 0 499999999 sys_pll_div16_en 0 0 0 499999999 sys_pll_div16 0 0 0 31249999 fixed_pll_dco 1 1 1 3987999985 fixed_pll 3 3 1 1993999993Unpatch:
+ sudo cat
/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq\/sys/devices/system/cpu/cpufreq/policy2/cpuinfo_cur_freq1000000
500000
+ sudo cat/sys/kernel/debug/meson-clk-msr/measure_summary
+ grep -i '\(sys_\|hifi_\|fixed_\)pll'hifi_pll 0 +/-1562Hz sys_pll_div16 0 +/-1562Hz sys_pll_cpub_div16 0 +/-1562Hz + sudo cat /sys/kernel/debug/clk/clk_summary + grep -i '\(sys_\|hifi_\|fixed_\)pll' hifi_pll_dco 0 0 0 0 hifi_pll 0 0 0 0 sys_pll_dco 1 1 0 4800000000 sys_pll 0 0 0 1200000000 sys_pll_div16_en 0 0 0 1200000000 sys_pll_div16 0 0 0 75000000 fixed_pll_dco 1 1 1 3999999939 fixed_pll 3 3 1 1999999970Fixes 085a4ea93d54 ("clk: meson: g12a: add peripheral clock controller")Signed-off-by Da Xue <[email protected]>--- drivers/clk/meson/g12a.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/clk/meson/g12a.c +7
-3@@ -157,7 +157,7 @@ static struct clk_regmap g12a_fixed_pll_dco = { .frac = { .reg_off = HHI_FIX_PLL_CNTL1, .shift = 0, - .width = 17, + .width = 19, }, .l = { .reg_off = HHI_FIX_PLL_CNTL0,@@ -223,6 +223,11 @@ static struct clk_regmap g12a_sys_pll_dco = { .shift = 10, .width =5 , }, + .frac = { + .reg_off =HHI_SYS_PLL_CNTL1 , + .shift = 0, + .width = 19, + }, .l = { .reg_off =HHI_SYS_PLL_CNTL0 , .shift = 31,@@ -1901,7 +1906,7 @@ static struct clk_regmap g12a_hifi_pll_dco = { .frac = { .reg_off = HHI_HIFI_PLL_CNTL1, .shift = 0, - .width = 17, + .width = 19, }, .l = { .reg_off = HHI_HIFI_PLL_CNTL0, --2.47.2
_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
Jerome Brunet
maintainerQuoted 5 lines · Chuan Liu
Hi Da:
Thanks for your feedback. but this patch is wrong.
Quoted 8 lines
Quoted 4 lines · Da Xue
[ EXTERNAL EMAIL ]
The bit range 17:0 does not match the datasheet for A311D / S905D3. Change the bit range to 18:0 for FIX and HIFI PLLs to match datasheet.
The upper 2 bits (bit18, bit17) of the frac were deprecated long ago.
deprecated ? that is really confusing
That seems to imply that it does have an effect but you are choosing not to use it. Please clarify.
Quoted 4 lines
The actual effective bit field for frac is bit[16:0]. However, the corresponding datasheet has not been updated. I will provide feedback and update the datasheet accordingly.
What about bit 17 and 18 then ? does it have any effect at all ?
Quoted 11 lines
Quoted 3 lines
The frac field is missing for sys pll so add that as well.
PLLs with frac support are used in scenarios requiring a wide range of output frequencies (e.g., audio/video applications).
Since
sys_pllis dedicated to clocking the CPU and does not require such frequency versatility, it does not support fractional frequency multiplication.
You are mixing "HW support" and "usage choice" here.
What I read is :
* Da says the SYS PLL does have HW support for the frac parameter
* Amlogic does not see the point of using it since the CPU does not require fine tuning of the rate.
Is that correct ? or is the HW just no present ?
Quoted 95 lines
Quoted 95 lines
Patched:
+ sudo cat
/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq\/sys/devices/system/cpu/cpufreq/policy2/cpuinfo_cur_freq996999
500000
+ sudo cat/sys/kernel/debug/meson-clk-msr/measure_summary
+ grep -i '\(sys_\|hifi_\|fixed_\)pll'hifi_pll 0 +/-1562Hz sys_pll_div16 0 +/-1562Hz sys_pll_cpub_div16 0 +/-1562Hz + sudo cat /sys/kernel/debug/clk/clk_summary + grep -i '\(sys_\|hifi_\|fixed_\)pll' hifi_pll_dco 0 0 0 0 hifi_pll 0 0 0 0 sys_pll_dco 1 1 0 3999999985 sys_pll 0 0 0 499999999 sys_pll_div16_en 0 0 0 499999999 sys_pll_div16 0 0 0 31249999 fixed_pll_dco 1 1 1 3987999985 fixed_pll 3 3 1 1993999993Unpatch:
+ sudo cat
/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq\/sys/devices/system/cpu/cpufreq/policy2/cpuinfo_cur_freq1000000
500000
+ sudo cat/sys/kernel/debug/meson-clk-msr/measure_summary
+ grep -i '\(sys_\|hifi_\|fixed_\)pll'hifi_pll 0 +/-1562Hz sys_pll_div16 0 +/-1562Hz sys_pll_cpub_div16 0 +/-1562Hz + sudo cat /sys/kernel/debug/clk/clk_summary + grep -i '\(sys_\|hifi_\|fixed_\)pll' hifi_pll_dco 0 0 0 0 hifi_pll 0 0 0 0 sys_pll_dco 1 1 0 4800000000 sys_pll 0 0 0 1200000000 sys_pll_div16_en 0 0 0 1200000000 sys_pll_div16 0 0 0 75000000 fixed_pll_dco 1 1 1 3999999939 fixed_pll 3 3 1 1999999970Fixes 085a4ea93d54 ("clk: meson: g12a: add peripheral clock controller")Signed-off-by Da Xue <[email protected]>--- drivers/clk/meson/g12a.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/clk/meson/g12a.c +7
-3@@ -157,7 +157,7 @@ static struct clk_regmap g12a_fixed_pll_dco = { .frac = { .reg_off = HHI_FIX_PLL_CNTL1, .shift = 0, - .width = 17, + .width = 19, }, .l = { .reg_off = HHI_FIX_PLL_CNTL0,@@ -223,6 +223,11 @@ static struct clk_regmap g12a_sys_pll_dco = { .shift = 10, .width =5 , }, + .frac = { + .reg_off =HHI_SYS_PLL_CNTL1 , + .shift = 0, + .width = 19, + }, .l = { .reg_off =HHI_SYS_PLL_CNTL0 , .shift = 31,@@ -1901,7 +1906,7 @@ static struct clk_regmap g12a_hifi_pll_dco = { .frac = { .reg_off = HHI_HIFI_PLL_CNTL1, .shift = 0, - .width = 17, + .width = 19, }, .l = { .reg_off = HHI_HIFI_PLL_CNTL0, --2.47.2
_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
Signature · 1 line
Jerome
Hi Jerome:
Quoted 12 lines · Jerome Brunet
[ EXTERNAL EMAIL ]
Quoted 8 lines · Chuan Liu
Hi Da:
Thanks for your feedback. but this patch is wrong.
Quoted 2 lines · Da Xue
[ EXTERNAL EMAIL ]
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines
The bit range 17:0 does not match the datasheet for A311D / S905D3. Change the bit range to 18:0 for FIX and HIFI PLLs to match datasheet.
The upper 2 bits (bit18, bit17) of the frac were deprecated long ago.
deprecated ? that is really confusing
That seems to imply that it does have an effect but you are choosing not to use it. Please clarify.
After investigating the historical context of this issue, the original design intent for frac[18:0] was as follows:
Bit [18]: Configure the sign for fractional multiplication:
0 → The fractional parameter configured in bits [17:0] is positive:
fout = 24M * (m + frac / frac_max) / n
1 → The fractional parameter configured in bits [17:0] is negative:
fout = 24M * (m - frac / frac_max) / n
Bits [17:0]: Fractional multiplier parameter, where:
bit[17] - bit[0] = 1/2^0 + 1/2^1 + ... + 1/2^17
However, the functionality of both bit [18] and bit [17] could be replaced by simply adjusting the integer ‘m’ value. Moreover, actual testing revealed that these bits did not perform as expected. Consequently, this feature was eventually deprecated.
Quoted 5 lines
Quoted 4 lines
The actual effective bit field for frac is bit[16:0]. However, the corresponding datasheet has not been updated. I will provide feedback and update the datasheet accordingly.
What about bit 17 and 18 then ? does it have any effect at all ?
The functionality of these two bits is deprecated, please ignore it.
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
The frac field is missing for sys pll so add that as well.
PLLs with frac support are used in scenarios requiring a wide range of output frequencies (e.g., audio/video applications).
Since
sys_pllis dedicated to clocking the CPU and does not require such frequency versatility, it does not support fractional frequency multiplication.You are mixing "HW support" and "usage choice" here.
Alright, the previous explanation may have caused some misunderstanding. The actual intent was to explain why the SYS PLL does not support frac.
Quoted 7 lines
What I read is :
* Da says the SYS PLL does have HW support for the frac parameter
* Amlogic does not see the point of using it since the CPU does not require fine tuning of the rate.Is that correct ? or is the HW just no present ?
The SYS PLL HW does not present frac functionality.
Quoted 94 lines
Quoted 88 lines
Quoted 88 lines
Patched:
+ sudo cat
/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq\/sys/devices/system/cpu/cpufreq/policy2/cpuinfo_cur_freq996999
500000
+ sudo cat/sys/kernel/debug/meson-clk-msr/measure_summary
+ grep -i '\(sys_\|hifi_\|fixed_\)pll'hifi_pll 0 +/-1562Hz sys_pll_div16 0 +/-1562Hz sys_pll_cpub_div16 0 +/-1562Hz + sudo cat /sys/kernel/debug/clk/clk_summary + grep -i '\(sys_\|hifi_\|fixed_\)pll' hifi_pll_dco 0 0 0 0 hifi_pll 0 0 0 0 sys_pll_dco 1 1 0 3999999985 sys_pll 0 0 0 499999999 sys_pll_div16_en 0 0 0 499999999 sys_pll_div16 0 0 0 31249999 fixed_pll_dco 1 1 1 3987999985 fixed_pll 3 3 1 1993999993Unpatch:
+ sudo cat
/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq\/sys/devices/system/cpu/cpufreq/policy2/cpuinfo_cur_freq1000000
500000
+ sudo cat/sys/kernel/debug/meson-clk-msr/measure_summary
+ grep -i '\(sys_\|hifi_\|fixed_\)pll'hifi_pll 0 +/-1562Hz sys_pll_div16 0 +/-1562Hz sys_pll_cpub_div16 0 +/-1562Hz + sudo cat /sys/kernel/debug/clk/clk_summary + grep -i '\(sys_\|hifi_\|fixed_\)pll' hifi_pll_dco 0 0 0 0 hifi_pll 0 0 0 0 sys_pll_dco 1 1 0 4800000000 sys_pll 0 0 0 1200000000 sys_pll_div16_en 0 0 0 1200000000 sys_pll_div16 0 0 0 75000000 fixed_pll_dco 1 1 1 3999999939 fixed_pll 3 3 1 1999999970Fixes 085a4ea93d54 ("clk: meson: g12a: add peripheral clock controller")Signed-off-by Da Xue<[email protected]>--- drivers/clk/meson/g12a.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/clk/meson/g12a.c +7
-3@@ -157,7 +157,7 @@ static struct clk_regmap g12a_fixed_pll_dco = { .frac = { .reg_off = HHI_FIX_PLL_CNTL1, .shift = 0, - .width = 17, + .width = 19, }, .l = { .reg_off = HHI_FIX_PLL_CNTL0,@@ -223,6 +223,11 @@ static struct clk_regmap g12a_sys_pll_dco = { .shift = 10, .width =5 , }, + .frac = { + .reg_off =HHI_SYS_PLL_CNTL1 , + .shift = 0, + .width = 19, + }, .l = { .reg_off =HHI_SYS_PLL_CNTL0 , .shift = 31,@@ -1901,7 +1906,7 @@ static struct clk_regmap g12a_hifi_pll_dco = { .frac = { .reg_off = HHI_HIFI_PLL_CNTL1, .shift = 0, - .width = 17, + .width = 19, }, .l = { .reg_off = HHI_HIFI_PLL_CNTL0, --2.47.2
Quoted 4 lines
Quoted 4 lines
_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic--
Jerome