Fix AST2600 hpll calculate formula
cover Fix AST2600 hpll calculate formula
AST2600 HPLL calculate has few different with other pll calculate
Ryan Chen (1):
clk:aspeed:Fix AST2600 hpll calculate formula
drivers/clk/clk-ast2600.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
Signature · 1 line
2.17.1
PATCH 1/1 clk:aspeed:Fix AST2600 hpll calculate formula
AST2600 HPLL calculate formula [SCU200]
HPLL Numerator(M): have fixed value depend on SCU strap. M = SCU500[10] ? 0x5F : SCU500[8] ? 0xBF : SCU200[12:0]
if SCU500[10] = 1, M=0x5F.
else if SCU500[10]=0 & SCU500[8]=1, M=0xBF. others (SCU510[10]=0 and SCU510[8]=0)
depend on SCU200[12:0] (default 0x8F) register setting.
HPLL Denumerator (N) = SCU200[18:13] (default 0x2)
HPLL Divider (P) = SCU200[22:19] (default 0x0)
--- drivers/clk/clk-ast2600.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
drivers/clk/clk-ast2600.c +28 -1
@@ -169,6 +169,33 @@ static const struct clk_div_table ast2600_div_table[] = { };/* For hpll/dpll/epll/mpll */ +static struct clk_hw *ast2600_calc_hpll (const char *name,u32 val) +{ +unsigned int mult, div; +u32 hwstrap =readl (scu_g6_base +ASPEED_G6_STRAP1 ); + +if (val &BIT (24 )) { +/* Pass through mode */ + mult = div =1 ; + }else { +/* F = 25Mhz * [(M + 2) / (n + 1)] / (p + 1) */ +u32 m = val &0x1fff ; +u32 n = (val >>13 ) &0x3f ; +u32 p = (val >>19 ) &0xf ; + +if (hwstrap &BIT (10 )) + m =0x5F ; +else { +if (hwstrap &BIT (8 )) + m =0xBF ; + } + mult = (m +1 ) / (n +1 ); + div = (p +1 ); + } +return clk_hw_register_fixed_factor (NULL , name,"clkin" ,0 , + mult, div); +}; +static struct clk_hw *ast2600_calc_pll (const char *name,u32 val) {unsigned int mult, div;
@@ -716,7 +743,7 @@ static void __init aspeed_g6_cc(struct regmap *map)* and we assume that it is enabled */ regmap_read (map,ASPEED_HPLL_PARAM , &val); - aspeed_g6_clk_data->hws[ASPEED_CLK_HPLL ] =ast2600_calc_pll ("hpll" , val); + aspeed_g6_clk_data->hws[ASPEED_CLK_HPLL ] =ast2600_calc_hpll ("hpll" , val);regmap_read (map,ASPEED_MPLL_PARAM , &val); aspeed_g6_clk_data->hws[ASPEED_CLK_MPLL ] =ast2600_calc_pll ("mpll" , val);
Signature · 1 line
2.17.1
Stephen Boyd
maintainerRe: [PATCH 1/1] clk:aspeed:Fix AST2600 hpll calculate formula
Quoting Ryan Chen (2021-08-18 01:05:18)
Quoted 9 lines
AST2600 HPLL calculate formula [SCU200]
HPLL Numerator(M): have fixed value depend on SCU strap. M = SCU500[10] ?0x5F: SCU500[8] ?0xBF: SCU200[12:0]if SCU500[10] = 1, M=0x5F.
else if SCU500[10]=0 & SCU500[8]=1, M=0xBF. others (SCU510[10]=0 and SCU510[8]=0)
depend on SCU200[12:0] (default0x8F) register setting.
Quoted 4 lines
HPLL Denumerator (N) = SCU200[18:13] (default
0x2)
HPLL Divider (P) = SCU200[22:19] (default0x0)Signed-off-by Ryan Chen <[email protected]>
Any Fixes tag? Joel, can you review?
Stephen Boyd
maintainerQuoting Ryan Chen (2021-08-18 01:05:17)
Quoted 3 lines
AST2600 HPLL calculate has few different with other pll calculate
Ryan Chen (1):
Please don't send cover letters for a single patch.
Quoted 8 lines
clk:aspeed:Fix AST2600 hpll calculate formula
drivers/clk/clk-ast2600.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)Signature · 1 line
2.17.1
Quoted 9 lines
-----Original Message-----
From: Stephen Boyd <[email protected]>
Sent: Sunday, August 29, 2021 12:37 PM
To: Andrew Jeffery <[email protected]>; Joel Stanley <[email protected]>; Michael Turquette <[email protected]>; BMC-SW <[email protected]>; [email protected]; [email protected]; Ryan Chen <[email protected]>
Subject: Re: [PATCH 0/1] Fix AST2600 hpll calculate formula
Quoted 6 lines
Quoting Ryan Chen (2021-08-18 01:05:17)
Quoted 3 lines
AST2600 HPLL calculate has few different with other pll calculate
Ryan Chen (1):
Please don't send cover letters for a single patch.
Got it, thanks.
Quoted 9 lines
Quoted 9 lines
clk:aspeed:Fix AST2600 hpll calculate formula
drivers/clk/clk-ast2600.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)--
2.17.1
RE: [PATCH 1/1] clk:aspeed:Fix AST2600 hpll calculate formula
In reply to Stephen BoydQuoted 19 lines
-----Original Message-----
From: Stephen Boyd <[email protected]>
Sent: Sunday, August 29, 2021 12:37 PM
To: Andrew Jeffery <[email protected]>; Joel Stanley <[email protected]>; Michael Turquette <[email protected]>; BMC-SW <[email protected]>; [email protected]; [email protected]; Ryan Chen <[email protected]>
Subject: Re: [PATCH 1/1] clk:aspeed:Fix AST2600 hpll calculate formulaQuoting Ryan Chen (2021-08-18 01:05:18)
Quoted 9 lines
AST2600 HPLL calculate formula [SCU200] HPLL Numerator(M): have fixed value depend on SCU strap.
M = SCU500[10] ?0x5F: SCU500[8] ?0xBF: SCU200[12:0]if SCU500[10] = 1, M=0x5F.
else if SCU500[10]=0 & SCU500[8]=1, M=0xBF. others (SCU510[10]=0 and SCU510[8]=0)
depend on SCU200[12:0] (default0x8F) register setting.
Quoted 6 lines
Quoted 4 lines
HPLL Denumerator (N) = SCU200[18:13] (default
0x2)
HPLL Divider (P) = SCU200[22:19] (default0x0)Signed-off-by Ryan Chen <[email protected]>Any Fixes tag? Joel, can you review?
Hello Joel,
Should I apply to this tag? d3d04f6c330a
Re: [PATCH 1/1] clk:aspeed:Fix AST2600 hpll calculate formula
In reply to Ryan ChenHello Ryan,
Thanks for the patch. I have some questions about it below.
Quoted 4 lines · Ryan Chen
AST2600 HPLL calculate formula [SCU200]
HPLL Numerator(M): have fixed value depend on SCU strap. M = SCU500[10] ?0x5F: SCU500[8] ?0xBF: SCU200[12:0]
I see from the datasheet:
CPU frequency selection
000 1.2GHz
001 1.6GHz
010 1.2GHz
011 1.6GHz
100 800MHz
101 800MHz
110 800MHz
111 800MHz
So when the system is running at 800MHz or 1.6GHz, the value for the numerator (m) in SCU204 is incorrect, and must be overridden?
Quoted 7 lines
if SCU500[10] = 1, M=0x5F.
else if SCU500[10]=0 & SCU500[8]=1, M=0xBF. others (SCU510[10]=0 and SCU510[8]=0)
depend on SCU200[12:0] (default0x8F) register setting.HPLL Denumerator (N) = SCU200[18:13] (default
0x2)
HPLL Divider (P) = SCU200[22:19] (default0x0)
Is this the case for all revisions of the soc, from A0 through to A3?
Do you have a datasheet update that captures this information?
When you resend, please add a fixes line as follows, as this code has been present since we introduced the driver:
Quoted 11 lines
Signed-off-by Ryan Chen <[email protected]>--- drivers/clk/clk-ast2600.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)drivers/clk/clk-ast2600.c +0
-0
drivers/clk/clk-ast2600.c static const struct clk_div_table ast2600_div_table[] = { · line 171
Quoted 3 lines
drivers/clk/clk-ast2600.c +0
-0@@ -169,6 +169,33 @@ static const struct clk_div_table ast2600_div_table[] = { };/* For hpll/dpll/epll/mpll */
This comment needs to stay with ast2600_calc_pll, and just drop hpll from the list.
Quoted 5 lines
drivers/clk/clk-ast2600.c +5
-0+static struct clk_hw *ast2600_calc_hpll (const char *name,u32 val) +{ +unsigned int mult, div; +u32 hwstrap =readl (scu_g6_base +ASPEED_G6_STRAP1 ); +
drivers/clk/clk-ast2600.c static const struct clk_div_table ast2600_div_table[] = { · line 186
Quoted 10 lines
drivers/clk/clk-ast2600.c +10
-0+if (val &BIT (24 )) { +/* Pass through mode */ + mult = div =1 ; + }else { +/* F = 25Mhz * [(M + 2) / (n + 1)] / (p + 1) */ +u32 m = val &0x1fff ; +u32 n = (val >>13 ) &0x3f ; +u32 p = (val >>19 ) &0xf ; + +if (hwstrap &BIT (10 ))
So this is testing if the CPU is running at 800Mhz.
drivers/clk/clk-ast2600.c static const struct clk_div_table ast2600_div_table[] = { · line 189
Quoted 3 lines
drivers/clk/clk-ast2600.c +3
-0+ m =0x5F ; + else { +if (hwstrap &BIT (8 ))
And this is testing if the CPU is running at 1.6GHz.
I would write it like this:
u32 m;
if (hwstrap & BIT(10)) {
/* CPU running at 800MHz */
m = 95;
} else if (hwstrap & BIT(10)) {
/* CPU running at 1.6GHz */ m = 191;
} else {
/* CPU running at 1.2Ghz */
m = val & 0x1fff;
}
Cheers,
Joel
RE: [PATCH 1/1] clk:aspeed:Fix AST2600 hpll calculate formula
Quoted 33 lines
-----Original Message-----
From: Joel Stanley <[email protected]>
Sent: Wednesday, September 1, 2021 2:49 PM
To: Ryan Chen <[email protected]>
Cc: BMC-SW <[email protected]>; Michael Turquette <[email protected]>; Stephen Boyd <[email protected]>; Andrew Jeffery <[email protected]>; [email protected]; Linux Kernel Mailing List <[email protected]>
Subject: Re: [PATCH 1/1] clk:aspeed:Fix AST2600 hpll calculate formulaHello Ryan,
Thanks for the patch. I have some questions about it below.
Quoted 4 lines · Ryan Chen
AST2600 HPLL calculate formula [SCU200] HPLL Numerator(M): have fixed value depend on SCU strap.
M = SCU500[10] ?0x5F: SCU500[8] ?0xBF: SCU200[12:0]I see from the datasheet:
CPU frequency selection
000 1.2GHz
001 1.6GHz
010 1.2GHz
011 1.6GHz
100 800MHz
101 800MHz
110 800MHz
111 800MHz
Quoted 3 lines
So when the system is running at 800MHz or 1.6GHz, the value for the numerator (m) in SCU204 is incorrect, and must be overridden?
M is in SCU200 not SCU204.
The patch code is point out the issue, that not only check the SCU200 to calculate the hpll, but also need check the SCU500[10] and SCU510[8], it will effect the M value.
Quoted 9 lines
Quoted 7 lines
if SCU500[10] = 1, M=0x5F.
else if SCU500[10]=0 & SCU500[8]=1, M=0xBF. others (SCU510[10]=0 and SCU510[8]=0)
depend on SCU200[12:0] (default0x8F) register setting.HPLL Denumerator (N) = SCU200[18:13] (default
0x2)
HPLL Divider (P) = SCU200[22:19] (default0x0)Is this the case for all revisions of the soc, from A0 through to A3?
Yes. it is.
Quoted 2 lines
Do you have a datasheet update that captures this information?
No.
Quoted 3 lines
When you resend, please add a fixes line as follows, as this code has been present since we introduced the driver:
Thanks a lot.
Quoted 62 lines
Fixes d3d04f6c330a ("clk: Add support for AST2600 SoC")Quoted 11 lines
Signed-off-by Ryan Chen <[email protected]>--- drivers/clk/clk-ast2600.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)drivers/clk/clk-ast2600.c +0
-0drivers/clk/clk-ast2600.c static const struct clk_div_table · line 171
Quoted 3 lines
drivers/clk/clk-ast2600.c +0
-0@@ -169,6 +169,33 @@ static const struct clk_div_table ast2600_div_table[] = { };/* For hpll/dpll/epll/mpll */ This comment needs to stay with
ast2600_calc_pll, and just drop hpll from the list.Quoted 4 lines
drivers/clk/clk-ast2600.c +4
-0+static struct clk_hw *ast2600_calc_hpll (const char *name,u32 val) { +unsigned int mult, div; +u32 hwstrap =readl (scu_g6_base +ASPEED_G6_STRAP1 ); +drivers/clk/clk-ast2600.c static const struct clk_div_table ast2600_div_table[] = { · line 186
Quoted 10 lines
drivers/clk/clk-ast2600.c +10
-0+if (val &BIT (24 )) { +/* Pass through mode */ + mult = div =1 ; + }else { +/* F = 25Mhz * [(M + 2) / (n + 1)] / (p + 1) */ +u32 m = val &0x1fff ; +u32 n = (val >>13 ) &0x3f ; +u32 p = (val >>19 ) &0xf ; + +if (hwstrap &BIT (10 ))So this is testing if the CPU is running at 800Mhz.
drivers/clk/clk-ast2600.c static const struct clk_div_table ast2600_div_table[] = { · line 189
Quoted 3 lines
drivers/clk/clk-ast2600.c +3
-0+ m =0x5F ; + else { +if (hwstrap &BIT (8 ))And this is testing if the CPU is running at 1.6GHz.
I would write it like this:
u32 m;
if (hwstrap & BIT(10)) { /* CPU running at 800MHz */ m = 95; } else if (hwstrap & BIT(10)) { /* CPU running at 1.6GHz */ m = 191; } else { /* CPU running at 1.2Ghz */m = val &
0x1fff;
}Cheers,
Joel