Fix AST2600A2 APLL calculate formuula
cover Fix AST2600A2 APLL calculate formuula
AST2600 A1/A2 have different pll, this patch fix for AST2600 A2 APLL calculate.
Ryan Chen (1):
clk: aspeed: Fix APLL calculate formula for ast2600-A2
drivers/clk/clk-ast2600.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/1 clk: aspeed: Fix APLL calculate formula for ast2600-A2
AST2600A1/A2 have different pll calculate formula.
--- drivers/clk/clk-ast2600.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-)
drivers/clk/clk-ast2600.c +27 -10
@@ -17,7 +17,8 @@#define ASPEED_G6_NUM_CLKS 71 -#define ASPEED_G6_SILICON_REV 0x004 +#define ASPEED_G6_SILICON_REV 0x014 +#define CHIP_REVISION_ID GENMASK(23, 16)#define ASPEED_G6_RESET_CTRL 0x040#define ASPEED_G6_RESET_CTRL2 0x050
@@ -190,18 +191,34 @@ static struct clk_hw *ast2600_calc_pll(const char *name, u32 val)static struct clk_hw *ast2600_calc_apll (const char *name,u32 val) {unsigned int mult, div; +u32 chip_id =readl (scu_g6_base +ASPEED_G6_SILICON_REV ); -if (val &BIT (20 )) { -/* Pass through mode */ - mult = div =1 ; +if (((chip_id &CHIP_REVISION_ID ) >>16 ) >=2 ) { +if (val &BIT (24 )) { +/* Pass through mode */ + mult = div =1 ; + }else { +/* F = 25Mhz * [(m + 1) / (n + 1)] / (p + 1) */ +u32 m = val &0x1fff ; +u32 n = (val >>13 ) &0x3f ; +u32 p = (val >>19 ) &0xf ; + + mult = (m +1 ); + div = (n +1 ) * (p +1 ); + } }else { -/* F = 25Mhz * (2-od) * [(m + 2) / (n + 1)] */ -u32 m = (val >>5 ) &0x3f ; -u32 od = (val >>4 ) &0x1 ; -u32 n = val &0xf ; +if (val &BIT (20 )) { +/* Pass through mode */ + mult = div =1 ; + }else { +/* F = 25Mhz * (2-od) * [(m + 2) / (n + 1)] */ +u32 m = (val >>5 ) &0x3f ; +u32 od = (val >>4 ) &0x1 ; +u32 n = val &0xf ; - mult = (2 - od) * (m +2 ); - div = n +1 ; + mult = (2 - od) * (m +2 ); + div = n +1 ; + } }return clk_hw_register_fixed_factor (NULL , name,"clkin" ,0 , mult, div);
Signature · 1 line
2.17.1
Re: [PATCH 1/1] clk: aspeed: Fix APLL calculate formula for ast2600-A2
Quoted 1 line · Ryan Chen
AST2600A1/A2 have different pll calculate formula.
To clarify, only the A0 has the old calculation, and all subsequent revisions use the new calculation?
If this is the case, do we need to support A0 in mainline linux, or should we drop support for A0 and only support A1, A2 and onwards?
You should add a line to indicate this is a fix:
Also, when sending single patches you do not need to include the cover letter. You should include all of the relevant information in the patch's commit message.
Quoted 67 lines
Signed-off-by Ryan Chen <[email protected]>---
drivers/clk/clk-ast2600.c | 37 +++++++++++++++++++++++++++----------1 file changed, 27 insertions(+), 10 deletions(-)drivers/clk/clk-ast2600.c +0
-0@@ -17,7 +17,8 @@
#define ASPEED_G6_NUM_CLKS 71drivers/clk/clk-ast2600.c +2
-1-#define ASPEED_G6_SILICON_REV 0x004 +#define ASPEED_G6_SILICON_REV 0x014 +#define CHIP_REVISION_ID GENMASK(23, 16)
#define ASPEED_G6_RESET_CTRL 0x040
#define ASPEED_G6_RESET_CTRL2 0x050drivers/clk/clk-ast2600.c +1
-0@@ -190,18 +191,34 @@ static struct clk_hw *ast2600_calc_pll(const char *name, u32 val) static struct clk_hw *ast2600_calc_apll(const char *name, u32 val) { unsigned int mult, div; + u32 chip_id = readl(scu_g6_base + ASPEED_G6_SILICON_REV);
- if (val & BIT(20)) {
- /* Pass through mode */
- mult = div = 1;
+ if (((chip_id&CHIP_REVISION_ID) >> 16) >= 2) { + if (val & BIT(24)) {
+ /* Pass through mode */
+ mult = div = 1;
+ } else {
+ /* F = 25Mhz * [(m + 1) / (n + 1)] / (p + 1) */
+ u32 m = val &0x1fff;
+ u32 n = (val >> 13) &0x3f;
+ u32 p = (val >> 19) &0xf;
+
+ mult = (m + 1);
+ div = (n + 1) * (p + 1);
+ }
} else {
- /* F = 25Mhz * (2-od) * [(m + 2) / (n + 1)] */ - u32 m = (val >> 5) &0x3f;
- u32 od = (val >> 4) &0x1;
- u32 n = val &0xf;
+ if (val & BIT(20)) {
+ /* Pass through mode */
+ mult = div = 1;
+ } else {
+ /* F = 25Mhz * (2-od) * [(m + 2) / (n + 1)] */
+ u32 m = (val >> 5) &0x3f;
+ u32 od = (val >> 4) &0x1;
+ u32 n = val &0xf;
- mult = (2 - od) * (m + 2);
- div = n + 1;
+ mult = (2 - od) * (m + 2);
+ div = n + 1;
+ }
}
returnclk_hw_register_fixed_factor(NULL, name, "clkin", 0, mult, div);
RE: [PATCH 1/1] clk: aspeed: Fix APLL calculate formula for ast2600-A2
Quoted 10 lines
-----Original Message-----
From: Joel Stanley <[email protected]>
Sent: Tuesday, January 19, 2021 10:20 AM
To: Ryan Chen <[email protected]>; Michael Turquette <[email protected]>; Stephen Boyd <[email protected]>; [email protected]; [email protected]; [email protected]; BMC-SW <[email protected]>
Cc: [email protected]; Andrew Jeffery <[email protected]>
Subject: Re: [PATCH 1/1] clk: aspeed: Fix APLL calculate formula for ast2600-A2
Quoted 9 lines
Quoted 1 line · Ryan Chen
AST2600A1/A2 have different pll calculate formula.
To clarify, only the A0 has the old calculation, and all subsequent revisions use the new calculation?
If this is the case, do we need to support A0 in mainline linux, or should we drop support for A0 and only support A1, A2 and onwards?
A0/A1 is use older calculate formula
After A2 is new calculate formula as the patch.
Quoted 4 lines
You should add a line to indicate this is a fix:
Fixes d3d04f6c330a ("clk: Add support for AST2600 SoC")
Got it. so should I send new patch?
Quoted 75 lines
Also, when sending single patches you do not need to include the cover letter. You should include all of the relevant information in the patch's commit message.
Quoted 11 lines
Signed-off-by Ryan Chen <[email protected]>---
drivers/clk/clk-ast2600.c | 37 +++++++++++++++++++++++++++----------1 file changed, 27 insertions(+), 10 deletions(-)drivers/clk/clk-ast2600.c +0
-0drivers/clk/clk-ast2600.c line 20
Quoted 5 lines
drivers/clk/clk-ast2600.c +1
-1@@ -17,7 +17,8 @@ #define ASPEED_G6_NUM_CLKS 71 -#define ASPEED_G6_SILICON_REV 0x004 +#define ASPEED_G6_SILICON_REV 0x014 #define
CHIP_REVISION_IDdrivers/clk/clk-ast2600.c
Quoted 4 lines
drivers/clk/clk-ast2600.c +1
-0+GENMASK(23, 16) #define ASPEED_G6_RESET_CTRL 0x040 #define ASPEED_G6_RESET_CTRL2 0x050 @@ -190,18+191,34 @@
Quoted 6 lines
static struct
clk_hw*ast2600_calc_pll(const char *name, u32 val) static structclk_hw*ast2600_calc_apll(const char *name, u32 val) {
unsigned int mult, div;
+ u32chip_id=readl(scu_g6_base + ASPEED_G6_SILICON_REV);Quoted 9 lines
- if (val & BIT(20)) {
- /* Pass through mode */
- mult = div = 1;
+ if (((chip_id&CHIP_REVISION_ID) >> 16) >= 2) { + if (val & BIT(24)) {
+ /* Pass through mode */
+ mult = div = 1;
+ } else {
+ /* F = 25Mhz * [(m + 1) / (n + 1)] / (p +1)
Quoted 10 lines
*/
+ u32 m = val &0x1fff;
+ u32 n = (val >> 13) &0x3f; + u32 p = (val >> 19) &0xf;
+
+ mult = (m + 1);
+ div = (n + 1) * (p + 1);
+ }
} else {
- /* F = 25Mhz * (2-od) * [(m + 2) / (n + 1)] */Quoted 8 lines
- u32 m = (val >> 5) &
0x3f;
- u32 od = (val >> 4) &0x1;
- u32 n = val &0xf;
+ if (val & BIT(20)) {
+ /* Pass through mode */
+ mult = div = 1;
+ } else {
+ /* F = 25Mhz * (2-od) * [(m + 2) / (n +1)]
Quoted 13 lines
*/
+ u32 m = (val >> 5) &0x3f; + u32 od = (val >> 4) &0x1; + u32 n = val &0xf;- mult = (2 - od) * (m + 2);
- div = n + 1;
+ mult = (2 - od) * (m + 2);
+ div = n + 1;
+ }
}
returnclk_hw_register_fixed_factor(NULL, name, "clkin", 0, mult, div);
Re: [PATCH 1/1] clk: aspeed: Fix APLL calculate formula for ast2600-A2
Quoted 14 lines · Ryan Chen
Quoted 14 lines
-----Original Message-----
From: Joel Stanley <[email protected]>
Sent: Tuesday, January 19, 2021 10:20 AM
To: Ryan Chen <[email protected]>; Michael Turquette <[email protected]>; Stephen Boyd <[email protected]>; [email protected]; [email protected]; [email protected]; BMC-SW <[email protected]>
Cc: [email protected]; Andrew Jeffery <[email protected]>
Subject: Re: [PATCH 1/1] clk: aspeed: Fix APLL calculate formula for ast2600-A2Quoted 1 line · Ryan Chen
AST2600A1/A2 have different pll calculate formula.
Quoted 8 lines
Quoted 6 lines
To clarify, only the A0 has the old calculation, and all subsequent revisions use the new calculation?
If this is the case, do we need to support A0 in mainline linux, or should we drop support for A0 and only support A1, A2 and onwards?
A0/A1 is use older calculate formula
After A2 is new calculate formula as the patch.
Thanks for clarifying. I suggest you change the commit log to say something like this:
Starting from A2, the A-PLL calculation has changed. Use the existing formula for A0/A1 and the new formula for A2 onwards.
Quoted 6 lines
Quoted 5 lines
You should add a line to indicate this is a fix:
Fixes d3d04f6c330a ("clk: Add support for AST2600 SoC")Got it. so should I send new patch?
Yes, please consider adjusting the commit message as I suggested above, and add the fixes line.
Quoted 6 lines
Quoted 6 lines
drivers/clk/clk-ast2600.c static struct clk_hw *ast2600_calc_pll(const char *name, u32 val) · line 196
Quoted 6 lines
drivers/clk/clk-ast2600.c +2
-3+u32 chip_id =readl (scu_g6_base +ASPEED_G6_SILICON_REV ); -if (val &BIT (20 )) { -/* Pass through mode */ - mult = div =1 ; +if (((chip_id &CHIP_REVISION_ID ) >>16 ) >=2 ) {
Will this test be true if there are future versions of the chip (A3, etc)?
Cheers,
Joel
RE: [PATCH 1/1] clk: aspeed: Fix APLL calculate formula for ast2600-A2
Quoted 53 lines
-----Original Message-----
From: Joel Stanley <[email protected]>
Sent: Tuesday, January 19, 2021 11:10 AM
To: Ryan Chen <[email protected]>
Cc: Joel Stanley <[email protected]>; Michael Turquette <[email protected]>; Stephen Boyd <[email protected]>; [email protected]; [email protected]; [email protected]; BMC-SW <[email protected]>; Andrew Jeffery <[email protected]>
Subject: Re: [PATCH 1/1] clk: aspeed: Fix APLL calculate formula for ast2600-A2Quoted 15 lines · Ryan Chen
Quoted 15 lines
-----Original Message-----
From: Joel Stanley <[email protected]>
Sent: Tuesday, January 19, 2021 10:20 AM
To: Ryan Chen <[email protected]>; Michael Turquette <[email protected]>; Stephen Boyd <[email protected]>; [email protected]; [email protected]; [email protected]; BMC-SW <[email protected]>
Cc: [email protected]; Andrew Jeffery <[email protected]>
Subject: Re: [PATCH 1/1] clk: aspeed: Fix APLL calculate formula for ast2600-A2Quoted 1 line · Ryan Chen
AST2600A1/A2 have different pll calculate formula.
Quoted 8 lines
Quoted 6 lines
To clarify, only the A0 has the old calculation, and all subsequent revisions use the new calculation?
If this is the case, do we need to support A0 in mainline linux, or should we drop support for A0 and only support A1, A2 and onwards?
A0/A1 is use older calculate formula
After A2 is new calculate formula as the patch.Thanks for clarifying. I suggest you change the commit log to say something like this:
Starting from A2, the A-PLL calculation has changed. Use the existing formula for A0/A1 and the new formula for A2 onwards.
Quoted 6 lines
Quoted 5 lines
You should add a line to indicate this is a fix:
Fixes d3d04f6c330a ("clk: Add support for AST2600 SoC")Got it. so should I send new patch?
Yes, please consider adjusting the commit message as I suggested above, and add the fixes line.
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
drivers/clk/clk-ast2600.c static struct clk_hw *ast2600_calc_pll(const char *name, u32 val) · line 196
Quoted 6 lines
drivers/clk/clk-ast2600.c +2
-3+u32 chip_id =readl (scu_g6_base +ASPEED_G6_SILICON_REV ); -if (val &BIT (20 )) { -/* Pass through mode */ - mult = div =1 ; +if (((chip_id &CHIP_REVISION_ID ) >>16 ) >=2 ) {Will this test be true if there are future versions of the chip (A3, etc)?
Yes, is also support for A3.
PATCH v2 1/1 clk: aspeed: Fix APLL calculate formula from ast2600-A2
In reply to Ryan ChenStarting from A2, the A-PLL calculation has changed. Use the existing formula for A0/A1 and the new formula for A2 onwards.
--- drivers/clk/clk-ast2600.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-)
drivers/clk/clk-ast2600.c +27 -10
@@ -17,7 +17,8 @@#define ASPEED_G6_NUM_CLKS 71 -#define ASPEED_G6_SILICON_REV 0x004 +#define ASPEED_G6_SILICON_REV 0x014 +#define CHIP_REVISION_ID GENMASK(23, 16)#define ASPEED_G6_RESET_CTRL 0x040#define ASPEED_G6_RESET_CTRL2 0x050
@@ -190,18 +191,34 @@ static struct clk_hw *ast2600_calc_pll(const char *name, u32 val)static struct clk_hw *ast2600_calc_apll (const char *name,u32 val) {unsigned int mult, div; +u32 chip_id =readl (scu_g6_base +ASPEED_G6_SILICON_REV ); -if (val &BIT (20 )) { -/* Pass through mode */ - mult = div =1 ; +if (((chip_id &CHIP_REVISION_ID ) >>16 ) >=2 ) { +if (val &BIT (24 )) { +/* Pass through mode */ + mult = div =1 ; + }else { +/* F = 25Mhz * [(m + 1) / (n + 1)] / (p + 1) */ +u32 m = val &0x1fff ; +u32 n = (val >>13 ) &0x3f ; +u32 p = (val >>19 ) &0xf ; + + mult = (m +1 ); + div = (n +1 ) * (p +1 ); + } }else { -/* F = 25Mhz * (2-od) * [(m + 2) / (n + 1)] */ -u32 m = (val >>5 ) &0x3f ; -u32 od = (val >>4 ) &0x1 ; -u32 n = val &0xf ; +if (val &BIT (20 )) { +/* Pass through mode */ + mult = div =1 ; + }else { +/* F = 25Mhz * (2-od) * [(m + 2) / (n + 1)] */ +u32 m = (val >>5 ) &0x3f ; +u32 od = (val >>4 ) &0x1 ; +u32 n = val &0xf ; - mult = (2 - od) * (m +2 ); - div = n +1 ; + mult = (2 - od) * (m +2 ); + div = n +1 ; + } }return clk_hw_register_fixed_factor (NULL , name,"clkin" ,0 , mult, div);
Signature · 1 line
2.17.1
Re: [PATCH v2] clk: aspeed: Fix APLL calculate formula from ast2600-A2
Quoted 6 lines · Ryan Chen
Starting from A2, the A-PLL calculation has changed. Use the existing formula for A0/A1 and the new formula for A2 onwards.
Fixes d3d04f6c330a ("clk: Add support for AST2600 SoC")Signed-off-by Ryan Chen <[email protected]>
Quoted 65 lines
--- drivers/clk/clk-ast2600.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-)drivers/clk/clk-ast2600.c +27
-11@@ -17,7 +17,8 @@#define ASPEED_G6_NUM_CLKS 71 -#define ASPEED_G6_SILICON_REV 0x004 +#define ASPEED_G6_SILICON_REV 0x014 +#define CHIP_REVISION_ID GENMASK(23, 16)#define ASPEED_G6_RESET_CTRL 0x040#define ASPEED_G6_RESET_CTRL2 0x050@@ -190,18 +191,34 @@ static struct clk_hw *ast2600_calc_pll(const char *name, u32 val)static struct clk_hw *ast2600_calc_apll (const char *name,u32 val) {unsigned int mult, div; +u32 chip_id =readl (scu_g6_base +ASPEED_G6_SILICON_REV ); -if (val &BIT (20 )) { -/* Pass through mode */ - mult = div =1 ; +if (((chip_id &CHIP_REVISION_ID ) >>16 ) >=2 ) { +if (val &BIT (24 )) { +/* Pass through mode */ + mult = div =1 ; + }else { +/* F = 25Mhz * [(m + 1) / (n + 1)] / (p + 1) */ +u32 m = val &0x1fff ; +u32 n = (val >>13 ) &0x3f ; +u32 p = (val >>19 ) &0xf ; + + mult = (m +1 ); + div = (n +1 ) * (p +1 ); + } }else { -/* F = 25Mhz * (2-od) * [(m + 2) / (n + 1)] */ -u32 m = (val >>5 ) &0x3f ; -u32 od = (val >>4 ) &0x1 ; -u32 n = val &0xf ; +if (val &BIT (20 )) { +/* Pass through mode */ + mult = div =1 ; + }else { +/* F = 25Mhz * (2-od) * [(m + 2) / (n + 1)] */ +u32 m = (val >>5 ) &0x3f ; +u32 od = (val >>4 ) &0x1 ; +u32 n = val &0xf ; - mult = (2 - od) * (m +2 ); - div = n +1 ; + mult = (2 - od) * (m +2 ); + div = n +1 ; + } }return clk_hw_register_fixed_factor (NULL , name,"clkin" ,0 , mult, div); --2.17.1
Re: [PATCH v2] clk: aspeed: Fix APLL calculate formula from ast2600-A2
In reply to Ryan ChenQuoting Ryan Chen (2021-01-18 22:17:15)
Quoted 6 lines
Starting from A2, the A-PLL calculation has changed. Use the existing formula for A0/A1 and the new formula for A2 onwards.
Fixes d3d04f6c330a ("clk: Add support for AST2600 SoC")Signed-off-by Ryan Chen <[email protected]>---
Applied to clk-next