1ce1d86dcS周琰杰 (Zhou Yanjie) // SPDX-License-Identifier: GPL-2.0
2ce1d86dcS周琰杰 (Zhou Yanjie) /*
3ce1d86dcS周琰杰 (Zhou Yanjie) * X1830 SoC CGU driver
4ce1d86dcS周琰杰 (Zhou Yanjie) * Copyright (c) 2019 周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com>
5ce1d86dcS周琰杰 (Zhou Yanjie) */
6ce1d86dcS周琰杰 (Zhou Yanjie)
7ce1d86dcS周琰杰 (Zhou Yanjie) #include <linux/clk-provider.h>
8ce1d86dcS周琰杰 (Zhou Yanjie) #include <linux/delay.h>
9ce1d86dcS周琰杰 (Zhou Yanjie) #include <linux/io.h>
10ce1d86dcS周琰杰 (Zhou Yanjie) #include <linux/of.h>
11ce1d86dcS周琰杰 (Zhou Yanjie)
12c4a11bf4SPaul Cercueil #include <dt-bindings/clock/ingenic,x1830-cgu.h>
13ce1d86dcS周琰杰 (Zhou Yanjie)
14ce1d86dcS周琰杰 (Zhou Yanjie) #include "cgu.h"
15ce1d86dcS周琰杰 (Zhou Yanjie) #include "pm.h"
16ce1d86dcS周琰杰 (Zhou Yanjie)
17ce1d86dcS周琰杰 (Zhou Yanjie) /* CGU register offsets */
18ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_CPCCR 0x00
19ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_CPPCR 0x0c
20ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_APLL 0x10
21ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_MPLL 0x14
22ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_CLKGR0 0x20
23ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_OPCR 0x24
24ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_CLKGR1 0x28
25ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_DDRCDR 0x2c
26ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_USBPCR 0x3c
27ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_USBRDT 0x40
28ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_USBVBFIL 0x44
29ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_USBPCR1 0x48
30ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_MACCDR 0x54
31ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_EPLL 0x58
32ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_I2SCDR 0x60
33ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_LPCDR 0x64
34ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_MSC0CDR 0x68
35ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_I2SCDR1 0x70
36ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_SSICDR 0x74
37ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_CIMCDR 0x7c
38ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_MSC1CDR 0xa4
39ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_CMP_INTR 0xb0
40ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_CMP_INTRE 0xb4
41ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_DRCG 0xd0
42ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_CPCSR 0xd4
43ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_VPLL 0xe0
44ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_MACPHYC 0xe8
45ce1d86dcS周琰杰 (Zhou Yanjie)
46ce1d86dcS周琰杰 (Zhou Yanjie) /* bits within the OPCR register */
47ce1d86dcS周琰杰 (Zhou Yanjie) #define OPCR_GATE_USBPHYCLK BIT(23)
48ce1d86dcS周琰杰 (Zhou Yanjie) #define OPCR_SPENDN0 BIT(7)
49ce1d86dcS周琰杰 (Zhou Yanjie) #define OPCR_SPENDN1 BIT(6)
50ce1d86dcS周琰杰 (Zhou Yanjie)
51ce1d86dcS周琰杰 (Zhou Yanjie) /* bits within the USBPCR register */
52ce1d86dcS周琰杰 (Zhou Yanjie) #define USBPCR_SIDDQ BIT(21)
53ce1d86dcS周琰杰 (Zhou Yanjie) #define USBPCR_OTG_DISABLE BIT(20)
54ce1d86dcS周琰杰 (Zhou Yanjie)
55ce1d86dcS周琰杰 (Zhou Yanjie) static struct ingenic_cgu *cgu;
56ce1d86dcS周琰杰 (Zhou Yanjie)
x1830_usb_phy_enable(struct clk_hw * hw)57ce1d86dcS周琰杰 (Zhou Yanjie) static int x1830_usb_phy_enable(struct clk_hw *hw)
58ce1d86dcS周琰杰 (Zhou Yanjie) {
59ce1d86dcS周琰杰 (Zhou Yanjie) void __iomem *reg_opcr = cgu->base + CGU_REG_OPCR;
60ce1d86dcS周琰杰 (Zhou Yanjie) void __iomem *reg_usbpcr = cgu->base + CGU_REG_USBPCR;
61ce1d86dcS周琰杰 (Zhou Yanjie)
62ce1d86dcS周琰杰 (Zhou Yanjie) writel((readl(reg_opcr) | OPCR_SPENDN0) & ~OPCR_GATE_USBPHYCLK, reg_opcr);
63ce1d86dcS周琰杰 (Zhou Yanjie) writel(readl(reg_usbpcr) & ~USBPCR_OTG_DISABLE & ~USBPCR_SIDDQ, reg_usbpcr);
64ce1d86dcS周琰杰 (Zhou Yanjie) return 0;
65ce1d86dcS周琰杰 (Zhou Yanjie) }
66ce1d86dcS周琰杰 (Zhou Yanjie)
x1830_usb_phy_disable(struct clk_hw * hw)67ce1d86dcS周琰杰 (Zhou Yanjie) static void x1830_usb_phy_disable(struct clk_hw *hw)
68ce1d86dcS周琰杰 (Zhou Yanjie) {
69ce1d86dcS周琰杰 (Zhou Yanjie) void __iomem *reg_opcr = cgu->base + CGU_REG_OPCR;
70ce1d86dcS周琰杰 (Zhou Yanjie) void __iomem *reg_usbpcr = cgu->base + CGU_REG_USBPCR;
71ce1d86dcS周琰杰 (Zhou Yanjie)
72ce1d86dcS周琰杰 (Zhou Yanjie) writel((readl(reg_opcr) & ~OPCR_SPENDN0) | OPCR_GATE_USBPHYCLK, reg_opcr);
73ce1d86dcS周琰杰 (Zhou Yanjie) writel(readl(reg_usbpcr) | USBPCR_OTG_DISABLE | USBPCR_SIDDQ, reg_usbpcr);
74ce1d86dcS周琰杰 (Zhou Yanjie) }
75ce1d86dcS周琰杰 (Zhou Yanjie)
x1830_usb_phy_is_enabled(struct clk_hw * hw)76ce1d86dcS周琰杰 (Zhou Yanjie) static int x1830_usb_phy_is_enabled(struct clk_hw *hw)
77ce1d86dcS周琰杰 (Zhou Yanjie) {
78ce1d86dcS周琰杰 (Zhou Yanjie) void __iomem *reg_opcr = cgu->base + CGU_REG_OPCR;
79ce1d86dcS周琰杰 (Zhou Yanjie) void __iomem *reg_usbpcr = cgu->base + CGU_REG_USBPCR;
80ce1d86dcS周琰杰 (Zhou Yanjie)
81ce1d86dcS周琰杰 (Zhou Yanjie) return (readl(reg_opcr) & OPCR_SPENDN0) &&
82ce1d86dcS周琰杰 (Zhou Yanjie) !(readl(reg_usbpcr) & USBPCR_SIDDQ) &&
83ce1d86dcS周琰杰 (Zhou Yanjie) !(readl(reg_usbpcr) & USBPCR_OTG_DISABLE);
84ce1d86dcS周琰杰 (Zhou Yanjie) }
85ce1d86dcS周琰杰 (Zhou Yanjie)
86ce1d86dcS周琰杰 (Zhou Yanjie) static const struct clk_ops x1830_otg_phy_ops = {
87ce1d86dcS周琰杰 (Zhou Yanjie) .enable = x1830_usb_phy_enable,
88ce1d86dcS周琰杰 (Zhou Yanjie) .disable = x1830_usb_phy_disable,
89ce1d86dcS周琰杰 (Zhou Yanjie) .is_enabled = x1830_usb_phy_is_enabled,
90ce1d86dcS周琰杰 (Zhou Yanjie) };
91ce1d86dcS周琰杰 (Zhou Yanjie)
92ce1d86dcS周琰杰 (Zhou Yanjie) static const s8 pll_od_encoding[64] = {
93ce1d86dcS周琰杰 (Zhou Yanjie) 0x0, 0x1, -1, 0x2, -1, -1, -1, 0x3,
94ce1d86dcS周琰杰 (Zhou Yanjie) -1, -1, -1, -1, -1, -1, -1, 0x4,
95ce1d86dcS周琰杰 (Zhou Yanjie) -1, -1, -1, -1, -1, -1, -1, -1,
96ce1d86dcS周琰杰 (Zhou Yanjie) -1, -1, -1, -1, -1, -1, -1, 0x5,
97ce1d86dcS周琰杰 (Zhou Yanjie) -1, -1, -1, -1, -1, -1, -1, -1,
98ce1d86dcS周琰杰 (Zhou Yanjie) -1, -1, -1, -1, -1, -1, -1, -1,
99ce1d86dcS周琰杰 (Zhou Yanjie) -1, -1, -1, -1, -1, -1, -1, -1,
100ce1d86dcS周琰杰 (Zhou Yanjie) -1, -1, -1, -1, -1, -1, -1, 0x6,
101ce1d86dcS周琰杰 (Zhou Yanjie) };
102ce1d86dcS周琰杰 (Zhou Yanjie)
103ce1d86dcS周琰杰 (Zhou Yanjie) static const struct ingenic_cgu_clk_info x1830_cgu_clocks[] = {
104ce1d86dcS周琰杰 (Zhou Yanjie)
105ce1d86dcS周琰杰 (Zhou Yanjie) /* External clocks */
106ce1d86dcS周琰杰 (Zhou Yanjie)
107ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_EXCLK] = { "ext", CGU_CLK_EXT },
108ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_RTCLK] = { "rtc", CGU_CLK_EXT },
109ce1d86dcS周琰杰 (Zhou Yanjie)
110ce1d86dcS周琰杰 (Zhou Yanjie) /* PLLs */
111ce1d86dcS周琰杰 (Zhou Yanjie)
112ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_APLL] = {
113ce1d86dcS周琰杰 (Zhou Yanjie) "apll", CGU_CLK_PLL,
114ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, -1, -1, -1 },
115ce1d86dcS周琰杰 (Zhou Yanjie) .pll = {
116ce1d86dcS周琰杰 (Zhou Yanjie) .reg = CGU_REG_APLL,
117ce1d86dcS周琰杰 (Zhou Yanjie) .rate_multiplier = 2,
118ce1d86dcS周琰杰 (Zhou Yanjie) .m_shift = 20,
119ce1d86dcS周琰杰 (Zhou Yanjie) .m_bits = 9,
120ce1d86dcS周琰杰 (Zhou Yanjie) .m_offset = 1,
121ce1d86dcS周琰杰 (Zhou Yanjie) .n_shift = 14,
122ce1d86dcS周琰杰 (Zhou Yanjie) .n_bits = 6,
123ce1d86dcS周琰杰 (Zhou Yanjie) .n_offset = 1,
124ce1d86dcS周琰杰 (Zhou Yanjie) .od_shift = 11,
125ce1d86dcS周琰杰 (Zhou Yanjie) .od_bits = 3,
126ce1d86dcS周琰杰 (Zhou Yanjie) .od_max = 64,
127ce1d86dcS周琰杰 (Zhou Yanjie) .od_encoding = pll_od_encoding,
128ce1d86dcS周琰杰 (Zhou Yanjie) .bypass_reg = CGU_REG_CPPCR,
129ce1d86dcS周琰杰 (Zhou Yanjie) .bypass_bit = 30,
130ce1d86dcS周琰杰 (Zhou Yanjie) .enable_bit = 0,
131ce1d86dcS周琰杰 (Zhou Yanjie) .stable_bit = 3,
132ce1d86dcS周琰杰 (Zhou Yanjie) },
133ce1d86dcS周琰杰 (Zhou Yanjie) },
134ce1d86dcS周琰杰 (Zhou Yanjie)
135ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_MPLL] = {
136ce1d86dcS周琰杰 (Zhou Yanjie) "mpll", CGU_CLK_PLL,
137ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, -1, -1, -1 },
138ce1d86dcS周琰杰 (Zhou Yanjie) .pll = {
139ce1d86dcS周琰杰 (Zhou Yanjie) .reg = CGU_REG_MPLL,
140ce1d86dcS周琰杰 (Zhou Yanjie) .rate_multiplier = 2,
141ce1d86dcS周琰杰 (Zhou Yanjie) .m_shift = 20,
142ce1d86dcS周琰杰 (Zhou Yanjie) .m_bits = 9,
143ce1d86dcS周琰杰 (Zhou Yanjie) .m_offset = 1,
144ce1d86dcS周琰杰 (Zhou Yanjie) .n_shift = 14,
145ce1d86dcS周琰杰 (Zhou Yanjie) .n_bits = 6,
146ce1d86dcS周琰杰 (Zhou Yanjie) .n_offset = 1,
147ce1d86dcS周琰杰 (Zhou Yanjie) .od_shift = 11,
148ce1d86dcS周琰杰 (Zhou Yanjie) .od_bits = 3,
149ce1d86dcS周琰杰 (Zhou Yanjie) .od_max = 64,
150ce1d86dcS周琰杰 (Zhou Yanjie) .od_encoding = pll_od_encoding,
151ce1d86dcS周琰杰 (Zhou Yanjie) .bypass_reg = CGU_REG_CPPCR,
152ce1d86dcS周琰杰 (Zhou Yanjie) .bypass_bit = 28,
153ce1d86dcS周琰杰 (Zhou Yanjie) .enable_bit = 0,
154ce1d86dcS周琰杰 (Zhou Yanjie) .stable_bit = 3,
155ce1d86dcS周琰杰 (Zhou Yanjie) },
156ce1d86dcS周琰杰 (Zhou Yanjie) },
157ce1d86dcS周琰杰 (Zhou Yanjie)
158ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_EPLL] = {
159ce1d86dcS周琰杰 (Zhou Yanjie) "epll", CGU_CLK_PLL,
160ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, -1, -1, -1 },
161ce1d86dcS周琰杰 (Zhou Yanjie) .pll = {
162ce1d86dcS周琰杰 (Zhou Yanjie) .reg = CGU_REG_EPLL,
163ce1d86dcS周琰杰 (Zhou Yanjie) .rate_multiplier = 2,
164ce1d86dcS周琰杰 (Zhou Yanjie) .m_shift = 20,
165ce1d86dcS周琰杰 (Zhou Yanjie) .m_bits = 9,
166ce1d86dcS周琰杰 (Zhou Yanjie) .m_offset = 1,
167ce1d86dcS周琰杰 (Zhou Yanjie) .n_shift = 14,
168ce1d86dcS周琰杰 (Zhou Yanjie) .n_bits = 6,
169ce1d86dcS周琰杰 (Zhou Yanjie) .n_offset = 1,
170ce1d86dcS周琰杰 (Zhou Yanjie) .od_shift = 11,
171ce1d86dcS周琰杰 (Zhou Yanjie) .od_bits = 3,
172ce1d86dcS周琰杰 (Zhou Yanjie) .od_max = 64,
173ce1d86dcS周琰杰 (Zhou Yanjie) .od_encoding = pll_od_encoding,
174ce1d86dcS周琰杰 (Zhou Yanjie) .bypass_reg = CGU_REG_CPPCR,
175ce1d86dcS周琰杰 (Zhou Yanjie) .bypass_bit = 24,
176ce1d86dcS周琰杰 (Zhou Yanjie) .enable_bit = 0,
177ce1d86dcS周琰杰 (Zhou Yanjie) .stable_bit = 3,
178ce1d86dcS周琰杰 (Zhou Yanjie) },
179ce1d86dcS周琰杰 (Zhou Yanjie) },
180ce1d86dcS周琰杰 (Zhou Yanjie)
181ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_VPLL] = {
182ce1d86dcS周琰杰 (Zhou Yanjie) "vpll", CGU_CLK_PLL,
183ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, -1, -1, -1 },
184ce1d86dcS周琰杰 (Zhou Yanjie) .pll = {
185ce1d86dcS周琰杰 (Zhou Yanjie) .reg = CGU_REG_VPLL,
186ce1d86dcS周琰杰 (Zhou Yanjie) .rate_multiplier = 2,
187ce1d86dcS周琰杰 (Zhou Yanjie) .m_shift = 20,
188ce1d86dcS周琰杰 (Zhou Yanjie) .m_bits = 9,
189ce1d86dcS周琰杰 (Zhou Yanjie) .m_offset = 1,
190ce1d86dcS周琰杰 (Zhou Yanjie) .n_shift = 14,
191ce1d86dcS周琰杰 (Zhou Yanjie) .n_bits = 6,
192ce1d86dcS周琰杰 (Zhou Yanjie) .n_offset = 1,
193ce1d86dcS周琰杰 (Zhou Yanjie) .od_shift = 11,
194ce1d86dcS周琰杰 (Zhou Yanjie) .od_bits = 3,
195ce1d86dcS周琰杰 (Zhou Yanjie) .od_max = 64,
196ce1d86dcS周琰杰 (Zhou Yanjie) .od_encoding = pll_od_encoding,
197ce1d86dcS周琰杰 (Zhou Yanjie) .bypass_reg = CGU_REG_CPPCR,
198ce1d86dcS周琰杰 (Zhou Yanjie) .bypass_bit = 26,
199ce1d86dcS周琰杰 (Zhou Yanjie) .enable_bit = 0,
200ce1d86dcS周琰杰 (Zhou Yanjie) .stable_bit = 3,
201ce1d86dcS周琰杰 (Zhou Yanjie) },
202ce1d86dcS周琰杰 (Zhou Yanjie) },
203ce1d86dcS周琰杰 (Zhou Yanjie)
204ce1d86dcS周琰杰 (Zhou Yanjie) /* Custom (SoC-specific) OTG PHY */
205ce1d86dcS周琰杰 (Zhou Yanjie)
206ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_OTGPHY] = {
207ce1d86dcS周琰杰 (Zhou Yanjie) "otg_phy", CGU_CLK_CUSTOM,
208ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, -1, -1, -1 },
209ce1d86dcS周琰杰 (Zhou Yanjie) .custom = { &x1830_otg_phy_ops },
210ce1d86dcS周琰杰 (Zhou Yanjie) },
211ce1d86dcS周琰杰 (Zhou Yanjie)
212ce1d86dcS周琰杰 (Zhou Yanjie) /* Muxes & dividers */
213ce1d86dcS周琰杰 (Zhou Yanjie)
214ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_SCLKA] = {
215ce1d86dcS周琰杰 (Zhou Yanjie) "sclk_a", CGU_CLK_MUX,
216ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { -1, X1830_CLK_EXCLK, X1830_CLK_APLL, -1 },
217ce1d86dcS周琰杰 (Zhou Yanjie) .mux = { CGU_REG_CPCCR, 30, 2 },
218ce1d86dcS周琰杰 (Zhou Yanjie) },
219ce1d86dcS周琰杰 (Zhou Yanjie)
220ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_CPUMUX] = {
221ce1d86dcS周琰杰 (Zhou Yanjie) "cpu_mux", CGU_CLK_MUX,
222ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { -1, X1830_CLK_SCLKA, X1830_CLK_MPLL, -1 },
223ce1d86dcS周琰杰 (Zhou Yanjie) .mux = { CGU_REG_CPCCR, 28, 2 },
224ce1d86dcS周琰杰 (Zhou Yanjie) },
225ce1d86dcS周琰杰 (Zhou Yanjie)
226ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_CPU] = {
227ce1d86dcS周琰杰 (Zhou Yanjie) "cpu", CGU_CLK_DIV | CGU_CLK_GATE,
228*ca54d06fSAidan MacDonald .flags = CLK_IS_CRITICAL,
229ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_CPUMUX, -1, -1, -1 },
230ce1d86dcS周琰杰 (Zhou Yanjie) .div = { CGU_REG_CPCCR, 0, 1, 4, 22, -1, -1 },
231ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR1, 15 },
232ce1d86dcS周琰杰 (Zhou Yanjie) },
233ce1d86dcS周琰杰 (Zhou Yanjie)
234ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_L2CACHE] = {
235ce1d86dcS周琰杰 (Zhou Yanjie) "l2cache", CGU_CLK_DIV,
236*ca54d06fSAidan MacDonald /*
237*ca54d06fSAidan MacDonald * The L2 cache clock is critical if caches are enabled and
238*ca54d06fSAidan MacDonald * disabling it or any parent clocks will hang the system.
239*ca54d06fSAidan MacDonald */
240*ca54d06fSAidan MacDonald .flags = CLK_IS_CRITICAL,
241ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_CPUMUX, -1, -1, -1 },
242ce1d86dcS周琰杰 (Zhou Yanjie) .div = { CGU_REG_CPCCR, 4, 1, 4, 22, -1, -1 },
243ce1d86dcS周琰杰 (Zhou Yanjie) },
244ce1d86dcS周琰杰 (Zhou Yanjie)
245ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_AHB0] = {
246ce1d86dcS周琰杰 (Zhou Yanjie) "ahb0", CGU_CLK_MUX | CGU_CLK_DIV,
247ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { -1, X1830_CLK_SCLKA, X1830_CLK_MPLL, -1 },
248ce1d86dcS周琰杰 (Zhou Yanjie) .mux = { CGU_REG_CPCCR, 26, 2 },
249ce1d86dcS周琰杰 (Zhou Yanjie) .div = { CGU_REG_CPCCR, 8, 1, 4, 21, -1, -1 },
250ce1d86dcS周琰杰 (Zhou Yanjie) },
251ce1d86dcS周琰杰 (Zhou Yanjie)
252ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_AHB2PMUX] = {
253ce1d86dcS周琰杰 (Zhou Yanjie) "ahb2_apb_mux", CGU_CLK_MUX,
254ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { -1, X1830_CLK_SCLKA, X1830_CLK_MPLL, -1 },
255ce1d86dcS周琰杰 (Zhou Yanjie) .mux = { CGU_REG_CPCCR, 24, 2 },
256ce1d86dcS周琰杰 (Zhou Yanjie) },
257ce1d86dcS周琰杰 (Zhou Yanjie)
258ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_AHB2] = {
259ce1d86dcS周琰杰 (Zhou Yanjie) "ahb2", CGU_CLK_DIV,
260ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_AHB2PMUX, -1, -1, -1 },
261ce1d86dcS周琰杰 (Zhou Yanjie) .div = { CGU_REG_CPCCR, 12, 1, 4, 20, -1, -1 },
262ce1d86dcS周琰杰 (Zhou Yanjie) },
263ce1d86dcS周琰杰 (Zhou Yanjie)
264ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_PCLK] = {
265ce1d86dcS周琰杰 (Zhou Yanjie) "pclk", CGU_CLK_DIV | CGU_CLK_GATE,
266ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_AHB2PMUX, -1, -1, -1 },
267ce1d86dcS周琰杰 (Zhou Yanjie) .div = { CGU_REG_CPCCR, 16, 1, 4, 20, -1, -1 },
268ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR1, 14 },
269ce1d86dcS周琰杰 (Zhou Yanjie) },
270ce1d86dcS周琰杰 (Zhou Yanjie)
271ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_DDR] = {
272ce1d86dcS周琰杰 (Zhou Yanjie) "ddr", CGU_CLK_MUX | CGU_CLK_DIV | CGU_CLK_GATE,
273*ca54d06fSAidan MacDonald /*
274*ca54d06fSAidan MacDonald * Disabling DDR clock or its parents will render DRAM
275*ca54d06fSAidan MacDonald * inaccessible; mark it critical.
276*ca54d06fSAidan MacDonald */
277*ca54d06fSAidan MacDonald .flags = CLK_IS_CRITICAL,
278ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { -1, X1830_CLK_SCLKA, X1830_CLK_MPLL, -1 },
279ce1d86dcS周琰杰 (Zhou Yanjie) .mux = { CGU_REG_DDRCDR, 30, 2 },
280ce1d86dcS周琰杰 (Zhou Yanjie) .div = { CGU_REG_DDRCDR, 0, 1, 4, 29, 28, 27 },
281ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 31 },
282ce1d86dcS周琰杰 (Zhou Yanjie) },
283ce1d86dcS周琰杰 (Zhou Yanjie)
284ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_MAC] = {
285ce1d86dcS周琰杰 (Zhou Yanjie) "mac", CGU_CLK_MUX | CGU_CLK_DIV | CGU_CLK_GATE,
286ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_SCLKA, X1830_CLK_MPLL,
287ce1d86dcS周琰杰 (Zhou Yanjie) X1830_CLK_VPLL, X1830_CLK_EPLL },
288ce1d86dcS周琰杰 (Zhou Yanjie) .mux = { CGU_REG_MACCDR, 30, 2 },
289ce1d86dcS周琰杰 (Zhou Yanjie) .div = { CGU_REG_MACCDR, 0, 1, 8, 29, 28, 27 },
290ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR1, 4 },
291ce1d86dcS周琰杰 (Zhou Yanjie) },
292ce1d86dcS周琰杰 (Zhou Yanjie)
293ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_LCD] = {
294ce1d86dcS周琰杰 (Zhou Yanjie) "lcd", CGU_CLK_MUX | CGU_CLK_DIV | CGU_CLK_GATE,
295ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_SCLKA, X1830_CLK_MPLL,
296ce1d86dcS周琰杰 (Zhou Yanjie) X1830_CLK_VPLL, X1830_CLK_EPLL },
297ce1d86dcS周琰杰 (Zhou Yanjie) .mux = { CGU_REG_LPCDR, 30, 2 },
298ce1d86dcS周琰杰 (Zhou Yanjie) .div = { CGU_REG_LPCDR, 0, 1, 8, 28, 27, 26 },
299ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR1, 9 },
300ce1d86dcS周琰杰 (Zhou Yanjie) },
301ce1d86dcS周琰杰 (Zhou Yanjie)
302ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_MSCMUX] = {
303ce1d86dcS周琰杰 (Zhou Yanjie) "msc_mux", CGU_CLK_MUX,
304ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_SCLKA, X1830_CLK_MPLL,
305ce1d86dcS周琰杰 (Zhou Yanjie) X1830_CLK_VPLL, X1830_CLK_EPLL },
306ce1d86dcS周琰杰 (Zhou Yanjie) .mux = { CGU_REG_MSC0CDR, 30, 2 },
307ce1d86dcS周琰杰 (Zhou Yanjie) },
308ce1d86dcS周琰杰 (Zhou Yanjie)
309ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_MSC0] = {
310ce1d86dcS周琰杰 (Zhou Yanjie) "msc0", CGU_CLK_DIV | CGU_CLK_GATE,
311ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_MSCMUX, -1, -1, -1 },
312ce1d86dcS周琰杰 (Zhou Yanjie) .div = { CGU_REG_MSC0CDR, 0, 2, 8, 29, 28, 27 },
313ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 4 },
314ce1d86dcS周琰杰 (Zhou Yanjie) },
315ce1d86dcS周琰杰 (Zhou Yanjie)
316ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_MSC1] = {
317ce1d86dcS周琰杰 (Zhou Yanjie) "msc1", CGU_CLK_DIV | CGU_CLK_GATE,
318ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_MSCMUX, -1, -1, -1 },
319ce1d86dcS周琰杰 (Zhou Yanjie) .div = { CGU_REG_MSC1CDR, 0, 2, 8, 29, 28, 27 },
320ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 5 },
321ce1d86dcS周琰杰 (Zhou Yanjie) },
322ce1d86dcS周琰杰 (Zhou Yanjie)
323ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_SSIPLL] = {
324ce1d86dcS周琰杰 (Zhou Yanjie) "ssi_pll", CGU_CLK_MUX | CGU_CLK_DIV,
325ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_SCLKA, X1830_CLK_MPLL,
326ce1d86dcS周琰杰 (Zhou Yanjie) X1830_CLK_VPLL, X1830_CLK_EPLL },
327ce1d86dcS周琰杰 (Zhou Yanjie) .mux = { CGU_REG_SSICDR, 30, 2 },
328ce1d86dcS周琰杰 (Zhou Yanjie) .div = { CGU_REG_SSICDR, 0, 1, 8, 28, 27, 26 },
329ce1d86dcS周琰杰 (Zhou Yanjie) },
330ce1d86dcS周琰杰 (Zhou Yanjie)
331ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_SSIPLL_DIV2] = {
332ce1d86dcS周琰杰 (Zhou Yanjie) "ssi_pll_div2", CGU_CLK_FIXDIV,
333ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_SSIPLL },
334ce1d86dcS周琰杰 (Zhou Yanjie) .fixdiv = { 2 },
335ce1d86dcS周琰杰 (Zhou Yanjie) },
336ce1d86dcS周琰杰 (Zhou Yanjie)
337ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_SSIMUX] = {
338ce1d86dcS周琰杰 (Zhou Yanjie) "ssi_mux", CGU_CLK_MUX,
339ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, X1830_CLK_SSIPLL_DIV2, -1, -1 },
340ce1d86dcS周琰杰 (Zhou Yanjie) .mux = { CGU_REG_SSICDR, 29, 1 },
341ce1d86dcS周琰杰 (Zhou Yanjie) },
342ce1d86dcS周琰杰 (Zhou Yanjie)
34382df5b73S周琰杰 (Zhou Yanjie) [X1830_CLK_EXCLK_DIV512] = {
34482df5b73S周琰杰 (Zhou Yanjie) "exclk_div512", CGU_CLK_FIXDIV,
34582df5b73S周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK },
34682df5b73S周琰杰 (Zhou Yanjie) .fixdiv = { 512 },
34782df5b73S周琰杰 (Zhou Yanjie) },
34882df5b73S周琰杰 (Zhou Yanjie)
34982df5b73S周琰杰 (Zhou Yanjie) [X1830_CLK_RTC] = {
35082df5b73S周琰杰 (Zhou Yanjie) "rtc_ercs", CGU_CLK_MUX | CGU_CLK_GATE,
35182df5b73S周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK_DIV512, X1830_CLK_RTCLK },
35282df5b73S周琰杰 (Zhou Yanjie) .mux = { CGU_REG_OPCR, 2, 1},
35382df5b73S周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 29 },
35482df5b73S周琰杰 (Zhou Yanjie) },
35582df5b73S周琰杰 (Zhou Yanjie)
356ce1d86dcS周琰杰 (Zhou Yanjie) /* Gate-only clocks */
357ce1d86dcS周琰杰 (Zhou Yanjie)
358ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_EMC] = {
359ce1d86dcS周琰杰 (Zhou Yanjie) "emc", CGU_CLK_GATE,
360ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_AHB2, -1, -1, -1 },
361ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 0 },
362ce1d86dcS周琰杰 (Zhou Yanjie) },
363ce1d86dcS周琰杰 (Zhou Yanjie)
364ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_EFUSE] = {
365ce1d86dcS周琰杰 (Zhou Yanjie) "efuse", CGU_CLK_GATE,
366ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_AHB2, -1, -1, -1 },
367ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 1 },
368ce1d86dcS周琰杰 (Zhou Yanjie) },
369ce1d86dcS周琰杰 (Zhou Yanjie)
370ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_OTG] = {
371ce1d86dcS周琰杰 (Zhou Yanjie) "otg", CGU_CLK_GATE,
372ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, -1, -1, -1 },
373ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 3 },
374ce1d86dcS周琰杰 (Zhou Yanjie) },
375ce1d86dcS周琰杰 (Zhou Yanjie)
376ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_SSI0] = {
377ce1d86dcS周琰杰 (Zhou Yanjie) "ssi0", CGU_CLK_GATE,
378ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_SSIMUX, -1, -1, -1 },
379ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 6 },
380ce1d86dcS周琰杰 (Zhou Yanjie) },
381ce1d86dcS周琰杰 (Zhou Yanjie)
382ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_SMB0] = {
383ce1d86dcS周琰杰 (Zhou Yanjie) "smb0", CGU_CLK_GATE,
384ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_PCLK, -1, -1, -1 },
385ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 7 },
386ce1d86dcS周琰杰 (Zhou Yanjie) },
387ce1d86dcS周琰杰 (Zhou Yanjie)
388ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_SMB1] = {
389ce1d86dcS周琰杰 (Zhou Yanjie) "smb1", CGU_CLK_GATE,
390ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_PCLK, -1, -1, -1 },
391ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 8 },
392ce1d86dcS周琰杰 (Zhou Yanjie) },
393ce1d86dcS周琰杰 (Zhou Yanjie)
394ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_SMB2] = {
395ce1d86dcS周琰杰 (Zhou Yanjie) "smb2", CGU_CLK_GATE,
396ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_PCLK, -1, -1, -1 },
397ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 9 },
398ce1d86dcS周琰杰 (Zhou Yanjie) },
399ce1d86dcS周琰杰 (Zhou Yanjie)
400ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_UART0] = {
401ce1d86dcS周琰杰 (Zhou Yanjie) "uart0", CGU_CLK_GATE,
402ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, -1, -1, -1 },
403ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 14 },
404ce1d86dcS周琰杰 (Zhou Yanjie) },
405ce1d86dcS周琰杰 (Zhou Yanjie)
406ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_UART1] = {
407ce1d86dcS周琰杰 (Zhou Yanjie) "uart1", CGU_CLK_GATE,
408ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, -1, -1, -1 },
409ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 15 },
410ce1d86dcS周琰杰 (Zhou Yanjie) },
411ce1d86dcS周琰杰 (Zhou Yanjie)
412ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_SSI1] = {
413ce1d86dcS周琰杰 (Zhou Yanjie) "ssi1", CGU_CLK_GATE,
414ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_SSIMUX, -1, -1, -1 },
415ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 19 },
416ce1d86dcS周琰杰 (Zhou Yanjie) },
417ce1d86dcS周琰杰 (Zhou Yanjie)
418ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_SFC] = {
419ce1d86dcS周琰杰 (Zhou Yanjie) "sfc", CGU_CLK_GATE,
420ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_SSIPLL, -1, -1, -1 },
421ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 20 },
422ce1d86dcS周琰杰 (Zhou Yanjie) },
423ce1d86dcS周琰杰 (Zhou Yanjie)
424ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_PDMA] = {
425ce1d86dcS周琰杰 (Zhou Yanjie) "pdma", CGU_CLK_GATE,
426ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, -1, -1, -1 },
427ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 21 },
428ce1d86dcS周琰杰 (Zhou Yanjie) },
429ce1d86dcS周琰杰 (Zhou Yanjie)
430ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_TCU] = {
431ce1d86dcS周琰杰 (Zhou Yanjie) "tcu", CGU_CLK_GATE,
432ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, -1, -1, -1 },
433ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 30 },
434ce1d86dcS周琰杰 (Zhou Yanjie) },
435ce1d86dcS周琰杰 (Zhou Yanjie)
436ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_DTRNG] = {
437ce1d86dcS周琰杰 (Zhou Yanjie) "dtrng", CGU_CLK_GATE,
438ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_PCLK, -1, -1, -1 },
439ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR1, 1 },
440ce1d86dcS周琰杰 (Zhou Yanjie) },
441ce1d86dcS周琰杰 (Zhou Yanjie)
442ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_OST] = {
443ce1d86dcS周琰杰 (Zhou Yanjie) "ost", CGU_CLK_GATE,
444ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, -1, -1, -1 },
445ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR1, 11 },
446ce1d86dcS周琰杰 (Zhou Yanjie) },
447ce1d86dcS周琰杰 (Zhou Yanjie) };
448ce1d86dcS周琰杰 (Zhou Yanjie)
x1830_cgu_init(struct device_node * np)449ce1d86dcS周琰杰 (Zhou Yanjie) static void __init x1830_cgu_init(struct device_node *np)
450ce1d86dcS周琰杰 (Zhou Yanjie) {
451ce1d86dcS周琰杰 (Zhou Yanjie) int retval;
452ce1d86dcS周琰杰 (Zhou Yanjie)
453ce1d86dcS周琰杰 (Zhou Yanjie) cgu = ingenic_cgu_new(x1830_cgu_clocks,
454ce1d86dcS周琰杰 (Zhou Yanjie) ARRAY_SIZE(x1830_cgu_clocks), np);
455ce1d86dcS周琰杰 (Zhou Yanjie) if (!cgu) {
456ce1d86dcS周琰杰 (Zhou Yanjie) pr_err("%s: failed to initialise CGU\n", __func__);
457ce1d86dcS周琰杰 (Zhou Yanjie) return;
458ce1d86dcS周琰杰 (Zhou Yanjie) }
459ce1d86dcS周琰杰 (Zhou Yanjie)
460ce1d86dcS周琰杰 (Zhou Yanjie) retval = ingenic_cgu_register_clocks(cgu);
461ce1d86dcS周琰杰 (Zhou Yanjie) if (retval) {
462ce1d86dcS周琰杰 (Zhou Yanjie) pr_err("%s: failed to register CGU Clocks\n", __func__);
463ce1d86dcS周琰杰 (Zhou Yanjie) return;
464ce1d86dcS周琰杰 (Zhou Yanjie) }
465ce1d86dcS周琰杰 (Zhou Yanjie)
466ce1d86dcS周琰杰 (Zhou Yanjie) ingenic_cgu_register_syscore_ops(cgu);
467ce1d86dcS周琰杰 (Zhou Yanjie) }
468ce1d86dcS周琰杰 (Zhou Yanjie) /*
469ce1d86dcS周琰杰 (Zhou Yanjie) * CGU has some children devices, this is useful for probing children devices
470ce1d86dcS周琰杰 (Zhou Yanjie) * in the case where the device node is compatible with "simple-mfd".
471ce1d86dcS周琰杰 (Zhou Yanjie) */
472ce1d86dcS周琰杰 (Zhou Yanjie) CLK_OF_DECLARE_DRIVER(x1830_cgu, "ingenic,x1830-cgu", x1830_cgu_init);
473