|
38 | 38 | #include "clk.h"
|
39 | 39 | #include "clk-cpu.h"
|
40 | 40 |
|
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 |
| - |
69 | 41 | struct exynos_cpuclk;
|
70 | 42 |
|
71 | 43 | typedef int (*exynos_rate_change_fn_t)(struct clk_notifier_data *ndata,
|
@@ -103,6 +75,15 @@ struct exynos_cpuclk {
|
103 | 75 | exynos_rate_change_fn_t post_rate_cb;
|
104 | 76 | };
|
105 | 77 |
|
| 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 | + |
106 | 87 | /*
|
107 | 88 | * Helper function to wait until divider(s) have stabilized after the divider
|
108 | 89 | * value has changed.
|
@@ -142,33 +123,21 @@ static void wait_until_mux_stable(void __iomem *mux_reg, u32 mux_pos,
|
142 | 123 | pr_err("%s: re-parenting mux timed-out\n", __func__);
|
143 | 124 | }
|
144 | 125 |
|
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 -------------------------------------------------------- */ |
153 | 127 |
|
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 |
167 | 134 |
|
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) |
172 | 141 |
|
173 | 142 | /*
|
174 | 143 | * 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,
|
300 | 269 | return 0;
|
301 | 270 | }
|
302 | 271 |
|
| 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 | + |
303 | 281 | /*
|
304 | 282 | * Helper function to set the 'safe' dividers for the CPU clock. The parameters
|
305 | 283 | * 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,
|
398 | 376 | return 0;
|
399 | 377 | }
|
400 | 378 |
|
| 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 | + |
401 | 409 | /*
|
402 | 410 | * This notifier function is called for the pre-rate and post-rate change
|
403 | 411 | * notifications of the parent clock of cpuclk.
|
|
0 commit comments