1aec5f36cSKonrad Dybcio // SPDX-License-Identifier: GPL-2.0-only
2aec5f36cSKonrad Dybcio /*
3aec5f36cSKonrad Dybcio * Copyright (c) 2021, The Linux Foundation. All rights reserved.
4aec5f36cSKonrad Dybcio * Copyright (c) 2022, Linaro Limited
5aec5f36cSKonrad Dybcio */
6aec5f36cSKonrad Dybcio
7aec5f36cSKonrad Dybcio #include <linux/clk-provider.h>
8aec5f36cSKonrad Dybcio #include <linux/module.h>
9aec5f36cSKonrad Dybcio #include <linux/platform_device.h>
10aec5f36cSKonrad Dybcio #include <linux/regmap.h>
11aec5f36cSKonrad Dybcio
12aec5f36cSKonrad Dybcio #include <dt-bindings/clock/qcom,sm6375-dispcc.h>
13aec5f36cSKonrad Dybcio
14aec5f36cSKonrad Dybcio #include "clk-alpha-pll.h"
15aec5f36cSKonrad Dybcio #include "clk-branch.h"
16aec5f36cSKonrad Dybcio #include "clk-rcg.h"
17aec5f36cSKonrad Dybcio #include "clk-regmap-divider.h"
18aec5f36cSKonrad Dybcio #include "common.h"
19aec5f36cSKonrad Dybcio #include "gdsc.h"
20aec5f36cSKonrad Dybcio #include "reset.h"
21aec5f36cSKonrad Dybcio
22aec5f36cSKonrad Dybcio enum {
23aec5f36cSKonrad Dybcio DT_BI_TCXO,
24aec5f36cSKonrad Dybcio DT_GCC_DISP_GPLL0_CLK,
25aec5f36cSKonrad Dybcio DT_DSI0_PHY_PLL_OUT_BYTECLK,
26aec5f36cSKonrad Dybcio DT_DSI0_PHY_PLL_OUT_DSICLK,
27aec5f36cSKonrad Dybcio };
28aec5f36cSKonrad Dybcio
29aec5f36cSKonrad Dybcio enum {
30aec5f36cSKonrad Dybcio P_BI_TCXO,
31aec5f36cSKonrad Dybcio P_DISP_CC_PLL0_OUT_EVEN,
32aec5f36cSKonrad Dybcio P_DISP_CC_PLL0_OUT_MAIN,
33aec5f36cSKonrad Dybcio P_DSI0_PHY_PLL_OUT_BYTECLK,
34aec5f36cSKonrad Dybcio P_DSI0_PHY_PLL_OUT_DSICLK,
35aec5f36cSKonrad Dybcio P_GCC_DISP_GPLL0_CLK,
36aec5f36cSKonrad Dybcio };
37aec5f36cSKonrad Dybcio
38fcd9354cSChristophe JAILLET static const struct pll_vco lucid_vco[] = {
39aec5f36cSKonrad Dybcio { 249600000, 2000000000, 0 },
40aec5f36cSKonrad Dybcio };
41aec5f36cSKonrad Dybcio
42aec5f36cSKonrad Dybcio /* 615MHz */
43aec5f36cSKonrad Dybcio static const struct alpha_pll_config disp_cc_pll0_config = {
44aec5f36cSKonrad Dybcio .l = 0x20,
45aec5f36cSKonrad Dybcio .alpha = 0x800,
46aec5f36cSKonrad Dybcio .config_ctl_val = 0x20485699,
47aec5f36cSKonrad Dybcio .config_ctl_hi_val = 0x00002261,
48aec5f36cSKonrad Dybcio .config_ctl_hi1_val = 0x329a299c,
49aec5f36cSKonrad Dybcio .user_ctl_val = 0x00000001,
50aec5f36cSKonrad Dybcio .user_ctl_hi_val = 0x00000805,
51aec5f36cSKonrad Dybcio .user_ctl_hi1_val = 0x00000000,
52aec5f36cSKonrad Dybcio };
53aec5f36cSKonrad Dybcio
54aec5f36cSKonrad Dybcio static struct clk_alpha_pll disp_cc_pll0 = {
55aec5f36cSKonrad Dybcio .offset = 0x0,
56aec5f36cSKonrad Dybcio .vco_table = lucid_vco,
57aec5f36cSKonrad Dybcio .num_vco = ARRAY_SIZE(lucid_vco),
58aec5f36cSKonrad Dybcio .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID],
59aec5f36cSKonrad Dybcio .clkr = {
60aec5f36cSKonrad Dybcio .hw.init = &(struct clk_init_data){
61aec5f36cSKonrad Dybcio .name = "disp_cc_pll0",
62aec5f36cSKonrad Dybcio .parent_data = &(const struct clk_parent_data){
63aec5f36cSKonrad Dybcio .index = DT_BI_TCXO,
64aec5f36cSKonrad Dybcio },
65aec5f36cSKonrad Dybcio .num_parents = 1,
66aec5f36cSKonrad Dybcio .ops = &clk_alpha_pll_lucid_ops,
67aec5f36cSKonrad Dybcio },
68aec5f36cSKonrad Dybcio },
69aec5f36cSKonrad Dybcio };
70aec5f36cSKonrad Dybcio
71aec5f36cSKonrad Dybcio static const struct parent_map disp_cc_parent_map_0[] = {
72aec5f36cSKonrad Dybcio { P_BI_TCXO, 0 },
73aec5f36cSKonrad Dybcio { P_DSI0_PHY_PLL_OUT_BYTECLK, 1 },
74aec5f36cSKonrad Dybcio };
75aec5f36cSKonrad Dybcio
76aec5f36cSKonrad Dybcio static const struct clk_parent_data disp_cc_parent_data_0[] = {
77aec5f36cSKonrad Dybcio { .index = DT_BI_TCXO },
78aec5f36cSKonrad Dybcio { .index = DT_DSI0_PHY_PLL_OUT_BYTECLK },
79aec5f36cSKonrad Dybcio };
80aec5f36cSKonrad Dybcio
81aec5f36cSKonrad Dybcio static const struct parent_map disp_cc_parent_map_1[] = {
82aec5f36cSKonrad Dybcio { P_BI_TCXO, 0 },
83aec5f36cSKonrad Dybcio { P_DISP_CC_PLL0_OUT_MAIN, 1 },
84aec5f36cSKonrad Dybcio { P_GCC_DISP_GPLL0_CLK, 4 },
85aec5f36cSKonrad Dybcio { P_DISP_CC_PLL0_OUT_EVEN, 5 },
86aec5f36cSKonrad Dybcio };
87aec5f36cSKonrad Dybcio
88aec5f36cSKonrad Dybcio static const struct clk_parent_data disp_cc_parent_data_1[] = {
89aec5f36cSKonrad Dybcio { .index = DT_BI_TCXO },
90aec5f36cSKonrad Dybcio { .hw = &disp_cc_pll0.clkr.hw },
91aec5f36cSKonrad Dybcio { .index = DT_GCC_DISP_GPLL0_CLK },
92aec5f36cSKonrad Dybcio { .hw = &disp_cc_pll0.clkr.hw },
93aec5f36cSKonrad Dybcio };
94aec5f36cSKonrad Dybcio
95aec5f36cSKonrad Dybcio static const struct parent_map disp_cc_parent_map_2[] = {
96aec5f36cSKonrad Dybcio { P_BI_TCXO, 0 },
97aec5f36cSKonrad Dybcio { P_GCC_DISP_GPLL0_CLK, 4 },
98aec5f36cSKonrad Dybcio };
99aec5f36cSKonrad Dybcio
100aec5f36cSKonrad Dybcio static const struct clk_parent_data disp_cc_parent_data_2[] = {
101aec5f36cSKonrad Dybcio { .index = DT_BI_TCXO },
102aec5f36cSKonrad Dybcio { .index = DT_GCC_DISP_GPLL0_CLK },
103aec5f36cSKonrad Dybcio };
104aec5f36cSKonrad Dybcio
105aec5f36cSKonrad Dybcio static const struct parent_map disp_cc_parent_map_3[] = {
106aec5f36cSKonrad Dybcio { P_BI_TCXO, 0 },
107aec5f36cSKonrad Dybcio { P_DSI0_PHY_PLL_OUT_DSICLK, 1 },
108aec5f36cSKonrad Dybcio };
109aec5f36cSKonrad Dybcio
110aec5f36cSKonrad Dybcio static const struct clk_parent_data disp_cc_parent_data_3[] = {
111aec5f36cSKonrad Dybcio { .index = DT_BI_TCXO },
112aec5f36cSKonrad Dybcio { .index = DT_DSI0_PHY_PLL_OUT_DSICLK },
113aec5f36cSKonrad Dybcio };
114aec5f36cSKonrad Dybcio
115aec5f36cSKonrad Dybcio static const struct parent_map disp_cc_parent_map_4[] = {
116aec5f36cSKonrad Dybcio { P_BI_TCXO, 0 },
117aec5f36cSKonrad Dybcio };
118aec5f36cSKonrad Dybcio
119aec5f36cSKonrad Dybcio static const struct clk_parent_data disp_cc_parent_data_4[] = {
120aec5f36cSKonrad Dybcio { .index = DT_BI_TCXO },
121aec5f36cSKonrad Dybcio };
122aec5f36cSKonrad Dybcio
123aec5f36cSKonrad Dybcio static const struct freq_tbl ftbl_disp_cc_mdss_ahb_clk_src[] = {
124aec5f36cSKonrad Dybcio F(19200000, P_BI_TCXO, 1, 0, 0),
125aec5f36cSKonrad Dybcio F(37500000, P_GCC_DISP_GPLL0_CLK, 8, 0, 0),
126aec5f36cSKonrad Dybcio F(75000000, P_GCC_DISP_GPLL0_CLK, 4, 0, 0),
127aec5f36cSKonrad Dybcio { }
128aec5f36cSKonrad Dybcio };
129aec5f36cSKonrad Dybcio
130aec5f36cSKonrad Dybcio static struct clk_rcg2 disp_cc_mdss_ahb_clk_src = {
131aec5f36cSKonrad Dybcio .cmd_rcgr = 0x115c,
132aec5f36cSKonrad Dybcio .mnd_width = 0,
133aec5f36cSKonrad Dybcio .hid_width = 5,
134aec5f36cSKonrad Dybcio .parent_map = disp_cc_parent_map_2,
135aec5f36cSKonrad Dybcio .freq_tbl = ftbl_disp_cc_mdss_ahb_clk_src,
136aec5f36cSKonrad Dybcio .clkr.hw.init = &(struct clk_init_data){
137aec5f36cSKonrad Dybcio .name = "disp_cc_mdss_ahb_clk_src",
138aec5f36cSKonrad Dybcio .parent_data = disp_cc_parent_data_2,
139aec5f36cSKonrad Dybcio .num_parents = ARRAY_SIZE(disp_cc_parent_data_2),
140aec5f36cSKonrad Dybcio .ops = &clk_rcg2_shared_ops,
141aec5f36cSKonrad Dybcio },
142aec5f36cSKonrad Dybcio };
143aec5f36cSKonrad Dybcio
144aec5f36cSKonrad Dybcio static struct clk_rcg2 disp_cc_mdss_byte0_clk_src = {
145aec5f36cSKonrad Dybcio .cmd_rcgr = 0x10c4,
146aec5f36cSKonrad Dybcio .mnd_width = 0,
147aec5f36cSKonrad Dybcio .hid_width = 5,
148aec5f36cSKonrad Dybcio .parent_map = disp_cc_parent_map_0,
149aec5f36cSKonrad Dybcio .clkr.hw.init = &(struct clk_init_data){
150aec5f36cSKonrad Dybcio .name = "disp_cc_mdss_byte0_clk_src",
151aec5f36cSKonrad Dybcio .parent_data = disp_cc_parent_data_0,
152aec5f36cSKonrad Dybcio .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
153aec5f36cSKonrad Dybcio .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE,
154aec5f36cSKonrad Dybcio .ops = &clk_byte2_ops,
155aec5f36cSKonrad Dybcio },
156aec5f36cSKonrad Dybcio };
157aec5f36cSKonrad Dybcio
158aec5f36cSKonrad Dybcio static const struct freq_tbl ftbl_disp_cc_mdss_esc0_clk_src[] = {
159aec5f36cSKonrad Dybcio F(19200000, P_BI_TCXO, 1, 0, 0),
160aec5f36cSKonrad Dybcio { }
161aec5f36cSKonrad Dybcio };
162aec5f36cSKonrad Dybcio
163aec5f36cSKonrad Dybcio static struct clk_rcg2 disp_cc_mdss_esc0_clk_src = {
164aec5f36cSKonrad Dybcio .cmd_rcgr = 0x10e0,
165aec5f36cSKonrad Dybcio .mnd_width = 0,
166aec5f36cSKonrad Dybcio .hid_width = 5,
167aec5f36cSKonrad Dybcio .parent_map = disp_cc_parent_map_0,
168aec5f36cSKonrad Dybcio .freq_tbl = ftbl_disp_cc_mdss_esc0_clk_src,
169aec5f36cSKonrad Dybcio .clkr.hw.init = &(struct clk_init_data){
170aec5f36cSKonrad Dybcio .name = "disp_cc_mdss_esc0_clk_src",
171aec5f36cSKonrad Dybcio .parent_data = disp_cc_parent_data_0,
172aec5f36cSKonrad Dybcio .num_parents = ARRAY_SIZE(disp_cc_parent_data_0),
173aec5f36cSKonrad Dybcio .ops = &clk_rcg2_shared_ops,
174aec5f36cSKonrad Dybcio },
175aec5f36cSKonrad Dybcio };
176aec5f36cSKonrad Dybcio
177aec5f36cSKonrad Dybcio static const struct freq_tbl ftbl_disp_cc_mdss_mdp_clk_src[] = {
178aec5f36cSKonrad Dybcio F(200000000, P_GCC_DISP_GPLL0_CLK, 1.5, 0, 0),
179aec5f36cSKonrad Dybcio F(300000000, P_GCC_DISP_GPLL0_CLK, 1, 0, 0),
180aec5f36cSKonrad Dybcio F(373500000, P_DISP_CC_PLL0_OUT_MAIN, 2, 0, 0),
181aec5f36cSKonrad Dybcio F(470000000, P_DISP_CC_PLL0_OUT_MAIN, 2, 0, 0),
182aec5f36cSKonrad Dybcio F(560000000, P_DISP_CC_PLL0_OUT_MAIN, 2, 0, 0),
183aec5f36cSKonrad Dybcio { }
184aec5f36cSKonrad Dybcio };
185aec5f36cSKonrad Dybcio
186aec5f36cSKonrad Dybcio static struct clk_rcg2 disp_cc_mdss_mdp_clk_src = {
187aec5f36cSKonrad Dybcio .cmd_rcgr = 0x107c,
188aec5f36cSKonrad Dybcio .mnd_width = 0,
189aec5f36cSKonrad Dybcio .hid_width = 5,
190aec5f36cSKonrad Dybcio .parent_map = disp_cc_parent_map_1,
191aec5f36cSKonrad Dybcio .freq_tbl = ftbl_disp_cc_mdss_mdp_clk_src,
192aec5f36cSKonrad Dybcio .clkr.hw.init = &(struct clk_init_data){
193aec5f36cSKonrad Dybcio .name = "disp_cc_mdss_mdp_clk_src",
194aec5f36cSKonrad Dybcio .parent_data = disp_cc_parent_data_1,
195aec5f36cSKonrad Dybcio .num_parents = ARRAY_SIZE(disp_cc_parent_data_1),
196aec5f36cSKonrad Dybcio .flags = CLK_SET_RATE_PARENT,
197aec5f36cSKonrad Dybcio .ops = &clk_rcg2_shared_ops,
198aec5f36cSKonrad Dybcio },
199aec5f36cSKonrad Dybcio };
200aec5f36cSKonrad Dybcio
201aec5f36cSKonrad Dybcio static struct clk_rcg2 disp_cc_mdss_pclk0_clk_src = {
202aec5f36cSKonrad Dybcio .cmd_rcgr = 0x1064,
203aec5f36cSKonrad Dybcio .mnd_width = 8,
204aec5f36cSKonrad Dybcio .hid_width = 5,
205aec5f36cSKonrad Dybcio .parent_map = disp_cc_parent_map_3,
206aec5f36cSKonrad Dybcio .clkr.hw.init = &(struct clk_init_data){
207aec5f36cSKonrad Dybcio .name = "disp_cc_mdss_pclk0_clk_src",
208aec5f36cSKonrad Dybcio .parent_data = disp_cc_parent_data_3,
209aec5f36cSKonrad Dybcio .num_parents = ARRAY_SIZE(disp_cc_parent_data_3),
210aec5f36cSKonrad Dybcio .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE,
211aec5f36cSKonrad Dybcio .ops = &clk_pixel_ops,
212aec5f36cSKonrad Dybcio },
213aec5f36cSKonrad Dybcio };
214aec5f36cSKonrad Dybcio
215aec5f36cSKonrad Dybcio static const struct freq_tbl ftbl_disp_cc_mdss_rot_clk_src[] = {
216aec5f36cSKonrad Dybcio F(200000000, P_GCC_DISP_GPLL0_CLK, 1.5, 0, 0),
217aec5f36cSKonrad Dybcio F(300000000, P_GCC_DISP_GPLL0_CLK, 1, 0, 0),
218aec5f36cSKonrad Dybcio { }
219aec5f36cSKonrad Dybcio };
220aec5f36cSKonrad Dybcio
221aec5f36cSKonrad Dybcio static struct clk_rcg2 disp_cc_mdss_rot_clk_src = {
222aec5f36cSKonrad Dybcio .cmd_rcgr = 0x1094,
223aec5f36cSKonrad Dybcio .mnd_width = 0,
224aec5f36cSKonrad Dybcio .hid_width = 5,
225aec5f36cSKonrad Dybcio .parent_map = disp_cc_parent_map_1,
226aec5f36cSKonrad Dybcio .freq_tbl = ftbl_disp_cc_mdss_rot_clk_src,
227aec5f36cSKonrad Dybcio .clkr.hw.init = &(struct clk_init_data){
228aec5f36cSKonrad Dybcio .name = "disp_cc_mdss_rot_clk_src",
229aec5f36cSKonrad Dybcio .parent_data = disp_cc_parent_data_1,
230aec5f36cSKonrad Dybcio .num_parents = ARRAY_SIZE(disp_cc_parent_data_1),
231aec5f36cSKonrad Dybcio .ops = &clk_rcg2_shared_ops,
232aec5f36cSKonrad Dybcio },
233aec5f36cSKonrad Dybcio };
234aec5f36cSKonrad Dybcio
235aec5f36cSKonrad Dybcio static struct clk_rcg2 disp_cc_mdss_vsync_clk_src = {
236aec5f36cSKonrad Dybcio .cmd_rcgr = 0x10ac,
237aec5f36cSKonrad Dybcio .mnd_width = 0,
238aec5f36cSKonrad Dybcio .hid_width = 5,
239aec5f36cSKonrad Dybcio .parent_map = disp_cc_parent_map_4,
240aec5f36cSKonrad Dybcio .freq_tbl = ftbl_disp_cc_mdss_esc0_clk_src,
241aec5f36cSKonrad Dybcio .clkr.hw.init = &(struct clk_init_data){
242aec5f36cSKonrad Dybcio .name = "disp_cc_mdss_vsync_clk_src",
243aec5f36cSKonrad Dybcio .parent_data = disp_cc_parent_data_4,
244aec5f36cSKonrad Dybcio .num_parents = ARRAY_SIZE(disp_cc_parent_data_4),
245aec5f36cSKonrad Dybcio .ops = &clk_rcg2_ops,
246aec5f36cSKonrad Dybcio },
247aec5f36cSKonrad Dybcio };
248aec5f36cSKonrad Dybcio
249aec5f36cSKonrad Dybcio static struct clk_regmap_div disp_cc_mdss_byte0_div_clk_src = {
250aec5f36cSKonrad Dybcio .reg = 0x10dc,
251aec5f36cSKonrad Dybcio .shift = 0,
252aec5f36cSKonrad Dybcio .width = 4,
253aec5f36cSKonrad Dybcio .clkr.hw.init = &(struct clk_init_data) {
254aec5f36cSKonrad Dybcio .name = "disp_cc_mdss_byte0_div_clk_src",
2550e042233SDmitry Baryshkov .parent_hws = (const struct clk_hw*[]) {
2560e042233SDmitry Baryshkov &disp_cc_mdss_byte0_clk_src.clkr.hw,
257aec5f36cSKonrad Dybcio },
258aec5f36cSKonrad Dybcio .num_parents = 1,
259aec5f36cSKonrad Dybcio .ops = &clk_regmap_div_ops,
260aec5f36cSKonrad Dybcio },
261aec5f36cSKonrad Dybcio };
262aec5f36cSKonrad Dybcio
263aec5f36cSKonrad Dybcio static struct clk_branch disp_cc_mdss_ahb_clk = {
264aec5f36cSKonrad Dybcio .halt_reg = 0x104c,
265aec5f36cSKonrad Dybcio .halt_check = BRANCH_HALT,
266aec5f36cSKonrad Dybcio .clkr = {
267aec5f36cSKonrad Dybcio .enable_reg = 0x104c,
268aec5f36cSKonrad Dybcio .enable_mask = BIT(0),
269aec5f36cSKonrad Dybcio .hw.init = &(struct clk_init_data){
270aec5f36cSKonrad Dybcio .name = "disp_cc_mdss_ahb_clk",
271aec5f36cSKonrad Dybcio .parent_hws = (const struct clk_hw*[]){
272aec5f36cSKonrad Dybcio &disp_cc_mdss_ahb_clk_src.clkr.hw,
273aec5f36cSKonrad Dybcio },
274aec5f36cSKonrad Dybcio .num_parents = 1,
275aec5f36cSKonrad Dybcio .flags = CLK_SET_RATE_PARENT,
276aec5f36cSKonrad Dybcio .ops = &clk_branch2_ops,
277aec5f36cSKonrad Dybcio },
278aec5f36cSKonrad Dybcio },
279aec5f36cSKonrad Dybcio };
280aec5f36cSKonrad Dybcio
281aec5f36cSKonrad Dybcio static struct clk_branch disp_cc_mdss_byte0_clk = {
282aec5f36cSKonrad Dybcio .halt_reg = 0x102c,
283aec5f36cSKonrad Dybcio .halt_check = BRANCH_HALT,
284aec5f36cSKonrad Dybcio .clkr = {
285aec5f36cSKonrad Dybcio .enable_reg = 0x102c,
286aec5f36cSKonrad Dybcio .enable_mask = BIT(0),
287aec5f36cSKonrad Dybcio .hw.init = &(struct clk_init_data){
288aec5f36cSKonrad Dybcio .name = "disp_cc_mdss_byte0_clk",
289aec5f36cSKonrad Dybcio .parent_hws = (const struct clk_hw*[]){
290aec5f36cSKonrad Dybcio &disp_cc_mdss_byte0_clk_src.clkr.hw,
291aec5f36cSKonrad Dybcio },
292aec5f36cSKonrad Dybcio .num_parents = 1,
293aec5f36cSKonrad Dybcio .flags = CLK_SET_RATE_PARENT,
294aec5f36cSKonrad Dybcio .ops = &clk_branch2_ops,
295aec5f36cSKonrad Dybcio },
296aec5f36cSKonrad Dybcio },
297aec5f36cSKonrad Dybcio };
298aec5f36cSKonrad Dybcio
299aec5f36cSKonrad Dybcio static struct clk_branch disp_cc_mdss_byte0_intf_clk = {
300aec5f36cSKonrad Dybcio .halt_reg = 0x1030,
301aec5f36cSKonrad Dybcio .halt_check = BRANCH_HALT,
302aec5f36cSKonrad Dybcio .clkr = {
303aec5f36cSKonrad Dybcio .enable_reg = 0x1030,
304aec5f36cSKonrad Dybcio .enable_mask = BIT(0),
305aec5f36cSKonrad Dybcio .hw.init = &(struct clk_init_data){
306aec5f36cSKonrad Dybcio .name = "disp_cc_mdss_byte0_intf_clk",
307aec5f36cSKonrad Dybcio .parent_hws = (const struct clk_hw*[]){
308aec5f36cSKonrad Dybcio &disp_cc_mdss_byte0_div_clk_src.clkr.hw,
309aec5f36cSKonrad Dybcio },
310aec5f36cSKonrad Dybcio .num_parents = 1,
311aec5f36cSKonrad Dybcio .flags = CLK_SET_RATE_PARENT,
312aec5f36cSKonrad Dybcio .ops = &clk_branch2_ops,
313aec5f36cSKonrad Dybcio },
314aec5f36cSKonrad Dybcio },
315aec5f36cSKonrad Dybcio };
316aec5f36cSKonrad Dybcio
317aec5f36cSKonrad Dybcio static struct clk_branch disp_cc_mdss_esc0_clk = {
318aec5f36cSKonrad Dybcio .halt_reg = 0x1034,
319aec5f36cSKonrad Dybcio .halt_check = BRANCH_HALT,
320aec5f36cSKonrad Dybcio .clkr = {
321aec5f36cSKonrad Dybcio .enable_reg = 0x1034,
322aec5f36cSKonrad Dybcio .enable_mask = BIT(0),
323aec5f36cSKonrad Dybcio .hw.init = &(struct clk_init_data){
324aec5f36cSKonrad Dybcio .name = "disp_cc_mdss_esc0_clk",
325aec5f36cSKonrad Dybcio .parent_hws = (const struct clk_hw*[]){
326aec5f36cSKonrad Dybcio &disp_cc_mdss_esc0_clk_src.clkr.hw,
327aec5f36cSKonrad Dybcio },
328aec5f36cSKonrad Dybcio .num_parents = 1,
329aec5f36cSKonrad Dybcio .flags = CLK_SET_RATE_PARENT,
330aec5f36cSKonrad Dybcio .ops = &clk_branch2_ops,
331aec5f36cSKonrad Dybcio },
332aec5f36cSKonrad Dybcio },
333aec5f36cSKonrad Dybcio };
334aec5f36cSKonrad Dybcio
335aec5f36cSKonrad Dybcio static struct clk_branch disp_cc_mdss_mdp_clk = {
336aec5f36cSKonrad Dybcio .halt_reg = 0x1010,
337aec5f36cSKonrad Dybcio .halt_check = BRANCH_HALT,
338aec5f36cSKonrad Dybcio .clkr = {
339aec5f36cSKonrad Dybcio .enable_reg = 0x1010,
340aec5f36cSKonrad Dybcio .enable_mask = BIT(0),
341aec5f36cSKonrad Dybcio .hw.init = &(struct clk_init_data){
342aec5f36cSKonrad Dybcio .name = "disp_cc_mdss_mdp_clk",
343aec5f36cSKonrad Dybcio .parent_hws = (const struct clk_hw*[]){
344aec5f36cSKonrad Dybcio &disp_cc_mdss_mdp_clk_src.clkr.hw,
345aec5f36cSKonrad Dybcio },
346aec5f36cSKonrad Dybcio .num_parents = 1,
347aec5f36cSKonrad Dybcio .flags = CLK_SET_RATE_PARENT,
348aec5f36cSKonrad Dybcio .ops = &clk_branch2_ops,
349aec5f36cSKonrad Dybcio },
350aec5f36cSKonrad Dybcio },
351aec5f36cSKonrad Dybcio };
352aec5f36cSKonrad Dybcio
353aec5f36cSKonrad Dybcio static struct clk_branch disp_cc_mdss_mdp_lut_clk = {
354aec5f36cSKonrad Dybcio .halt_reg = 0x1020,
355aec5f36cSKonrad Dybcio .halt_check = BRANCH_HALT_VOTED,
356aec5f36cSKonrad Dybcio .clkr = {
357aec5f36cSKonrad Dybcio .enable_reg = 0x1020,
358aec5f36cSKonrad Dybcio .enable_mask = BIT(0),
359aec5f36cSKonrad Dybcio .hw.init = &(struct clk_init_data){
360aec5f36cSKonrad Dybcio .name = "disp_cc_mdss_mdp_lut_clk",
361aec5f36cSKonrad Dybcio .parent_hws = (const struct clk_hw*[]){
362aec5f36cSKonrad Dybcio &disp_cc_mdss_mdp_clk_src.clkr.hw,
363aec5f36cSKonrad Dybcio },
364aec5f36cSKonrad Dybcio .num_parents = 1,
365aec5f36cSKonrad Dybcio .flags = CLK_SET_RATE_PARENT,
366aec5f36cSKonrad Dybcio .ops = &clk_branch2_ops,
367aec5f36cSKonrad Dybcio },
368aec5f36cSKonrad Dybcio },
369aec5f36cSKonrad Dybcio };
370aec5f36cSKonrad Dybcio
371aec5f36cSKonrad Dybcio static struct clk_branch disp_cc_mdss_non_gdsc_ahb_clk = {
372aec5f36cSKonrad Dybcio .halt_reg = 0x2004,
373aec5f36cSKonrad Dybcio .halt_check = BRANCH_HALT_VOTED,
374aec5f36cSKonrad Dybcio .clkr = {
375aec5f36cSKonrad Dybcio .enable_reg = 0x2004,
376aec5f36cSKonrad Dybcio .enable_mask = BIT(0),
377aec5f36cSKonrad Dybcio .hw.init = &(struct clk_init_data){
378aec5f36cSKonrad Dybcio .name = "disp_cc_mdss_non_gdsc_ahb_clk",
379aec5f36cSKonrad Dybcio .parent_hws = (const struct clk_hw*[]){
380aec5f36cSKonrad Dybcio &disp_cc_mdss_ahb_clk_src.clkr.hw,
381aec5f36cSKonrad Dybcio },
382aec5f36cSKonrad Dybcio .num_parents = 1,
383aec5f36cSKonrad Dybcio .flags = CLK_SET_RATE_PARENT,
384aec5f36cSKonrad Dybcio .ops = &clk_branch2_ops,
385aec5f36cSKonrad Dybcio },
386aec5f36cSKonrad Dybcio },
387aec5f36cSKonrad Dybcio };
388aec5f36cSKonrad Dybcio
389aec5f36cSKonrad Dybcio static struct clk_branch disp_cc_mdss_pclk0_clk = {
390aec5f36cSKonrad Dybcio .halt_reg = 0x1168,
391aec5f36cSKonrad Dybcio .halt_check = BRANCH_HALT,
392aec5f36cSKonrad Dybcio .clkr = {
393aec5f36cSKonrad Dybcio .enable_reg = 0x1168,
394aec5f36cSKonrad Dybcio .enable_mask = BIT(0),
395aec5f36cSKonrad Dybcio .hw.init = &(struct clk_init_data){
396aec5f36cSKonrad Dybcio .name = "disp_cc_mdss_pclk0_clk",
397aec5f36cSKonrad Dybcio .parent_hws = (const struct clk_hw*[]){
398aec5f36cSKonrad Dybcio &disp_cc_mdss_pclk0_clk_src.clkr.hw,
399aec5f36cSKonrad Dybcio },
400aec5f36cSKonrad Dybcio .num_parents = 1,
401aec5f36cSKonrad Dybcio .flags = CLK_SET_RATE_PARENT,
402aec5f36cSKonrad Dybcio .ops = &clk_branch2_ops,
403aec5f36cSKonrad Dybcio },
404aec5f36cSKonrad Dybcio },
405aec5f36cSKonrad Dybcio };
406aec5f36cSKonrad Dybcio
407aec5f36cSKonrad Dybcio static struct clk_branch disp_cc_mdss_rot_clk = {
408aec5f36cSKonrad Dybcio .halt_reg = 0x1018,
409aec5f36cSKonrad Dybcio .halt_check = BRANCH_HALT,
410aec5f36cSKonrad Dybcio .clkr = {
411aec5f36cSKonrad Dybcio .enable_reg = 0x1018,
412aec5f36cSKonrad Dybcio .enable_mask = BIT(0),
413aec5f36cSKonrad Dybcio .hw.init = &(struct clk_init_data){
414aec5f36cSKonrad Dybcio .name = "disp_cc_mdss_rot_clk",
415aec5f36cSKonrad Dybcio .parent_hws = (const struct clk_hw*[]){
416aec5f36cSKonrad Dybcio &disp_cc_mdss_rot_clk_src.clkr.hw,
417aec5f36cSKonrad Dybcio },
418aec5f36cSKonrad Dybcio .num_parents = 1,
419aec5f36cSKonrad Dybcio .flags = CLK_SET_RATE_PARENT,
420aec5f36cSKonrad Dybcio .ops = &clk_branch2_ops,
421aec5f36cSKonrad Dybcio },
422aec5f36cSKonrad Dybcio },
423aec5f36cSKonrad Dybcio };
424aec5f36cSKonrad Dybcio
425aec5f36cSKonrad Dybcio static struct clk_branch disp_cc_mdss_rscc_ahb_clk = {
426aec5f36cSKonrad Dybcio .halt_reg = 0x200c,
427aec5f36cSKonrad Dybcio .halt_check = BRANCH_HALT,
428aec5f36cSKonrad Dybcio .clkr = {
429aec5f36cSKonrad Dybcio .enable_reg = 0x200c,
430aec5f36cSKonrad Dybcio .enable_mask = BIT(0),
431aec5f36cSKonrad Dybcio .hw.init = &(struct clk_init_data){
432aec5f36cSKonrad Dybcio .name = "disp_cc_mdss_rscc_ahb_clk",
433aec5f36cSKonrad Dybcio .parent_hws = (const struct clk_hw*[]){
434aec5f36cSKonrad Dybcio &disp_cc_mdss_ahb_clk_src.clkr.hw,
435aec5f36cSKonrad Dybcio },
436aec5f36cSKonrad Dybcio .num_parents = 1,
437aec5f36cSKonrad Dybcio .flags = CLK_SET_RATE_PARENT,
438aec5f36cSKonrad Dybcio .ops = &clk_branch2_ops,
439aec5f36cSKonrad Dybcio },
440aec5f36cSKonrad Dybcio },
441aec5f36cSKonrad Dybcio };
442aec5f36cSKonrad Dybcio
443aec5f36cSKonrad Dybcio static struct clk_branch disp_cc_mdss_rscc_vsync_clk = {
444aec5f36cSKonrad Dybcio .halt_reg = 0x2008,
445aec5f36cSKonrad Dybcio .halt_check = BRANCH_HALT,
446aec5f36cSKonrad Dybcio .clkr = {
447aec5f36cSKonrad Dybcio .enable_reg = 0x2008,
448aec5f36cSKonrad Dybcio .enable_mask = BIT(0),
449aec5f36cSKonrad Dybcio .hw.init = &(struct clk_init_data){
450aec5f36cSKonrad Dybcio .name = "disp_cc_mdss_rscc_vsync_clk",
451aec5f36cSKonrad Dybcio .parent_hws = (const struct clk_hw*[]){
452aec5f36cSKonrad Dybcio &disp_cc_mdss_vsync_clk_src.clkr.hw,
453aec5f36cSKonrad Dybcio },
454aec5f36cSKonrad Dybcio .num_parents = 1,
455aec5f36cSKonrad Dybcio .flags = CLK_SET_RATE_PARENT,
456aec5f36cSKonrad Dybcio .ops = &clk_branch2_ops,
457aec5f36cSKonrad Dybcio },
458aec5f36cSKonrad Dybcio },
459aec5f36cSKonrad Dybcio };
460aec5f36cSKonrad Dybcio
461aec5f36cSKonrad Dybcio static struct clk_branch disp_cc_mdss_vsync_clk = {
462aec5f36cSKonrad Dybcio .halt_reg = 0x1028,
463aec5f36cSKonrad Dybcio .halt_check = BRANCH_HALT,
464aec5f36cSKonrad Dybcio .clkr = {
465aec5f36cSKonrad Dybcio .enable_reg = 0x1028,
466aec5f36cSKonrad Dybcio .enable_mask = BIT(0),
467aec5f36cSKonrad Dybcio .hw.init = &(struct clk_init_data){
468aec5f36cSKonrad Dybcio .name = "disp_cc_mdss_vsync_clk",
469aec5f36cSKonrad Dybcio .parent_hws = (const struct clk_hw*[]){
470aec5f36cSKonrad Dybcio &disp_cc_mdss_vsync_clk_src.clkr.hw,
471aec5f36cSKonrad Dybcio },
472aec5f36cSKonrad Dybcio .num_parents = 1,
473aec5f36cSKonrad Dybcio .flags = CLK_SET_RATE_PARENT,
474aec5f36cSKonrad Dybcio .ops = &clk_branch2_ops,
475aec5f36cSKonrad Dybcio },
476aec5f36cSKonrad Dybcio },
477aec5f36cSKonrad Dybcio };
478aec5f36cSKonrad Dybcio
479aec5f36cSKonrad Dybcio static struct clk_branch disp_cc_sleep_clk = {
480aec5f36cSKonrad Dybcio .halt_check = BRANCH_HALT,
481aec5f36cSKonrad Dybcio .clkr = {
482aec5f36cSKonrad Dybcio .enable_reg = 0x5004,
483aec5f36cSKonrad Dybcio .enable_mask = BIT(0),
484aec5f36cSKonrad Dybcio .hw.init = &(struct clk_init_data){
485aec5f36cSKonrad Dybcio .name = "disp_cc_sleep_clk",
486aec5f36cSKonrad Dybcio .flags = CLK_IS_CRITICAL,
487aec5f36cSKonrad Dybcio .ops = &clk_branch2_ops,
488aec5f36cSKonrad Dybcio },
489aec5f36cSKonrad Dybcio },
490aec5f36cSKonrad Dybcio };
491aec5f36cSKonrad Dybcio
492aec5f36cSKonrad Dybcio static struct clk_branch disp_cc_xo_clk = {
493aec5f36cSKonrad Dybcio .halt_check = BRANCH_HALT,
494aec5f36cSKonrad Dybcio .clkr = {
495aec5f36cSKonrad Dybcio .enable_reg = 0x5008,
496aec5f36cSKonrad Dybcio .enable_mask = BIT(0),
497aec5f36cSKonrad Dybcio .hw.init = &(struct clk_init_data){
498aec5f36cSKonrad Dybcio .name = "disp_cc_xo_clk",
499aec5f36cSKonrad Dybcio .flags = CLK_IS_CRITICAL,
500aec5f36cSKonrad Dybcio .ops = &clk_branch2_ops,
501aec5f36cSKonrad Dybcio },
502aec5f36cSKonrad Dybcio },
503aec5f36cSKonrad Dybcio };
504aec5f36cSKonrad Dybcio
505aec5f36cSKonrad Dybcio static struct gdsc mdss_gdsc = {
506aec5f36cSKonrad Dybcio .gdscr = 0x1004,
507aec5f36cSKonrad Dybcio .en_rest_wait_val = 0x2,
508aec5f36cSKonrad Dybcio .en_few_wait_val = 0x2,
509aec5f36cSKonrad Dybcio .clk_dis_wait_val = 0xf,
510aec5f36cSKonrad Dybcio .pd = {
511aec5f36cSKonrad Dybcio .name = "mdss_gdsc",
512aec5f36cSKonrad Dybcio },
513aec5f36cSKonrad Dybcio .pwrsts = PWRSTS_OFF_ON,
514aec5f36cSKonrad Dybcio .flags = HW_CTRL,
515aec5f36cSKonrad Dybcio };
516aec5f36cSKonrad Dybcio
517aec5f36cSKonrad Dybcio static struct clk_regmap *disp_cc_sm6375_clocks[] = {
518aec5f36cSKonrad Dybcio [DISP_CC_MDSS_AHB_CLK] = &disp_cc_mdss_ahb_clk.clkr,
519aec5f36cSKonrad Dybcio [DISP_CC_MDSS_AHB_CLK_SRC] = &disp_cc_mdss_ahb_clk_src.clkr,
520aec5f36cSKonrad Dybcio [DISP_CC_MDSS_BYTE0_CLK] = &disp_cc_mdss_byte0_clk.clkr,
521aec5f36cSKonrad Dybcio [DISP_CC_MDSS_BYTE0_CLK_SRC] = &disp_cc_mdss_byte0_clk_src.clkr,
522aec5f36cSKonrad Dybcio [DISP_CC_MDSS_BYTE0_DIV_CLK_SRC] = &disp_cc_mdss_byte0_div_clk_src.clkr,
523aec5f36cSKonrad Dybcio [DISP_CC_MDSS_BYTE0_INTF_CLK] = &disp_cc_mdss_byte0_intf_clk.clkr,
524aec5f36cSKonrad Dybcio [DISP_CC_MDSS_ESC0_CLK] = &disp_cc_mdss_esc0_clk.clkr,
525aec5f36cSKonrad Dybcio [DISP_CC_MDSS_ESC0_CLK_SRC] = &disp_cc_mdss_esc0_clk_src.clkr,
526aec5f36cSKonrad Dybcio [DISP_CC_MDSS_MDP_CLK] = &disp_cc_mdss_mdp_clk.clkr,
527aec5f36cSKonrad Dybcio [DISP_CC_MDSS_MDP_CLK_SRC] = &disp_cc_mdss_mdp_clk_src.clkr,
528aec5f36cSKonrad Dybcio [DISP_CC_MDSS_MDP_LUT_CLK] = &disp_cc_mdss_mdp_lut_clk.clkr,
529aec5f36cSKonrad Dybcio [DISP_CC_MDSS_NON_GDSC_AHB_CLK] = &disp_cc_mdss_non_gdsc_ahb_clk.clkr,
530aec5f36cSKonrad Dybcio [DISP_CC_MDSS_PCLK0_CLK] = &disp_cc_mdss_pclk0_clk.clkr,
531aec5f36cSKonrad Dybcio [DISP_CC_MDSS_PCLK0_CLK_SRC] = &disp_cc_mdss_pclk0_clk_src.clkr,
532aec5f36cSKonrad Dybcio [DISP_CC_MDSS_ROT_CLK] = &disp_cc_mdss_rot_clk.clkr,
533aec5f36cSKonrad Dybcio [DISP_CC_MDSS_ROT_CLK_SRC] = &disp_cc_mdss_rot_clk_src.clkr,
534aec5f36cSKonrad Dybcio [DISP_CC_MDSS_RSCC_AHB_CLK] = &disp_cc_mdss_rscc_ahb_clk.clkr,
535aec5f36cSKonrad Dybcio [DISP_CC_MDSS_RSCC_VSYNC_CLK] = &disp_cc_mdss_rscc_vsync_clk.clkr,
536aec5f36cSKonrad Dybcio [DISP_CC_MDSS_VSYNC_CLK] = &disp_cc_mdss_vsync_clk.clkr,
537aec5f36cSKonrad Dybcio [DISP_CC_MDSS_VSYNC_CLK_SRC] = &disp_cc_mdss_vsync_clk_src.clkr,
538aec5f36cSKonrad Dybcio [DISP_CC_PLL0] = &disp_cc_pll0.clkr,
539aec5f36cSKonrad Dybcio [DISP_CC_SLEEP_CLK] = &disp_cc_sleep_clk.clkr,
540aec5f36cSKonrad Dybcio [DISP_CC_XO_CLK] = &disp_cc_xo_clk.clkr,
541aec5f36cSKonrad Dybcio };
542aec5f36cSKonrad Dybcio
543aec5f36cSKonrad Dybcio static const struct qcom_reset_map disp_cc_sm6375_resets[] = {
544aec5f36cSKonrad Dybcio [DISP_CC_MDSS_CORE_BCR] = { 0x1000 },
545aec5f36cSKonrad Dybcio [DISP_CC_MDSS_RSCC_BCR] = { 0x2000 },
546aec5f36cSKonrad Dybcio };
547aec5f36cSKonrad Dybcio
548aec5f36cSKonrad Dybcio static struct gdsc *disp_cc_sm6375_gdscs[] = {
549aec5f36cSKonrad Dybcio [MDSS_GDSC] = &mdss_gdsc,
550aec5f36cSKonrad Dybcio };
551aec5f36cSKonrad Dybcio
552aec5f36cSKonrad Dybcio static const struct regmap_config disp_cc_sm6375_regmap_config = {
553aec5f36cSKonrad Dybcio .reg_bits = 32,
554aec5f36cSKonrad Dybcio .reg_stride = 4,
555aec5f36cSKonrad Dybcio .val_bits = 32,
556aec5f36cSKonrad Dybcio .max_register = 0x10000,
557aec5f36cSKonrad Dybcio .fast_io = true,
558aec5f36cSKonrad Dybcio };
559aec5f36cSKonrad Dybcio
560aec5f36cSKonrad Dybcio static const struct qcom_cc_desc disp_cc_sm6375_desc = {
561aec5f36cSKonrad Dybcio .config = &disp_cc_sm6375_regmap_config,
562aec5f36cSKonrad Dybcio .clks = disp_cc_sm6375_clocks,
563aec5f36cSKonrad Dybcio .num_clks = ARRAY_SIZE(disp_cc_sm6375_clocks),
564aec5f36cSKonrad Dybcio .resets = disp_cc_sm6375_resets,
565aec5f36cSKonrad Dybcio .num_resets = ARRAY_SIZE(disp_cc_sm6375_resets),
566aec5f36cSKonrad Dybcio .gdscs = disp_cc_sm6375_gdscs,
567aec5f36cSKonrad Dybcio .num_gdscs = ARRAY_SIZE(disp_cc_sm6375_gdscs),
568aec5f36cSKonrad Dybcio };
569aec5f36cSKonrad Dybcio
570aec5f36cSKonrad Dybcio static const struct of_device_id disp_cc_sm6375_match_table[] = {
571aec5f36cSKonrad Dybcio { .compatible = "qcom,sm6375-dispcc" },
572aec5f36cSKonrad Dybcio { }
573aec5f36cSKonrad Dybcio };
574aec5f36cSKonrad Dybcio MODULE_DEVICE_TABLE(of, disp_cc_sm6375_match_table);
575aec5f36cSKonrad Dybcio
disp_cc_sm6375_probe(struct platform_device * pdev)576aec5f36cSKonrad Dybcio static int disp_cc_sm6375_probe(struct platform_device *pdev)
577aec5f36cSKonrad Dybcio {
578aec5f36cSKonrad Dybcio struct regmap *regmap;
579aec5f36cSKonrad Dybcio
580aec5f36cSKonrad Dybcio regmap = qcom_cc_map(pdev, &disp_cc_sm6375_desc);
581aec5f36cSKonrad Dybcio if (IS_ERR(regmap))
582aec5f36cSKonrad Dybcio return PTR_ERR(regmap);
583aec5f36cSKonrad Dybcio
584aec5f36cSKonrad Dybcio clk_lucid_pll_configure(&disp_cc_pll0, regmap, &disp_cc_pll0_config);
585aec5f36cSKonrad Dybcio
586*9f93a0a4SLuo Jie return qcom_cc_really_probe(&pdev->dev, &disp_cc_sm6375_desc, regmap);
587aec5f36cSKonrad Dybcio }
588aec5f36cSKonrad Dybcio
589aec5f36cSKonrad Dybcio static struct platform_driver disp_cc_sm6375_driver = {
590aec5f36cSKonrad Dybcio .probe = disp_cc_sm6375_probe,
591aec5f36cSKonrad Dybcio .driver = {
592aec5f36cSKonrad Dybcio .name = "disp_cc-sm6375",
593aec5f36cSKonrad Dybcio .of_match_table = disp_cc_sm6375_match_table,
594aec5f36cSKonrad Dybcio },
595aec5f36cSKonrad Dybcio };
596aec5f36cSKonrad Dybcio
597c334ecf3SDmitry Baryshkov module_platform_driver(disp_cc_sm6375_driver);
598aec5f36cSKonrad Dybcio
599aec5f36cSKonrad Dybcio MODULE_DESCRIPTION("QTI DISPCC SM6375 Driver");
600aec5f36cSKonrad Dybcio MODULE_LICENSE("GPL");
601