Skip to content

Commit 3270ffe

Browse files
Will McVickerSylwester Nawrocki
authored andcommitted
clk: samsung: add support for CPU clocks
Adds 'struct samsung_cpu_clock' and corresponding CPU clock registration function to the samsung common clk driver. This allows samsung clock drivers to register their CPU clocks with the samsung_cmu_register_one() API. Currently the exynos5433 apollo and atlas clks have their own custom init functions to handle registering their CPU clocks. With this patch we can drop their custom CLK_OF_DECLARE functions and directly call samsung_cmu_register_one(). Signed-off-by: Will McVicker <[email protected]> Tested-by: Marek Szyprowski <[email protected]> Acked-by: Krzysztof Kozlowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sylwester Nawrocki <[email protected]>
1 parent 7dd0557 commit 3270ffe

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

drivers/clk/samsung/clk-cpu.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,3 +469,21 @@ int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx,
469469
kfree(cpuclk);
470470
return ret;
471471
}
472+
473+
void __init samsung_clk_register_cpu(struct samsung_clk_provider *ctx,
474+
const struct samsung_cpu_clock *list, unsigned int nr_clk)
475+
{
476+
unsigned int idx;
477+
unsigned int num_cfgs;
478+
struct clk_hw **hws = ctx->clk_data.hws;
479+
480+
for (idx = 0; idx < nr_clk; idx++, list++) {
481+
/* find count of configuration rates in cfg */
482+
for (num_cfgs = 0; list->cfg[num_cfgs].prate != 0; )
483+
num_cfgs++;
484+
485+
exynos_register_cpu_clock(ctx, list->id, list->name, hws[list->parent_id],
486+
hws[list->alt_parent_id], list->offset, list->cfg, num_cfgs,
487+
list->flags);
488+
}
489+
}

drivers/clk/samsung/clk.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ struct samsung_clk_provider * __init samsung_cmu_register_one(
378378
samsung_clk_extended_sleep_init(reg_base,
379379
cmu->clk_regs, cmu->nr_clk_regs,
380380
cmu->suspend_regs, cmu->nr_suspend_regs);
381+
if (cmu->cpu_clks)
382+
samsung_clk_register_cpu(ctx, cmu->cpu_clks, cmu->nr_cpu_clks);
381383

382384
samsung_clk_of_add_provider(np, ctx);
383385

drivers/clk/samsung/clk.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,27 @@ struct samsung_pll_clock {
271271
__PLL(_typ, _id, _name, _pname, CLK_GET_RATE_NOCACHE, _lock, \
272272
_con, _rtable)
273273

274+
struct samsung_cpu_clock {
275+
unsigned int id;
276+
const char *name;
277+
unsigned int parent_id;
278+
unsigned int alt_parent_id;
279+
unsigned long flags;
280+
int offset;
281+
const struct exynos_cpuclk_cfg_data *cfg;
282+
};
283+
284+
#define CPU_CLK(_id, _name, _pid, _apid, _flags, _offset, _cfg) \
285+
{ \
286+
.id = _id, \
287+
.name = _name, \
288+
.parent_id = _pid, \
289+
.alt_parent_id = _apid, \
290+
.flags = _flags, \
291+
.offset = _offset, \
292+
.cfg = _cfg, \
293+
}
294+
274295
struct samsung_clock_reg_cache {
275296
struct list_head node;
276297
void __iomem *reg_base;
@@ -301,6 +322,9 @@ struct samsung_cmu_info {
301322
unsigned int nr_fixed_factor_clks;
302323
/* total number of clocks with IDs assigned*/
303324
unsigned int nr_clk_ids;
325+
/* list of cpu clocks and respective count */
326+
const struct samsung_cpu_clock *cpu_clks;
327+
unsigned int nr_cpu_clks;
304328

305329
/* list and number of clocks registers */
306330
const unsigned long *clk_regs;
@@ -350,6 +374,8 @@ extern void __init samsung_clk_register_gate(struct samsung_clk_provider *ctx,
350374
extern void __init samsung_clk_register_pll(struct samsung_clk_provider *ctx,
351375
const struct samsung_pll_clock *pll_list,
352376
unsigned int nr_clk, void __iomem *base);
377+
extern void samsung_clk_register_cpu(struct samsung_clk_provider *ctx,
378+
const struct samsung_cpu_clock *list, unsigned int nr_clk);
353379

354380
extern struct samsung_clk_provider __init *samsung_cmu_register_one(
355381
struct device_node *,

0 commit comments

Comments
 (0)