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(19200000, P_XO
, 1, 2, 5),
189 F(24000000, P_XO
, 1, 1, 2),
193 static struct clk_rcg2 blsp1_qup1_i2c_apps_clk_src
= {
196 .parent_map
= gcc_xo_200_map
,
197 .freq_tbl
= ftbl_gcc_blsp1_qup1_2_i2c_apps_clk
,
198 .clkr
.hw
.init
= &(struct clk_init_data
){
199 .name
= "blsp1_qup1_i2c_apps_clk_src",
200 .parent_names
= gcc_xo_200
,
202 .ops
= &clk_rcg2_ops
,
206 static struct clk_branch gcc_blsp1_qup1_i2c_apps_clk
= {
209 .enable_reg
= 0x2008,
210 .enable_mask
= BIT(0),
211 .hw
.init
= &(struct clk_init_data
){
212 .name
= "gcc_blsp1_qup1_i2c_apps_clk",
213 .parent_names
= (const char *[]){
214 "blsp1_qup1_i2c_apps_clk_src",
217 .ops
= &clk_branch2_ops
,
218 .flags
= CLK_SET_RATE_PARENT
,
223 static struct clk_rcg2 blsp1_qup2_i2c_apps_clk_src
= {
226 .parent_map
= gcc_xo_200_map
,
227 .freq_tbl
= ftbl_gcc_blsp1_qup1_2_i2c_apps_clk
,
228 .clkr
.hw
.init
= &(struct clk_init_data
){
229 .name
= "blsp1_qup2_i2c_apps_clk_src",
230 .parent_names
= gcc_xo_200
,
232 .ops
= &clk_rcg2_ops
,
236 static struct clk_branch gcc_blsp1_qup2_i2c_apps_clk
= {
239 .enable_reg
= 0x3010,
240 .enable_mask
= BIT(0),
241 .hw
.init
= &(struct clk_init_data
){
242 .name
= "gcc_blsp1_qup2_i2c_apps_clk",
243 .parent_names
= (const char *[]){
244 "blsp1_qup2_i2c_apps_clk_src",
247 .ops
= &clk_branch2_ops
,
248 .flags
= CLK_SET_RATE_PARENT
,
253 static const struct freq_tbl ftbl_gcc_blsp1_qup1_2_spi_apps_clk
[] = {
254 F(960000, P_XO
, 12, 1, 4),
255 F(4800000, P_XO
, 1, 1, 10),
256 F(9600000, P_XO
, 1, 1, 5),
257 F(15000000, P_XO
, 1, 1, 3),
258 F(19200000, P_XO
, 1, 2, 5),
259 F(24000000, P_XO
, 1, 1, 2),
260 F(48000000, P_XO
, 1, 0, 0),
264 static struct clk_rcg2 blsp1_qup1_spi_apps_clk_src
= {
268 .parent_map
= gcc_xo_200_spi_map
,
269 .freq_tbl
= ftbl_gcc_blsp1_qup1_2_spi_apps_clk
,
270 .clkr
.hw
.init
= &(struct clk_init_data
){
271 .name
= "blsp1_qup1_spi_apps_clk_src",
272 .parent_names
= gcc_xo_200_spi
,
274 .ops
= &clk_rcg2_ops
,
278 static struct clk_branch gcc_blsp1_qup1_spi_apps_clk
= {
281 .enable_reg
= 0x2004,
282 .enable_mask
= BIT(0),
283 .hw
.init
= &(struct clk_init_data
){
284 .name
= "gcc_blsp1_qup1_spi_apps_clk",
285 .parent_names
= (const char *[]){
286 "blsp1_qup1_spi_apps_clk_src",
289 .ops
= &clk_branch2_ops
,
290 .flags
= CLK_SET_RATE_PARENT
,
295 static struct clk_rcg2 blsp1_qup2_spi_apps_clk_src
= {
299 .freq_tbl
= ftbl_gcc_blsp1_qup1_2_spi_apps_clk
,
300 .parent_map
= gcc_xo_200_spi_map
,
301 .clkr
.hw
.init
= &(struct clk_init_data
){
302 .name
= "blsp1_qup2_spi_apps_clk_src",
303 .parent_names
= gcc_xo_200_spi
,
305 .ops
= &clk_rcg2_ops
,
309 static struct clk_branch gcc_blsp1_qup2_spi_apps_clk
= {
312 .enable_reg
= 0x300c,
313 .enable_mask
= BIT(0),
314 .hw
.init
= &(struct clk_init_data
){
315 .name
= "gcc_blsp1_qup2_spi_apps_clk",
316 .parent_names
= (const char *[]){
317 "blsp1_qup2_spi_apps_clk_src",
320 .ops
= &clk_branch2_ops
,
321 .flags
= CLK_SET_RATE_PARENT
,
326 static const struct freq_tbl ftbl_gcc_blsp1_uart1_2_apps_clk
[] = {
327 F(1843200, P_FEPLL200
, 1, 144, 15625),
328 F(3686400, P_FEPLL200
, 1, 288, 15625),
329 F(7372800, P_FEPLL200
, 1, 576, 15625),
330 F(14745600, P_FEPLL200
, 1, 1152, 15625),
331 F(16000000, P_FEPLL200
, 1, 2, 25),
332 F(24000000, P_XO
, 1, 1, 2),
333 F(32000000, P_FEPLL200
, 1, 4, 25),
334 F(40000000, P_FEPLL200
, 1, 1, 5),
335 F(46400000, P_FEPLL200
, 1, 29, 125),
336 F(48000000, P_XO
, 1, 0, 0),
340 static struct clk_rcg2 blsp1_uart1_apps_clk_src
= {
344 .freq_tbl
= ftbl_gcc_blsp1_uart1_2_apps_clk
,
345 .parent_map
= gcc_xo_200_spi_map
,
346 .clkr
.hw
.init
= &(struct clk_init_data
){
347 .name
= "blsp1_uart1_apps_clk_src",
348 .parent_names
= gcc_xo_200_spi
,
350 .ops
= &clk_rcg2_ops
,
354 static struct clk_branch gcc_blsp1_uart1_apps_clk
= {
357 .enable_reg
= 0x203c,
358 .enable_mask
= BIT(0),
359 .hw
.init
= &(struct clk_init_data
){
360 .name
= "gcc_blsp1_uart1_apps_clk",
361 .parent_names
= (const char *[]){
362 "blsp1_uart1_apps_clk_src",
364 .flags
= CLK_SET_RATE_PARENT
,
366 .ops
= &clk_branch2_ops
,
371 static struct clk_rcg2 blsp1_uart2_apps_clk_src
= {
375 .freq_tbl
= ftbl_gcc_blsp1_uart1_2_apps_clk
,
376 .parent_map
= gcc_xo_200_spi_map
,
377 .clkr
.hw
.init
= &(struct clk_init_data
){
378 .name
= "blsp1_uart2_apps_clk_src",
379 .parent_names
= gcc_xo_200_spi
,
381 .ops
= &clk_rcg2_ops
,
385 static struct clk_branch gcc_blsp1_uart2_apps_clk
= {
388 .enable_reg
= 0x302c,
389 .enable_mask
= BIT(0),
390 .hw
.init
= &(struct clk_init_data
){
391 .name
= "gcc_blsp1_uart2_apps_clk",
392 .parent_names
= (const char *[]){
393 "blsp1_uart2_apps_clk_src",
396 .ops
= &clk_branch2_ops
,
397 .flags
= CLK_SET_RATE_PARENT
,
402 static const struct freq_tbl ftbl_gcc_gp_clk
[] = {
403 F(1250000, P_FEPLL200
, 1, 16, 0),
404 F(2500000, P_FEPLL200
, 1, 8, 0),
405 F(5000000, P_FEPLL200
, 1, 4, 0),
409 static struct clk_rcg2 gp1_clk_src
= {
413 .freq_tbl
= ftbl_gcc_gp_clk
,
414 .parent_map
= gcc_xo_200_map
,
415 .clkr
.hw
.init
= &(struct clk_init_data
){
416 .name
= "gp1_clk_src",
417 .parent_names
= gcc_xo_200
,
419 .ops
= &clk_rcg2_ops
,
423 static struct clk_branch gcc_gp1_clk
= {
426 .enable_reg
= 0x8000,
427 .enable_mask
= BIT(0),
428 .hw
.init
= &(struct clk_init_data
){
429 .name
= "gcc_gp1_clk",
430 .parent_names
= (const char *[]){
434 .ops
= &clk_branch2_ops
,
435 .flags
= CLK_SET_RATE_PARENT
,
440 static struct clk_rcg2 gp2_clk_src
= {
444 .freq_tbl
= ftbl_gcc_gp_clk
,
445 .parent_map
= gcc_xo_200_map
,
446 .clkr
.hw
.init
= &(struct clk_init_data
){
447 .name
= "gp2_clk_src",
448 .parent_names
= gcc_xo_200
,
450 .ops
= &clk_rcg2_ops
,
454 static struct clk_branch gcc_gp2_clk
= {
457 .enable_reg
= 0x9000,
458 .enable_mask
= BIT(0),
459 .hw
.init
= &(struct clk_init_data
){
460 .name
= "gcc_gp2_clk",
461 .parent_names
= (const char *[]){
465 .ops
= &clk_branch2_ops
,
466 .flags
= CLK_SET_RATE_PARENT
,
471 static struct clk_rcg2 gp3_clk_src
= {
475 .freq_tbl
= ftbl_gcc_gp_clk
,
476 .parent_map
= gcc_xo_200_map
,
477 .clkr
.hw
.init
= &(struct clk_init_data
){
478 .name
= "gp3_clk_src",
479 .parent_names
= gcc_xo_200
,
481 .ops
= &clk_rcg2_ops
,
485 static struct clk_branch gcc_gp3_clk
= {
488 .enable_reg
= 0xa000,
489 .enable_mask
= BIT(0),
490 .hw
.init
= &(struct clk_init_data
){
491 .name
= "gcc_gp3_clk",
492 .parent_names
= (const char *[]){
496 .ops
= &clk_branch2_ops
,
497 .flags
= CLK_SET_RATE_PARENT
,
502 static const struct freq_tbl ftbl_gcc_sdcc1_apps_clk
[] = {
503 F(144000, P_XO
, 1, 3, 240),
504 F(400000, P_XO
, 1, 1, 0),
505 F(20000000, P_FEPLL500
, 1, 1, 25),
506 F(25000000, P_FEPLL500
, 1, 1, 20),
507 F(50000000, P_FEPLL500
, 1, 1, 10),
508 F(100000000, P_FEPLL500
, 1, 1, 5),
509 F(193000000, P_DDRPLL
, 1, 0, 0),
513 static struct clk_rcg2 sdcc1_apps_clk_src
= {
516 .freq_tbl
= ftbl_gcc_sdcc1_apps_clk
,
517 .parent_map
= gcc_xo_sdcc1_500_map
,
518 .clkr
.hw
.init
= &(struct clk_init_data
){
519 .name
= "sdcc1_apps_clk_src",
520 .parent_names
= gcc_xo_sdcc1_500
,
522 .ops
= &clk_rcg2_ops
,
523 .flags
= CLK_SET_RATE_PARENT
,
527 static const struct freq_tbl ftbl_gcc_apps_clk
[] = {
528 F(48000000, P_XO
, 1, 0, 0),
529 F(200000000, P_FEPLL200
, 1, 0, 0),
530 F(500000000, P_FEPLL500
, 1, 0, 0),
531 F(626000000, P_DDRPLLAPSS
, 1, 0, 0),
535 static struct clk_rcg2 apps_clk_src
= {
538 .freq_tbl
= ftbl_gcc_apps_clk
,
539 .parent_map
= gcc_xo_ddr_500_200_map
,
540 .clkr
.hw
.init
= &(struct clk_init_data
){
541 .name
= "apps_clk_src",
542 .parent_names
= gcc_xo_ddr_500_200
,
544 .ops
= &clk_rcg2_ops
,
548 static const struct freq_tbl ftbl_gcc_apps_ahb_clk
[] = {
549 F(48000000, P_XO
, 1, 0, 0),
550 F(100000000, P_FEPLL200
, 2, 0, 0),
554 static struct clk_rcg2 apps_ahb_clk_src
= {
557 .parent_map
= gcc_xo_200_500_map
,
558 .freq_tbl
= ftbl_gcc_apps_ahb_clk
,
559 .clkr
.hw
.init
= &(struct clk_init_data
){
560 .name
= "apps_ahb_clk_src",
561 .parent_names
= gcc_xo_200_500
,
563 .ops
= &clk_rcg2_ops
,
567 static struct clk_branch gcc_apss_ahb_clk
= {
569 .halt_check
= BRANCH_HALT_VOTED
,
571 .enable_reg
= 0x6000,
572 .enable_mask
= BIT(14),
573 .hw
.init
= &(struct clk_init_data
){
574 .name
= "gcc_apss_ahb_clk",
575 .parent_names
= (const char *[]){
579 .ops
= &clk_branch2_ops
,
580 .flags
= CLK_SET_RATE_PARENT
,
585 static struct clk_branch gcc_blsp1_ahb_clk
= {
587 .halt_check
= BRANCH_HALT_VOTED
,
589 .enable_reg
= 0x6000,
590 .enable_mask
= BIT(10),
591 .hw
.init
= &(struct clk_init_data
){
592 .name
= "gcc_blsp1_ahb_clk",
593 .parent_names
= (const char *[]){
597 .ops
= &clk_branch2_ops
,
602 static struct clk_branch gcc_dcd_xo_clk
= {
605 .enable_reg
= 0x2103c,
606 .enable_mask
= BIT(0),
607 .hw
.init
= &(struct clk_init_data
){
608 .name
= "gcc_dcd_xo_clk",
609 .parent_names
= (const char *[]){
613 .ops
= &clk_branch2_ops
,
618 static struct clk_branch gcc_boot_rom_ahb_clk
= {
621 .enable_reg
= 0x1300c,
622 .enable_mask
= BIT(0),
623 .hw
.init
= &(struct clk_init_data
){
624 .name
= "gcc_boot_rom_ahb_clk",
625 .parent_names
= (const char *[]){
629 .ops
= &clk_branch2_ops
,
630 .flags
= CLK_SET_RATE_PARENT
,
635 static struct clk_branch gcc_crypto_ahb_clk
= {
637 .halt_check
= BRANCH_HALT_VOTED
,
639 .enable_reg
= 0x6000,
640 .enable_mask
= BIT(0),
641 .hw
.init
= &(struct clk_init_data
){
642 .name
= "gcc_crypto_ahb_clk",
643 .parent_names
= (const char *[]){
647 .ops
= &clk_branch2_ops
,
652 static struct clk_branch gcc_crypto_axi_clk
= {
654 .halt_check
= BRANCH_HALT_VOTED
,
656 .enable_reg
= 0x6000,
657 .enable_mask
= BIT(1),
658 .hw
.init
= &(struct clk_init_data
){
659 .name
= "gcc_crypto_axi_clk",
660 .parent_names
= (const char *[]){
664 .ops
= &clk_branch2_ops
,
669 static struct clk_branch gcc_crypto_clk
= {
671 .halt_check
= BRANCH_HALT_VOTED
,
673 .enable_reg
= 0x6000,
674 .enable_mask
= BIT(2),
675 .hw
.init
= &(struct clk_init_data
){
676 .name
= "gcc_crypto_clk",
677 .parent_names
= (const char *[]){
681 .ops
= &clk_branch2_ops
,
686 static struct clk_branch gcc_ess_clk
= {
689 .enable_reg
= 0x12010,
690 .enable_mask
= BIT(0),
691 .hw
.init
= &(struct clk_init_data
){
692 .name
= "gcc_ess_clk",
693 .parent_names
= (const char *[]){
694 "fephy_125m_dly_clk_src",
697 .ops
= &clk_branch2_ops
,
698 .flags
= CLK_SET_RATE_PARENT
,
703 static struct clk_branch gcc_imem_axi_clk
= {
705 .halt_check
= BRANCH_HALT_VOTED
,
707 .enable_reg
= 0x6000,
708 .enable_mask
= BIT(17),
709 .hw
.init
= &(struct clk_init_data
){
710 .name
= "gcc_imem_axi_clk",
711 .parent_names
= (const char *[]){
715 .ops
= &clk_branch2_ops
,
720 static struct clk_branch gcc_imem_cfg_ahb_clk
= {
723 .enable_reg
= 0xe008,
724 .enable_mask
= BIT(0),
725 .hw
.init
= &(struct clk_init_data
){
726 .name
= "gcc_imem_cfg_ahb_clk",
727 .parent_names
= (const char *[]){
731 .ops
= &clk_branch2_ops
,
736 static struct clk_branch gcc_pcie_ahb_clk
= {
739 .enable_reg
= 0x1d00c,
740 .enable_mask
= BIT(0),
741 .hw
.init
= &(struct clk_init_data
){
742 .name
= "gcc_pcie_ahb_clk",
743 .parent_names
= (const char *[]){
747 .ops
= &clk_branch2_ops
,
752 static struct clk_branch gcc_pcie_axi_m_clk
= {
755 .enable_reg
= 0x1d004,
756 .enable_mask
= BIT(0),
757 .hw
.init
= &(struct clk_init_data
){
758 .name
= "gcc_pcie_axi_m_clk",
759 .parent_names
= (const char *[]){
763 .ops
= &clk_branch2_ops
,
768 static struct clk_branch gcc_pcie_axi_s_clk
= {
771 .enable_reg
= 0x1d008,
772 .enable_mask
= BIT(0),
773 .hw
.init
= &(struct clk_init_data
){
774 .name
= "gcc_pcie_axi_s_clk",
775 .parent_names
= (const char *[]){
779 .ops
= &clk_branch2_ops
,
784 static struct clk_branch gcc_prng_ahb_clk
= {
786 .halt_check
= BRANCH_HALT_VOTED
,
788 .enable_reg
= 0x6000,
789 .enable_mask
= BIT(8),
790 .hw
.init
= &(struct clk_init_data
){
791 .name
= "gcc_prng_ahb_clk",
792 .parent_names
= (const char *[]){
796 .ops
= &clk_branch2_ops
,
801 static struct clk_branch gcc_qpic_ahb_clk
= {
804 .enable_reg
= 0x1c008,
805 .enable_mask
= BIT(0),
806 .hw
.init
= &(struct clk_init_data
){
807 .name
= "gcc_qpic_ahb_clk",
808 .parent_names
= (const char *[]){
812 .ops
= &clk_branch2_ops
,
817 static struct clk_branch gcc_qpic_clk
= {
820 .enable_reg
= 0x1c004,
821 .enable_mask
= BIT(0),
822 .hw
.init
= &(struct clk_init_data
){
823 .name
= "gcc_qpic_clk",
824 .parent_names
= (const char *[]){
828 .ops
= &clk_branch2_ops
,
833 static struct clk_branch gcc_sdcc1_ahb_clk
= {
836 .enable_reg
= 0x18010,
837 .enable_mask
= BIT(0),
838 .hw
.init
= &(struct clk_init_data
){
839 .name
= "gcc_sdcc1_ahb_clk",
840 .parent_names
= (const char *[]){
844 .ops
= &clk_branch2_ops
,
849 static struct clk_branch gcc_sdcc1_apps_clk
= {
852 .enable_reg
= 0x1800c,
853 .enable_mask
= BIT(0),
854 .hw
.init
= &(struct clk_init_data
){
855 .name
= "gcc_sdcc1_apps_clk",
856 .parent_names
= (const char *[]){
857 "sdcc1_apps_clk_src",
860 .ops
= &clk_branch2_ops
,
861 .flags
= CLK_SET_RATE_PARENT
,
866 static struct clk_branch gcc_tlmm_ahb_clk
= {
868 .halt_check
= BRANCH_HALT_VOTED
,
870 .enable_reg
= 0x6000,
871 .enable_mask
= BIT(5),
872 .hw
.init
= &(struct clk_init_data
){
873 .name
= "gcc_tlmm_ahb_clk",
874 .parent_names
= (const char *[]){
878 .ops
= &clk_branch2_ops
,
883 static struct clk_branch gcc_usb2_master_clk
= {
886 .enable_reg
= 0x1e00c,
887 .enable_mask
= BIT(0),
888 .hw
.init
= &(struct clk_init_data
){
889 .name
= "gcc_usb2_master_clk",
890 .parent_names
= (const char *[]){
894 .ops
= &clk_branch2_ops
,
899 static struct clk_branch gcc_usb2_sleep_clk
= {
902 .enable_reg
= 0x1e010,
903 .enable_mask
= BIT(0),
904 .hw
.init
= &(struct clk_init_data
){
905 .name
= "gcc_usb2_sleep_clk",
906 .parent_names
= (const char *[]){
910 .ops
= &clk_branch2_ops
,
915 static struct clk_branch gcc_usb2_mock_utmi_clk
= {
918 .enable_reg
= 0x1e014,
919 .enable_mask
= BIT(0),
920 .hw
.init
= &(struct clk_init_data
){
921 .name
= "gcc_usb2_mock_utmi_clk",
922 .parent_names
= (const char *[]){
923 "usb30_mock_utmi_clk_src",
926 .ops
= &clk_branch2_ops
,
927 .flags
= CLK_SET_RATE_PARENT
,
932 static const struct freq_tbl ftbl_gcc_usb30_mock_utmi_clk
[] = {
933 F(2000000, P_FEPLL200
, 10, 0, 0),
937 static struct clk_rcg2 usb30_mock_utmi_clk_src
= {
940 .parent_map
= gcc_xo_200_map
,
941 .freq_tbl
= ftbl_gcc_usb30_mock_utmi_clk
,
942 .clkr
.hw
.init
= &(struct clk_init_data
){
943 .name
= "usb30_mock_utmi_clk_src",
944 .parent_names
= gcc_xo_200
,
946 .ops
= &clk_rcg2_ops
,
950 static struct clk_branch gcc_usb3_master_clk
= {
953 .enable_reg
= 0x1e028,
954 .enable_mask
= BIT(0),
955 .hw
.init
= &(struct clk_init_data
){
956 .name
= "gcc_usb3_master_clk",
957 .parent_names
= (const char *[]){
961 .ops
= &clk_branch2_ops
,
966 static struct clk_branch gcc_usb3_sleep_clk
= {
969 .enable_reg
= 0x1e02C,
970 .enable_mask
= BIT(0),
971 .hw
.init
= &(struct clk_init_data
){
972 .name
= "gcc_usb3_sleep_clk",
973 .parent_names
= (const char *[]){
977 .ops
= &clk_branch2_ops
,
982 static struct clk_branch gcc_usb3_mock_utmi_clk
= {
985 .enable_reg
= 0x1e030,
986 .enable_mask
= BIT(0),
987 .hw
.init
= &(struct clk_init_data
){
988 .name
= "gcc_usb3_mock_utmi_clk",
989 .parent_names
= (const char *[]){
990 "usb30_mock_utmi_clk_src",
993 .ops
= &clk_branch2_ops
,
994 .flags
= CLK_SET_RATE_PARENT
,
999 static const struct freq_tbl ftbl_gcc_fephy_dly_clk
[] = {
1000 F(125000000, P_FEPLL125DLY
, 1, 0, 0),
1004 static struct clk_rcg2 fephy_125m_dly_clk_src
= {
1005 .cmd_rcgr
= 0x12000,
1007 .parent_map
= gcc_xo_125_dly_map
,
1008 .freq_tbl
= ftbl_gcc_fephy_dly_clk
,
1009 .clkr
.hw
.init
= &(struct clk_init_data
){
1010 .name
= "fephy_125m_dly_clk_src",
1011 .parent_names
= gcc_xo_125_dly
,
1013 .ops
= &clk_rcg2_ops
,
1018 static const struct freq_tbl ftbl_gcc_wcss2g_clk
[] = {
1019 F(48000000, P_XO
, 1, 0, 0),
1020 F(250000000, P_FEPLLWCSS2G
, 1, 0, 0),
1024 static struct clk_rcg2 wcss2g_clk_src
= {
1025 .cmd_rcgr
= 0x1f000,
1027 .freq_tbl
= ftbl_gcc_wcss2g_clk
,
1028 .parent_map
= gcc_xo_wcss2g_map
,
1029 .clkr
.hw
.init
= &(struct clk_init_data
){
1030 .name
= "wcss2g_clk_src",
1031 .parent_names
= gcc_xo_wcss2g
,
1033 .ops
= &clk_rcg2_ops
,
1034 .flags
= CLK_SET_RATE_PARENT
,
1038 static struct clk_branch gcc_wcss2g_clk
= {
1039 .halt_reg
= 0x1f00C,
1041 .enable_reg
= 0x1f00C,
1042 .enable_mask
= BIT(0),
1043 .hw
.init
= &(struct clk_init_data
){
1044 .name
= "gcc_wcss2g_clk",
1045 .parent_names
= (const char *[]){
1049 .ops
= &clk_branch2_ops
,
1050 .flags
= CLK_SET_RATE_PARENT
,
1055 static struct clk_branch gcc_wcss2g_ref_clk
= {
1056 .halt_reg
= 0x1f00C,
1058 .enable_reg
= 0x1f00C,
1059 .enable_mask
= BIT(0),
1060 .hw
.init
= &(struct clk_init_data
){
1061 .name
= "gcc_wcss2g_ref_clk",
1062 .parent_names
= (const char *[]){
1066 .ops
= &clk_branch2_ops
,
1067 .flags
= CLK_SET_RATE_PARENT
,
1072 static struct clk_branch gcc_wcss2g_rtc_clk
= {
1073 .halt_reg
= 0x1f010,
1075 .enable_reg
= 0x1f010,
1076 .enable_mask
= BIT(0),
1077 .hw
.init
= &(struct clk_init_data
){
1078 .name
= "gcc_wcss2g_rtc_clk",
1079 .parent_names
= (const char *[]){
1080 "gcc_sleep_clk_src",
1083 .ops
= &clk_branch2_ops
,
1088 static const struct freq_tbl ftbl_gcc_wcss5g_clk
[] = {
1089 F(48000000, P_XO
, 1, 0, 0),
1090 F(250000000, P_FEPLLWCSS5G
, 1, 0, 0),
1094 static struct clk_rcg2 wcss5g_clk_src
= {
1095 .cmd_rcgr
= 0x20000,
1097 .parent_map
= gcc_xo_wcss5g_map
,
1098 .freq_tbl
= ftbl_gcc_wcss5g_clk
,
1099 .clkr
.hw
.init
= &(struct clk_init_data
){
1100 .name
= "wcss5g_clk_src",
1101 .parent_names
= gcc_xo_wcss5g
,
1103 .ops
= &clk_rcg2_ops
,
1107 static struct clk_branch gcc_wcss5g_clk
= {
1108 .halt_reg
= 0x2000c,
1110 .enable_reg
= 0x2000c,
1111 .enable_mask
= BIT(0),
1112 .hw
.init
= &(struct clk_init_data
){
1113 .name
= "gcc_wcss5g_clk",
1114 .parent_names
= (const char *[]){
1118 .ops
= &clk_branch2_ops
,
1119 .flags
= CLK_SET_RATE_PARENT
,
1124 static struct clk_branch gcc_wcss5g_ref_clk
= {
1125 .halt_reg
= 0x2000c,
1127 .enable_reg
= 0x2000c,
1128 .enable_mask
= BIT(0),
1129 .hw
.init
= &(struct clk_init_data
){
1130 .name
= "gcc_wcss5g_ref_clk",
1131 .parent_names
= (const char *[]){
1135 .ops
= &clk_branch2_ops
,
1136 .flags
= CLK_SET_RATE_PARENT
,
1141 static struct clk_branch gcc_wcss5g_rtc_clk
= {
1142 .halt_reg
= 0x20010,
1144 .enable_reg
= 0x20010,
1145 .enable_mask
= BIT(0),
1146 .hw
.init
= &(struct clk_init_data
){
1147 .name
= "gcc_wcss5g_rtc_clk",
1148 .parent_names
= (const char *[]){
1149 "gcc_sleep_clk_src",
1152 .ops
= &clk_branch2_ops
,
1153 .flags
= CLK_SET_RATE_PARENT
,
1158 static struct clk_regmap
*gcc_ipq4019_clocks
[] = {
1159 [AUDIO_CLK_SRC
] = &audio_clk_src
.clkr
,
1160 [BLSP1_QUP1_I2C_APPS_CLK_SRC
] = &blsp1_qup1_i2c_apps_clk_src
.clkr
,
1161 [BLSP1_QUP1_SPI_APPS_CLK_SRC
] = &blsp1_qup1_spi_apps_clk_src
.clkr
,
1162 [BLSP1_QUP2_I2C_APPS_CLK_SRC
] = &blsp1_qup2_i2c_apps_clk_src
.clkr
,
1163 [BLSP1_QUP2_SPI_APPS_CLK_SRC
] = &blsp1_qup2_spi_apps_clk_src
.clkr
,
1164 [BLSP1_UART1_APPS_CLK_SRC
] = &blsp1_uart1_apps_clk_src
.clkr
,
1165 [BLSP1_UART2_APPS_CLK_SRC
] = &blsp1_uart2_apps_clk_src
.clkr
,
1166 [GCC_USB3_MOCK_UTMI_CLK_SRC
] = &usb30_mock_utmi_clk_src
.clkr
,
1167 [GCC_APPS_CLK_SRC
] = &apps_clk_src
.clkr
,
1168 [GCC_APPS_AHB_CLK_SRC
] = &apps_ahb_clk_src
.clkr
,
1169 [GP1_CLK_SRC
] = &gp1_clk_src
.clkr
,
1170 [GP2_CLK_SRC
] = &gp2_clk_src
.clkr
,
1171 [GP3_CLK_SRC
] = &gp3_clk_src
.clkr
,
1172 [SDCC1_APPS_CLK_SRC
] = &sdcc1_apps_clk_src
.clkr
,
1173 [FEPHY_125M_DLY_CLK_SRC
] = &fephy_125m_dly_clk_src
.clkr
,
1174 [WCSS2G_CLK_SRC
] = &wcss2g_clk_src
.clkr
,
1175 [WCSS5G_CLK_SRC
] = &wcss5g_clk_src
.clkr
,
1176 [GCC_APSS_AHB_CLK
] = &gcc_apss_ahb_clk
.clkr
,
1177 [GCC_AUDIO_AHB_CLK
] = &gcc_audio_ahb_clk
.clkr
,
1178 [GCC_AUDIO_PWM_CLK
] = &gcc_audio_pwm_clk
.clkr
,
1179 [GCC_BLSP1_AHB_CLK
] = &gcc_blsp1_ahb_clk
.clkr
,
1180 [GCC_BLSP1_QUP1_I2C_APPS_CLK
] = &gcc_blsp1_qup1_i2c_apps_clk
.clkr
,
1181 [GCC_BLSP1_QUP1_SPI_APPS_CLK
] = &gcc_blsp1_qup1_spi_apps_clk
.clkr
,
1182 [GCC_BLSP1_QUP2_I2C_APPS_CLK
] = &gcc_blsp1_qup2_i2c_apps_clk
.clkr
,
1183 [GCC_BLSP1_QUP2_SPI_APPS_CLK
] = &gcc_blsp1_qup2_spi_apps_clk
.clkr
,
1184 [GCC_BLSP1_UART1_APPS_CLK
] = &gcc_blsp1_uart1_apps_clk
.clkr
,
1185 [GCC_BLSP1_UART2_APPS_CLK
] = &gcc_blsp1_uart2_apps_clk
.clkr
,
1186 [GCC_DCD_XO_CLK
] = &gcc_dcd_xo_clk
.clkr
,
1187 [GCC_GP1_CLK
] = &gcc_gp1_clk
.clkr
,
1188 [GCC_GP2_CLK
] = &gcc_gp2_clk
.clkr
,
1189 [GCC_GP3_CLK
] = &gcc_gp3_clk
.clkr
,
1190 [GCC_BOOT_ROM_AHB_CLK
] = &gcc_boot_rom_ahb_clk
.clkr
,
1191 [GCC_CRYPTO_AHB_CLK
] = &gcc_crypto_ahb_clk
.clkr
,
1192 [GCC_CRYPTO_AXI_CLK
] = &gcc_crypto_axi_clk
.clkr
,
1193 [GCC_CRYPTO_CLK
] = &gcc_crypto_clk
.clkr
,
1194 [GCC_ESS_CLK
] = &gcc_ess_clk
.clkr
,
1195 [GCC_IMEM_AXI_CLK
] = &gcc_imem_axi_clk
.clkr
,
1196 [GCC_IMEM_CFG_AHB_CLK
] = &gcc_imem_cfg_ahb_clk
.clkr
,
1197 [GCC_PCIE_AHB_CLK
] = &gcc_pcie_ahb_clk
.clkr
,
1198 [GCC_PCIE_AXI_M_CLK
] = &gcc_pcie_axi_m_clk
.clkr
,
1199 [GCC_PCIE_AXI_S_CLK
] = &gcc_pcie_axi_s_clk
.clkr
,
1200 [GCC_PRNG_AHB_CLK
] = &gcc_prng_ahb_clk
.clkr
,
1201 [GCC_QPIC_AHB_CLK
] = &gcc_qpic_ahb_clk
.clkr
,
1202 [GCC_QPIC_CLK
] = &gcc_qpic_clk
.clkr
,
1203 [GCC_SDCC1_AHB_CLK
] = &gcc_sdcc1_ahb_clk
.clkr
,
1204 [GCC_SDCC1_APPS_CLK
] = &gcc_sdcc1_apps_clk
.clkr
,
1205 [GCC_TLMM_AHB_CLK
] = &gcc_tlmm_ahb_clk
.clkr
,
1206 [GCC_USB2_MASTER_CLK
] = &gcc_usb2_master_clk
.clkr
,
1207 [GCC_USB2_SLEEP_CLK
] = &gcc_usb2_sleep_clk
.clkr
,
1208 [GCC_USB2_MOCK_UTMI_CLK
] = &gcc_usb2_mock_utmi_clk
.clkr
,
1209 [GCC_USB3_MASTER_CLK
] = &gcc_usb3_master_clk
.clkr
,
1210 [GCC_USB3_SLEEP_CLK
] = &gcc_usb3_sleep_clk
.clkr
,
1211 [GCC_USB3_MOCK_UTMI_CLK
] = &gcc_usb3_mock_utmi_clk
.clkr
,
1212 [GCC_WCSS2G_CLK
] = &gcc_wcss2g_clk
.clkr
,
1213 [GCC_WCSS2G_REF_CLK
] = &gcc_wcss2g_ref_clk
.clkr
,
1214 [GCC_WCSS2G_RTC_CLK
] = &gcc_wcss2g_rtc_clk
.clkr
,
1215 [GCC_WCSS5G_CLK
] = &gcc_wcss5g_clk
.clkr
,
1216 [GCC_WCSS5G_REF_CLK
] = &gcc_wcss5g_ref_clk
.clkr
,
1217 [GCC_WCSS5G_RTC_CLK
] = &gcc_wcss5g_rtc_clk
.clkr
,
1220 static const struct qcom_reset_map gcc_ipq4019_resets
[] = {
1221 [WIFI0_CPU_INIT_RESET
] = { 0x1f008, 5 },
1222 [WIFI0_RADIO_SRIF_RESET
] = { 0x1f008, 4 },
1223 [WIFI0_RADIO_WARM_RESET
] = { 0x1f008, 3 },
1224 [WIFI0_RADIO_COLD_RESET
] = { 0x1f008, 2 },
1225 [WIFI0_CORE_WARM_RESET
] = { 0x1f008, 1 },
1226 [WIFI0_CORE_COLD_RESET
] = { 0x1f008, 0 },
1227 [WIFI1_CPU_INIT_RESET
] = { 0x20008, 5 },
1228 [WIFI1_RADIO_SRIF_RESET
] = { 0x20008, 4 },
1229 [WIFI1_RADIO_WARM_RESET
] = { 0x20008, 3 },
1230 [WIFI1_RADIO_COLD_RESET
] = { 0x20008, 2 },
1231 [WIFI1_CORE_WARM_RESET
] = { 0x20008, 1 },
1232 [WIFI1_CORE_COLD_RESET
] = { 0x20008, 0 },
1233 [USB3_UNIPHY_PHY_ARES
] = { 0x1e038, 5 },
1234 [USB3_HSPHY_POR_ARES
] = { 0x1e038, 4 },
1235 [USB3_HSPHY_S_ARES
] = { 0x1e038, 2 },
1236 [USB2_HSPHY_POR_ARES
] = { 0x1e01c, 4 },
1237 [USB2_HSPHY_S_ARES
] = { 0x1e01c, 2 },
1238 [PCIE_PHY_AHB_ARES
] = { 0x1d010, 11 },
1239 [PCIE_AHB_ARES
] = { 0x1d010, 10 },
1240 [PCIE_PWR_ARES
] = { 0x1d010, 9 },
1241 [PCIE_PIPE_STICKY_ARES
] = { 0x1d010, 8 },
1242 [PCIE_AXI_M_STICKY_ARES
] = { 0x1d010, 7 },
1243 [PCIE_PHY_ARES
] = { 0x1d010, 6 },
1244 [PCIE_PARF_XPU_ARES
] = { 0x1d010, 5 },
1245 [PCIE_AXI_S_XPU_ARES
] = { 0x1d010, 4 },
1246 [PCIE_AXI_M_VMIDMT_ARES
] = { 0x1d010, 3 },
1247 [PCIE_PIPE_ARES
] = { 0x1d010, 2 },
1248 [PCIE_AXI_S_ARES
] = { 0x1d010, 1 },
1249 [PCIE_AXI_M_ARES
] = { 0x1d010, 0 },
1250 [ESS_RESET
] = { 0x12008, 0},
1251 [GCC_BLSP1_BCR
] = {0x01000, 0},
1252 [GCC_BLSP1_QUP1_BCR
] = {0x02000, 0},
1253 [GCC_BLSP1_UART1_BCR
] = {0x02038, 0},
1254 [GCC_BLSP1_QUP2_BCR
] = {0x03008, 0},
1255 [GCC_BLSP1_UART2_BCR
] = {0x03028, 0},
1256 [GCC_BIMC_BCR
] = {0x04000, 0},
1257 [GCC_TLMM_BCR
] = {0x05000, 0},
1258 [GCC_IMEM_BCR
] = {0x0E000, 0},
1259 [GCC_ESS_BCR
] = {0x12008, 0},
1260 [GCC_PRNG_BCR
] = {0x13000, 0},
1261 [GCC_BOOT_ROM_BCR
] = {0x13008, 0},
1262 [GCC_CRYPTO_BCR
] = {0x16000, 0},
1263 [GCC_SDCC1_BCR
] = {0x18000, 0},
1264 [GCC_SEC_CTRL_BCR
] = {0x1A000, 0},
1265 [GCC_AUDIO_BCR
] = {0x1B008, 0},
1266 [GCC_QPIC_BCR
] = {0x1C000, 0},
1267 [GCC_PCIE_BCR
] = {0x1D000, 0},
1268 [GCC_USB2_BCR
] = {0x1E008, 0},
1269 [GCC_USB2_PHY_BCR
] = {0x1E018, 0},
1270 [GCC_USB3_BCR
] = {0x1E024, 0},
1271 [GCC_USB3_PHY_BCR
] = {0x1E034, 0},
1272 [GCC_SYSTEM_NOC_BCR
] = {0x21000, 0},
1273 [GCC_PCNOC_BCR
] = {0x2102C, 0},
1274 [GCC_DCD_BCR
] = {0x21038, 0},
1275 [GCC_SNOC_BUS_TIMEOUT0_BCR
] = {0x21064, 0},
1276 [GCC_SNOC_BUS_TIMEOUT1_BCR
] = {0x2106C, 0},
1277 [GCC_SNOC_BUS_TIMEOUT2_BCR
] = {0x21074, 0},
1278 [GCC_SNOC_BUS_TIMEOUT3_BCR
] = {0x2107C, 0},
1279 [GCC_PCNOC_BUS_TIMEOUT0_BCR
] = {0x21084, 0},
1280 [GCC_PCNOC_BUS_TIMEOUT1_BCR
] = {0x2108C, 0},
1281 [GCC_PCNOC_BUS_TIMEOUT2_BCR
] = {0x21094, 0},
1282 [GCC_PCNOC_BUS_TIMEOUT3_BCR
] = {0x2109C, 0},
1283 [GCC_PCNOC_BUS_TIMEOUT4_BCR
] = {0x210A4, 0},
1284 [GCC_PCNOC_BUS_TIMEOUT5_BCR
] = {0x210AC, 0},
1285 [GCC_PCNOC_BUS_TIMEOUT6_BCR
] = {0x210B4, 0},
1286 [GCC_PCNOC_BUS_TIMEOUT7_BCR
] = {0x210BC, 0},
1287 [GCC_PCNOC_BUS_TIMEOUT8_BCR
] = {0x210C4, 0},
1288 [GCC_PCNOC_BUS_TIMEOUT9_BCR
] = {0x210CC, 0},
1289 [GCC_TCSR_BCR
] = {0x22000, 0},
1290 [GCC_MPM_BCR
] = {0x24000, 0},
1291 [GCC_SPDM_BCR
] = {0x25000, 0},
1294 static const struct regmap_config gcc_ipq4019_regmap_config
= {
1298 .max_register
= 0x2dfff,
1302 static const struct qcom_cc_desc gcc_ipq4019_desc
= {
1303 .config
= &gcc_ipq4019_regmap_config
,
1304 .clks
= gcc_ipq4019_clocks
,
1305 .num_clks
= ARRAY_SIZE(gcc_ipq4019_clocks
),
1306 .resets
= gcc_ipq4019_resets
,
1307 .num_resets
= ARRAY_SIZE(gcc_ipq4019_resets
),
1310 static const struct of_device_id gcc_ipq4019_match_table
[] = {
1311 { .compatible
= "qcom,gcc-ipq4019" },
1314 MODULE_DEVICE_TABLE(of
, gcc_ipq4019_match_table
);
1316 static int gcc_ipq4019_probe(struct platform_device
*pdev
)
1318 struct device
*dev
= &pdev
->dev
;
1320 clk_register_fixed_rate(dev
, "fepll125", "xo", 0, 200000000);
1321 clk_register_fixed_rate(dev
, "fepll125dly", "xo", 0, 200000000);
1322 clk_register_fixed_rate(dev
, "fepllwcss2g", "xo", 0, 200000000);
1323 clk_register_fixed_rate(dev
, "fepllwcss5g", "xo", 0, 200000000);
1324 clk_register_fixed_rate(dev
, "fepll200", "xo", 0, 200000000);
1325 clk_register_fixed_rate(dev
, "fepll500", "xo", 0, 200000000);
1326 clk_register_fixed_rate(dev
, "ddrpllapss", "xo", 0, 666000000);
1328 return qcom_cc_probe(pdev
, &gcc_ipq4019_desc
);
1331 static struct platform_driver gcc_ipq4019_driver
= {
1332 .probe
= gcc_ipq4019_probe
,
1334 .name
= "qcom,gcc-ipq4019",
1335 .of_match_table
= gcc_ipq4019_match_table
,
1339 static int __init
gcc_ipq4019_init(void)
1341 return platform_driver_register(&gcc_ipq4019_driver
);
1343 core_initcall(gcc_ipq4019_init
);
1345 static void __exit
gcc_ipq4019_exit(void)
1347 platform_driver_unregister(&gcc_ipq4019_driver
);
1349 module_exit(gcc_ipq4019_exit
);
1351 MODULE_ALIAS("platform:gcc-ipq4019");
1352 MODULE_LICENSE("GPL v2");
1353 MODULE_DESCRIPTION("QCOM GCC IPQ4019 driver");