Skip to content

Commit 98e6da6

Browse files
Andre-ARMwens
authored andcommitted
clk: sunxi-ng: d1: Add missing divider for MMC mod clocks
The D1/R528/T113 SoCs have a hidden divider of 2 in the MMC mod clocks, just as other recent SoCs. So far we did not describe that, which led to the resulting MMC clock rate to be only half of its intended value. Use a macro that allows to describe a fixed post-divider, to compensate for that divisor. This brings the MMC performance on those SoCs to its expected level, so about 23 MB/s for SD cards, instead of the 11 MB/s measured so far. Fixes: 35b97bb ("clk: sunxi-ng: Add support for the D1 SoC clocks") Reported-by: Kuba Szczodrzyński <[email protected]> Signed-off-by: Andre Przywara <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Chen-Yu Tsai <[email protected]>
1 parent 4a9c3c3 commit 98e6da6

File tree

2 files changed

+47
-19
lines changed

2 files changed

+47
-19
lines changed

drivers/clk/sunxi-ng/ccu-sun20i-d1.c

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -412,19 +412,23 @@ static const struct clk_parent_data mmc0_mmc1_parents[] = {
412412
{ .hw = &pll_periph0_2x_clk.common.hw },
413413
{ .hw = &pll_audio1_div2_clk.common.hw },
414414
};
415-
static SUNXI_CCU_MP_DATA_WITH_MUX_GATE(mmc0_clk, "mmc0", mmc0_mmc1_parents, 0x830,
416-
0, 4, /* M */
417-
8, 2, /* P */
418-
24, 3, /* mux */
419-
BIT(31), /* gate */
420-
0);
421-
422-
static SUNXI_CCU_MP_DATA_WITH_MUX_GATE(mmc1_clk, "mmc1", mmc0_mmc1_parents, 0x834,
423-
0, 4, /* M */
424-
8, 2, /* P */
425-
24, 3, /* mux */
426-
BIT(31), /* gate */
427-
0);
415+
static SUNXI_CCU_MP_DATA_WITH_MUX_GATE_POSTDIV(mmc0_clk, "mmc0",
416+
mmc0_mmc1_parents, 0x830,
417+
0, 4, /* M */
418+
8, 2, /* P */
419+
24, 3, /* mux */
420+
BIT(31), /* gate */
421+
2, /* post-div */
422+
0);
423+
424+
static SUNXI_CCU_MP_DATA_WITH_MUX_GATE_POSTDIV(mmc1_clk, "mmc1",
425+
mmc0_mmc1_parents, 0x834,
426+
0, 4, /* M */
427+
8, 2, /* P */
428+
24, 3, /* mux */
429+
BIT(31), /* gate */
430+
2, /* post-div */
431+
0);
428432

429433
static const struct clk_parent_data mmc2_parents[] = {
430434
{ .fw_name = "hosc" },
@@ -433,12 +437,14 @@ static const struct clk_parent_data mmc2_parents[] = {
433437
{ .hw = &pll_periph0_800M_clk.common.hw },
434438
{ .hw = &pll_audio1_div2_clk.common.hw },
435439
};
436-
static SUNXI_CCU_MP_DATA_WITH_MUX_GATE(mmc2_clk, "mmc2", mmc2_parents, 0x838,
437-
0, 4, /* M */
438-
8, 2, /* P */
439-
24, 3, /* mux */
440-
BIT(31), /* gate */
441-
0);
440+
static SUNXI_CCU_MP_DATA_WITH_MUX_GATE_POSTDIV(mmc2_clk, "mmc2", mmc2_parents,
441+
0x838,
442+
0, 4, /* M */
443+
8, 2, /* P */
444+
24, 3, /* mux */
445+
BIT(31), /* gate */
446+
2, /* post-div */
447+
0);
442448

443449
static SUNXI_CCU_GATE_HWS(bus_mmc0_clk, "bus-mmc0", psi_ahb_hws,
444450
0x84c, BIT(0), 0);

drivers/clk/sunxi-ng/ccu_mp.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,28 @@ struct ccu_mp {
5252
} \
5353
}
5454

55+
#define SUNXI_CCU_MP_DATA_WITH_MUX_GATE_POSTDIV(_struct, _name, _parents, \
56+
_reg, \
57+
_mshift, _mwidth, \
58+
_pshift, _pwidth, \
59+
_muxshift, _muxwidth, \
60+
_gate, _postdiv, _flags)\
61+
struct ccu_mp _struct = { \
62+
.enable = _gate, \
63+
.m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
64+
.p = _SUNXI_CCU_DIV(_pshift, _pwidth), \
65+
.mux = _SUNXI_CCU_MUX(_muxshift, _muxwidth), \
66+
.fixed_post_div = _postdiv, \
67+
.common = { \
68+
.reg = _reg, \
69+
.features = CCU_FEATURE_FIXED_POSTDIV, \
70+
.hw.init = CLK_HW_INIT_PARENTS_DATA(_name, \
71+
_parents, \
72+
&ccu_mp_ops, \
73+
_flags), \
74+
} \
75+
}
76+
5577
#define SUNXI_CCU_MP_WITH_MUX_GATE(_struct, _name, _parents, _reg, \
5678
_mshift, _mwidth, \
5779
_pshift, _pwidth, \

0 commit comments

Comments
 (0)