Skip to content

Commit c2407ab

Browse files
Eddie Jamesbebarino
authored andcommitted
clk: AST2600: Add mux for EMMC clock
The EMMC clock can be derived from either the HPLL or the MPLL. Register a clock mux so that the rate is calculated correctly based upon the parent. Signed-off-by: Eddie James <[email protected]> Reviewed-by: Andrew Jeffery <[email protected]> Link: https://lore.kernel.org/r/[email protected] Acked-by: Joel Stanley <[email protected]> Fixes: d3d04f6 ("clk: Add support for AST2600 SoC") Signed-off-by: Stephen Boyd <[email protected]>
1 parent 8e3709d commit c2407ab

File tree

1 file changed

+41
-8
lines changed

1 file changed

+41
-8
lines changed

drivers/clk/clk-ast2600.c

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,18 @@ static const struct clk_div_table ast2600_eclk_div_table[] = {
131131
{ 0 }
132132
};
133133

134+
static const struct clk_div_table ast2600_emmc_extclk_div_table[] = {
135+
{ 0x0, 2 },
136+
{ 0x1, 4 },
137+
{ 0x2, 6 },
138+
{ 0x3, 8 },
139+
{ 0x4, 10 },
140+
{ 0x5, 12 },
141+
{ 0x6, 14 },
142+
{ 0x7, 16 },
143+
{ 0 }
144+
};
145+
134146
static const struct clk_div_table ast2600_mac_div_table[] = {
135147
{ 0x0, 4 },
136148
{ 0x1, 4 },
@@ -390,6 +402,11 @@ static struct clk_hw *aspeed_g6_clk_hw_register_gate(struct device *dev,
390402
return hw;
391403
}
392404

405+
static const char *const emmc_extclk_parent_names[] = {
406+
"emmc_extclk_hpll_in",
407+
"mpll",
408+
};
409+
393410
static const char * const vclk_parent_names[] = {
394411
"dpll",
395412
"d1pll",
@@ -459,16 +476,32 @@ static int aspeed_g6_clk_probe(struct platform_device *pdev)
459476
return PTR_ERR(hw);
460477
aspeed_g6_clk_data->hws[ASPEED_CLK_UARTX] = hw;
461478

462-
/* EMMC ext clock divider */
463-
hw = clk_hw_register_gate(dev, "emmc_extclk_gate", "hpll", 0,
464-
scu_g6_base + ASPEED_G6_CLK_SELECTION1, 15, 0,
465-
&aspeed_g6_clk_lock);
479+
/* EMMC ext clock */
480+
hw = clk_hw_register_fixed_factor(dev, "emmc_extclk_hpll_in", "hpll",
481+
0, 1, 2);
466482
if (IS_ERR(hw))
467483
return PTR_ERR(hw);
468-
hw = clk_hw_register_divider_table(dev, "emmc_extclk", "emmc_extclk_gate", 0,
469-
scu_g6_base + ASPEED_G6_CLK_SELECTION1, 12, 3, 0,
470-
ast2600_div_table,
471-
&aspeed_g6_clk_lock);
484+
485+
hw = clk_hw_register_mux(dev, "emmc_extclk_mux",
486+
emmc_extclk_parent_names,
487+
ARRAY_SIZE(emmc_extclk_parent_names), 0,
488+
scu_g6_base + ASPEED_G6_CLK_SELECTION1, 11, 1,
489+
0, &aspeed_g6_clk_lock);
490+
if (IS_ERR(hw))
491+
return PTR_ERR(hw);
492+
493+
hw = clk_hw_register_gate(dev, "emmc_extclk_gate", "emmc_extclk_mux",
494+
0, scu_g6_base + ASPEED_G6_CLK_SELECTION1,
495+
15, 0, &aspeed_g6_clk_lock);
496+
if (IS_ERR(hw))
497+
return PTR_ERR(hw);
498+
499+
hw = clk_hw_register_divider_table(dev, "emmc_extclk",
500+
"emmc_extclk_gate", 0,
501+
scu_g6_base +
502+
ASPEED_G6_CLK_SELECTION1, 12,
503+
3, 0, ast2600_emmc_extclk_div_table,
504+
&aspeed_g6_clk_lock);
472505
if (IS_ERR(hw))
473506
return PTR_ERR(hw);
474507
aspeed_g6_clk_data->hws[ASPEED_CLK_EMMC] = hw;

0 commit comments

Comments
 (0)