Skip to content

Commit 6d7d203

Browse files
Sam Protsenkokrzk
authored andcommitted
clk: samsung: Pass register layout type explicitly to CLK_CPU()
Use a dedicated enum field to explicitly specify which register layout should be used for the CPU clock, instead of passing it as a bit flag. This way it would be possible to keep the chip-specific data in some array, where each chip structure could be accessed by its corresponding layout index. It prepares clk-cpu.c for adding new chips support, which might have different data for different CPU clusters. No functional change. Signed-off-by: Sam Protsenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Krzysztof Kozlowski <[email protected]>
1 parent 338f1c2 commit 6d7d203

File tree

8 files changed

+29
-17
lines changed

8 files changed

+29
-17
lines changed

drivers/clk/samsung/clk-cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx,
465465
cpuclk->lock = &ctx->lock;
466466
cpuclk->flags = clk_data->flags;
467467
cpuclk->clk_nb.notifier_call = exynos_cpuclk_notifier_cb;
468-
if (clk_data->flags & CLK_CPU_HAS_E5433_REGS_LAYOUT) {
468+
if (clk_data->reg_layout == CPUCLK_LAYOUT_E5433) {
469469
cpuclk->pre_rate_cb = exynos5433_cpuclk_pre_rate_change;
470470
cpuclk->post_rate_cb = exynos5433_cpuclk_post_rate_change;
471471
} else {

drivers/clk/samsung/clk-cpu.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,16 @@
1212
#define CLK_CPU_HAS_DIV1 BIT(0)
1313
/* When ALT parent is active, debug clocks need safe divider values */
1414
#define CLK_CPU_NEEDS_DEBUG_ALT_DIV BIT(1)
15-
/* The CPU clock registers have Exynos5433-compatible layout */
16-
#define CLK_CPU_HAS_E5433_REGS_LAYOUT BIT(2)
15+
16+
/**
17+
* enum exynos_cpuclk_layout - CPU clock registers layout compatibility
18+
* @CPUCLK_LAYOUT_E4210: Exynos4210 compatible layout
19+
* @CPUCLK_LAYOUT_E5433: Exynos5433 compatible layout
20+
*/
21+
enum exynos_cpuclk_layout {
22+
CPUCLK_LAYOUT_E4210,
23+
CPUCLK_LAYOUT_E5433,
24+
};
1725

1826
/**
1927
* struct exynos_cpuclk_cfg_data - config data to setup cpu clocks

drivers/clk/samsung/clk-exynos3250.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ static const struct exynos_cpuclk_cfg_data e3250_armclk_d[] __initconst = {
775775

776776
static const struct samsung_cpu_clock exynos3250_cpu_clks[] __initconst = {
777777
CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MPLL_USER_C,
778-
CLK_CPU_HAS_DIV1, 0x14000, e3250_armclk_d),
778+
CLK_CPU_HAS_DIV1, 0x14000, CPUCLK_LAYOUT_E4210, e3250_armclk_d),
779779
};
780780

781781
static void __init exynos3_core_down_clock(void __iomem *reg_base)

drivers/clk/samsung/clk-exynos4.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,19 +1253,19 @@ static const struct exynos_cpuclk_cfg_data e4412_armclk_d[] __initconst = {
12531253
static const struct samsung_cpu_clock exynos4210_cpu_clks[] __initconst = {
12541254
CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_SCLK_MPLL,
12551255
CLK_CPU_NEEDS_DEBUG_ALT_DIV | CLK_CPU_HAS_DIV1, 0x14000,
1256-
e4210_armclk_d),
1256+
CPUCLK_LAYOUT_E4210, e4210_armclk_d),
12571257
};
12581258

12591259
static const struct samsung_cpu_clock exynos4212_cpu_clks[] __initconst = {
12601260
CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MPLL_USER_C,
12611261
CLK_CPU_NEEDS_DEBUG_ALT_DIV | CLK_CPU_HAS_DIV1, 0x14000,
1262-
e4212_armclk_d),
1262+
CPUCLK_LAYOUT_E4210, e4212_armclk_d),
12631263
};
12641264

12651265
static const struct samsung_cpu_clock exynos4412_cpu_clks[] __initconst = {
12661266
CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MPLL_USER_C,
12671267
CLK_CPU_NEEDS_DEBUG_ALT_DIV | CLK_CPU_HAS_DIV1, 0x14000,
1268-
e4412_armclk_d),
1268+
CPUCLK_LAYOUT_E4210, e4412_armclk_d),
12691269
};
12701270

12711271
/* register exynos4 clocks */

drivers/clk/samsung/clk-exynos5250.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,8 @@ static const struct exynos_cpuclk_cfg_data exynos5250_armclk_d[] __initconst = {
777777

778778
static const struct samsung_cpu_clock exynos5250_cpu_clks[] __initconst = {
779779
CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MPLL,
780-
CLK_CPU_HAS_DIV1, 0x0, exynos5250_armclk_d),
780+
CLK_CPU_HAS_DIV1, 0x0, CPUCLK_LAYOUT_E4210,
781+
exynos5250_armclk_d),
781782
};
782783

783784
static const struct of_device_id ext_clk_match[] __initconst = {

drivers/clk/samsung/clk-exynos5420.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,16 +1556,16 @@ static const struct exynos_cpuclk_cfg_data exynos5420_kfcclk_d[] __initconst = {
15561556

15571557
static const struct samsung_cpu_clock exynos5420_cpu_clks[] __initconst = {
15581558
CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MSPLL_CPU, 0,
1559-
0x0, exynos5420_eglclk_d),
1559+
0x0, CPUCLK_LAYOUT_E4210, exynos5420_eglclk_d),
15601560
CPU_CLK(CLK_KFC_CLK, "kfcclk", CLK_MOUT_KPLL, CLK_MOUT_MSPLL_KFC, 0,
1561-
0x28000, exynos5420_kfcclk_d),
1561+
0x28000, CPUCLK_LAYOUT_E4210, exynos5420_kfcclk_d),
15621562
};
15631563

15641564
static const struct samsung_cpu_clock exynos5800_cpu_clks[] __initconst = {
15651565
CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MSPLL_CPU, 0,
1566-
0x0, exynos5800_eglclk_d),
1566+
0x0, CPUCLK_LAYOUT_E4210, exynos5800_eglclk_d),
15671567
CPU_CLK(CLK_KFC_CLK, "kfcclk", CLK_MOUT_KPLL, CLK_MOUT_MSPLL_KFC, 0,
1568-
0x28000, exynos5420_kfcclk_d),
1568+
0x28000, CPUCLK_LAYOUT_E4210, exynos5420_kfcclk_d),
15691569
};
15701570

15711571
static const struct of_device_id ext_clk_match[] __initconst = {

drivers/clk/samsung/clk-exynos5433.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3700,8 +3700,8 @@ static const struct exynos_cpuclk_cfg_data exynos5433_apolloclk_d[] __initconst
37003700

37013701
static const struct samsung_cpu_clock apollo_cpu_clks[] __initconst = {
37023702
CPU_CLK(CLK_SCLK_APOLLO, "apolloclk", CLK_MOUT_APOLLO_PLL,
3703-
CLK_MOUT_BUS_PLL_APOLLO_USER, CLK_CPU_HAS_E5433_REGS_LAYOUT,
3704-
0x0, exynos5433_apolloclk_d),
3703+
CLK_MOUT_BUS_PLL_APOLLO_USER, 0, 0x0,
3704+
CPUCLK_LAYOUT_E5433, exynos5433_apolloclk_d),
37053705
};
37063706

37073707
static const struct samsung_cmu_info apollo_cmu_info __initconst = {
@@ -3944,8 +3944,8 @@ static const struct exynos_cpuclk_cfg_data exynos5433_atlasclk_d[] __initconst =
39443944

39453945
static const struct samsung_cpu_clock atlas_cpu_clks[] __initconst = {
39463946
CPU_CLK(CLK_SCLK_ATLAS, "atlasclk", CLK_MOUT_ATLAS_PLL,
3947-
CLK_MOUT_BUS_PLL_ATLAS_USER, CLK_CPU_HAS_E5433_REGS_LAYOUT,
3948-
0x0, exynos5433_atlasclk_d),
3947+
CLK_MOUT_BUS_PLL_ATLAS_USER, 0, 0x0,
3948+
CPUCLK_LAYOUT_E5433, exynos5433_atlasclk_d),
39493949
};
39503950

39513951
static const struct samsung_cmu_info atlas_cmu_info __initconst = {

drivers/clk/samsung/clk.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <linux/clk-provider.h>
1414
#include "clk-pll.h"
15+
#include "clk-cpu.h"
1516

1617
/**
1718
* struct samsung_clk_provider - information about clock provider
@@ -282,17 +283,19 @@ struct samsung_cpu_clock {
282283
unsigned int alt_parent_id;
283284
unsigned long flags;
284285
int offset;
286+
enum exynos_cpuclk_layout reg_layout;
285287
const struct exynos_cpuclk_cfg_data *cfg;
286288
};
287289

288-
#define CPU_CLK(_id, _name, _pid, _apid, _flags, _offset, _cfg) \
290+
#define CPU_CLK(_id, _name, _pid, _apid, _flags, _offset, _layout, _cfg) \
289291
{ \
290292
.id = _id, \
291293
.name = _name, \
292294
.parent_id = _pid, \
293295
.alt_parent_id = _apid, \
294296
.flags = _flags, \
295297
.offset = _offset, \
298+
.reg_layout = _layout, \
296299
.cfg = _cfg, \
297300
}
298301

0 commit comments

Comments
 (0)