2 * Copyright (c) 2015 The Linux Foundation. All rights reserved.
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #include <linux/kernel.h>
15 #include <linux/err.h>
16 #include <linux/platform_device.h>
17 #include <linux/module.h>
19 #include <linux/of_device.h>
20 #include <linux/clk-provider.h>
21 #include <linux/regmap.h>
22 #include <linux/reset-controller.h>
24 #include <dt-bindings/clock/qcom,gcc-ipq4019.h>
27 #include "clk-regmap.h"
29 #include "clk-branch.h"
43 static struct parent_map gcc_xo_200_500_map
[] = {
49 static const char * const gcc_xo_200_500
[] = {
55 static struct parent_map gcc_xo_200_map
[] = {
60 static const char * const gcc_xo_200
[] = {
65 static struct parent_map gcc_xo_200_spi_map
[] = {
70 static const char * const gcc_xo_200_spi
[] = {
75 static struct parent_map gcc_xo_sdcc1_500_map
[] = {
81 static const char * const gcc_xo_sdcc1_500
[] = {
87 static struct parent_map gcc_xo_wcss2g_map
[] = {
92 static const char * const gcc_xo_wcss2g
[] = {
97 static struct parent_map gcc_xo_wcss5g_map
[] = {
102 static const char * const gcc_xo_wcss5g
[] = {
107 static struct parent_map gcc_xo_125_dly_map
[] = {
109 { P_FEPLL125DLY
, 1 },
112 static const char * const gcc_xo_125_dly
[] = {
117 static struct parent_map gcc_xo_ddr_500_200_map
[] = {
124 static const char * const gcc_xo_ddr_500_200
[] = {
131 #define F(f, s, h, m, n) { (f), (s), (2 * (h) - 1), (m), (n) }
133 static const struct freq_tbl ftbl_gcc_audio_pwm_clk
[] = {
134 F(48000000, P_XO
, 1, 0, 0),
135 F(200000000, P_FEPLL200
, 1, 0, 0),
139 static struct clk_rcg2 audio_clk_src
= {
142 .parent_map
= gcc_xo_200_map
,
143 .freq_tbl
= ftbl_gcc_audio_pwm_clk
,
144 .clkr
.hw
.init
= &(struct clk_init_data
){
145 .name
= "audio_clk_src",
146 .parent_names
= gcc_xo_200
,
148 .ops
= &clk_rcg2_ops
,
153 static struct clk_branch gcc_audio_ahb_clk
= {
156 .enable_reg
= 0x1b010,
157 .enable_mask
= BIT(0),
158 .hw
.init
= &(struct clk_init_data
){
159 .name
= "gcc_audio_ahb_clk",
160 .parent_names
= (const char *[]){
163 .flags
= CLK_SET_RATE_PARENT
,
165 .ops
= &clk_branch2_ops
,
170 static struct clk_branch gcc_audio_pwm_clk
= {
173 .enable_reg
= 0x1b00C,
174 .enable_mask
= BIT(0),
175 .hw
.init
= &(struct clk_init_data
){
176 .name
= "gcc_audio_pwm_clk",
177 .parent_names
= (const char *[]){
180 .flags
= CLK_SET_RATE_PARENT
,
182 .ops
= &clk_branch2_ops
,
187 static const struct freq_tbl ftbl_gcc_blsp1_qup1_2_i2c_apps_clk
[] = {
188 F(19050000, P_FEPLL200
, 10.5, 1, 1),
192 static struct clk_rcg2 blsp1_qup1_i2c_apps_clk_src
= {
195 .parent_map
= gcc_xo_200_map
,
196 .freq_tbl
= ftbl_gcc_blsp1_qup1_2_i2c_apps_clk
,
197 .clkr
.hw
.init
= &(struct clk_init_data
){
198 .name
= "blsp1_qup1_i2c_apps_clk_src",
199 .parent_names
= gcc_xo_200
,
201 .ops
= &clk_rcg2_ops
,
205 static struct clk_branch gcc_blsp1_qup1_i2c_apps_clk
= {
208 .enable_reg
= 0x2008,
209 .enable_mask
= BIT(0),
210 .hw
.init
= &(struct clk_init_data
){
211 .name
= "gcc_blsp1_qup1_i2c_apps_clk",
212 .parent_names
= (const char *[]){
213 "blsp1_qup1_i2c_apps_clk_src",
216 .ops
= &clk_branch2_ops
,
217 .flags
= CLK_SET_RATE_PARENT
,
222 static struct clk_rcg2 blsp1_qup2_i2c_apps_clk_src
= {
225 .parent_map
= gcc_xo_200_map
,
226 .freq_tbl
= ftbl_gcc_blsp1_qup1_2_i2c_apps_clk
,
227 .clkr
.hw
.init
= &(struct clk_init_data
){
228 .name
= "blsp1_qup2_i2c_apps_clk_src",
229 .parent_names
= gcc_xo_200
,
231 .ops
= &clk_rcg2_ops
,
235 static struct clk_branch gcc_blsp1_qup2_i2c_apps_clk
= {
238 .enable_reg
= 0x3010,
239 .enable_mask
= BIT(0),
240 .hw
.init
= &(struct clk_init_data
){
241 .name
= "gcc_blsp1_qup2_i2c_apps_clk",
242 .parent_names
= (const char *[]){
243 "blsp1_qup2_i2c_apps_clk_src",
246 .ops
= &clk_branch2_ops
,
247 .flags
= CLK_SET_RATE_PARENT
,
252 static const struct freq_tbl ftbl_gcc_blsp1_qup1_2_spi_apps_clk
[] = {
253 F(960000, P_XO
, 12, 1, 4),
254 F(4800000, P_XO
, 1, 1, 10),
255 F(9600000, P_XO
, 1, 1, 5),
256 F(15000000, P_XO
, 1, 1, 3),
257 F(19200000, P_XO
, 1, 2, 5),
258 F(24000000, P_XO
, 1, 1, 2),
259 F(48000000, P_XO
, 1, 0, 0),
263 static struct clk_rcg2 blsp1_qup1_spi_apps_clk_src
= {
267 .parent_map
= gcc_xo_200_spi_map
,
268 .freq_tbl
= ftbl_gcc_blsp1_qup1_2_spi_apps_clk
,
269 .clkr
.hw
.init
= &(struct clk_init_data
){
270 .name
= "blsp1_qup1_spi_apps_clk_src",
271 .parent_names
= gcc_xo_200_spi
,
273 .ops
= &clk_rcg2_ops
,
277 static struct clk_branch gcc_blsp1_qup1_spi_apps_clk
= {
280 .enable_reg
= 0x2004,
281 .enable_mask
= BIT(0),
282 .hw
.init
= &(struct clk_init_data
){
283 .name
= "gcc_blsp1_qup1_spi_apps_clk",
284 .parent_names
= (const char *[]){
285 "blsp1_qup1_spi_apps_clk_src",
288 .ops
= &clk_branch2_ops
,
289 .flags
= CLK_SET_RATE_PARENT
,
294 static struct clk_rcg2 blsp1_qup2_spi_apps_clk_src
= {
298 .freq_tbl
= ftbl_gcc_blsp1_qup1_2_spi_apps_clk
,
299 .parent_map
= gcc_xo_200_spi_map
,
300 .clkr
.hw
.init
= &(struct clk_init_data
){
301 .name
= "blsp1_qup2_spi_apps_clk_src",
302 .parent_names
= gcc_xo_200_spi
,
304 .ops
= &clk_rcg2_ops
,
308 static struct clk_branch gcc_blsp1_qup2_spi_apps_clk
= {
311 .enable_reg
= 0x300c,
312 .enable_mask
= BIT(0),
313 .hw
.init
= &(struct clk_init_data
){
314 .name
= "gcc_blsp1_qup2_spi_apps_clk",
315 .parent_names
= (const char *[]){
316 "blsp1_qup2_spi_apps_clk_src",
319 .ops
= &clk_branch2_ops
,
320 .flags
= CLK_SET_RATE_PARENT
,
325 static const struct freq_tbl ftbl_gcc_blsp1_uart1_2_apps_clk
[] = {
326 F(1843200, P_FEPLL200
, 1, 144, 15625),
327 F(3686400, P_FEPLL200
, 1, 288, 15625),
328 F(7372800, P_FEPLL200
, 1, 576, 15625),
329 F(14745600, P_FEPLL200
, 1, 1152, 15625),
330 F(16000000, P_FEPLL200
, 1, 2, 25),
331 F(24000000, P_XO
, 1, 1, 2),
332 F(32000000, P_FEPLL200
, 1, 4, 25),
333 F(40000000, P_FEPLL200
, 1, 1, 5),
334 F(46400000, P_FEPLL200
, 1, 29, 125),
335 F(48000000, P_XO
, 1, 0, 0),
339 static struct clk_rcg2 blsp1_uart1_apps_clk_src
= {
343 .freq_tbl
= ftbl_gcc_blsp1_uart1_2_apps_clk
,
344 .parent_map
= gcc_xo_200_spi_map
,
345 .clkr
.hw
.init
= &(struct clk_init_data
){
346 .name
= "blsp1_uart1_apps_clk_src",
347 .parent_names
= gcc_xo_200_spi
,
349 .ops
= &clk_rcg2_ops
,
353 static struct clk_branch gcc_blsp1_uart1_apps_clk
= {
356 .enable_reg
= 0x203c,
357 .enable_mask
= BIT(0),
358 .hw
.init
= &(struct clk_init_data
){
359 .name
= "gcc_blsp1_uart1_apps_clk",
360 .parent_names
= (const char *[]){
361 "blsp1_uart1_apps_clk_src",
363 .flags
= CLK_SET_RATE_PARENT
,
365 .ops
= &clk_branch2_ops
,
370 static struct clk_rcg2 blsp1_uart2_apps_clk_src
= {
374 .freq_tbl
= ftbl_gcc_blsp1_uart1_2_apps_clk
,
375 .parent_map
= gcc_xo_200_spi_map
,
376 .clkr
.hw
.init
= &(struct clk_init_data
){
377 .name
= "blsp1_uart2_apps_clk_src",
378 .parent_names
= gcc_xo_200_spi
,
380 .ops
= &clk_rcg2_ops
,
384 static struct clk_branch gcc_blsp1_uart2_apps_clk
= {
387 .enable_reg
= 0x302c,
388 .enable_mask
= BIT(0),
389 .hw
.init
= &(struct clk_init_data
){
390 .name
= "gcc_blsp1_uart2_apps_clk",
391 .parent_names
= (const char *[]){
392 "blsp1_uart2_apps_clk_src",
395 .ops
= &clk_branch2_ops
,
396 .flags
= CLK_SET_RATE_PARENT
,
401 static const struct freq_tbl ftbl_gcc_gp_clk
[] = {
402 F(1250000, P_FEPLL200
, 1, 16, 0),
403 F(2500000, P_FEPLL200
, 1, 8, 0),
404 F(5000000, P_FEPLL200
, 1, 4, 0),
408 static struct clk_rcg2 gp1_clk_src
= {
412 .freq_tbl
= ftbl_gcc_gp_clk
,
413 .parent_map
= gcc_xo_200_map
,
414 .clkr
.hw
.init
= &(struct clk_init_data
){
415 .name
= "gp1_clk_src",
416 .parent_names
= gcc_xo_200
,
418 .ops
= &clk_rcg2_ops
,
422 static struct clk_branch gcc_gp1_clk
= {
425 .enable_reg
= 0x8000,
426 .enable_mask
= BIT(0),
427 .hw
.init
= &(struct clk_init_data
){
428 .name
= "gcc_gp1_clk",
429 .parent_names
= (const char *[]){
433 .ops
= &clk_branch2_ops
,
434 .flags
= CLK_SET_RATE_PARENT
,
439 static struct clk_rcg2 gp2_clk_src
= {
443 .freq_tbl
= ftbl_gcc_gp_clk
,
444 .parent_map
= gcc_xo_200_map
,
445 .clkr
.hw
.init
= &(struct clk_init_data
){
446 .name
= "gp2_clk_src",
447 .parent_names
= gcc_xo_200
,
449 .ops
= &clk_rcg2_ops
,
453 static struct clk_branch gcc_gp2_clk
= {
456 .enable_reg
= 0x9000,
457 .enable_mask
= BIT(0),
458 .hw
.init
= &(struct clk_init_data
){
459 .name
= "gcc_gp2_clk",
460 .parent_names
= (const char *[]){
464 .ops
= &clk_branch2_ops
,
465 .flags
= CLK_SET_RATE_PARENT
,
470 static struct clk_rcg2 gp3_clk_src
= {
474 .freq_tbl
= ftbl_gcc_gp_clk
,
475 .parent_map
= gcc_xo_200_map
,
476 .clkr
.hw
.init
= &(struct clk_init_data
){
477 .name
= "gp3_clk_src",
478 .parent_names
= gcc_xo_200
,
480 .ops
= &clk_rcg2_ops
,
484 static struct clk_branch gcc_gp3_clk
= {
487 .enable_reg
= 0xa000,
488 .enable_mask
= BIT(0),
489 .hw
.init
= &(struct clk_init_data
){
490 .name
= "gcc_gp3_clk",
491 .parent_names
= (const char *[]){
495 .ops
= &clk_branch2_ops
,
496 .flags
= CLK_SET_RATE_PARENT
,
501 static const struct freq_tbl ftbl_gcc_sdcc1_apps_clk
[] = {
502 F(144000, P_XO
, 1, 3, 240),
503 F(400000, P_XO
, 1, 1, 0),
504 F(20000000, P_FEPLL500
, 1, 1, 25),
505 F(25000000, P_FEPLL500
, 1, 1, 20),
506 F(50000000, P_FEPLL500
, 1, 1, 10),
507 F(100000000, P_FEPLL500
, 1, 1, 5),
508 F(193000000, P_DDRPLL
, 1, 0, 0),
512 static struct clk_rcg2 sdcc1_apps_clk_src
= {
515 .freq_tbl
= ftbl_gcc_sdcc1_apps_clk
,
516 .parent_map
= gcc_xo_sdcc1_500_map
,
517 .clkr
.hw
.init
= &(struct clk_init_data
){
518 .name
= "sdcc1_apps_clk_src",
519 .parent_names
= gcc_xo_sdcc1_500
,
521 .ops
= &clk_rcg2_ops
,
522 .flags
= CLK_SET_RATE_PARENT
,
526 static const struct freq_tbl ftbl_gcc_apps_clk
[] = {
527 F(48000000, P_XO
, 1, 0, 0),
528 F(200000000, P_FEPLL200
, 1, 0, 0),
529 F(500000000, P_FEPLL500
, 1, 0, 0),
530 F(626000000, P_DDRPLLAPSS
, 1, 0, 0),
534 static struct clk_rcg2 apps_clk_src
= {
537 .freq_tbl
= ftbl_gcc_apps_clk
,
538 .parent_map
= gcc_xo_ddr_500_200_map
,
539 .clkr
.hw
.init
= &(struct clk_init_data
){
540 .name
= "apps_clk_src",
541 .parent_names
= gcc_xo_ddr_500_200
,
543 .ops
= &clk_rcg2_ops
,
547 static const struct freq_tbl ftbl_gcc_apps_ahb_clk
[] = {
548 F(48000000, P_XO
, 1, 0, 0),
549 F(100000000, P_FEPLL200
, 2, 0, 0),
553 static struct clk_rcg2 apps_ahb_clk_src
= {
556 .parent_map
= gcc_xo_200_500_map
,
557 .freq_tbl
= ftbl_gcc_apps_ahb_clk
,
558 .clkr
.hw
.init
= &(struct clk_init_data
){
559 .name
= "apps_ahb_clk_src",
560 .parent_names
= gcc_xo_200_500
,
562 .ops
= &clk_rcg2_ops
,
566 static struct clk_branch gcc_apss_ahb_clk
= {
568 .halt_check
= BRANCH_HALT_VOTED
,
570 .enable_reg
= 0x6000,
571 .enable_mask
= BIT(14),
572 .hw
.init
= &(struct clk_init_data
){
573 .name
= "gcc_apss_ahb_clk",
574 .parent_names
= (const char *[]){
578 .ops
= &clk_branch2_ops
,
579 .flags
= CLK_SET_RATE_PARENT
,
584 static struct clk_branch gcc_blsp1_ahb_clk
= {
586 .halt_check
= BRANCH_HALT_VOTED
,
588 .enable_reg
= 0x6000,
589 .enable_mask
= BIT(10),
590 .hw
.init
= &(struct clk_init_data
){
591 .name
= "gcc_blsp1_ahb_clk",
592 .parent_names
= (const char *[]){
596 .ops
= &clk_branch2_ops
,
601 static struct clk_branch gcc_dcd_xo_clk
= {
604 .enable_reg
= 0x2103c,
605 .enable_mask
= BIT(0),
606 .hw
.init
= &(struct clk_init_data
){
607 .name
= "gcc_dcd_xo_clk",
608 .parent_names
= (const char *[]){
612 .ops
= &clk_branch2_ops
,
617 static struct clk_branch gcc_boot_rom_ahb_clk
= {
620 .enable_reg
= 0x1300c,
621 .enable_mask
= BIT(0),
622 .hw
.init
= &(struct clk_init_data
){
623 .name
= "gcc_boot_rom_ahb_clk",
624 .parent_names
= (const char *[]){
628 .ops
= &clk_branch2_ops
,
629 .flags
= CLK_SET_RATE_PARENT
,
634 static struct clk_branch gcc_crypto_ahb_clk
= {
636 .halt_check
= BRANCH_HALT_VOTED
,
638 .enable_reg
= 0x6000,
639 .enable_mask
= BIT(0),
640 .hw
.init
= &(struct clk_init_data
){
641 .name
= "gcc_crypto_ahb_clk",
642 .parent_names
= (const char *[]){
646 .ops
= &clk_branch2_ops
,
651 static struct clk_branch gcc_crypto_axi_clk
= {
653 .halt_check
= BRANCH_HALT_VOTED
,
655 .enable_reg
= 0x6000,
656 .enable_mask
= BIT(1),
657 .hw
.init
= &(struct clk_init_data
){
658 .name
= "gcc_crypto_axi_clk",
659 .parent_names
= (const char *[]){
663 .ops
= &clk_branch2_ops
,
668 static struct clk_branch gcc_crypto_clk
= {
670 .halt_check
= BRANCH_HALT_VOTED
,
672 .enable_reg
= 0x6000,
673 .enable_mask
= BIT(2),
674 .hw
.init
= &(struct clk_init_data
){
675 .name
= "gcc_crypto_clk",
676 .parent_names
= (const char *[]){
680 .ops
= &clk_branch2_ops
,
685 static struct clk_branch gcc_ess_clk
= {
688 .enable_reg
= 0x12010,
689 .enable_mask
= BIT(0),
690 .hw
.init
= &(struct clk_init_data
){
691 .name
= "gcc_ess_clk",
692 .parent_names
= (const char *[]){
693 "fephy_125m_dly_clk_src",
696 .ops
= &clk_branch2_ops
,
697 .flags
= CLK_SET_RATE_PARENT
,
702 static struct clk_branch gcc_imem_axi_clk
= {
704 .halt_check
= BRANCH_HALT_VOTED
,
706 .enable_reg
= 0x6000,
707 .enable_mask
= BIT(17),
708 .hw
.init
= &(struct clk_init_data
){
709 .name
= "gcc_imem_axi_clk",
710 .parent_names
= (const char *[]){
714 .ops
= &clk_branch2_ops
,
719 static struct clk_branch gcc_imem_cfg_ahb_clk
= {
722 .enable_reg
= 0xe008,
723 .enable_mask
= BIT(0),
724 .hw
.init
= &(struct clk_init_data
){
725 .name
= "gcc_imem_cfg_ahb_clk",
726 .parent_names
= (const char *[]){
730 .ops
= &clk_branch2_ops
,
735 static struct clk_branch gcc_pcie_ahb_clk
= {
738 .enable_reg
= 0x1d00c,
739 .enable_mask
= BIT(0),
740 .hw
.init
= &(struct clk_init_data
){
741 .name
= "gcc_pcie_ahb_clk",
742 .parent_names
= (const char *[]){
746 .ops
= &clk_branch2_ops
,
751 static struct clk_branch gcc_pcie_axi_m_clk
= {
754 .enable_reg
= 0x1d004,
755 .enable_mask
= BIT(0),
756 .hw
.init
= &(struct clk_init_data
){
757 .name
= "gcc_pcie_axi_m_clk",
758 .parent_names
= (const char *[]){
762 .ops
= &clk_branch2_ops
,
767 static struct clk_branch gcc_pcie_axi_s_clk
= {
770 .enable_reg
= 0x1d008,
771 .enable_mask
= BIT(0),
772 .hw
.init
= &(struct clk_init_data
){
773 .name
= "gcc_pcie_axi_s_clk",
774 .parent_names
= (const char *[]){
778 .ops
= &clk_branch2_ops
,
783 static struct clk_branch gcc_prng_ahb_clk
= {
785 .halt_check
= BRANCH_HALT_VOTED
,
787 .enable_reg
= 0x6000,
788 .enable_mask
= BIT(8),
789 .hw
.init
= &(struct clk_init_data
){
790 .name
= "gcc_prng_ahb_clk",
791 .parent_names
= (const char *[]){
795 .ops
= &clk_branch2_ops
,
800 static struct clk_branch gcc_qpic_ahb_clk
= {
803 .enable_reg
= 0x1c008,
804 .enable_mask
= BIT(0),
805 .hw
.init
= &(struct clk_init_data
){
806 .name
= "gcc_qpic_ahb_clk",
807 .parent_names
= (const char *[]){
811 .ops
= &clk_branch2_ops
,
816 static struct clk_branch gcc_qpic_clk
= {
819 .enable_reg
= 0x1c004,
820 .enable_mask
= BIT(0),
821 .hw
.init
= &(struct clk_init_data
){
822 .name
= "gcc_qpic_clk",
823 .parent_names
= (const char *[]){
827 .ops
= &clk_branch2_ops
,
832 static struct clk_branch gcc_sdcc1_ahb_clk
= {
835 .enable_reg
= 0x18010,
836 .enable_mask
= BIT(0),
837 .hw
.init
= &(struct clk_init_data
){
838 .name
= "gcc_sdcc1_ahb_clk",
839 .parent_names
= (const char *[]){
843 .ops
= &clk_branch2_ops
,
848 static struct clk_branch gcc_sdcc1_apps_clk
= {
851 .enable_reg
= 0x1800c,
852 .enable_mask
= BIT(0),
853 .hw
.init
= &(struct clk_init_data
){
854 .name
= "gcc_sdcc1_apps_clk",
855 .parent_names
= (const char *[]){
856 "sdcc1_apps_clk_src",
859 .ops
= &clk_branch2_ops
,
860 .flags
= CLK_SET_RATE_PARENT
,
865 static struct clk_branch gcc_tlmm_ahb_clk
= {
867 .halt_check
= BRANCH_HALT_VOTED
,
869 .enable_reg
= 0x6000,
870 .enable_mask
= BIT(5),
871 .hw
.init
= &(struct clk_init_data
){
872 .name
= "gcc_tlmm_ahb_clk",
873 .parent_names
= (const char *[]){
877 .ops
= &clk_branch2_ops
,
882 static struct clk_branch gcc_usb2_master_clk
= {
885 .enable_reg
= 0x1e00c,
886 .enable_mask
= BIT(0),
887 .hw
.init
= &(struct clk_init_data
){
888 .name
= "gcc_usb2_master_clk",
889 .parent_names
= (const char *[]){
893 .ops
= &clk_branch2_ops
,
898 static struct clk_branch gcc_usb2_sleep_clk
= {
901 .enable_reg
= 0x1e010,
902 .enable_mask
= BIT(0),
903 .hw
.init
= &(struct clk_init_data
){
904 .name
= "gcc_usb2_sleep_clk",
905 .parent_names
= (const char *[]){
909 .ops
= &clk_branch2_ops
,
914 static struct clk_branch gcc_usb2_mock_utmi_clk
= {
917 .enable_reg
= 0x1e014,
918 .enable_mask
= BIT(0),
919 .hw
.init
= &(struct clk_init_data
){
920 .name
= "gcc_usb2_mock_utmi_clk",
921 .parent_names
= (const char *[]){
922 "usb30_mock_utmi_clk_src",
925 .ops
= &clk_branch2_ops
,
926 .flags
= CLK_SET_RATE_PARENT
,
931 static const struct freq_tbl ftbl_gcc_usb30_mock_utmi_clk
[] = {
932 F(2000000, P_FEPLL200
, 10, 0, 0),
936 static struct clk_rcg2 usb30_mock_utmi_clk_src
= {
939 .parent_map
= gcc_xo_200_map
,
940 .freq_tbl
= ftbl_gcc_usb30_mock_utmi_clk
,
941 .clkr
.hw
.init
= &(struct clk_init_data
){
942 .name
= "usb30_mock_utmi_clk_src",
943 .parent_names
= gcc_xo_200
,
945 .ops
= &clk_rcg2_ops
,
949 static struct clk_branch gcc_usb3_master_clk
= {
952 .enable_reg
= 0x1e028,
953 .enable_mask
= BIT(0),
954 .hw
.init
= &(struct clk_init_data
){
955 .name
= "gcc_usb3_master_clk",
956 .parent_names
= (const char *[]){
960 .ops
= &clk_branch2_ops
,
965 static struct clk_branch gcc_usb3_sleep_clk
= {
968 .enable_reg
= 0x1e02C,
969 .enable_mask
= BIT(0),
970 .hw
.init
= &(struct clk_init_data
){
971 .name
= "gcc_usb3_sleep_clk",
972 .parent_names
= (const char *[]){
976 .ops
= &clk_branch2_ops
,
981 static struct clk_branch gcc_usb3_mock_utmi_clk
= {
984 .enable_reg
= 0x1e030,
985 .enable_mask
= BIT(0),
986 .hw
.init
= &(struct clk_init_data
){
987 .name
= "gcc_usb3_mock_utmi_clk",
988 .parent_names
= (const char *[]){
989 "usb30_mock_utmi_clk_src",
992 .ops
= &clk_branch2_ops
,
993 .flags
= CLK_SET_RATE_PARENT
,
998 static const struct freq_tbl ftbl_gcc_fephy_dly_clk
[] = {
999 F(125000000, P_FEPLL125DLY
, 1, 0, 0),
1003 static struct clk_rcg2 fephy_125m_dly_clk_src
= {
1004 .cmd_rcgr
= 0x12000,
1006 .parent_map
= gcc_xo_125_dly_map
,
1007 .freq_tbl
= ftbl_gcc_fephy_dly_clk
,
1008 .clkr
.hw
.init
= &(struct clk_init_data
){
1009 .name
= "fephy_125m_dly_clk_src",
1010 .parent_names
= gcc_xo_125_dly
,
1012 .ops
= &clk_rcg2_ops
,
1017 static const struct freq_tbl ftbl_gcc_wcss2g_clk
[] = {
1018 F(48000000, P_XO
, 1, 0, 0),
1019 F(250000000, P_FEPLLWCSS2G
, 1, 0, 0),
1023 static struct clk_rcg2 wcss2g_clk_src
= {
1024 .cmd_rcgr
= 0x1f000,
1026 .freq_tbl
= ftbl_gcc_wcss2g_clk
,
1027 .parent_map
= gcc_xo_wcss2g_map
,
1028 .clkr
.hw
.init
= &(struct clk_init_data
){
1029 .name
= "wcss2g_clk_src",
1030 .parent_names
= gcc_xo_wcss2g
,
1032 .ops
= &clk_rcg2_ops
,
1033 .flags
= CLK_SET_RATE_PARENT
,
1037 static struct clk_branch gcc_wcss2g_clk
= {
1038 .halt_reg
= 0x1f00C,
1040 .enable_reg
= 0x1f00C,
1041 .enable_mask
= BIT(0),
1042 .hw
.init
= &(struct clk_init_data
){
1043 .name
= "gcc_wcss2g_clk",
1044 .parent_names
= (const char *[]){
1048 .ops
= &clk_branch2_ops
,
1049 .flags
= CLK_SET_RATE_PARENT
,
1054 static struct clk_branch gcc_wcss2g_ref_clk
= {
1055 .halt_reg
= 0x1f00C,
1057 .enable_reg
= 0x1f00C,
1058 .enable_mask
= BIT(0),
1059 .hw
.init
= &(struct clk_init_data
){
1060 .name
= "gcc_wcss2g_ref_clk",
1061 .parent_names
= (const char *[]){
1065 .ops
= &clk_branch2_ops
,
1066 .flags
= CLK_SET_RATE_PARENT
,
1071 static struct clk_branch gcc_wcss2g_rtc_clk
= {
1072 .halt_reg
= 0x1f010,
1074 .enable_reg
= 0x1f010,
1075 .enable_mask
= BIT(0),
1076 .hw
.init
= &(struct clk_init_data
){
1077 .name
= "gcc_wcss2g_rtc_clk",
1078 .parent_names
= (const char *[]){
1079 "gcc_sleep_clk_src",
1082 .ops
= &clk_branch2_ops
,
1087 static const struct freq_tbl ftbl_gcc_wcss5g_clk
[] = {
1088 F(48000000, P_XO
, 1, 0, 0),
1089 F(250000000, P_FEPLLWCSS5G
, 1, 0, 0),
1093 static struct clk_rcg2 wcss5g_clk_src
= {
1094 .cmd_rcgr
= 0x20000,
1096 .parent_map
= gcc_xo_wcss5g_map
,
1097 .freq_tbl
= ftbl_gcc_wcss5g_clk
,
1098 .clkr
.hw
.init
= &(struct clk_init_data
){
1099 .name
= "wcss5g_clk_src",
1100 .parent_names
= gcc_xo_wcss5g
,
1102 .ops
= &clk_rcg2_ops
,
1106 static struct clk_branch gcc_wcss5g_clk
= {
1107 .halt_reg
= 0x2000c,
1109 .enable_reg
= 0x2000c,
1110 .enable_mask
= BIT(0),
1111 .hw
.init
= &(struct clk_init_data
){
1112 .name
= "gcc_wcss5g_clk",
1113 .parent_names
= (const char *[]){
1117 .ops
= &clk_branch2_ops
,
1118 .flags
= CLK_SET_RATE_PARENT
,
1123 static struct clk_branch gcc_wcss5g_ref_clk
= {
1124 .halt_reg
= 0x2000c,
1126 .enable_reg
= 0x2000c,
1127 .enable_mask
= BIT(0),
1128 .hw
.init
= &(struct clk_init_data
){
1129 .name
= "gcc_wcss5g_ref_clk",
1130 .parent_names
= (const char *[]){
1134 .ops
= &clk_branch2_ops
,
1135 .flags
= CLK_SET_RATE_PARENT
,
1140 static struct clk_branch gcc_wcss5g_rtc_clk
= {
1141 .halt_reg
= 0x20010,
1143 .enable_reg
= 0x20010,
1144 .enable_mask
= BIT(0),
1145 .hw
.init
= &(struct clk_init_data
){
1146 .name
= "gcc_wcss5g_rtc_clk",
1147 .parent_names
= (const char *[]){
1148 "gcc_sleep_clk_src",
1151 .ops
= &clk_branch2_ops
,
1152 .flags
= CLK_SET_RATE_PARENT
,
1157 static struct clk_regmap
*gcc_ipq4019_clocks
[] = {
1158 [AUDIO_CLK_SRC
] = &audio_clk_src
.clkr
,
1159 [BLSP1_QUP1_I2C_APPS_CLK_SRC
] = &blsp1_qup1_i2c_apps_clk_src
.clkr
,
1160 [BLSP1_QUP1_SPI_APPS_CLK_SRC
] = &blsp1_qup1_spi_apps_clk_src
.clkr
,
1161 [BLSP1_QUP2_I2C_APPS_CLK_SRC
] = &blsp1_qup2_i2c_apps_clk_src
.clkr
,
1162 [BLSP1_QUP2_SPI_APPS_CLK_SRC
] = &blsp1_qup2_spi_apps_clk_src
.clkr
,
1163 [BLSP1_UART1_APPS_CLK_SRC
] = &blsp1_uart1_apps_clk_src
.clkr
,
1164 [BLSP1_UART2_APPS_CLK_SRC
] = &blsp1_uart2_apps_clk_src
.clkr
,
1165 [GCC_USB3_MOCK_UTMI_CLK_SRC
] = &usb30_mock_utmi_clk_src
.clkr
,
1166 [GCC_APPS_CLK_SRC
] = &apps_clk_src
.clkr
,
1167 [GCC_APPS_AHB_CLK_SRC
] = &apps_ahb_clk_src
.clkr
,
1168 [GP1_CLK_SRC
] = &gp1_clk_src
.clkr
,
1169 [GP2_CLK_SRC
] = &gp2_clk_src
.clkr
,
1170 [GP3_CLK_SRC
] = &gp3_clk_src
.clkr
,
1171 [SDCC1_APPS_CLK_SRC
] = &sdcc1_apps_clk_src
.clkr
,
1172 [FEPHY_125M_DLY_CLK_SRC
] = &fephy_125m_dly_clk_src
.clkr
,
1173 [WCSS2G_CLK_SRC
] = &wcss2g_clk_src
.clkr
,
1174 [WCSS5G_CLK_SRC
] = &wcss5g_clk_src
.clkr
,
1175 [GCC_APSS_AHB_CLK
] = &gcc_apss_ahb_clk
.clkr
,
1176 [GCC_AUDIO_AHB_CLK
] = &gcc_audio_ahb_clk
.clkr
,
1177 [GCC_AUDIO_PWM_CLK
] = &gcc_audio_pwm_clk
.clkr
,
1178 [GCC_BLSP1_AHB_CLK
] = &gcc_blsp1_ahb_clk
.clkr
,
1179 [GCC_BLSP1_QUP1_I2C_APPS_CLK
] = &gcc_blsp1_qup1_i2c_apps_clk
.clkr
,
1180 [GCC_BLSP1_QUP1_SPI_APPS_CLK
] = &gcc_blsp1_qup1_spi_apps_clk
.clkr
,
1181 [GCC_BLSP1_QUP2_I2C_APPS_CLK
] = &gcc_blsp1_qup2_i2c_apps_clk
.clkr
,
1182 [GCC_BLSP1_QUP2_SPI_APPS_CLK
] = &gcc_blsp1_qup2_spi_apps_clk
.clkr
,
1183 [GCC_BLSP1_UART1_APPS_CLK
] = &gcc_blsp1_uart1_apps_clk
.clkr
,
1184 [GCC_BLSP1_UART2_APPS_CLK
] = &gcc_blsp1_uart2_apps_clk
.clkr
,
1185 [GCC_DCD_XO_CLK
] = &gcc_dcd_xo_clk
.clkr
,
1186 [GCC_GP1_CLK
] = &gcc_gp1_clk
.clkr
,
1187 [GCC_GP2_CLK
] = &gcc_gp2_clk
.clkr
,
1188 [GCC_GP3_CLK
] = &gcc_gp3_clk
.clkr
,
1189 [GCC_BOOT_ROM_AHB_CLK
] = &gcc_boot_rom_ahb_clk
.clkr
,
1190 [GCC_CRYPTO_AHB_CLK
] = &gcc_crypto_ahb_clk
.clkr
,
1191 [GCC_CRYPTO_AXI_CLK
] = &gcc_crypto_axi_clk
.clkr
,
1192 [GCC_CRYPTO_CLK
] = &gcc_crypto_clk
.clkr
,
1193 [GCC_ESS_CLK
] = &gcc_ess_clk
.clkr
,
1194 [GCC_IMEM_AXI_CLK
] = &gcc_imem_axi_clk
.clkr
,
1195 [GCC_IMEM_CFG_AHB_CLK
] = &gcc_imem_cfg_ahb_clk
.clkr
,
1196 [GCC_PCIE_AHB_CLK
] = &gcc_pcie_ahb_clk
.clkr
,
1197 [GCC_PCIE_AXI_M_CLK
] = &gcc_pcie_axi_m_clk
.clkr
,
1198 [GCC_PCIE_AXI_S_CLK
] = &gcc_pcie_axi_s_clk
.clkr
,
1199 [GCC_PRNG_AHB_CLK
] = &gcc_prng_ahb_clk
.clkr
,
1200 [GCC_QPIC_AHB_CLK
] = &gcc_qpic_ahb_clk
.clkr
,
1201 [GCC_QPIC_CLK
] = &gcc_qpic_clk
.clkr
,
1202 [GCC_SDCC1_AHB_CLK
] = &gcc_sdcc1_ahb_clk
.clkr
,
1203 [GCC_SDCC1_APPS_CLK
] = &gcc_sdcc1_apps_clk
.clkr
,
1204 [GCC_TLMM_AHB_CLK
] = &gcc_tlmm_ahb_clk
.clkr
,
1205 [GCC_USB2_MASTER_CLK
] = &gcc_usb2_master_clk
.clkr
,
1206 [GCC_USB2_SLEEP_CLK
] = &gcc_usb2_sleep_clk
.clkr
,
1207 [GCC_USB2_MOCK_UTMI_CLK
] = &gcc_usb2_mock_utmi_clk
.clkr
,
1208 [GCC_USB3_MASTER_CLK
] = &gcc_usb3_master_clk
.clkr
,
1209 [GCC_USB3_SLEEP_CLK
] = &gcc_usb3_sleep_clk
.clkr
,
1210 [GCC_USB3_MOCK_UTMI_CLK
] = &gcc_usb3_mock_utmi_clk
.clkr
,
1211 [GCC_WCSS2G_CLK
] = &gcc_wcss2g_clk
.clkr
,
1212 [GCC_WCSS2G_REF_CLK
] = &gcc_wcss2g_ref_clk
.clkr
,
1213 [GCC_WCSS2G_RTC_CLK
] = &gcc_wcss2g_rtc_clk
.clkr
,
1214 [GCC_WCSS5G_CLK
] = &gcc_wcss5g_clk
.clkr
,
1215 [GCC_WCSS5G_REF_CLK
] = &gcc_wcss5g_ref_clk
.clkr
,
1216 [GCC_WCSS5G_RTC_CLK
] = &gcc_wcss5g_rtc_clk
.clkr
,
1219 static const struct qcom_reset_map gcc_ipq4019_resets
[] = {
1220 [WIFI0_CPU_INIT_RESET
] = { 0x1f008, 5 },
1221 [WIFI0_RADIO_SRIF_RESET
] = { 0x1f008, 4 },
1222 [WIFI0_RADIO_WARM_RESET
] = { 0x1f008, 3 },
1223 [WIFI0_RADIO_COLD_RESET
] = { 0x1f008, 2 },
1224 [WIFI0_CORE_WARM_RESET
] = { 0x1f008, 1 },
1225 [WIFI0_CORE_COLD_RESET
] = { 0x1f008, 0 },
1226 [WIFI1_CPU_INIT_RESET
] = { 0x20008, 5 },
1227 [WIFI1_RADIO_SRIF_RESET
] = { 0x20008, 4 },
1228 [WIFI1_RADIO_WARM_RESET
] = { 0x20008, 3 },
1229 [WIFI1_RADIO_COLD_RESET
] = { 0x20008, 2 },
1230 [WIFI1_CORE_WARM_RESET
] = { 0x20008, 1 },
1231 [WIFI1_CORE_COLD_RESET
] = { 0x20008, 0 },
1232 [USB3_UNIPHY_PHY_ARES
] = { 0x1e038, 5 },
1233 [USB3_HSPHY_POR_ARES
] = { 0x1e038, 4 },
1234 [USB3_HSPHY_S_ARES
] = { 0x1e038, 2 },
1235 [USB2_HSPHY_POR_ARES
] = { 0x1e01c, 4 },
1236 [USB2_HSPHY_S_ARES
] = { 0x1e01c, 2 },
1237 [PCIE_PHY_AHB_ARES
] = { 0x1d010, 11 },
1238 [PCIE_AHB_ARES
] = { 0x1d010, 10 },
1239 [PCIE_PWR_ARES
] = { 0x1d010, 9 },
1240 [PCIE_PIPE_STICKY_ARES
] = { 0x1d010, 8 },
1241 [PCIE_AXI_M_STICKY_ARES
] = { 0x1d010, 7 },
1242 [PCIE_PHY_ARES
] = { 0x1d010, 6 },
1243 [PCIE_PARF_XPU_ARES
] = { 0x1d010, 5 },
1244 [PCIE_AXI_S_XPU_ARES
] = { 0x1d010, 4 },
1245 [PCIE_AXI_M_VMIDMT_ARES
] = { 0x1d010, 3 },
1246 [PCIE_PIPE_ARES
] = { 0x1d010, 2 },
1247 [PCIE_AXI_S_ARES
] = { 0x1d010, 1 },
1248 [PCIE_AXI_M_ARES
] = { 0x1d010, 0 },
1249 [ESS_RESET
] = { 0x12008, 0},
1250 [GCC_BLSP1_BCR
] = {0x01000, 0},
1251 [GCC_BLSP1_QUP1_BCR
] = {0x02000, 0},
1252 [GCC_BLSP1_UART1_BCR
] = {0x02038, 0},
1253 [GCC_BLSP1_QUP2_BCR
] = {0x03008, 0},
1254 [GCC_BLSP1_UART2_BCR
] = {0x03028, 0},
1255 [GCC_BIMC_BCR
] = {0x04000, 0},
1256 [GCC_TLMM_BCR
] = {0x05000, 0},
1257 [GCC_IMEM_BCR
] = {0x0E000, 0},
1258 [GCC_ESS_BCR
] = {0x12008, 0},
1259 [GCC_PRNG_BCR
] = {0x13000, 0},
1260 [GCC_BOOT_ROM_BCR
] = {0x13008, 0},
1261 [GCC_CRYPTO_BCR
] = {0x16000, 0},
1262 [GCC_SDCC1_BCR
] = {0x18000, 0},
1263 [GCC_SEC_CTRL_BCR
] = {0x1A000, 0},
1264 [GCC_AUDIO_BCR
] = {0x1B008, 0},
1265 [GCC_QPIC_BCR
] = {0x1C000, 0},
1266 [GCC_PCIE_BCR
] = {0x1D000, 0},
1267 [GCC_USB2_BCR
] = {0x1E008, 0},
1268 [GCC_USB2_PHY_BCR
] = {0x1E018, 0},
1269 [GCC_USB3_BCR
] = {0x1E024, 0},
1270 [GCC_USB3_PHY_BCR
] = {0x1E034, 0},
1271 [GCC_SYSTEM_NOC_BCR
] = {0x21000, 0},
1272 [GCC_PCNOC_BCR
] = {0x2102C, 0},
1273 [GCC_DCD_BCR
] = {0x21038, 0},
1274 [GCC_SNOC_BUS_TIMEOUT0_BCR
] = {0x21064, 0},
1275 [GCC_SNOC_BUS_TIMEOUT1_BCR
] = {0x2106C, 0},
1276 [GCC_SNOC_BUS_TIMEOUT2_BCR
] = {0x21074, 0},
1277 [GCC_SNOC_BUS_TIMEOUT3_BCR
] = {0x2107C, 0},
1278 [GCC_PCNOC_BUS_TIMEOUT0_BCR
] = {0x21084, 0},
1279 [GCC_PCNOC_BUS_TIMEOUT1_BCR
] = {0x2108C, 0},
1280 [GCC_PCNOC_BUS_TIMEOUT2_BCR
] = {0x21094, 0},
1281 [GCC_PCNOC_BUS_TIMEOUT3_BCR
] = {0x2109C, 0},
1282 [GCC_PCNOC_BUS_TIMEOUT4_BCR
] = {0x210A4, 0},
1283 [GCC_PCNOC_BUS_TIMEOUT5_BCR
] = {0x210AC, 0},
1284 [GCC_PCNOC_BUS_TIMEOUT6_BCR
] = {0x210B4, 0},
1285 [GCC_PCNOC_BUS_TIMEOUT7_BCR
] = {0x210BC, 0},
1286 [GCC_PCNOC_BUS_TIMEOUT8_BCR
] = {0x210C4, 0},
1287 [GCC_PCNOC_BUS_TIMEOUT9_BCR
] = {0x210CC, 0},
1288 [GCC_TCSR_BCR
] = {0x22000, 0},
1289 [GCC_MPM_BCR
] = {0x24000, 0},
1290 [GCC_SPDM_BCR
] = {0x25000, 0},
1293 static const struct regmap_config gcc_ipq4019_regmap_config
= {
1297 .max_register
= 0x2dfff,
1301 static const struct qcom_cc_desc gcc_ipq4019_desc
= {
1302 .config
= &gcc_ipq4019_regmap_config
,
1303 .clks
= gcc_ipq4019_clocks
,
1304 .num_clks
= ARRAY_SIZE(gcc_ipq4019_clocks
),
1305 .resets
= gcc_ipq4019_resets
,
1306 .num_resets
= ARRAY_SIZE(gcc_ipq4019_resets
),
1309 static const struct of_device_id gcc_ipq4019_match_table
[] = {
1310 { .compatible
= "qcom,gcc-ipq4019" },
1313 MODULE_DEVICE_TABLE(of
, gcc_ipq4019_match_table
);
1315 static int gcc_ipq4019_probe(struct platform_device
*pdev
)
1317 struct device
*dev
= &pdev
->dev
;
1319 clk_register_fixed_rate(dev
, "fepll125", "xo", 0, 200000000);
1320 clk_register_fixed_rate(dev
, "fepll125dly", "xo", 0, 200000000);
1321 clk_register_fixed_rate(dev
, "fepllwcss2g", "xo", 0, 200000000);
1322 clk_register_fixed_rate(dev
, "fepllwcss5g", "xo", 0, 200000000);
1323 clk_register_fixed_rate(dev
, "fepll200", "xo", 0, 200000000);
1324 clk_register_fixed_rate(dev
, "fepll500", "xo", 0, 200000000);
1325 clk_register_fixed_rate(dev
, "ddrpllapss", "xo", 0, 666000000);
1327 return qcom_cc_probe(pdev
, &gcc_ipq4019_desc
);
1330 static struct platform_driver gcc_ipq4019_driver
= {
1331 .probe
= gcc_ipq4019_probe
,
1333 .name
= "qcom,gcc-ipq4019",
1334 .of_match_table
= gcc_ipq4019_match_table
,
1338 static int __init
gcc_ipq4019_init(void)
1340 return platform_driver_register(&gcc_ipq4019_driver
);
1342 core_initcall(gcc_ipq4019_init
);
1344 static void __exit
gcc_ipq4019_exit(void)
1346 platform_driver_unregister(&gcc_ipq4019_driver
);
1348 module_exit(gcc_ipq4019_exit
);
1350 MODULE_ALIAS("platform:gcc-ipq4019");
1351 MODULE_LICENSE("GPL v2");
1352 MODULE_DESCRIPTION("QCOM GCC IPQ4019 driver");