[RFC PATCH 0/7] clk: mediatek: Move to struct clk_hw provider APIs

Stephen Boyd sboyd at kernel.org
Thu Apr 21 18:40:42 PDT 2022


Quoting Chen-Yu Tsai (2022-04-20 23:05:10)
> 
> Not exactly. All the clocks in the MTK drivers are allocated at runtime,
> so we can't use clk_parent_data to point to not-yet-allocated clk_hw-s.
> Instead we'll need to have
> 
>     struct mtk_clk_parent_data {
>         unsigned int clk_id; /* Match CLK_XXX_YYY from dt-binding headers */
>         ... /* remaining fields same as mtk_clk_parent_data */
>     };
> 
> and create the actual clk_parent_data at runtime by looking up clk_id in
> the set of already registered clks:
> 
>     int mtk_clk_register_XXX(..., struct mtk_clk_parent_data *pdata,
>                              struct clk_hw_onecell_data *clk_data) {
>         struct clk_parent_data data = {
>             .hw = clk_data[pdata->clk_id],
>             /* copy other fields verbatim */
>         };
>         ...
>     }
> 
> Obviously this forces some ordering of how the clks are registered.
> I believe the order is already correct, and if it isn't, it would be
> easy to detect, and we can reorder things to fix it.

If this is a common problem, we may need to come up with a generic
solution that either adds a new clk registration API that fills in the
clk_parent_data hw pointer or add another member to struct
clk_parent_data that says "index into this other array of clk_hw
pointers".



More information about the Linux-mediatek mailing list