Skip to content

Commit 2d49106

Browse files
Eddie Jamesbebarino
authored andcommitted
clk: ast2600: Fix AHB clock divider for A1
The latest specs for the AST2600 A1 chip include some different bit definitions for calculating the AHB clock divider. Implement these in order to get the correct AHB clock value in Linux. Signed-off-by: Eddie James <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Fixes: d3d04f6 ("clk: Add support for AST2600 SoC") Signed-off-by: Stephen Boyd <[email protected]>
1 parent 8f3d9f3 commit 2d49106

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

drivers/clk/clk-ast2600.c

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -642,14 +642,22 @@ static const u32 ast2600_a0_axi_ahb_div_table[] = {
642642
2, 2, 3, 5,
643643
};
644644

645-
static const u32 ast2600_a1_axi_ahb_div_table[] = {
646-
4, 6, 2, 4,
645+
static const u32 ast2600_a1_axi_ahb_div0_tbl[] = {
646+
3, 2, 3, 4,
647+
};
648+
649+
static const u32 ast2600_a1_axi_ahb_div1_tbl[] = {
650+
3, 4, 6, 8,
651+
};
652+
653+
static const u32 ast2600_a1_axi_ahb200_tbl[] = {
654+
3, 4, 3, 4, 2, 2, 2, 2,
647655
};
648656

649657
static void __init aspeed_g6_cc(struct regmap *map)
650658
{
651659
struct clk_hw *hw;
652-
u32 val, div, chip_id, axi_div, ahb_div;
660+
u32 val, div, divbits, chip_id, axi_div, ahb_div;
653661

654662
clk_hw_register_fixed_rate(NULL, "clkin", NULL, 0, 25000000);
655663

@@ -679,11 +687,22 @@ static void __init aspeed_g6_cc(struct regmap *map)
679687
else
680688
axi_div = 2;
681689

690+
divbits = (val >> 11) & 0x3;
682691
regmap_read(map, ASPEED_G6_SILICON_REV, &chip_id);
683-
if (chip_id & BIT(16))
684-
ahb_div = ast2600_a1_axi_ahb_div_table[(val >> 11) & 0x3];
685-
else
692+
if (chip_id & BIT(16)) {
693+
if (!divbits) {
694+
ahb_div = ast2600_a1_axi_ahb200_tbl[(val >> 8) & 0x3];
695+
if (val & BIT(16))
696+
ahb_div *= 2;
697+
} else {
698+
if (val & BIT(16))
699+
ahb_div = ast2600_a1_axi_ahb_div1_tbl[divbits];
700+
else
701+
ahb_div = ast2600_a1_axi_ahb_div0_tbl[divbits];
702+
}
703+
} else {
686704
ahb_div = ast2600_a0_axi_ahb_div_table[(val >> 11) & 0x3];
705+
}
687706

688707
hw = clk_hw_register_fixed_factor(NULL, "ahb", "hpll", 0, 1, axi_div * ahb_div);
689708
aspeed_g6_clk_data->hws[ASPEED_CLK_AHB] = hw;

0 commit comments

Comments
 (0)