Skip to content

Commit e2ceaa8

Browse files
committed
Merge branches 'clk-composite-determine-fix', 'clk-allwinner', 'clk-amlogic' and 'clk-samsung' into clk-next
* clk-composite-determine-fix: clk: composite: Use rate_ops.determine_rate when also a mux is available clk: composite: Also consider .determine_rate for rate + mux composites * clk-allwinner: clk: sunxi: sun8i-apb0: Make use of the helper function devm_platform_ioremap_resource() clk: sunxi: sun6i-ar100: Make use of the helper function devm_platform_ioremap_resource() clk: sunxi: sun6i-apb0-gates: Make use of the helper function devm_platform_ioremap_resource() clk: sunxi: sun6i-apb0: Make use of the helper function devm_platform_ioremap_resource() clk: sunxi-ng: ccu-sun9i-a80-usb: Make use of the helper function devm_platform_ioremap_resource() clk: sunxi-ng: ccu-sun9i-a80-de: Make use of the helper function devm_platform_ioremap_resource() clk: sunxi-ng: ccu-sun9i-a80: Make use of the helper function devm_platform_ioremap_resource() clk: sunxi-ng: ccu-sun8i-r40: Make use of the helper function devm_platform_ioremap_resource() clk: sunxi-ng: ccu-sun8i-de2: Make use of the helper function devm_platform_ioremap_resource() clk: sunxi-ng: ccu-sun8i-a83t: Make use of the helper function devm_platform_ioremap_resource() clk: sunxi-ng: ccu-sun50i-h6: Make use of the helper function devm_platform_ioremap_resource() clk: sunxi-ng: ccu-sun50i-a64: Make use of the helper function devm_platform_ioremap_resource() clk: sunxi: clk-mod0: Make use of the helper function devm_platform_ioremap_resource() dt-bindings: clocks: Fix typo in the H6 compatible clk: sunxi-ng: Use a separate lock for each CCU instance clk: sunxi-ng: Prevent unbinding CCUs via sysfs clk: sunxi-ng: Unregister clocks/resets when unbinding clk: sunxi-ng: Add machine dependency to A83T CCU clk: sunxi-ng: mux: Remove unused 'reg' field * clk-amlogic: clk: meson: meson8b: Make the video clock trees mutable clk: meson: meson8b: Initialize the HDMI PLL registers clk: meson: meson8b: Add the HDMI PLL M/N parameters clk: meson: meson8b: Add the vid_pll_lvds_en gate clock clk: meson: meson8b: Use CLK_SET_RATE_NO_REPARENT for vclk{,2}_in_sel clk: meson: meson8b: Export the video clocks * clk-samsung: clk: samsung: describe drivers in Kconfig clk: samsung: exynos5433: update apollo and atlas clock probing clk: samsung: add support for CPU clocks clk: samsung: Introduce Exynos850 clock driver dt-bindings: clock: Document Exynos850 CMU bindings dt-bindings: clock: Add bindings definitions for Exynos850 CMU clk: samsung: clk-pll: Implement pll0831x PLL type clk: samsung: clk-pll: Implement pll0822x PLL type clk: samsung: s5pv210-audss: Make use of devm_platform_ioremap_resource() clk: samsung: exynos5433: Make use of devm_platform_ioremap_resource() clk: samsung: exynos4412-isp: Make use of devm_platform_ioremap_resource() clk: samsung: exynos-audss: Make use of devm_platform_ioremap_resource()
5 parents 8d741ec + 6594988 + a69cd91 + 151a994 + 4e44a0b commit e2ceaa8

Some content is hidden

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

49 files changed

+1800
-259
lines changed

Documentation/devicetree/bindings/clock/allwinner,sun8i-a83t-de2-clk.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ properties:
2424
- const: allwinner,sun8i-v3s-de2-clk
2525
- const: allwinner,sun50i-a64-de2-clk
2626
- const: allwinner,sun50i-h5-de2-clk
27-
- const: allwinner,sun50i-h6-de2-clk
27+
- const: allwinner,sun50i-h6-de3-clk
2828
- items:
2929
- const: allwinner,sun8i-r40-de2-clk
3030
- const: allwinner,sun8i-h3-de2-clk
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/clock/samsung,exynos850-clock.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Samsung Exynos850 SoC clock controller
8+
9+
maintainers:
10+
- Sam Protsenko <[email protected]>
11+
- Chanwoo Choi <[email protected]>
12+
- Krzysztof Kozlowski <[email protected]>
13+
- Sylwester Nawrocki <[email protected]>
14+
- Tomasz Figa <[email protected]>
15+
16+
description: |
17+
Exynos850 clock controller is comprised of several CMU units, generating
18+
clocks for different domains. Those CMU units are modeled as separate device
19+
tree nodes, and might depend on each other. Root clocks in that clock tree are
20+
two external clocks:: OSCCLK (26 MHz) and RTCCLK (32768 Hz). Those external
21+
clocks must be defined as fixed-rate clocks in dts.
22+
23+
CMU_TOP is a top-level CMU, where all base clocks are prepared using PLLs and
24+
dividers; all other leaf clocks (other CMUs) are usually derived from CMU_TOP.
25+
26+
Each clock is assigned an identifier and client nodes can use this identifier
27+
to specify the clock which they consume. All clocks available for usage
28+
in clock consumer nodes are defined as preprocessor macros in
29+
'dt-bindings/clock/exynos850.h' header.
30+
31+
properties:
32+
compatible:
33+
enum:
34+
- samsung,exynos850-cmu-top
35+
- samsung,exynos850-cmu-core
36+
- samsung,exynos850-cmu-dpu
37+
- samsung,exynos850-cmu-hsi
38+
- samsung,exynos850-cmu-peri
39+
40+
clocks:
41+
minItems: 1
42+
maxItems: 5
43+
44+
clock-names:
45+
minItems: 1
46+
maxItems: 5
47+
48+
"#clock-cells":
49+
const: 1
50+
51+
reg:
52+
maxItems: 1
53+
54+
allOf:
55+
- if:
56+
properties:
57+
compatible:
58+
contains:
59+
const: samsung,exynos850-cmu-top
60+
61+
then:
62+
properties:
63+
clocks:
64+
items:
65+
- description: External reference clock (26 MHz)
66+
67+
clock-names:
68+
items:
69+
- const: oscclk
70+
71+
- if:
72+
properties:
73+
compatible:
74+
contains:
75+
const: samsung,exynos850-cmu-core
76+
77+
then:
78+
properties:
79+
clocks:
80+
items:
81+
- description: External reference clock (26 MHz)
82+
- description: CMU_CORE bus clock (from CMU_TOP)
83+
- description: CCI clock (from CMU_TOP)
84+
- description: eMMC clock (from CMU_TOP)
85+
- description: SSS clock (from CMU_TOP)
86+
87+
clock-names:
88+
items:
89+
- const: oscclk
90+
- const: dout_core_bus
91+
- const: dout_core_cci
92+
- const: dout_core_mmc_embd
93+
- const: dout_core_sss
94+
95+
- if:
96+
properties:
97+
compatible:
98+
contains:
99+
const: samsung,exynos850-cmu-dpu
100+
101+
then:
102+
properties:
103+
clocks:
104+
items:
105+
- description: External reference clock (26 MHz)
106+
- description: DPU clock (from CMU_TOP)
107+
108+
clock-names:
109+
items:
110+
- const: oscclk
111+
- const: dout_dpu
112+
113+
- if:
114+
properties:
115+
compatible:
116+
contains:
117+
const: samsung,exynos850-cmu-hsi
118+
119+
then:
120+
properties:
121+
clocks:
122+
items:
123+
- description: External reference clock (26 MHz)
124+
- description: External RTC clock (32768 Hz)
125+
- description: CMU_HSI bus clock (from CMU_TOP)
126+
- description: SD card clock (from CMU_TOP)
127+
- description: "USB 2.0 DRD clock (from CMU_TOP)"
128+
129+
clock-names:
130+
items:
131+
- const: oscclk
132+
- const: rtcclk
133+
- const: dout_hsi_bus
134+
- const: dout_hsi_mmc_card
135+
- const: dout_hsi_usb20drd
136+
137+
- if:
138+
properties:
139+
compatible:
140+
contains:
141+
const: samsung,exynos850-cmu-peri
142+
143+
then:
144+
properties:
145+
clocks:
146+
items:
147+
- description: External reference clock (26 MHz)
148+
- description: CMU_PERI bus clock (from CMU_TOP)
149+
- description: UART clock (from CMU_TOP)
150+
- description: Parent clock for HSI2C and SPI (from CMU_TOP)
151+
152+
clock-names:
153+
items:
154+
- const: oscclk
155+
- const: dout_peri_bus
156+
- const: dout_peri_uart
157+
- const: dout_peri_ip
158+
159+
required:
160+
- compatible
161+
- "#clock-cells"
162+
- clocks
163+
- clock-names
164+
- reg
165+
166+
additionalProperties: false
167+
168+
examples:
169+
# Clock controller node for CMU_PERI
170+
- |
171+
#include <dt-bindings/clock/exynos850.h>
172+
173+
cmu_peri: clock-controller@10030000 {
174+
compatible = "samsung,exynos850-cmu-peri";
175+
reg = <0x10030000 0x8000>;
176+
#clock-cells = <1>;
177+
178+
clocks = <&oscclk>, <&cmu_top CLK_DOUT_PERI_BUS>,
179+
<&cmu_top CLK_DOUT_PERI_UART>,
180+
<&cmu_top CLK_DOUT_PERI_IP>;
181+
clock-names = "oscclk", "dout_peri_bus",
182+
"dout_peri_uart", "dout_peri_ip";
183+
};
184+
185+
...

drivers/clk/clk-composite.c

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,29 @@ static unsigned long clk_composite_recalc_rate(struct clk_hw *hw,
4242
return rate_ops->recalc_rate(rate_hw, parent_rate);
4343
}
4444

45+
static int clk_composite_determine_rate_for_parent(struct clk_hw *rate_hw,
46+
struct clk_rate_request *req,
47+
struct clk_hw *parent_hw,
48+
const struct clk_ops *rate_ops)
49+
{
50+
long rate;
51+
52+
req->best_parent_hw = parent_hw;
53+
req->best_parent_rate = clk_hw_get_rate(parent_hw);
54+
55+
if (rate_ops->determine_rate)
56+
return rate_ops->determine_rate(rate_hw, req);
57+
58+
rate = rate_ops->round_rate(rate_hw, req->rate,
59+
&req->best_parent_rate);
60+
if (rate < 0)
61+
return rate;
62+
63+
req->rate = rate;
64+
65+
return 0;
66+
}
67+
4568
static int clk_composite_determine_rate(struct clk_hw *hw,
4669
struct clk_rate_request *req)
4770
{
@@ -51,54 +74,56 @@ static int clk_composite_determine_rate(struct clk_hw *hw,
5174
struct clk_hw *rate_hw = composite->rate_hw;
5275
struct clk_hw *mux_hw = composite->mux_hw;
5376
struct clk_hw *parent;
54-
unsigned long parent_rate;
55-
long tmp_rate, best_rate = 0;
5677
unsigned long rate_diff;
5778
unsigned long best_rate_diff = ULONG_MAX;
58-
long rate;
59-
int i;
79+
unsigned long best_rate = 0;
80+
int i, ret;
6081

61-
if (rate_hw && rate_ops && rate_ops->determine_rate) {
62-
__clk_hw_set_clk(rate_hw, hw);
63-
return rate_ops->determine_rate(rate_hw, req);
64-
} else if (rate_hw && rate_ops && rate_ops->round_rate &&
65-
mux_hw && mux_ops && mux_ops->set_parent) {
82+
if (rate_hw && rate_ops &&
83+
(rate_ops->determine_rate || rate_ops->round_rate) &&
84+
mux_hw && mux_ops && mux_ops->set_parent) {
6685
req->best_parent_hw = NULL;
6786

6887
if (clk_hw_get_flags(hw) & CLK_SET_RATE_NO_REPARENT) {
88+
struct clk_rate_request tmp_req = *req;
89+
6990
parent = clk_hw_get_parent(mux_hw);
70-
req->best_parent_hw = parent;
71-
req->best_parent_rate = clk_hw_get_rate(parent);
7291

73-
rate = rate_ops->round_rate(rate_hw, req->rate,
74-
&req->best_parent_rate);
75-
if (rate < 0)
76-
return rate;
92+
ret = clk_composite_determine_rate_for_parent(rate_hw,
93+
&tmp_req,
94+
parent,
95+
rate_ops);
96+
if (ret)
97+
return ret;
98+
99+
req->rate = tmp_req.rate;
100+
req->best_parent_rate = tmp_req.best_parent_rate;
77101

78-
req->rate = rate;
79102
return 0;
80103
}
81104

82105
for (i = 0; i < clk_hw_get_num_parents(mux_hw); i++) {
106+
struct clk_rate_request tmp_req = *req;
107+
83108
parent = clk_hw_get_parent_by_index(mux_hw, i);
84109
if (!parent)
85110
continue;
86111

87-
parent_rate = clk_hw_get_rate(parent);
88-
89-
tmp_rate = rate_ops->round_rate(rate_hw, req->rate,
90-
&parent_rate);
91-
if (tmp_rate < 0)
112+
ret = clk_composite_determine_rate_for_parent(rate_hw,
113+
&tmp_req,
114+
parent,
115+
rate_ops);
116+
if (ret)
92117
continue;
93118

94-
rate_diff = abs(req->rate - tmp_rate);
119+
rate_diff = abs(req->rate - tmp_req.rate);
95120

96121
if (!rate_diff || !req->best_parent_hw
97122
|| best_rate_diff > rate_diff) {
98123
req->best_parent_hw = parent;
99-
req->best_parent_rate = parent_rate;
124+
req->best_parent_rate = tmp_req.best_parent_rate;
100125
best_rate_diff = rate_diff;
101-
best_rate = tmp_rate;
126+
best_rate = tmp_req.rate;
102127
}
103128

104129
if (!rate_diff)
@@ -107,6 +132,9 @@ static int clk_composite_determine_rate(struct clk_hw *hw,
107132

108133
req->rate = best_rate;
109134
return 0;
135+
} else if (rate_hw && rate_ops && rate_ops->determine_rate) {
136+
__clk_hw_set_clk(rate_hw, hw);
137+
return rate_ops->determine_rate(rate_hw, req);
110138
} else if (mux_hw && mux_ops && mux_ops->determine_rate) {
111139
__clk_hw_set_clk(mux_hw, hw);
112140
return mux_ops->determine_rate(mux_hw, req);

0 commit comments

Comments
 (0)