[PATCH 2/4] clk: thead: support changing DPU pixel clock rate
Brian Masney
bmasney at redhat.com
Thu Aug 21 11:29:55 PDT 2025
On Tue, Aug 12, 2025 at 01:42:56PM +0800, Icenowy Zheng wrote:
> The DPU pixel clock rate corresponds to the required dot clock of the
> display mode, so it needs to be tweakable.
>
> Add support to change it, by adding generic divider setting code,
> arming the code to the dpu0/dpu1 clocks, and setting the pixel clock
> connected to the DPU (after a gate) to CLK_SET_RATE_PARENT to propagate
> it to the dividers.
>
> Signed-off-by: Icenowy Zheng <uwu at icenowy.me>
> ---
> drivers/clk/thead/clk-th1520-ap.c | 87 +++++++++++++++++++++++++++++--
> 1 file changed, 82 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/clk/thead/clk-th1520-ap.c b/drivers/clk/thead/clk-th1520-ap.c
> index 2f87c7c2c3baf..3e81f3051cd6c 100644
> --- a/drivers/clk/thead/clk-th1520-ap.c
> +++ b/drivers/clk/thead/clk-th1520-ap.c
> @@ -55,6 +55,7 @@ struct ccu_gate {
>
> struct ccu_div {
> u32 enable;
> + u32 div_en;
> struct ccu_div_internal div;
> struct ccu_internal mux;
> struct ccu_common common;
> @@ -198,6 +199,78 @@ static unsigned long ccu_div_recalc_rate(struct clk_hw *hw,
> return rate;
> }
>
> +static long ccu_div_round_rate(struct clk_hw *hw, unsigned long rate,
> + unsigned long *parent_rate)
> +{
> + struct ccu_div *cd = hw_to_ccu_div(hw);
> + unsigned int val;
> +
> + if (!cd->div_en) {
> + regmap_read(cd->common.map, cd->common.cfg0, &val);
> + val = val >> cd->div.shift;
> + val &= GENMASK(cd->div.width - 1, 0);
> + return divider_ro_round_rate(hw, rate, parent_rate,
> + NULL, cd->div.width, cd->div.flags,
> + val);
> + } else {
> + return divider_round_rate(hw, rate, parent_rate,
> + NULL, cd->div.width, cd->div.flags);
> + }
> +}
The round_rate clk op is deprecated. Please convert this over to use
determine_rate.
Brian
More information about the linux-riscv
mailing list