Skip to content

Commit a66112e

Browse files
lpawelczgsomlo
authored andcommitted
LiteX: driver for MMCM
Original authors: Pawel Czarnecki <[email protected]>, Mateusz Holenko <[email protected]> DT bindings and documentation: Geert Uytterhoeven <[email protected]> Signed-off-by: Pawel Czarnecki <[email protected]> Signed-off-by: Mateusz Holenko <[email protected]> Signed-off-by: Geert Uytterhoeven <[email protected]> FIXME1: not updated or tested for 32-bit CSR data width, 64-bit CPU (gls) FIXME2: if possible, replace calls to '_litex_[get|set]_reg()' with the appropriate 'litex_[read|write][8|16|32|64]()'. If the size of a LiteX CSR access can't be determined at compile time, we should make available a set of public 'litex_[get|set]_reg()' methods that add 'BUG_ON(reg_size > sizeof(u64) || reg_size < 1)' on top of the call to '_litex_[get|set]_reg()'.
1 parent 7e39fce commit a66112e

File tree

5 files changed

+2149
-0
lines changed

5 files changed

+2149
-0
lines changed
Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/clock/litex,clock.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: LiteX clock control driver
8+
9+
description: |
10+
Common clock driver with MMCM unit for dynamic reconfiguration
11+
of up to 7 clock outputs with ability to change frequency, duty
12+
cycle and phase offset
13+
14+
maintainers:
15+
- Karol Gugala <[email protected]>
16+
- Mateusz Holenko <[email protected]>
17+
18+
properties:
19+
compatible:
20+
const: litex,clock
21+
22+
reg:
23+
description: Base address and lengths of the register space
24+
25+
"#clock-cells":
26+
description:
27+
Number of cells in a clock specifier;
28+
Typically 0 for nodes with a single clock output
29+
and 1 for nodes with multiple clock outputs.
30+
const: 1
31+
32+
"#address-cells":
33+
description:
34+
Number of cells that are needed to form the base address
35+
part in the reg property.
36+
const: 1
37+
38+
"#size-cells":
39+
description:
40+
Used to state how many cells are in each field of a reg property
41+
const: 0
42+
43+
clock-output-names:
44+
description:
45+
List of strings of clock output signal names indexed
46+
by the first cell in the clock specifier.
47+
minItems: 1
48+
maxItems: 7
49+
items:
50+
- const: CLKOUT0
51+
- const: CLKOUT1
52+
- const: CLKOUT2
53+
- const: CLKOUT3
54+
- const: CLKOUT4
55+
- const: CLKOUT5
56+
- const: CLKOUT6
57+
58+
litex,nclkout:
59+
description: Number of desired clock outputs
60+
$ref: /schemas/types.yaml#/definitions/uint32
61+
minimum: 1
62+
maximum: 7
63+
64+
litex,lock-timeout:
65+
description: Number of ms to wait for MMCM to assert LOCK signal
66+
$ref: /schemas/types.yaml#/definitions/uint32
67+
minimum: 1
68+
69+
litex,drdy-timeout:
70+
description: Number of ms to wait for MMCM to assert DRDY signal
71+
$ref: /schemas/types.yaml#/definitions/uint32
72+
minimum: 1
73+
74+
litex,sys-clock-freq:
75+
description: System clock frequency
76+
$ref: /schemas/types.yaml#/definitions/uint32
77+
78+
patternProperties:
79+
"^CLKOUT[0-6]$":
80+
description:
81+
Child node representing configurable clock outputs of MMCM unit
82+
type: object
83+
84+
properties:
85+
compatible:
86+
const: litex,clock
87+
88+
reg:
89+
description: clock output ID, zero-based numbering
90+
91+
litex,clock-frequency:
92+
description: default frequency in Hz for clock output
93+
$ref: /schemas/types.yaml#/definitions/uint32
94+
minimum: 1587000
95+
maximum: 100000000
96+
97+
litex,clock-phase:
98+
description: default phase offset given in degrees
99+
$ref: /schemas/types.yaml#/definitions/uint32
100+
minimum: 0
101+
maximum: 359
102+
103+
litex,clock-duty-num:
104+
description: default duty cycle numerator value
105+
$ref: /schemas/types.yaml#/definitions/uint32
106+
minimum: 1
107+
maximum: 100
108+
109+
litex,clock-duty-den:
110+
description: default duty cycle denominator value
111+
$ref: /schemas/types.yaml#/definitions/uint32
112+
minimum: 1
113+
maximum: 100
114+
115+
required:
116+
- compatible
117+
- "#clock-cells"
118+
- clock-output-names
119+
- reg
120+
- litex,clock-frequency
121+
- litex,clock-phase
122+
- litex,clock-duty-num
123+
- litex,clock-duty-den
124+
125+
required:
126+
- compatible
127+
- reg
128+
- "#clock-cells"
129+
- "#address-cells"
130+
- "#size-cells"
131+
- clock-output-names
132+
- litex,nclkout
133+
- CLKOUTx
134+
135+
additionalProperties: false
136+
137+
examples:
138+
- |
139+
clk0: clock-controller@f0003000 {
140+
compatible = "litex,clk";
141+
reg = <0x0 0xf0003000>, <0x0 0x100>;
142+
#clock-cells = <1>;
143+
#address-cells = <1>;
144+
#size-cells = <0>;
145+
clock-output-names = "CLKOUT0",
146+
"CLKOUT1",
147+
"CLKOUT2",
148+
"CLKOUT3",
149+
"CLKOUT4",
150+
"CLKOUT5",
151+
"CLKOUT6";
152+
litex,nclkout = <7>;
153+
154+
CLKOUT0: CLKOUT0@0 {
155+
compatible = "litex,clk";
156+
#clock-cells = <0>;
157+
clock-output-names = "CLKOUT0";
158+
reg = <0>;
159+
litex,clock-frequency = <50000000>;
160+
litex,clock-phase = <0>;
161+
litex,clock-duty = <50>;
162+
};
163+
164+
CLKOUT1: CLKOUT1@1 {
165+
compatible = "litex,clk";
166+
#clock-cells = <0>;
167+
clock-output-names = "CLKOUT1";
168+
reg = <1>;
169+
litex,clock-frequency = <50000000>;
170+
litex,clock-phase = <90>;
171+
litex,clock-duty = <50>;
172+
};
173+
174+
CLKOUT2: CLKOUT2@2 {
175+
compatible = "litex,clk";
176+
#clock-cells = <0>;
177+
clock-output-names = "CLKOUT2";
178+
reg = <2>;
179+
litex,clock-frequency = <25000000>;
180+
litex,clock-phase = <0>;
181+
litex,clock-duty = <25>;
182+
};
183+
184+
CLKOUT3: CLKOUT3@3 {
185+
compatible = "litex,clk";
186+
#clock-cells = <0>;
187+
clock-output-names = "CLKOUT3";
188+
reg = <3>;
189+
litex,clock-frequency = <12500000>;
190+
litex,clock-phase = <0>;
191+
litex,clock-duty = <75>;
192+
};
193+
194+
CLKOUT4: CLKOUT4@4 {
195+
compatible = "litex,clk";
196+
#clock-cells = <0>;
197+
clock-output-names = "CLKOUT4";
198+
reg = <4>;
199+
litex,clock-frequency = <6250000>;
200+
litex,clock-phase = <0>;
201+
litex,clock-duty = <50>;
202+
};
203+
204+
CLKOUT5: CLKOUT5@5 {
205+
compatible = "litex,clk";
206+
#clock-cells = <0>;
207+
clock-output-names = "CLKOUT5";
208+
reg = <5>;
209+
litex,clock-frequency = <3125000>;
210+
litex,clock-phase = <0>;
211+
litex,clock-duty = <50>;
212+
};
213+
214+
CLKOUT6: CLKOUT6@6 {
215+
compatible = "litex,clk";
216+
#clock-cells = <0>;
217+
clock-output-names = "CLKOUT6";
218+
reg = <6>;
219+
litex,clock-frequency = <1562500>;
220+
litex,clock-phase = <0>;
221+
litex,clock-duty = <5>;
222+
};
223+
};
224+
...

drivers/clk/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,12 @@ config COMMON_CLK_SP7021
467467
Not all features of the PLL are currently supported
468468
by the driver.
469469

470+
config COMMON_CLK_LITEX
471+
tristate "LiteX Clock control support"
472+
depends on COMMON_CLK && OF && LITEX_SOC_CONTROLLER
473+
help
474+
Clock control support for LiteX SoC builder, utilising MMCM unit and DRP registers
475+
470476
source "drivers/clk/actions/Kconfig"
471477
source "drivers/clk/analogbits/Kconfig"
472478
source "drivers/clk/baikal-t1/Kconfig"

drivers/clk/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ obj-$(CONFIG_CLK_HSDK) += clk-hsdk-pll.o
4242
obj-$(CONFIG_COMMON_CLK_K210) += clk-k210.o
4343
obj-$(CONFIG_LMK04832) += clk-lmk04832.o
4444
obj-$(CONFIG_COMMON_CLK_LAN966X) += clk-lan966x.o
45+
obj-$(CONFIG_COMMON_CLK_LITEX) += clk-litex.o
4546
obj-$(CONFIG_COMMON_CLK_LOCHNAGAR) += clk-lochnagar.o
4647
obj-$(CONFIG_MACH_LOONGSON32) += clk-loongson1.o
4748
obj-$(CONFIG_COMMON_CLK_LOONGSON2) += clk-loongson2.o

0 commit comments

Comments
 (0)