Skip to content

Commit 6286ce1

Browse files
aspeedtechbebarino
authored andcommitted
clk: aspeed: Fix APLL calculate formula from ast2600-A2
Starting from A2, the A-PLL calculation has changed. Use the existing formula for A0/A1 and the new formula for A2 onwards. Fixes: d3d04f6 ("clk: Add support for AST2600 SoC") Signed-off-by: Ryan Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Joel Stanley <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent 5c8fe58 commit 6286ce1

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

drivers/clk/clk-ast2600.c

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
#define ASPEED_G6_NUM_CLKS 71
1919

20-
#define ASPEED_G6_SILICON_REV 0x004
20+
#define ASPEED_G6_SILICON_REV 0x014
21+
#define CHIP_REVISION_ID GENMASK(23, 16)
2122

2223
#define ASPEED_G6_RESET_CTRL 0x040
2324
#define ASPEED_G6_RESET_CTRL2 0x050
@@ -190,18 +191,34 @@ static struct clk_hw *ast2600_calc_pll(const char *name, u32 val)
190191
static struct clk_hw *ast2600_calc_apll(const char *name, u32 val)
191192
{
192193
unsigned int mult, div;
194+
u32 chip_id = readl(scu_g6_base + ASPEED_G6_SILICON_REV);
193195

194-
if (val & BIT(20)) {
195-
/* Pass through mode */
196-
mult = div = 1;
196+
if (((chip_id & CHIP_REVISION_ID) >> 16) >= 2) {
197+
if (val & BIT(24)) {
198+
/* Pass through mode */
199+
mult = div = 1;
200+
} else {
201+
/* F = 25Mhz * [(m + 1) / (n + 1)] / (p + 1) */
202+
u32 m = val & 0x1fff;
203+
u32 n = (val >> 13) & 0x3f;
204+
u32 p = (val >> 19) & 0xf;
205+
206+
mult = (m + 1);
207+
div = (n + 1) * (p + 1);
208+
}
197209
} else {
198-
/* F = 25Mhz * (2-od) * [(m + 2) / (n + 1)] */
199-
u32 m = (val >> 5) & 0x3f;
200-
u32 od = (val >> 4) & 0x1;
201-
u32 n = val & 0xf;
210+
if (val & BIT(20)) {
211+
/* Pass through mode */
212+
mult = div = 1;
213+
} else {
214+
/* F = 25Mhz * (2-od) * [(m + 2) / (n + 1)] */
215+
u32 m = (val >> 5) & 0x3f;
216+
u32 od = (val >> 4) & 0x1;
217+
u32 n = val & 0xf;
202218

203-
mult = (2 - od) * (m + 2);
204-
div = n + 1;
219+
mult = (2 - od) * (m + 2);
220+
div = n + 1;
221+
}
205222
}
206223
return clk_hw_register_fixed_factor(NULL, name, "clkin", 0,
207224
mult, div);

0 commit comments

Comments
 (0)