Skip to content

Commit 9e89f02

Browse files
sremmind
authored andcommitted
clk: rockchip: support clocks registered late
When some clocks are registered late and some clocks are registered early we need to make sure the late registered clocks report probe defer until the final registration has happened. But we do not want to keep reporting probe defer after the late registration has happened. Also not all Rockchip SoCs have late registered clocks and may not need to report probe defer at all. This restructures code a bit, so that there is a new function rockchip_clk_init_early(), which should be used for initializing the CRU structure on SoCs making use of late initialization in addition to the early init. These platforms should call rockchip_clk_finalize() once all clocks have been registered. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> [added EXPORT_SYMBOL_GPL(rockchip_clk_finalize) to match the early function] Link: https://lore.kernel.org/r/20241211165957.94922-2-sebastian.reichel@collabora.com Signed-off-by: Heiko Stuebner <heiko@sntech.de>
1 parent 40384c8 commit 9e89f02

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

drivers/clk/rockchip/clk.c

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,17 @@ static struct clk *rockchip_clk_register_factor_branch(const char *name,
359359
return hw->clk;
360360
}
361361

362-
struct rockchip_clk_provider *rockchip_clk_init(struct device_node *np,
363-
void __iomem *base,
364-
unsigned long nr_clks)
362+
static struct rockchip_clk_provider *rockchip_clk_init_base(
363+
struct device_node *np, void __iomem *base,
364+
unsigned long nr_clks, bool has_late_clocks)
365365
{
366366
struct rockchip_clk_provider *ctx;
367367
struct clk **clk_table;
368+
struct clk *default_clk_val;
368369
int i;
369370

371+
default_clk_val = ERR_PTR(has_late_clocks ? -EPROBE_DEFER : -ENOENT);
372+
370373
ctx = kzalloc(sizeof(struct rockchip_clk_provider), GFP_KERNEL);
371374
if (!ctx)
372375
return ERR_PTR(-ENOMEM);
@@ -376,7 +379,7 @@ struct rockchip_clk_provider *rockchip_clk_init(struct device_node *np,
376379
goto err_free;
377380

378381
for (i = 0; i < nr_clks; ++i)
379-
clk_table[i] = ERR_PTR(-ENOENT);
382+
clk_table[i] = default_clk_val;
380383

381384
ctx->reg_base = base;
382385
ctx->clk_data.clks = clk_table;
@@ -393,8 +396,33 @@ struct rockchip_clk_provider *rockchip_clk_init(struct device_node *np,
393396
kfree(ctx);
394397
return ERR_PTR(-ENOMEM);
395398
}
399+
400+
struct rockchip_clk_provider *rockchip_clk_init(struct device_node *np,
401+
void __iomem *base,
402+
unsigned long nr_clks)
403+
{
404+
return rockchip_clk_init_base(np, base, nr_clks, false);
405+
}
396406
EXPORT_SYMBOL_GPL(rockchip_clk_init);
397407

408+
struct rockchip_clk_provider *rockchip_clk_init_early(struct device_node *np,
409+
void __iomem *base,
410+
unsigned long nr_clks)
411+
{
412+
return rockchip_clk_init_base(np, base, nr_clks, true);
413+
}
414+
EXPORT_SYMBOL_GPL(rockchip_clk_init_early);
415+
416+
void rockchip_clk_finalize(struct rockchip_clk_provider *ctx)
417+
{
418+
int i;
419+
420+
for (i = 0; i < ctx->clk_data.clk_num; ++i)
421+
if (ctx->clk_data.clks[i] == ERR_PTR(-EPROBE_DEFER))
422+
ctx->clk_data.clks[i] = ERR_PTR(-ENOENT);
423+
}
424+
EXPORT_SYMBOL_GPL(rockchip_clk_finalize);
425+
398426
void rockchip_clk_of_add_provider(struct device_node *np,
399427
struct rockchip_clk_provider *ctx)
400428
{

drivers/clk/rockchip/clk.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,9 @@ struct rockchip_clk_branch {
10241024

10251025
struct rockchip_clk_provider *rockchip_clk_init(struct device_node *np,
10261026
void __iomem *base, unsigned long nr_clks);
1027+
struct rockchip_clk_provider *rockchip_clk_init_early(struct device_node *np,
1028+
void __iomem *base, unsigned long nr_clks);
1029+
void rockchip_clk_finalize(struct rockchip_clk_provider *ctx);
10271030
void rockchip_clk_of_add_provider(struct device_node *np,
10281031
struct rockchip_clk_provider *ctx);
10291032
unsigned long rockchip_clk_find_max_clk_id(struct rockchip_clk_branch *list,

0 commit comments

Comments
 (0)