Skip to content

Commit 338f1c2

Browse files
Sam Protsenkokrzk
authored andcommitted
clk: samsung: Pass actual CPU clock registers base to CPU_CLK()
The documentation for struct exynos_cpuclk says .ctrl_base field should contain the controller base address. There are two different problems with that: 1. All Exynos clock drivers are actually passing CPU_SRC register offset via CPU_CLK() macro, which in turn gets assigned to mentioned .ctrl_base field. Because CPU_SRC register usually already has 0x200 offset from controller's base, all other register offsets in clk-cpu.c (like DIVs and MUXes) are specified as offsets from CPU_SRC offset, and not from controller's base. That makes things confusing and inconsistent with register offsets provided in Exynos clock drivers, also breaking the contract for .ctrl_base field as described in struct exynos_cpuclk doc. 2. Furthermore, some Exynos chips have an additional offset for the start of CPU clock registers block (inside of the CMU). There might be different reasons for that, e.g.: - The CMU contains clocks for two different CPUs (like in Exynos5420) - The CMU contains also non-CPU clocks as well (like in Exynos4) - The CPU CMU exists as a dedicated hardware block in the SoC layout, but is modelled as a part of bigger CMU in the driver (like in case of Exynos3250) That means the .ctrl_base field is actually not a controller's base, but instead it's a start address of the CPU clock registers inside of the CMU. Rework all register offsets in clk-cpu.c to be actual offsets from the CPU clock register block start, and fix offsets provided to CPU_CLK() macro in all Exynos clock drivers. Also clarify the .ctrl_base field documentation and rename it to just .base, because it doesn't really contain the CMU base. 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 be20ccc commit 338f1c2

File tree

6 files changed

+40
-39
lines changed

6 files changed

+40
-39
lines changed

drivers/clk/samsung/clk-cpu.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ typedef int (*exynos_rate_change_fn_t)(struct clk_notifier_data *ndata,
4848
* @hw: handle between CCF and CPU clock
4949
* @alt_parent: alternate parent clock to use when switching the speed
5050
* of the primary parent clock
51-
* @ctrl_base: base address of the clock controller
51+
* @base: start address of the CPU clock registers block
5252
* @lock: cpu clock domain register access lock
5353
* @cfg: cpu clock rate configuration data
5454
* @num_cfgs: number of array elements in @cfg array
@@ -64,7 +64,7 @@ typedef int (*exynos_rate_change_fn_t)(struct clk_notifier_data *ndata,
6464
struct exynos_cpuclk {
6565
struct clk_hw hw;
6666
const struct clk_hw *alt_parent;
67-
void __iomem *ctrl_base;
67+
void __iomem *base;
6868
spinlock_t *lock;
6969
const struct exynos_cpuclk_cfg_data *cfg;
7070
const unsigned long num_cfgs;
@@ -125,12 +125,12 @@ static void wait_until_mux_stable(void __iomem *mux_reg, u32 mux_pos,
125125

126126
/* ---- Exynos 3/4/5 -------------------------------------------------------- */
127127

128-
#define E4210_SRC_CPU 0x0
129-
#define E4210_STAT_CPU 0x200
130-
#define E4210_DIV_CPU0 0x300
131-
#define E4210_DIV_CPU1 0x304
132-
#define E4210_DIV_STAT_CPU0 0x400
133-
#define E4210_DIV_STAT_CPU1 0x404
128+
#define E4210_SRC_CPU 0x200
129+
#define E4210_STAT_CPU 0x400
130+
#define E4210_DIV_CPU0 0x500
131+
#define E4210_DIV_CPU1 0x504
132+
#define E4210_DIV_STAT_CPU0 0x600
133+
#define E4210_DIV_STAT_CPU1 0x604
134134

135135
#define E4210_DIV0_RATIO0_MASK GENMASK(2, 0)
136136
#define E4210_DIV1_HPM_MASK GENMASK(6, 4)
@@ -160,7 +160,7 @@ static int exynos_cpuclk_pre_rate_change(struct clk_notifier_data *ndata,
160160
struct exynos_cpuclk *cpuclk)
161161
{
162162
const struct exynos_cpuclk_cfg_data *cfg_data = cpuclk->cfg;
163-
void __iomem *base = cpuclk->ctrl_base;
163+
void __iomem *base = cpuclk->base;
164164
unsigned long alt_prate = clk_hw_get_rate(cpuclk->alt_parent);
165165
unsigned long div0, div1 = 0, mux_reg;
166166
unsigned long flags;
@@ -238,7 +238,7 @@ static int exynos_cpuclk_post_rate_change(struct clk_notifier_data *ndata,
238238
struct exynos_cpuclk *cpuclk)
239239
{
240240
const struct exynos_cpuclk_cfg_data *cfg_data = cpuclk->cfg;
241-
void __iomem *base = cpuclk->ctrl_base;
241+
void __iomem *base = cpuclk->base;
242242
unsigned long div = 0, div_mask = DIV_MASK;
243243
unsigned long mux_reg;
244244
unsigned long flags;
@@ -271,12 +271,12 @@ static int exynos_cpuclk_post_rate_change(struct clk_notifier_data *ndata,
271271

272272
/* ---- Exynos5433 ---------------------------------------------------------- */
273273

274-
#define E5433_MUX_SEL2 0x008
275-
#define E5433_MUX_STAT2 0x208
276-
#define E5433_DIV_CPU0 0x400
277-
#define E5433_DIV_CPU1 0x404
278-
#define E5433_DIV_STAT_CPU0 0x500
279-
#define E5433_DIV_STAT_CPU1 0x504
274+
#define E5433_MUX_SEL2 0x208
275+
#define E5433_MUX_STAT2 0x408
276+
#define E5433_DIV_CPU0 0x600
277+
#define E5433_DIV_CPU1 0x604
278+
#define E5433_DIV_STAT_CPU0 0x700
279+
#define E5433_DIV_STAT_CPU1 0x704
280280

281281
/*
282282
* Helper function to set the 'safe' dividers for the CPU clock. The parameters
@@ -299,7 +299,7 @@ static int exynos5433_cpuclk_pre_rate_change(struct clk_notifier_data *ndata,
299299
struct exynos_cpuclk *cpuclk)
300300
{
301301
const struct exynos_cpuclk_cfg_data *cfg_data = cpuclk->cfg;
302-
void __iomem *base = cpuclk->ctrl_base;
302+
void __iomem *base = cpuclk->base;
303303
unsigned long alt_prate = clk_hw_get_rate(cpuclk->alt_parent);
304304
unsigned long div0, div1 = 0, mux_reg;
305305
unsigned long flags;
@@ -359,7 +359,7 @@ static int exynos5433_cpuclk_pre_rate_change(struct clk_notifier_data *ndata,
359359
static int exynos5433_cpuclk_post_rate_change(struct clk_notifier_data *ndata,
360360
struct exynos_cpuclk *cpuclk)
361361
{
362-
void __iomem *base = cpuclk->ctrl_base;
362+
void __iomem *base = cpuclk->base;
363363
unsigned long div = 0, div_mask = DIV_MASK;
364364
unsigned long mux_reg;
365365
unsigned long flags;
@@ -461,7 +461,7 @@ static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx,
461461

462462
cpuclk->alt_parent = alt_parent;
463463
cpuclk->hw.init = &init;
464-
cpuclk->ctrl_base = ctx->reg_base + clk_data->offset;
464+
cpuclk->base = ctx->reg_base + clk_data->offset;
465465
cpuclk->lock = &ctx->lock;
466466
cpuclk->flags = clk_data->flags;
467467
cpuclk->clk_nb.notifier_call = exynos_cpuclk_notifier_cb;

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, 0x14200, e3250_armclk_d),
778+
CLK_CPU_HAS_DIV1, 0x14000, 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: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,17 +1252,20 @@ static const struct exynos_cpuclk_cfg_data e4412_armclk_d[] __initconst = {
12521252

12531253
static const struct samsung_cpu_clock exynos4210_cpu_clks[] __initconst = {
12541254
CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_SCLK_MPLL,
1255-
CLK_CPU_NEEDS_DEBUG_ALT_DIV | CLK_CPU_HAS_DIV1, 0x14200, e4210_armclk_d),
1255+
CLK_CPU_NEEDS_DEBUG_ALT_DIV | CLK_CPU_HAS_DIV1, 0x14000,
1256+
e4210_armclk_d),
12561257
};
12571258

12581259
static const struct samsung_cpu_clock exynos4212_cpu_clks[] __initconst = {
12591260
CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MPLL_USER_C,
1260-
CLK_CPU_NEEDS_DEBUG_ALT_DIV | CLK_CPU_HAS_DIV1, 0x14200, e4212_armclk_d),
1261+
CLK_CPU_NEEDS_DEBUG_ALT_DIV | CLK_CPU_HAS_DIV1, 0x14000,
1262+
e4212_armclk_d),
12611263
};
12621264

12631265
static const struct samsung_cpu_clock exynos4412_cpu_clks[] __initconst = {
12641266
CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MPLL_USER_C,
1265-
CLK_CPU_NEEDS_DEBUG_ALT_DIV | CLK_CPU_HAS_DIV1, 0x14200, e4412_armclk_d),
1267+
CLK_CPU_NEEDS_DEBUG_ALT_DIV | CLK_CPU_HAS_DIV1, 0x14000,
1268+
e4412_armclk_d),
12661269
};
12671270

12681271
/* register exynos4 clocks */

drivers/clk/samsung/clk-exynos5250.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,8 +776,8 @@ static const struct exynos_cpuclk_cfg_data exynos5250_armclk_d[] __initconst = {
776776
};
777777

778778
static const struct samsung_cpu_clock exynos5250_cpu_clks[] __initconst = {
779-
CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MPLL, CLK_CPU_HAS_DIV1, 0x200,
780-
exynos5250_armclk_d),
779+
CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MPLL,
780+
CLK_CPU_HAS_DIV1, 0x0, exynos5250_armclk_d),
781781
};
782782

783783
static const struct of_device_id ext_clk_match[] __initconst = {

drivers/clk/samsung/clk-exynos5420.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,17 +1555,17 @@ static const struct exynos_cpuclk_cfg_data exynos5420_kfcclk_d[] __initconst = {
15551555
};
15561556

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

15641564
static const struct samsung_cpu_clock exynos5800_cpu_clks[] __initconst = {
1565-
CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MSPLL_CPU, 0, 0x200,
1566-
exynos5800_eglclk_d),
1567-
CPU_CLK(CLK_KFC_CLK, "kfcclk", CLK_MOUT_KPLL, CLK_MOUT_MSPLL_KFC, 0, 0x28200,
1568-
exynos5420_kfcclk_d),
1565+
CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MSPLL_CPU, 0,
1566+
0x0, exynos5800_eglclk_d),
1567+
CPU_CLK(CLK_KFC_CLK, "kfcclk", CLK_MOUT_KPLL, CLK_MOUT_MSPLL_KFC, 0,
1568+
0x28000, 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 & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3700,9 +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,
3704-
CLK_CPU_HAS_E5433_REGS_LAYOUT, 0x200,
3705-
exynos5433_apolloclk_d),
3703+
CLK_MOUT_BUS_PLL_APOLLO_USER, CLK_CPU_HAS_E5433_REGS_LAYOUT,
3704+
0x0, exynos5433_apolloclk_d),
37063705
};
37073706

37083707
static const struct samsung_cmu_info apollo_cmu_info __initconst = {
@@ -3945,9 +3944,8 @@ static const struct exynos_cpuclk_cfg_data exynos5433_atlasclk_d[] __initconst =
39453944

39463945
static const struct samsung_cpu_clock atlas_cpu_clks[] __initconst = {
39473946
CPU_CLK(CLK_SCLK_ATLAS, "atlasclk", CLK_MOUT_ATLAS_PLL,
3948-
CLK_MOUT_BUS_PLL_ATLAS_USER,
3949-
CLK_CPU_HAS_E5433_REGS_LAYOUT, 0x200,
3950-
exynos5433_atlasclk_d),
3947+
CLK_MOUT_BUS_PLL_ATLAS_USER, CLK_CPU_HAS_E5433_REGS_LAYOUT,
3948+
0x0, exynos5433_atlasclk_d),
39513949
};
39523950

39533951
static const struct samsung_cmu_info atlas_cmu_info __initconst = {

0 commit comments

Comments
 (0)