Skip to content

Commit bf8eb12

Browse files
Frank Oltmannswens
authored andcommitted
clk: sunxi-ng: a64: select closest rate for pll-video0
Selecting the closest rate for pll-video0 instead of the closest rate that is less than the requested rate has no downside for this clock, while allowing for selecting a more suitable rate, e.g. for the connected panels. Furthermore, the algorithm that sets an NKM clock's parent benefits from the closest rate. Without it, the NKM clock's rate might drift away from the requested rate in the multiple successive calls to ccu_nkm_determine_rate that the clk framework performs when setting a clock rate. Therefore, configure pll-video0 and, in consequence, all of its descendents to select the closest rate. Acked-by: Maxime Ripard <mripard@kernel.org> Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com> Signed-off-by: Frank Oltmanns <frank@oltmanns.dev> Link: https://lore.kernel.org/r/20230807-pll-mipi_set_rate_parent-v6-10-f173239a4b59@oltmanns.dev Signed-off-by: Chen-Yu Tsai <wens@csie.org>
1 parent 253795a commit bf8eb12

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

drivers/clk/sunxi-ng/ccu-sun50i-a64.c

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static SUNXI_CCU_NM_WITH_SDM_GATE_LOCK(pll_audio_base_clk, "pll-audio-base",
6868
BIT(28), /* lock */
6969
CLK_SET_RATE_UNGATE);
7070

71-
static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX(pll_video0_clk, "pll-video0",
71+
static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX_CLOSEST(pll_video0_clk, "pll-video0",
7272
"osc24M", 0x010,
7373
192000000, /* Minimum rate */
7474
1008000000, /* Maximum rate */
@@ -181,6 +181,7 @@ static struct ccu_nkm pll_mipi_clk = {
181181
.hw.init = CLK_HW_INIT("pll-mipi", "pll-video0",
182182
&ccu_nkm_ops,
183183
CLK_SET_RATE_UNGATE | CLK_SET_RATE_PARENT),
184+
.features = CCU_FEATURE_CLOSEST_RATE,
184185
},
185186
};
186187

@@ -537,25 +538,18 @@ static SUNXI_CCU_M_WITH_MUX_GATE(de_clk, "de", de_parents,
537538

538539
static const char * const tcon0_parents[] = { "pll-mipi", "pll-video0-2x" };
539540
static const u8 tcon0_table[] = { 0, 2, };
540-
static SUNXI_CCU_MUX_TABLE_WITH_GATE(tcon0_clk, "tcon0", tcon0_parents,
541-
tcon0_table, 0x118, 24, 3, BIT(31),
542-
CLK_SET_RATE_PARENT |
543-
CLK_SET_RATE_NO_REPARENT);
541+
static SUNXI_CCU_MUX_TABLE_WITH_GATE_CLOSEST(tcon0_clk, "tcon0", tcon0_parents,
542+
tcon0_table, 0x118, 24, 3, BIT(31),
543+
CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT);
544544

545545
static const char * const tcon1_parents[] = { "pll-video0", "pll-video1" };
546546
static const u8 tcon1_table[] = { 0, 2, };
547-
static struct ccu_div tcon1_clk = {
548-
.enable = BIT(31),
549-
.div = _SUNXI_CCU_DIV(0, 4),
550-
.mux = _SUNXI_CCU_MUX_TABLE(24, 2, tcon1_table),
551-
.common = {
552-
.reg = 0x11c,
553-
.hw.init = CLK_HW_INIT_PARENTS("tcon1",
554-
tcon1_parents,
555-
&ccu_div_ops,
556-
CLK_SET_RATE_PARENT),
557-
},
558-
};
547+
static SUNXI_CCU_M_WITH_MUX_TABLE_GATE_CLOSEST(tcon1_clk, "tcon1", tcon1_parents,
548+
tcon1_table, 0x11c,
549+
0, 4, /* M */
550+
24, 2, /* mux */
551+
BIT(31), /* gate */
552+
CLK_SET_RATE_PARENT);
559553

560554
static const char * const deinterlace_parents[] = { "pll-periph0", "pll-periph1" };
561555
static SUNXI_CCU_M_WITH_MUX_GATE(deinterlace_clk, "deinterlace", deinterlace_parents,
@@ -585,8 +579,8 @@ static SUNXI_CCU_GATE(avs_clk, "avs", "osc24M",
585579
0x144, BIT(31), 0);
586580

587581
static const char * const hdmi_parents[] = { "pll-video0", "pll-video1" };
588-
static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_parents,
589-
0x150, 0, 4, 24, 2, BIT(31), CLK_SET_RATE_PARENT);
582+
static SUNXI_CCU_M_WITH_MUX_GATE_CLOSEST(hdmi_clk, "hdmi", hdmi_parents,
583+
0x150, 0, 4, 24, 2, BIT(31), CLK_SET_RATE_PARENT);
590584

591585
static SUNXI_CCU_GATE(hdmi_ddc_clk, "hdmi-ddc", "osc24M",
592586
0x154, BIT(31), 0);
@@ -598,9 +592,9 @@ static SUNXI_CCU_M_WITH_MUX_GATE(mbus_clk, "mbus", mbus_parents,
598592

599593
static const char * const dsi_dphy_parents[] = { "pll-video0", "pll-periph0" };
600594
static const u8 dsi_dphy_table[] = { 0, 2, };
601-
static SUNXI_CCU_M_WITH_MUX_TABLE_GATE(dsi_dphy_clk, "dsi-dphy",
602-
dsi_dphy_parents, dsi_dphy_table,
603-
0x168, 0, 4, 8, 2, BIT(15), CLK_SET_RATE_PARENT);
595+
static SUNXI_CCU_M_WITH_MUX_TABLE_GATE_CLOSEST(dsi_dphy_clk, "dsi-dphy",
596+
dsi_dphy_parents, dsi_dphy_table,
597+
0x168, 0, 4, 8, 2, BIT(15), CLK_SET_RATE_PARENT);
604598

605599
static SUNXI_CCU_M_WITH_GATE(gpu_clk, "gpu", "pll-gpu",
606600
0x1a0, 0, 3, BIT(31), CLK_SET_RATE_PARENT);

0 commit comments

Comments
 (0)