Skip to content

Commit 14350ed

Browse files
committed
Merge tag 'clk-v5.17-samsung' of https://git.kernel.org/pub/scm/linux/kernel/git/snawrocki/clk into clk-samsung
Pull Samsung clk driver updates from Sylwester Nawrocki: - removal of all remaining uses of __clk_lookup() in drivers/clk/samsung - refactoring of the CPU clocks registration to use common interface - an update of the Exynos850 driver (support for more clock domains) required by the E850-96 development board - initial clock driver for the Exynos7885 SoC (Samsung Galaxy A8) * tag 'clk-v5.17-samsung' of https://git.kernel.org/pub/scm/linux/kernel/git/snawrocki/clk: clk: samsung: Add initial Exynos7885 clock driver clk: samsung: clk-pll: Add support for pll1417x clk: samsung: Make exynos850_register_cmu shared dt-bindings: clock: Document Exynos7885 CMU bindings dt-bindings: clock: Add bindings definitions for Exynos7885 CMU clk: samsung: exynos850: Add missing sysreg clocks dt-bindings: clock: Add bindings for Exynos850 sysreg clocks clk: samsung: exynos850: Register clocks early clk: samsung: exynos850: Keep some crucial clocks running clk: samsung: exynos850: Implement CMU_CMGP domain dt-bindings: clock: Add bindings for Exynos850 CMU_CMGP clk: samsung: exynos850: Implement CMU_APM domain dt-bindings: clock: Add bindings for Exynos850 CMU_APM clk: samsung: Update CPU clk registration clk: samsung: Remove meaningless __init and extern from header files clk: samsung: remove __clk_lookup() usage dt-bindings: clock: samsung: add IDs for some core clocks
2 parents fa55b7d + 45bd816 commit 14350ed

24 files changed

+1503
-185
lines changed
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
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,exynos7885-clock.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Samsung Exynos7885 SoC clock controller
8+
9+
maintainers:
10+
- Dávid Virág <virag.david003@gmail.com>
11+
- Chanwoo Choi <cw00.choi@samsung.com>
12+
- Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
13+
- Sylwester Nawrocki <s.nawrocki@samsung.com>
14+
- Tomasz Figa <tomasz.figa@gmail.com>
15+
16+
description: |
17+
Exynos7885 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. The root clock in that root tree
20+
is an external clock: OSCCLK (26 MHz). This external clock must be defined
21+
as a fixed-rate clock 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/exynos7885.h' header.
30+
31+
properties:
32+
compatible:
33+
enum:
34+
- samsung,exynos7885-cmu-top
35+
- samsung,exynos7885-cmu-core
36+
- samsung,exynos7885-cmu-peri
37+
38+
clocks:
39+
minItems: 1
40+
maxItems: 10
41+
42+
clock-names:
43+
minItems: 1
44+
maxItems: 10
45+
46+
"#clock-cells":
47+
const: 1
48+
49+
reg:
50+
maxItems: 1
51+
52+
allOf:
53+
- if:
54+
properties:
55+
compatible:
56+
contains:
57+
const: samsung,exynos7885-cmu-top
58+
59+
then:
60+
properties:
61+
clocks:
62+
items:
63+
- description: External reference clock (26 MHz)
64+
65+
clock-names:
66+
items:
67+
- const: oscclk
68+
69+
- if:
70+
properties:
71+
compatible:
72+
contains:
73+
const: samsung,exynos7885-cmu-core
74+
75+
then:
76+
properties:
77+
clocks:
78+
items:
79+
- description: External reference clock (26 MHz)
80+
- description: CMU_CORE bus clock (from CMU_TOP)
81+
- description: CCI clock (from CMU_TOP)
82+
- description: G3D clock (from CMU_TOP)
83+
84+
clock-names:
85+
items:
86+
- const: oscclk
87+
- const: dout_core_bus
88+
- const: dout_core_cci
89+
- const: dout_core_g3d
90+
91+
- if:
92+
properties:
93+
compatible:
94+
contains:
95+
const: samsung,exynos7885-cmu-peri
96+
97+
then:
98+
properties:
99+
clocks:
100+
items:
101+
- description: External reference clock (26 MHz)
102+
- description: CMU_PERI bus clock (from CMU_TOP)
103+
- description: SPI0 clock (from CMU_TOP)
104+
- description: SPI1 clock (from CMU_TOP)
105+
- description: UART0 clock (from CMU_TOP)
106+
- description: UART1 clock (from CMU_TOP)
107+
- description: UART2 clock (from CMU_TOP)
108+
- description: USI0 clock (from CMU_TOP)
109+
- description: USI1 clock (from CMU_TOP)
110+
- description: USI2 clock (from CMU_TOP)
111+
112+
clock-names:
113+
items:
114+
- const: oscclk
115+
- const: dout_peri_bus
116+
- const: dout_peri_spi0
117+
- const: dout_peri_spi1
118+
- const: dout_peri_uart0
119+
- const: dout_peri_uart1
120+
- const: dout_peri_uart2
121+
- const: dout_peri_usi0
122+
- const: dout_peri_usi1
123+
- const: dout_peri_usi2
124+
125+
required:
126+
- compatible
127+
- "#clock-cells"
128+
- clocks
129+
- clock-names
130+
- reg
131+
132+
additionalProperties: false
133+
134+
examples:
135+
# Clock controller node for CMU_PERI
136+
- |
137+
#include <dt-bindings/clock/exynos7885.h>
138+
139+
cmu_peri: clock-controller@10010000 {
140+
compatible = "samsung,exynos7885-cmu-peri";
141+
reg = <0x10010000 0x8000>;
142+
#clock-cells = <1>;
143+
144+
clocks = <&oscclk>,
145+
<&cmu_top CLK_DOUT_PERI_BUS>,
146+
<&cmu_top CLK_DOUT_PERI_SPI0>,
147+
<&cmu_top CLK_DOUT_PERI_SPI1>,
148+
<&cmu_top CLK_DOUT_PERI_UART0>,
149+
<&cmu_top CLK_DOUT_PERI_UART1>,
150+
<&cmu_top CLK_DOUT_PERI_UART2>,
151+
<&cmu_top CLK_DOUT_PERI_USI0>,
152+
<&cmu_top CLK_DOUT_PERI_USI1>,
153+
<&cmu_top CLK_DOUT_PERI_USI2>;
154+
clock-names = "oscclk",
155+
"dout_peri_bus",
156+
"dout_peri_spi0",
157+
"dout_peri_spi1",
158+
"dout_peri_uart0",
159+
"dout_peri_uart1",
160+
"dout_peri_uart2",
161+
"dout_peri_usi0",
162+
"dout_peri_usi1",
163+
"dout_peri_usi2";
164+
};
165+
166+
...

Documentation/devicetree/bindings/clock/samsung,exynos850-clock.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ properties:
3232
compatible:
3333
enum:
3434
- samsung,exynos850-cmu-top
35+
- samsung,exynos850-cmu-apm
36+
- samsung,exynos850-cmu-cmgp
3537
- samsung,exynos850-cmu-core
3638
- samsung,exynos850-cmu-dpu
3739
- samsung,exynos850-cmu-hsi
@@ -68,6 +70,42 @@ allOf:
6870
items:
6971
- const: oscclk
7072

73+
- if:
74+
properties:
75+
compatible:
76+
contains:
77+
const: samsung,exynos850-cmu-apm
78+
79+
then:
80+
properties:
81+
clocks:
82+
items:
83+
- description: External reference clock (26 MHz)
84+
- description: CMU_APM bus clock (from CMU_TOP)
85+
86+
clock-names:
87+
items:
88+
- const: oscclk
89+
- const: dout_clkcmu_apm_bus
90+
91+
- if:
92+
properties:
93+
compatible:
94+
contains:
95+
const: samsung,exynos850-cmu-cmgp
96+
97+
then:
98+
properties:
99+
clocks:
100+
items:
101+
- description: External reference clock (26 MHz)
102+
- description: CMU_CMGP bus clock (from CMU_APM)
103+
104+
clock-names:
105+
items:
106+
- const: oscclk
107+
- const: gout_clkcmu_cmgp_bus
108+
71109
- if:
72110
properties:
73111
compatible:

drivers/clk/samsung/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ obj-$(CONFIG_EXYNOS_5420_COMMON_CLK) += clk-exynos5-subcmu.o
1616
obj-$(CONFIG_EXYNOS_ARM64_COMMON_CLK) += clk-exynos5433.o
1717
obj-$(CONFIG_EXYNOS_AUDSS_CLK_CON) += clk-exynos-audss.o
1818
obj-$(CONFIG_EXYNOS_CLKOUT) += clk-exynos-clkout.o
19+
obj-$(CONFIG_EXYNOS_ARM64_COMMON_CLK) += clk-exynos-arm64.o
1920
obj-$(CONFIG_EXYNOS_ARM64_COMMON_CLK) += clk-exynos7.o
21+
obj-$(CONFIG_EXYNOS_ARM64_COMMON_CLK) += clk-exynos7885.o
2022
obj-$(CONFIG_EXYNOS_ARM64_COMMON_CLK) += clk-exynos850.o
2123
obj-$(CONFIG_S3C2410_COMMON_CLK)+= clk-s3c2410.o
2224
obj-$(CONFIG_S3C2410_COMMON_DCLK)+= clk-s3c2410-dclk.o

drivers/clk/samsung/clk-cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ static int exynos5433_cpuclk_notifier_cb(struct notifier_block *nb,
400400
}
401401

402402
/* helper function to register a CPU clock */
403-
int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx,
403+
static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx,
404404
unsigned int lookup_id, const char *name,
405405
const struct clk_hw *parent, const struct clk_hw *alt_parent,
406406
unsigned long offset, const struct exynos_cpuclk_cfg_data *cfg,

drivers/clk/samsung/clk-cpu.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,4 @@ struct exynos_cpuclk {
6262
#define CLK_CPU_HAS_E5433_REGS_LAYOUT (1 << 2)
6363
};
6464

65-
int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx,
66-
unsigned int lookup_id, const char *name,
67-
const struct clk_hw *parent, const struct clk_hw *alt_parent,
68-
unsigned long offset,
69-
const struct exynos_cpuclk_cfg_data *cfg,
70-
unsigned long num_cfgs, unsigned long flags);
71-
7265
#endif /* __SAMSUNG_CLK_CPU_H */
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* Copyright (C) 2021 Linaro Ltd.
4+
* Copyright (C) 2021 Dávid Virág <virag.david003@gmail.com>
5+
* Author: Sam Protsenko <semen.protsenko@linaro.org>
6+
* Author: Dávid Virág <virag.david003@gmail.com>
7+
*
8+
* This file contains shared functions used by some arm64 Exynos SoCs,
9+
* such as Exynos7885 or Exynos850 to register and init CMUs.
10+
*/
11+
#include <linux/clk.h>
12+
#include <linux/of_address.h>
13+
14+
#include "clk-exynos-arm64.h"
15+
16+
/* Gate register bits */
17+
#define GATE_MANUAL BIT(20)
18+
#define GATE_ENABLE_HWACG BIT(28)
19+
20+
/* Gate register offsets range */
21+
#define GATE_OFF_START 0x2000
22+
#define GATE_OFF_END 0x2fff
23+
24+
/**
25+
* exynos_arm64_init_clocks - Set clocks initial configuration
26+
* @np: CMU device tree node with "reg" property (CMU addr)
27+
* @reg_offs: Register offsets array for clocks to init
28+
* @reg_offs_len: Number of register offsets in reg_offs array
29+
*
30+
* Set manual control mode for all gate clocks.
31+
*/
32+
static void __init exynos_arm64_init_clocks(struct device_node *np,
33+
const unsigned long *reg_offs, size_t reg_offs_len)
34+
{
35+
void __iomem *reg_base;
36+
size_t i;
37+
38+
reg_base = of_iomap(np, 0);
39+
if (!reg_base)
40+
panic("%s: failed to map registers\n", __func__);
41+
42+
for (i = 0; i < reg_offs_len; ++i) {
43+
void __iomem *reg = reg_base + reg_offs[i];
44+
u32 val;
45+
46+
/* Modify only gate clock registers */
47+
if (reg_offs[i] < GATE_OFF_START || reg_offs[i] > GATE_OFF_END)
48+
continue;
49+
50+
val = readl(reg);
51+
val |= GATE_MANUAL;
52+
val &= ~GATE_ENABLE_HWACG;
53+
writel(val, reg);
54+
}
55+
56+
iounmap(reg_base);
57+
}
58+
59+
/**
60+
* exynos_arm64_register_cmu - Register specified Exynos CMU domain
61+
* @dev: Device object; may be NULL if this function is not being
62+
* called from platform driver probe function
63+
* @np: CMU device tree node
64+
* @cmu: CMU data
65+
*
66+
* Register specified CMU domain, which includes next steps:
67+
*
68+
* 1. Enable parent clock of @cmu CMU
69+
* 2. Set initial registers configuration for @cmu CMU clocks
70+
* 3. Register @cmu CMU clocks using Samsung clock framework API
71+
*/
72+
void __init exynos_arm64_register_cmu(struct device *dev,
73+
struct device_node *np, const struct samsung_cmu_info *cmu)
74+
{
75+
/* Keep CMU parent clock running (needed for CMU registers access) */
76+
if (cmu->clk_name) {
77+
struct clk *parent_clk;
78+
79+
if (dev)
80+
parent_clk = clk_get(dev, cmu->clk_name);
81+
else
82+
parent_clk = of_clk_get_by_name(np, cmu->clk_name);
83+
84+
if (IS_ERR(parent_clk)) {
85+
pr_err("%s: could not find bus clock %s; err = %ld\n",
86+
__func__, cmu->clk_name, PTR_ERR(parent_clk));
87+
} else {
88+
clk_prepare_enable(parent_clk);
89+
}
90+
}
91+
92+
exynos_arm64_init_clocks(np, cmu->clk_regs, cmu->nr_clk_regs);
93+
samsung_cmu_register_one(np, cmu);
94+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* Copyright (C) 2021 Linaro Ltd.
4+
* Copyright (C) 2021 Dávid Virág <virag.david003@gmail.com>
5+
* Author: Sam Protsenko <semen.protsenko@linaro.org>
6+
* Author: Dávid Virág <virag.david003@gmail.com>
7+
*
8+
* This file contains shared functions used by some arm64 Exynos SoCs,
9+
* such as Exynos7885 or Exynos850 to register and init CMUs.
10+
*/
11+
12+
#ifndef __CLK_EXYNOS_ARM64_H
13+
#define __CLK_EXYNOS_ARM64_H
14+
15+
#include "clk.h"
16+
17+
void exynos_arm64_register_cmu(struct device *dev,
18+
struct device_node *np, const struct samsung_cmu_info *cmu);
19+
20+
#endif /* __CLK_EXYNOS_ARM64_H */

0 commit comments

Comments
 (0)