Skip to content

Commit be20ccc

Browse files
Sam Protsenkokrzk
authored andcommitted
clk: samsung: Group CPU clock functions by chip
clk-cpu.c is going to get messy as new chips support is added. Restructure the code by pulling related functions and definitions together, grouping those by their relation to a particular chip or other categories, to simplify the code navigation. 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 c9bc1f7 commit be20ccc

File tree

1 file changed

+61
-53
lines changed

1 file changed

+61
-53
lines changed

drivers/clk/samsung/clk-cpu.c

Lines changed: 61 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -38,34 +38,6 @@
3838
#include "clk.h"
3939
#include "clk-cpu.h"
4040

41-
#define E4210_SRC_CPU 0x0
42-
#define E4210_STAT_CPU 0x200
43-
#define E4210_DIV_CPU0 0x300
44-
#define E4210_DIV_CPU1 0x304
45-
#define E4210_DIV_STAT_CPU0 0x400
46-
#define E4210_DIV_STAT_CPU1 0x404
47-
48-
#define E5433_MUX_SEL2 0x008
49-
#define E5433_MUX_STAT2 0x208
50-
#define E5433_DIV_CPU0 0x400
51-
#define E5433_DIV_CPU1 0x404
52-
#define E5433_DIV_STAT_CPU0 0x500
53-
#define E5433_DIV_STAT_CPU1 0x504
54-
55-
#define E4210_DIV0_RATIO0_MASK GENMASK(2, 0)
56-
#define E4210_DIV1_HPM_MASK GENMASK(6, 4)
57-
#define E4210_DIV1_COPY_MASK GENMASK(2, 0)
58-
#define E4210_MUX_HPM_MASK BIT(20)
59-
#define E4210_DIV0_ATB_SHIFT 16
60-
#define E4210_DIV0_ATB_MASK (DIV_MASK << E4210_DIV0_ATB_SHIFT)
61-
62-
/* Divider stabilization time, msec */
63-
#define MAX_STAB_TIME 10
64-
#define MAX_DIV 8
65-
#define DIV_MASK GENMASK(2, 0)
66-
#define DIV_MASK_ALL GENMASK(31, 0)
67-
#define MUX_MASK GENMASK(2, 0)
68-
6941
struct exynos_cpuclk;
7042

7143
typedef int (*exynos_rate_change_fn_t)(struct clk_notifier_data *ndata,
@@ -103,6 +75,15 @@ struct exynos_cpuclk {
10375
exynos_rate_change_fn_t post_rate_cb;
10476
};
10577

78+
/* ---- Common code --------------------------------------------------------- */
79+
80+
/* Divider stabilization time, msec */
81+
#define MAX_STAB_TIME 10
82+
#define MAX_DIV 8
83+
#define DIV_MASK GENMASK(2, 0)
84+
#define DIV_MASK_ALL GENMASK(31, 0)
85+
#define MUX_MASK GENMASK(2, 0)
86+
10687
/*
10788
* Helper function to wait until divider(s) have stabilized after the divider
10889
* value has changed.
@@ -142,33 +123,21 @@ static void wait_until_mux_stable(void __iomem *mux_reg, u32 mux_pos,
142123
pr_err("%s: re-parenting mux timed-out\n", __func__);
143124
}
144125

145-
/* common round rate callback usable for all types of CPU clocks */
146-
static long exynos_cpuclk_round_rate(struct clk_hw *hw, unsigned long drate,
147-
unsigned long *prate)
148-
{
149-
struct clk_hw *parent = clk_hw_get_parent(hw);
150-
*prate = clk_hw_round_rate(parent, drate);
151-
return *prate;
152-
}
126+
/* ---- Exynos 3/4/5 -------------------------------------------------------- */
153127

154-
/* common recalc rate callback usable for all types of CPU clocks */
155-
static unsigned long exynos_cpuclk_recalc_rate(struct clk_hw *hw,
156-
unsigned long parent_rate)
157-
{
158-
/*
159-
* The CPU clock output (armclk) rate is the same as its parent
160-
* rate. Although there exist certain dividers inside the CPU
161-
* clock block that could be used to divide the parent clock,
162-
* the driver does not make use of them currently, except during
163-
* frequency transitions.
164-
*/
165-
return parent_rate;
166-
}
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
167134

168-
static const struct clk_ops exynos_cpuclk_clk_ops = {
169-
.recalc_rate = exynos_cpuclk_recalc_rate,
170-
.round_rate = exynos_cpuclk_round_rate,
171-
};
135+
#define E4210_DIV0_RATIO0_MASK GENMASK(2, 0)
136+
#define E4210_DIV1_HPM_MASK GENMASK(6, 4)
137+
#define E4210_DIV1_COPY_MASK GENMASK(2, 0)
138+
#define E4210_MUX_HPM_MASK BIT(20)
139+
#define E4210_DIV0_ATB_SHIFT 16
140+
#define E4210_DIV0_ATB_MASK (DIV_MASK << E4210_DIV0_ATB_SHIFT)
172141

173142
/*
174143
* Helper function to set the 'safe' dividers for the CPU clock. The parameters
@@ -300,6 +269,15 @@ static int exynos_cpuclk_post_rate_change(struct clk_notifier_data *ndata,
300269
return 0;
301270
}
302271

272+
/* ---- Exynos5433 ---------------------------------------------------------- */
273+
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
280+
303281
/*
304282
* Helper function to set the 'safe' dividers for the CPU clock. The parameters
305283
* div and mask contain the divider value and the register bit mask of the
@@ -398,6 +376,36 @@ static int exynos5433_cpuclk_post_rate_change(struct clk_notifier_data *ndata,
398376
return 0;
399377
}
400378

379+
/* -------------------------------------------------------------------------- */
380+
381+
/* Common round rate callback usable for all types of CPU clocks */
382+
static long exynos_cpuclk_round_rate(struct clk_hw *hw, unsigned long drate,
383+
unsigned long *prate)
384+
{
385+
struct clk_hw *parent = clk_hw_get_parent(hw);
386+
*prate = clk_hw_round_rate(parent, drate);
387+
return *prate;
388+
}
389+
390+
/* Common recalc rate callback usable for all types of CPU clocks */
391+
static unsigned long exynos_cpuclk_recalc_rate(struct clk_hw *hw,
392+
unsigned long parent_rate)
393+
{
394+
/*
395+
* The CPU clock output (armclk) rate is the same as its parent
396+
* rate. Although there exist certain dividers inside the CPU
397+
* clock block that could be used to divide the parent clock,
398+
* the driver does not make use of them currently, except during
399+
* frequency transitions.
400+
*/
401+
return parent_rate;
402+
}
403+
404+
static const struct clk_ops exynos_cpuclk_clk_ops = {
405+
.recalc_rate = exynos_cpuclk_recalc_rate,
406+
.round_rate = exynos_cpuclk_round_rate,
407+
};
408+
401409
/*
402410
* This notifier function is called for the pre-rate and post-rate change
403411
* notifications of the parent clock of cpuclk.

0 commit comments

Comments
 (0)