Skip to content

Commit 15afa04

Browse files
committed
Merge branches 'clk-ti', 'clk-amlogic', 'clk-tegra' and 'clk-samsung' into clk-next
* clk-ti: clk: keystone: sci-clk: add support for dynamically probing clocks clk: ti: add support for clock latching to mux clocks clk: ti: add support for clock latching to divider clocks clk: ti: add generic support for clock latching clk: ti: add support for register read-modify-write low-level operation dt-bindings: clock: ti: add latching support to mux and divider clocks * clk-amlogic: (50 commits) clk: meson: Drop unused local variable and add static clk: meson: clean-up clk81 clocks clk: meson: add fdiv clock gates clk: meson: add mpll pre-divider clk: meson: axg: add hifi pll clock clk: meson: axg: add hifi clock bindings clk: meson: add ROUND_CLOSEST to the pll driver clk: meson: add gp0 frac parameter for axg and gxl clk: meson: improve pll driver results with frac clk: meson: remove special gp0 lock loop clk: meson: poke pll CNTL last clk: meson: add fractional part of meson8b fixed_pll clk: meson: use hhi syscon if available clk: meson: remove obsolete cpu_clk clk: meson: rework meson8b cpu clock clk: meson: split divider and gate part of mpll clk: meson: migrate plls clocks to clk_regmap clk: meson: migrate the audio divider clock to clk_regmap clk: meson: migrate mplls clocks to clk_regmap clk: meson: add regmap helpers for parm ... * clk-tegra: clk: tegra: Fix pll_u rate configuration clk: tegra: Specify VDE clock rate clk: tegra20: Correct PLL_C_OUT1 setup clk: tegra: Mark HCLK, SCLK and EMC as critical clk: tegra: MBIST work around for Tegra210 clk: tegra: add fence_delay for clock registers clk: tegra: Add la clock for Tegra210 * clk-samsung: (22 commits) clk: samsung: Mark a few things static clk: samsung: Add fout=196608001 Hz EPLL rate entry for exynos4412 clk: samsung: exynos5250: Add missing clocks for FIMC LITE SYSMMU devices clk: samsung: exynos5420: Add more entries to EPLL rate table clk: samsung: exynos5420: Add CLK_SET_RATE_PARENT flag to mout_mau_epll_clk clk: samsung: exynos5250: Move PD-dependent clocks to Exynos5 sub-CMU clk: samsung: exynos5420: Move PD-dependent clocks to Exynos5 sub-CMU clk: samsung: Add Exynos5 sub-CMU clock driver soc: samsung: pm_domains: Add blacklisting clock handling clk: samsung: Add compile time PLL rate validators clk: samsung: s3c2410: Fix PLL rates clk: samsung: exynos7: Fix PLL rates clk: samsung: exynos5433: Fix PLL rates clk: samsung: exynos5260: Fix PLL rates clk: samsung: exynos5250: Fix PLL rates clk: samsung: exynos3250: Fix PLL rates clk: exynos5433: Extend list of available AUD_PLL output frequencies clk: exynos5433: Add CLK_IGNORE_UNUSED flag to sclk_ioclk_i2s1_bclk clk: samsung: Add a git tree entry to MAINTAINERS clk: samsung: Remove redundant dev_err call in exynos_audss_clk_probe() ...
4 parents 401fd20 + 5d1c04d + 91fab9d + 1871f0f commit 15afa04

55 files changed

Lines changed: 3806 additions & 2588 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎MAINTAINERS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12189,6 +12189,7 @@ M: Tomasz Figa <tomasz.figa@gmail.com>
1218912189
M: Chanwoo Choi <cw00.choi@samsung.com>
1219012190
S: Supported
1219112191
L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers)
12192+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/snawrocki/clk.git
1219212193
F: drivers/clk/samsung/
1219312194
F: include/dt-bindings/clock/exynos*.h
1219412195
F: Documentation/devicetree/bindings/clock/exynos*.txt

‎drivers/clk/clk-divider.c‎

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,10 @@
2828
* parent - fixed parent. No clk_set_parent support
2929
*/
3030

31-
#define div_mask(width) ((1 << (width)) - 1)
32-
3331
static unsigned int _get_table_maxdiv(const struct clk_div_table *table,
3432
u8 width)
3533
{
36-
unsigned int maxdiv = 0, mask = div_mask(width);
34+
unsigned int maxdiv = 0, mask = clk_div_mask(width);
3735
const struct clk_div_table *clkt;
3836

3937
for (clkt = table; clkt->div; clkt++)
@@ -57,12 +55,12 @@ static unsigned int _get_maxdiv(const struct clk_div_table *table, u8 width,
5755
unsigned long flags)
5856
{
5957
if (flags & CLK_DIVIDER_ONE_BASED)
60-
return div_mask(width);
58+
return clk_div_mask(width);
6159
if (flags & CLK_DIVIDER_POWER_OF_TWO)
62-
return 1 << div_mask(width);
60+
return 1 << clk_div_mask(width);
6361
if (table)
6462
return _get_table_maxdiv(table, width);
65-
return div_mask(width) + 1;
63+
return clk_div_mask(width) + 1;
6664
}
6765

6866
static unsigned int _get_table_div(const struct clk_div_table *table,
@@ -84,7 +82,7 @@ static unsigned int _get_div(const struct clk_div_table *table,
8482
if (flags & CLK_DIVIDER_POWER_OF_TWO)
8583
return 1 << val;
8684
if (flags & CLK_DIVIDER_MAX_AT_ZERO)
87-
return val ? val : div_mask(width) + 1;
85+
return val ? val : clk_div_mask(width) + 1;
8886
if (table)
8987
return _get_table_div(table, val);
9088
return val + 1;
@@ -109,7 +107,7 @@ static unsigned int _get_val(const struct clk_div_table *table,
109107
if (flags & CLK_DIVIDER_POWER_OF_TWO)
110108
return __ffs(div);
111109
if (flags & CLK_DIVIDER_MAX_AT_ZERO)
112-
return (div == div_mask(width) + 1) ? 0 : div;
110+
return (div == clk_div_mask(width) + 1) ? 0 : div;
113111
if (table)
114112
return _get_table_val(table, div);
115113
return div - 1;
@@ -141,7 +139,7 @@ static unsigned long clk_divider_recalc_rate(struct clk_hw *hw,
141139
unsigned int val;
142140

143141
val = clk_readl(divider->reg) >> divider->shift;
144-
val &= div_mask(divider->width);
142+
val &= clk_div_mask(divider->width);
145143

146144
return divider_recalc_rate(hw, parent_rate, val, divider->table,
147145
divider->flags, divider->width);
@@ -344,19 +342,43 @@ long divider_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
344342
}
345343
EXPORT_SYMBOL_GPL(divider_round_rate_parent);
346344

345+
long divider_ro_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
346+
unsigned long rate, unsigned long *prate,
347+
const struct clk_div_table *table, u8 width,
348+
unsigned long flags, unsigned int val)
349+
{
350+
int div;
351+
352+
div = _get_div(table, val, flags, width);
353+
354+
/* Even a read-only clock can propagate a rate change */
355+
if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) {
356+
if (!parent)
357+
return -EINVAL;
358+
359+
*prate = clk_hw_round_rate(parent, rate * div);
360+
}
361+
362+
return DIV_ROUND_UP_ULL((u64)*prate, div);
363+
}
364+
EXPORT_SYMBOL_GPL(divider_ro_round_rate_parent);
365+
366+
347367
static long clk_divider_round_rate(struct clk_hw *hw, unsigned long rate,
348368
unsigned long *prate)
349369
{
350370
struct clk_divider *divider = to_clk_divider(hw);
351-
int bestdiv;
352371

353372
/* if read only, just return current value */
354373
if (divider->flags & CLK_DIVIDER_READ_ONLY) {
355-
bestdiv = clk_readl(divider->reg) >> divider->shift;
356-
bestdiv &= div_mask(divider->width);
357-
bestdiv = _get_div(divider->table, bestdiv, divider->flags,
358-
divider->width);
359-
return DIV_ROUND_UP_ULL((u64)*prate, bestdiv);
374+
u32 val;
375+
376+
val = clk_readl(divider->reg) >> divider->shift;
377+
val &= clk_div_mask(divider->width);
378+
379+
return divider_ro_round_rate(hw, rate, prate, divider->table,
380+
divider->width, divider->flags,
381+
val);
360382
}
361383

362384
return divider_round_rate(hw, rate, prate, divider->table,
@@ -376,7 +398,7 @@ int divider_get_val(unsigned long rate, unsigned long parent_rate,
376398

377399
value = _get_val(table, div, flags, width);
378400

379-
return min_t(unsigned int, value, div_mask(width));
401+
return min_t(unsigned int, value, clk_div_mask(width));
380402
}
381403
EXPORT_SYMBOL_GPL(divider_get_val);
382404

@@ -399,10 +421,10 @@ static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,
399421
__acquire(divider->lock);
400422

401423
if (divider->flags & CLK_DIVIDER_HIWORD_MASK) {
402-
val = div_mask(divider->width) << (divider->shift + 16);
424+
val = clk_div_mask(divider->width) << (divider->shift + 16);
403425
} else {
404426
val = clk_readl(divider->reg);
405-
val &= ~(div_mask(divider->width) << divider->shift);
427+
val &= ~(clk_div_mask(divider->width) << divider->shift);
406428
}
407429
val |= (u32)value << divider->shift;
408430
clk_writel(val, divider->reg);

‎drivers/clk/clk-mux.c‎

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,72 +26,83 @@
2626
* parent - parent is adjustable through clk_set_parent
2727
*/
2828

29-
static u8 clk_mux_get_parent(struct clk_hw *hw)
29+
int clk_mux_val_to_index(struct clk_hw *hw, u32 *table, unsigned int flags,
30+
unsigned int val)
3031
{
31-
struct clk_mux *mux = to_clk_mux(hw);
3232
int num_parents = clk_hw_get_num_parents(hw);
33-
u32 val;
3433

35-
/*
36-
* FIXME need a mux-specific flag to determine if val is bitwise or numeric
37-
* e.g. sys_clkin_ck's clksel field is 3 bits wide, but ranges from 0x1
38-
* to 0x7 (index starts at one)
39-
* OTOH, pmd_trace_clk_mux_ck uses a separate bit for each clock, so
40-
* val = 0x4 really means "bit 2, index starts at bit 0"
41-
*/
42-
val = clk_readl(mux->reg) >> mux->shift;
43-
val &= mux->mask;
44-
45-
if (mux->table) {
34+
if (table) {
4635
int i;
4736

4837
for (i = 0; i < num_parents; i++)
49-
if (mux->table[i] == val)
38+
if (table[i] == val)
5039
return i;
5140
return -EINVAL;
5241
}
5342

54-
if (val && (mux->flags & CLK_MUX_INDEX_BIT))
43+
if (val && (flags & CLK_MUX_INDEX_BIT))
5544
val = ffs(val) - 1;
5645

57-
if (val && (mux->flags & CLK_MUX_INDEX_ONE))
46+
if (val && (flags & CLK_MUX_INDEX_ONE))
5847
val--;
5948

6049
if (val >= num_parents)
6150
return -EINVAL;
6251

6352
return val;
6453
}
54+
EXPORT_SYMBOL_GPL(clk_mux_val_to_index);
6555

66-
static int clk_mux_set_parent(struct clk_hw *hw, u8 index)
56+
unsigned int clk_mux_index_to_val(u32 *table, unsigned int flags, u8 index)
6757
{
68-
struct clk_mux *mux = to_clk_mux(hw);
69-
u32 val;
70-
unsigned long flags = 0;
58+
unsigned int val = index;
7159

72-
if (mux->table) {
73-
index = mux->table[index];
60+
if (table) {
61+
val = table[index];
7462
} else {
75-
if (mux->flags & CLK_MUX_INDEX_BIT)
76-
index = 1 << index;
63+
if (flags & CLK_MUX_INDEX_BIT)
64+
val = 1 << index;
7765

78-
if (mux->flags & CLK_MUX_INDEX_ONE)
79-
index++;
66+
if (flags & CLK_MUX_INDEX_ONE)
67+
val++;
8068
}
8169

70+
return val;
71+
}
72+
EXPORT_SYMBOL_GPL(clk_mux_index_to_val);
73+
74+
static u8 clk_mux_get_parent(struct clk_hw *hw)
75+
{
76+
struct clk_mux *mux = to_clk_mux(hw);
77+
u32 val;
78+
79+
val = clk_readl(mux->reg) >> mux->shift;
80+
val &= mux->mask;
81+
82+
return clk_mux_val_to_index(hw, mux->table, mux->flags, val);
83+
}
84+
85+
static int clk_mux_set_parent(struct clk_hw *hw, u8 index)
86+
{
87+
struct clk_mux *mux = to_clk_mux(hw);
88+
u32 val = clk_mux_index_to_val(mux->table, mux->flags, index);
89+
unsigned long flags = 0;
90+
u32 reg;
91+
8292
if (mux->lock)
8393
spin_lock_irqsave(mux->lock, flags);
8494
else
8595
__acquire(mux->lock);
8696

8797
if (mux->flags & CLK_MUX_HIWORD_MASK) {
88-
val = mux->mask << (mux->shift + 16);
98+
reg = mux->mask << (mux->shift + 16);
8999
} else {
90-
val = clk_readl(mux->reg);
91-
val &= ~(mux->mask << mux->shift);
100+
reg = clk_readl(mux->reg);
101+
reg &= ~(mux->mask << mux->shift);
92102
}
93-
val |= index << mux->shift;
94-
clk_writel(val, mux->reg);
103+
val = val << mux->shift;
104+
reg |= val;
105+
clk_writel(reg, mux->reg);
95106

96107
if (mux->lock)
97108
spin_unlock_irqrestore(mux->lock, flags);

‎drivers/clk/clk.c‎

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,8 +1125,10 @@ static int clk_core_round_rate_nolock(struct clk_core *core,
11251125
{
11261126
lockdep_assert_held(&prepare_lock);
11271127

1128-
if (!core)
1128+
if (!core) {
1129+
req->rate = 0;
11291130
return 0;
1131+
}
11301132

11311133
clk_core_init_rate_req(core, req);
11321134

@@ -2927,6 +2929,17 @@ static int __clk_core_init(struct clk_core *core)
29272929
core->orphan = true;
29282930
}
29292931

2932+
/*
2933+
* optional platform-specific magic
2934+
*
2935+
* The .init callback is not used by any of the basic clock types, but
2936+
* exists for weird hardware that must perform initialization magic.
2937+
* Please consider other ways of solving initialization problems before
2938+
* using this callback, as its use is discouraged.
2939+
*/
2940+
if (core->ops->init)
2941+
core->ops->init(core->hw);
2942+
29302943
/*
29312944
* Set clk's accuracy. The preferred method is to use
29322945
* .recalc_accuracy. For simple clocks and lazy developers the default
@@ -2967,49 +2980,43 @@ static int __clk_core_init(struct clk_core *core)
29672980
rate = 0;
29682981
core->rate = core->req_rate = rate;
29692982

2983+
/*
2984+
* Enable CLK_IS_CRITICAL clocks so newly added critical clocks
2985+
* don't get accidentally disabled when walking the orphan tree and
2986+
* reparenting clocks
2987+
*/
2988+
if (core->flags & CLK_IS_CRITICAL) {
2989+
unsigned long flags;
2990+
2991+
clk_core_prepare(core);
2992+
2993+
flags = clk_enable_lock();
2994+
clk_core_enable(core);
2995+
clk_enable_unlock(flags);
2996+
}
2997+
29702998
/*
29712999
* walk the list of orphan clocks and reparent any that newly finds a
29723000
* parent.
29733001
*/
29743002
hlist_for_each_entry_safe(orphan, tmp2, &clk_orphan_list, child_node) {
29753003
struct clk_core *parent = __clk_init_parent(orphan);
2976-
unsigned long flags;
29773004

29783005
/*
2979-
* we could call __clk_set_parent, but that would result in a
2980-
* redundant call to the .set_rate op, if it exists
3006+
* We need to use __clk_set_parent_before() and _after() to
3007+
* to properly migrate any prepare/enable count of the orphan
3008+
* clock. This is important for CLK_IS_CRITICAL clocks, which
3009+
* are enabled during init but might not have a parent yet.
29813010
*/
29823011
if (parent) {
29833012
/* update the clk tree topology */
2984-
flags = clk_enable_lock();
2985-
clk_reparent(orphan, parent);
2986-
clk_enable_unlock(flags);
3013+
__clk_set_parent_before(orphan, parent);
3014+
__clk_set_parent_after(orphan, parent, NULL);
29873015
__clk_recalc_accuracies(orphan);
29883016
__clk_recalc_rates(orphan, 0);
29893017
}
29903018
}
29913019

2992-
/*
2993-
* optional platform-specific magic
2994-
*
2995-
* The .init callback is not used by any of the basic clock types, but
2996-
* exists for weird hardware that must perform initialization magic.
2997-
* Please consider other ways of solving initialization problems before
2998-
* using this callback, as its use is discouraged.
2999-
*/
3000-
if (core->ops->init)
3001-
core->ops->init(core->hw);
3002-
3003-
if (core->flags & CLK_IS_CRITICAL) {
3004-
unsigned long flags;
3005-
3006-
clk_core_prepare(core);
3007-
3008-
flags = clk_enable_lock();
3009-
clk_core_enable(core);
3010-
clk_enable_unlock(flags);
3011-
}
3012-
30133020
kref_init(&core->ref);
30143021
out:
30153022
clk_pm_runtime_put(core);

‎drivers/clk/meson/Kconfig‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ config COMMON_CLK_AMLOGIC
33
depends on OF
44
depends on ARCH_MESON || COMPILE_TEST
55

6+
config COMMON_CLK_REGMAP_MESON
7+
bool
8+
select REGMAP
9+
610
config COMMON_CLK_MESON8B
711
bool
812
depends on COMMON_CLK_AMLOGIC
913
select RESET_CONTROLLER
14+
select COMMON_CLK_REGMAP_MESON
1015
help
1116
Support for the clock controller on AmLogic S802 (Meson8),
1217
S805 (Meson8b) and S812 (Meson8m2) devices. Say Y if you
@@ -16,6 +21,8 @@ config COMMON_CLK_GXBB
1621
bool
1722
depends on COMMON_CLK_AMLOGIC
1823
select RESET_CONTROLLER
24+
select COMMON_CLK_REGMAP_MESON
25+
select MFD_SYSCON
1926
help
2027
Support for the clock controller on AmLogic S905 devices, aka gxbb.
2128
Say Y if you want peripherals and CPU frequency scaling to work.
@@ -24,6 +31,8 @@ config COMMON_CLK_AXG
2431
bool
2532
depends on COMMON_CLK_AMLOGIC
2633
select RESET_CONTROLLER
34+
select COMMON_CLK_REGMAP_MESON
35+
select MFD_SYSCON
2736
help
2837
Support for the clock controller on AmLogic A113D devices, aka axg.
2938
Say Y if you want peripherals and CPU frequency scaling to work.

‎drivers/clk/meson/Makefile‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# Makefile for Meson specific clk
33
#
44

5-
obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-pll.o clk-cpu.o clk-mpll.o clk-audio-divider.o
5+
obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-pll.o clk-mpll.o clk-audio-divider.o
66
obj-$(CONFIG_COMMON_CLK_MESON8B) += meson8b.o
7-
obj-$(CONFIG_COMMON_CLK_GXBB) += gxbb.o gxbb-aoclk.o gxbb-aoclk-regmap.o gxbb-aoclk-32k.o
7+
obj-$(CONFIG_COMMON_CLK_GXBB) += gxbb.o gxbb-aoclk.o gxbb-aoclk-32k.o
88
obj-$(CONFIG_COMMON_CLK_AXG) += axg.o
9+
obj-$(CONFIG_COMMON_CLK_REGMAP_MESON) += clk-regmap.o

0 commit comments

Comments
 (0)