1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
4 * Copyright (c) BayLibre, SAS.
5 * Author : Neil Armstrong <narmstrong@baylibre.com>
8 #include <linux/kernel.h>
9 #include <linux/bitops.h>
10 #include <linux/err.h>
11 #include <linux/platform_device.h>
12 #include <linux/module.h>
14 #include <linux/of_device.h>
15 #include <linux/clk-provider.h>
16 #include <linux/regmap.h>
17 #include <linux/reset-controller.h>
19 #include <dt-bindings/clock/qcom,gcc-mdm9615.h>
20 #include <dt-bindings/reset/qcom,gcc-mdm9615.h>
23 #include "clk-regmap.h"
26 #include "clk-branch.h"
29 static struct clk_fixed_factor cxo
= {
32 .hw
.init
= &(struct clk_init_data
){
34 .parent_names
= (const char *[]){ "cxo_board" },
36 .ops
= &clk_fixed_factor_ops
,
40 static struct clk_pll pll0
= {
48 .clkr
.hw
.init
= &(struct clk_init_data
){
50 .parent_names
= (const char *[]){ "cxo" },
56 static struct clk_regmap pll0_vote
= {
58 .enable_mask
= BIT(0),
59 .hw
.init
= &(struct clk_init_data
){
61 .parent_names
= (const char *[]){ "pll8" },
63 .ops
= &clk_pll_vote_ops
,
67 static struct clk_regmap pll4_vote
= {
69 .enable_mask
= BIT(4),
70 .hw
.init
= &(struct clk_init_data
){
72 .parent_names
= (const char *[]){ "pll4" },
74 .ops
= &clk_pll_vote_ops
,
78 static struct clk_pll pll8
= {
86 .clkr
.hw
.init
= &(struct clk_init_data
){
88 .parent_names
= (const char *[]){ "cxo" },
94 static struct clk_regmap pll8_vote
= {
96 .enable_mask
= BIT(8),
97 .hw
.init
= &(struct clk_init_data
){
99 .parent_names
= (const char *[]){ "pll8" },
101 .ops
= &clk_pll_vote_ops
,
105 static struct clk_pll pll14
= {
109 .config_reg
= 0x31d4,
111 .status_reg
= 0x31d8,
113 .clkr
.hw
.init
= &(struct clk_init_data
){
115 .parent_names
= (const char *[]){ "cxo" },
121 static struct clk_regmap pll14_vote
= {
122 .enable_reg
= 0x34c0,
123 .enable_mask
= BIT(11),
124 .hw
.init
= &(struct clk_init_data
){
125 .name
= "pll14_vote",
126 .parent_names
= (const char *[]){ "pll14" },
128 .ops
= &clk_pll_vote_ops
,
138 static const struct parent_map gcc_cxo_pll8_map
[] = {
143 static const char * const gcc_cxo_pll8
[] = {
148 static const struct parent_map gcc_cxo_pll14_map
[] = {
153 static const char * const gcc_cxo_pll14
[] = {
158 static const struct parent_map gcc_cxo_map
[] = {
162 static const char * const gcc_cxo
[] = {
166 static struct freq_tbl clk_tbl_gsbi_uart
[] = {
167 { 1843200, P_PLL8
, 2, 6, 625 },
168 { 3686400, P_PLL8
, 2, 12, 625 },
169 { 7372800, P_PLL8
, 2, 24, 625 },
170 { 14745600, P_PLL8
, 2, 48, 625 },
171 { 16000000, P_PLL8
, 4, 1, 6 },
172 { 24000000, P_PLL8
, 4, 1, 4 },
173 { 32000000, P_PLL8
, 4, 1, 3 },
174 { 40000000, P_PLL8
, 1, 5, 48 },
175 { 46400000, P_PLL8
, 1, 29, 240 },
176 { 48000000, P_PLL8
, 4, 1, 2 },
177 { 51200000, P_PLL8
, 1, 2, 15 },
178 { 56000000, P_PLL8
, 1, 7, 48 },
179 { 58982400, P_PLL8
, 1, 96, 625 },
180 { 64000000, P_PLL8
, 2, 1, 3 },
184 static struct clk_rcg gsbi1_uart_src
= {
189 .mnctr_reset_bit
= 7,
190 .mnctr_mode_shift
= 5,
201 .parent_map
= gcc_cxo_pll8_map
,
203 .freq_tbl
= clk_tbl_gsbi_uart
,
205 .enable_reg
= 0x29d4,
206 .enable_mask
= BIT(11),
207 .hw
.init
= &(struct clk_init_data
){
208 .name
= "gsbi1_uart_src",
209 .parent_names
= gcc_cxo_pll8
,
212 .flags
= CLK_SET_PARENT_GATE
,
217 static struct clk_branch gsbi1_uart_clk
= {
221 .enable_reg
= 0x29d4,
222 .enable_mask
= BIT(9),
223 .hw
.init
= &(struct clk_init_data
){
224 .name
= "gsbi1_uart_clk",
225 .parent_names
= (const char *[]){
229 .ops
= &clk_branch_ops
,
230 .flags
= CLK_SET_RATE_PARENT
,
235 static struct clk_rcg gsbi2_uart_src
= {
240 .mnctr_reset_bit
= 7,
241 .mnctr_mode_shift
= 5,
252 .parent_map
= gcc_cxo_pll8_map
,
254 .freq_tbl
= clk_tbl_gsbi_uart
,
256 .enable_reg
= 0x29f4,
257 .enable_mask
= BIT(11),
258 .hw
.init
= &(struct clk_init_data
){
259 .name
= "gsbi2_uart_src",
260 .parent_names
= gcc_cxo_pll8
,
263 .flags
= CLK_SET_PARENT_GATE
,
268 static struct clk_branch gsbi2_uart_clk
= {
272 .enable_reg
= 0x29f4,
273 .enable_mask
= BIT(9),
274 .hw
.init
= &(struct clk_init_data
){
275 .name
= "gsbi2_uart_clk",
276 .parent_names
= (const char *[]){
280 .ops
= &clk_branch_ops
,
281 .flags
= CLK_SET_RATE_PARENT
,
286 static struct clk_rcg gsbi3_uart_src
= {
291 .mnctr_reset_bit
= 7,
292 .mnctr_mode_shift
= 5,
303 .parent_map
= gcc_cxo_pll8_map
,
305 .freq_tbl
= clk_tbl_gsbi_uart
,
307 .enable_reg
= 0x2a14,
308 .enable_mask
= BIT(11),
309 .hw
.init
= &(struct clk_init_data
){
310 .name
= "gsbi3_uart_src",
311 .parent_names
= gcc_cxo_pll8
,
314 .flags
= CLK_SET_PARENT_GATE
,
319 static struct clk_branch gsbi3_uart_clk
= {
323 .enable_reg
= 0x2a14,
324 .enable_mask
= BIT(9),
325 .hw
.init
= &(struct clk_init_data
){
326 .name
= "gsbi3_uart_clk",
327 .parent_names
= (const char *[]){
331 .ops
= &clk_branch_ops
,
332 .flags
= CLK_SET_RATE_PARENT
,
337 static struct clk_rcg gsbi4_uart_src
= {
342 .mnctr_reset_bit
= 7,
343 .mnctr_mode_shift
= 5,
354 .parent_map
= gcc_cxo_pll8_map
,
356 .freq_tbl
= clk_tbl_gsbi_uart
,
358 .enable_reg
= 0x2a34,
359 .enable_mask
= BIT(11),
360 .hw
.init
= &(struct clk_init_data
){
361 .name
= "gsbi4_uart_src",
362 .parent_names
= gcc_cxo_pll8
,
365 .flags
= CLK_SET_PARENT_GATE
,
370 static struct clk_branch gsbi4_uart_clk
= {
374 .enable_reg
= 0x2a34,
375 .enable_mask
= BIT(9),
376 .hw
.init
= &(struct clk_init_data
){
377 .name
= "gsbi4_uart_clk",
378 .parent_names
= (const char *[]){
382 .ops
= &clk_branch_ops
,
383 .flags
= CLK_SET_RATE_PARENT
,
388 static struct clk_rcg gsbi5_uart_src
= {
393 .mnctr_reset_bit
= 7,
394 .mnctr_mode_shift
= 5,
405 .parent_map
= gcc_cxo_pll8_map
,
407 .freq_tbl
= clk_tbl_gsbi_uart
,
409 .enable_reg
= 0x2a54,
410 .enable_mask
= BIT(11),
411 .hw
.init
= &(struct clk_init_data
){
412 .name
= "gsbi5_uart_src",
413 .parent_names
= gcc_cxo_pll8
,
416 .flags
= CLK_SET_PARENT_GATE
,
421 static struct clk_branch gsbi5_uart_clk
= {
425 .enable_reg
= 0x2a54,
426 .enable_mask
= BIT(9),
427 .hw
.init
= &(struct clk_init_data
){
428 .name
= "gsbi5_uart_clk",
429 .parent_names
= (const char *[]){
433 .ops
= &clk_branch_ops
,
434 .flags
= CLK_SET_RATE_PARENT
,
439 static struct freq_tbl clk_tbl_gsbi_qup
[] = {
440 { 960000, P_CXO
, 4, 1, 5 },
441 { 4800000, P_CXO
, 4, 0, 1 },
442 { 9600000, P_CXO
, 2, 0, 1 },
443 { 15060000, P_PLL8
, 1, 2, 51 },
444 { 24000000, P_PLL8
, 4, 1, 4 },
445 { 25600000, P_PLL8
, 1, 1, 15 },
446 { 48000000, P_PLL8
, 4, 1, 2 },
447 { 51200000, P_PLL8
, 1, 2, 15 },
451 static struct clk_rcg gsbi1_qup_src
= {
456 .mnctr_reset_bit
= 7,
457 .mnctr_mode_shift
= 5,
468 .parent_map
= gcc_cxo_pll8_map
,
470 .freq_tbl
= clk_tbl_gsbi_qup
,
472 .enable_reg
= 0x29cc,
473 .enable_mask
= BIT(11),
474 .hw
.init
= &(struct clk_init_data
){
475 .name
= "gsbi1_qup_src",
476 .parent_names
= gcc_cxo_pll8
,
479 .flags
= CLK_SET_PARENT_GATE
,
484 static struct clk_branch gsbi1_qup_clk
= {
488 .enable_reg
= 0x29cc,
489 .enable_mask
= BIT(9),
490 .hw
.init
= &(struct clk_init_data
){
491 .name
= "gsbi1_qup_clk",
492 .parent_names
= (const char *[]){ "gsbi1_qup_src" },
494 .ops
= &clk_branch_ops
,
495 .flags
= CLK_SET_RATE_PARENT
,
500 static struct clk_rcg gsbi2_qup_src
= {
505 .mnctr_reset_bit
= 7,
506 .mnctr_mode_shift
= 5,
517 .parent_map
= gcc_cxo_pll8_map
,
519 .freq_tbl
= clk_tbl_gsbi_qup
,
521 .enable_reg
= 0x29ec,
522 .enable_mask
= BIT(11),
523 .hw
.init
= &(struct clk_init_data
){
524 .name
= "gsbi2_qup_src",
525 .parent_names
= gcc_cxo_pll8
,
528 .flags
= CLK_SET_PARENT_GATE
,
533 static struct clk_branch gsbi2_qup_clk
= {
537 .enable_reg
= 0x29ec,
538 .enable_mask
= BIT(9),
539 .hw
.init
= &(struct clk_init_data
){
540 .name
= "gsbi2_qup_clk",
541 .parent_names
= (const char *[]){ "gsbi2_qup_src" },
543 .ops
= &clk_branch_ops
,
544 .flags
= CLK_SET_RATE_PARENT
,
549 static struct clk_rcg gsbi3_qup_src
= {
554 .mnctr_reset_bit
= 7,
555 .mnctr_mode_shift
= 5,
566 .parent_map
= gcc_cxo_pll8_map
,
568 .freq_tbl
= clk_tbl_gsbi_qup
,
570 .enable_reg
= 0x2a0c,
571 .enable_mask
= BIT(11),
572 .hw
.init
= &(struct clk_init_data
){
573 .name
= "gsbi3_qup_src",
574 .parent_names
= gcc_cxo_pll8
,
577 .flags
= CLK_SET_PARENT_GATE
,
582 static struct clk_branch gsbi3_qup_clk
= {
586 .enable_reg
= 0x2a0c,
587 .enable_mask
= BIT(9),
588 .hw
.init
= &(struct clk_init_data
){
589 .name
= "gsbi3_qup_clk",
590 .parent_names
= (const char *[]){ "gsbi3_qup_src" },
592 .ops
= &clk_branch_ops
,
593 .flags
= CLK_SET_RATE_PARENT
,
598 static struct clk_rcg gsbi4_qup_src
= {
603 .mnctr_reset_bit
= 7,
604 .mnctr_mode_shift
= 5,
615 .parent_map
= gcc_cxo_pll8_map
,
617 .freq_tbl
= clk_tbl_gsbi_qup
,
619 .enable_reg
= 0x2a2c,
620 .enable_mask
= BIT(11),
621 .hw
.init
= &(struct clk_init_data
){
622 .name
= "gsbi4_qup_src",
623 .parent_names
= gcc_cxo_pll8
,
626 .flags
= CLK_SET_PARENT_GATE
,
631 static struct clk_branch gsbi4_qup_clk
= {
635 .enable_reg
= 0x2a2c,
636 .enable_mask
= BIT(9),
637 .hw
.init
= &(struct clk_init_data
){
638 .name
= "gsbi4_qup_clk",
639 .parent_names
= (const char *[]){ "gsbi4_qup_src" },
641 .ops
= &clk_branch_ops
,
642 .flags
= CLK_SET_RATE_PARENT
,
647 static struct clk_rcg gsbi5_qup_src
= {
652 .mnctr_reset_bit
= 7,
653 .mnctr_mode_shift
= 5,
664 .parent_map
= gcc_cxo_pll8_map
,
666 .freq_tbl
= clk_tbl_gsbi_qup
,
668 .enable_reg
= 0x2a4c,
669 .enable_mask
= BIT(11),
670 .hw
.init
= &(struct clk_init_data
){
671 .name
= "gsbi5_qup_src",
672 .parent_names
= gcc_cxo_pll8
,
675 .flags
= CLK_SET_PARENT_GATE
,
680 static struct clk_branch gsbi5_qup_clk
= {
684 .enable_reg
= 0x2a4c,
685 .enable_mask
= BIT(9),
686 .hw
.init
= &(struct clk_init_data
){
687 .name
= "gsbi5_qup_clk",
688 .parent_names
= (const char *[]){ "gsbi5_qup_src" },
690 .ops
= &clk_branch_ops
,
691 .flags
= CLK_SET_RATE_PARENT
,
696 static const struct freq_tbl clk_tbl_gp
[] = {
697 { 9600000, P_CXO
, 2, 0, 0 },
698 { 19200000, P_CXO
, 1, 0, 0 },
702 static struct clk_rcg gp0_src
= {
707 .mnctr_reset_bit
= 7,
708 .mnctr_mode_shift
= 5,
719 .parent_map
= gcc_cxo_map
,
721 .freq_tbl
= clk_tbl_gp
,
723 .enable_reg
= 0x2d24,
724 .enable_mask
= BIT(11),
725 .hw
.init
= &(struct clk_init_data
){
727 .parent_names
= gcc_cxo
,
730 .flags
= CLK_SET_PARENT_GATE
,
735 static struct clk_branch gp0_clk
= {
739 .enable_reg
= 0x2d24,
740 .enable_mask
= BIT(9),
741 .hw
.init
= &(struct clk_init_data
){
743 .parent_names
= (const char *[]){ "gp0_src" },
745 .ops
= &clk_branch_ops
,
746 .flags
= CLK_SET_RATE_PARENT
,
751 static struct clk_rcg gp1_src
= {
756 .mnctr_reset_bit
= 7,
757 .mnctr_mode_shift
= 5,
768 .parent_map
= gcc_cxo_map
,
770 .freq_tbl
= clk_tbl_gp
,
772 .enable_reg
= 0x2d44,
773 .enable_mask
= BIT(11),
774 .hw
.init
= &(struct clk_init_data
){
776 .parent_names
= gcc_cxo
,
779 .flags
= CLK_SET_RATE_GATE
,
784 static struct clk_branch gp1_clk
= {
788 .enable_reg
= 0x2d44,
789 .enable_mask
= BIT(9),
790 .hw
.init
= &(struct clk_init_data
){
792 .parent_names
= (const char *[]){ "gp1_src" },
794 .ops
= &clk_branch_ops
,
795 .flags
= CLK_SET_RATE_PARENT
,
800 static struct clk_rcg gp2_src
= {
805 .mnctr_reset_bit
= 7,
806 .mnctr_mode_shift
= 5,
817 .parent_map
= gcc_cxo_map
,
819 .freq_tbl
= clk_tbl_gp
,
821 .enable_reg
= 0x2d64,
822 .enable_mask
= BIT(11),
823 .hw
.init
= &(struct clk_init_data
){
825 .parent_names
= gcc_cxo
,
828 .flags
= CLK_SET_RATE_GATE
,
833 static struct clk_branch gp2_clk
= {
837 .enable_reg
= 0x2d64,
838 .enable_mask
= BIT(9),
839 .hw
.init
= &(struct clk_init_data
){
841 .parent_names
= (const char *[]){ "gp2_src" },
843 .ops
= &clk_branch_ops
,
844 .flags
= CLK_SET_RATE_PARENT
,
849 static struct clk_branch pmem_clk
= {
855 .enable_reg
= 0x25a0,
856 .enable_mask
= BIT(4),
857 .hw
.init
= &(struct clk_init_data
){
859 .ops
= &clk_branch_ops
,
864 static struct clk_rcg prng_src
= {
872 .parent_map
= gcc_cxo_pll8_map
,
875 .hw
.init
= &(struct clk_init_data
){
877 .parent_names
= gcc_cxo_pll8
,
884 static struct clk_branch prng_clk
= {
886 .halt_check
= BRANCH_HALT_VOTED
,
889 .enable_reg
= 0x3080,
890 .enable_mask
= BIT(10),
891 .hw
.init
= &(struct clk_init_data
){
893 .parent_names
= (const char *[]){ "prng_src" },
895 .ops
= &clk_branch_ops
,
900 static const struct freq_tbl clk_tbl_sdc
[] = {
901 { 144000, P_CXO
, 1, 1, 133 },
902 { 400000, P_PLL8
, 4, 1, 240 },
903 { 16000000, P_PLL8
, 4, 1, 6 },
904 { 17070000, P_PLL8
, 1, 2, 45 },
905 { 20210000, P_PLL8
, 1, 1, 19 },
906 { 24000000, P_PLL8
, 4, 1, 4 },
907 { 38400000, P_PLL8
, 2, 1, 5 },
908 { 48000000, P_PLL8
, 4, 1, 2 },
909 { 64000000, P_PLL8
, 3, 1, 2 },
910 { 76800000, P_PLL8
, 1, 1, 5 },
914 static struct clk_rcg sdc1_src
= {
919 .mnctr_reset_bit
= 7,
920 .mnctr_mode_shift
= 5,
931 .parent_map
= gcc_cxo_pll8_map
,
933 .freq_tbl
= clk_tbl_sdc
,
935 .enable_reg
= 0x282c,
936 .enable_mask
= BIT(11),
937 .hw
.init
= &(struct clk_init_data
){
939 .parent_names
= gcc_cxo_pll8
,
946 static struct clk_branch sdc1_clk
= {
950 .enable_reg
= 0x282c,
951 .enable_mask
= BIT(9),
952 .hw
.init
= &(struct clk_init_data
){
954 .parent_names
= (const char *[]){ "sdc1_src" },
956 .ops
= &clk_branch_ops
,
957 .flags
= CLK_SET_RATE_PARENT
,
962 static struct clk_rcg sdc2_src
= {
967 .mnctr_reset_bit
= 7,
968 .mnctr_mode_shift
= 5,
979 .parent_map
= gcc_cxo_pll8_map
,
981 .freq_tbl
= clk_tbl_sdc
,
983 .enable_reg
= 0x284c,
984 .enable_mask
= BIT(11),
985 .hw
.init
= &(struct clk_init_data
){
987 .parent_names
= gcc_cxo_pll8
,
994 static struct clk_branch sdc2_clk
= {
998 .enable_reg
= 0x284c,
999 .enable_mask
= BIT(9),
1000 .hw
.init
= &(struct clk_init_data
){
1002 .parent_names
= (const char *[]){ "sdc2_src" },
1004 .ops
= &clk_branch_ops
,
1005 .flags
= CLK_SET_RATE_PARENT
,
1010 static const struct freq_tbl clk_tbl_usb
[] = {
1011 { 60000000, P_PLL8
, 1, 5, 32 },
1015 static struct clk_rcg usb_hs1_xcvr_src
= {
1020 .mnctr_reset_bit
= 7,
1021 .mnctr_mode_shift
= 5,
1032 .parent_map
= gcc_cxo_pll8_map
,
1034 .freq_tbl
= clk_tbl_usb
,
1036 .enable_reg
= 0x290c,
1037 .enable_mask
= BIT(11),
1038 .hw
.init
= &(struct clk_init_data
){
1039 .name
= "usb_hs1_xcvr_src",
1040 .parent_names
= gcc_cxo_pll8
,
1042 .ops
= &clk_rcg_ops
,
1043 .flags
= CLK_SET_RATE_GATE
,
1048 static struct clk_branch usb_hs1_xcvr_clk
= {
1052 .enable_reg
= 0x290c,
1053 .enable_mask
= BIT(9),
1054 .hw
.init
= &(struct clk_init_data
){
1055 .name
= "usb_hs1_xcvr_clk",
1056 .parent_names
= (const char *[]){ "usb_hs1_xcvr_src" },
1058 .ops
= &clk_branch_ops
,
1059 .flags
= CLK_SET_RATE_PARENT
,
1064 static struct clk_rcg usb_hsic_xcvr_fs_src
= {
1069 .mnctr_reset_bit
= 7,
1070 .mnctr_mode_shift
= 5,
1081 .parent_map
= gcc_cxo_pll8_map
,
1083 .freq_tbl
= clk_tbl_usb
,
1085 .enable_reg
= 0x2928,
1086 .enable_mask
= BIT(11),
1087 .hw
.init
= &(struct clk_init_data
){
1088 .name
= "usb_hsic_xcvr_fs_src",
1089 .parent_names
= gcc_cxo_pll8
,
1091 .ops
= &clk_rcg_ops
,
1092 .flags
= CLK_SET_RATE_GATE
,
1097 static struct clk_branch usb_hsic_xcvr_fs_clk
= {
1101 .enable_reg
= 0x2928,
1102 .enable_mask
= BIT(9),
1103 .hw
.init
= &(struct clk_init_data
){
1104 .name
= "usb_hsic_xcvr_fs_clk",
1106 (const char *[]){ "usb_hsic_xcvr_fs_src" },
1108 .ops
= &clk_branch_ops
,
1109 .flags
= CLK_SET_RATE_PARENT
,
1114 static const struct freq_tbl clk_tbl_usb_hs1_system
[] = {
1115 { 60000000, P_PLL8
, 1, 5, 32 },
1119 static struct clk_rcg usb_hs1_system_src
= {
1124 .mnctr_reset_bit
= 7,
1125 .mnctr_mode_shift
= 5,
1136 .parent_map
= gcc_cxo_pll8_map
,
1138 .freq_tbl
= clk_tbl_usb_hs1_system
,
1140 .enable_reg
= 0x36a4,
1141 .enable_mask
= BIT(11),
1142 .hw
.init
= &(struct clk_init_data
){
1143 .name
= "usb_hs1_system_src",
1144 .parent_names
= gcc_cxo_pll8
,
1146 .ops
= &clk_rcg_ops
,
1147 .flags
= CLK_SET_RATE_GATE
,
1152 static struct clk_branch usb_hs1_system_clk
= {
1156 .enable_reg
= 0x36a4,
1157 .enable_mask
= BIT(9),
1158 .hw
.init
= &(struct clk_init_data
){
1160 (const char *[]){ "usb_hs1_system_src" },
1162 .name
= "usb_hs1_system_clk",
1163 .ops
= &clk_branch_ops
,
1164 .flags
= CLK_SET_RATE_PARENT
| CLK_IGNORE_UNUSED
,
1169 static const struct freq_tbl clk_tbl_usb_hsic_system
[] = {
1170 { 64000000, P_PLL8
, 1, 1, 6 },
1174 static struct clk_rcg usb_hsic_system_src
= {
1179 .mnctr_reset_bit
= 7,
1180 .mnctr_mode_shift
= 5,
1191 .parent_map
= gcc_cxo_pll8_map
,
1193 .freq_tbl
= clk_tbl_usb_hsic_system
,
1195 .enable_reg
= 0x2b58,
1196 .enable_mask
= BIT(11),
1197 .hw
.init
= &(struct clk_init_data
){
1198 .name
= "usb_hsic_system_src",
1199 .parent_names
= gcc_cxo_pll8
,
1201 .ops
= &clk_rcg_ops
,
1202 .flags
= CLK_SET_RATE_GATE
,
1207 static struct clk_branch usb_hsic_system_clk
= {
1211 .enable_reg
= 0x2b58,
1212 .enable_mask
= BIT(9),
1213 .hw
.init
= &(struct clk_init_data
){
1215 (const char *[]){ "usb_hsic_system_src" },
1217 .name
= "usb_hsic_system_clk",
1218 .ops
= &clk_branch_ops
,
1219 .flags
= CLK_SET_RATE_PARENT
,
1224 static const struct freq_tbl clk_tbl_usb_hsic_hsic
[] = {
1225 { 48000000, P_PLL14
, 1, 0, 0 },
1229 static struct clk_rcg usb_hsic_hsic_src
= {
1234 .mnctr_reset_bit
= 7,
1235 .mnctr_mode_shift
= 5,
1246 .parent_map
= gcc_cxo_pll14_map
,
1248 .freq_tbl
= clk_tbl_usb_hsic_hsic
,
1250 .enable_reg
= 0x2b50,
1251 .enable_mask
= BIT(11),
1252 .hw
.init
= &(struct clk_init_data
){
1253 .name
= "usb_hsic_hsic_src",
1254 .parent_names
= gcc_cxo_pll14
,
1256 .ops
= &clk_rcg_ops
,
1257 .flags
= CLK_SET_RATE_GATE
,
1262 static struct clk_branch usb_hsic_hsic_clk
= {
1263 .halt_check
= BRANCH_HALT_DELAY
,
1265 .enable_reg
= 0x2b50,
1266 .enable_mask
= BIT(9),
1267 .hw
.init
= &(struct clk_init_data
){
1268 .parent_names
= (const char *[]){ "usb_hsic_hsic_src" },
1270 .name
= "usb_hsic_hsic_clk",
1271 .ops
= &clk_branch_ops
,
1272 .flags
= CLK_SET_RATE_PARENT
,
1277 static struct clk_branch usb_hsic_hsio_cal_clk
= {
1281 .enable_reg
= 0x2b48,
1282 .enable_mask
= BIT(0),
1283 .hw
.init
= &(struct clk_init_data
){
1284 .parent_names
= (const char *[]){ "cxo" },
1286 .name
= "usb_hsic_hsio_cal_clk",
1287 .ops
= &clk_branch_ops
,
1292 static struct clk_branch ce1_core_clk
= {
1298 .enable_reg
= 0x2724,
1299 .enable_mask
= BIT(4),
1300 .hw
.init
= &(struct clk_init_data
){
1301 .name
= "ce1_core_clk",
1302 .ops
= &clk_branch_ops
,
1307 static struct clk_branch ce1_h_clk
= {
1311 .enable_reg
= 0x2720,
1312 .enable_mask
= BIT(4),
1313 .hw
.init
= &(struct clk_init_data
){
1314 .name
= "ce1_h_clk",
1315 .ops
= &clk_branch_ops
,
1320 static struct clk_branch dma_bam_h_clk
= {
1326 .enable_reg
= 0x25c0,
1327 .enable_mask
= BIT(4),
1328 .hw
.init
= &(struct clk_init_data
){
1329 .name
= "dma_bam_h_clk",
1330 .ops
= &clk_branch_ops
,
1335 static struct clk_branch gsbi1_h_clk
= {
1341 .enable_reg
= 0x29c0,
1342 .enable_mask
= BIT(4),
1343 .hw
.init
= &(struct clk_init_data
){
1344 .name
= "gsbi1_h_clk",
1345 .ops
= &clk_branch_ops
,
1350 static struct clk_branch gsbi2_h_clk
= {
1356 .enable_reg
= 0x29e0,
1357 .enable_mask
= BIT(4),
1358 .hw
.init
= &(struct clk_init_data
){
1359 .name
= "gsbi2_h_clk",
1360 .ops
= &clk_branch_ops
,
1365 static struct clk_branch gsbi3_h_clk
= {
1371 .enable_reg
= 0x2a00,
1372 .enable_mask
= BIT(4),
1373 .hw
.init
= &(struct clk_init_data
){
1374 .name
= "gsbi3_h_clk",
1375 .ops
= &clk_branch_ops
,
1380 static struct clk_branch gsbi4_h_clk
= {
1386 .enable_reg
= 0x2a20,
1387 .enable_mask
= BIT(4),
1388 .hw
.init
= &(struct clk_init_data
){
1389 .name
= "gsbi4_h_clk",
1390 .ops
= &clk_branch_ops
,
1395 static struct clk_branch gsbi5_h_clk
= {
1401 .enable_reg
= 0x2a40,
1402 .enable_mask
= BIT(4),
1403 .hw
.init
= &(struct clk_init_data
){
1404 .name
= "gsbi5_h_clk",
1405 .ops
= &clk_branch_ops
,
1410 static struct clk_branch usb_hs1_h_clk
= {
1416 .enable_reg
= 0x2900,
1417 .enable_mask
= BIT(4),
1418 .hw
.init
= &(struct clk_init_data
){
1419 .name
= "usb_hs1_h_clk",
1420 .ops
= &clk_branch_ops
,
1425 static struct clk_branch usb_hsic_h_clk
= {
1429 .enable_reg
= 0x2920,
1430 .enable_mask
= BIT(4),
1431 .hw
.init
= &(struct clk_init_data
){
1432 .name
= "usb_hsic_h_clk",
1433 .ops
= &clk_branch_ops
,
1438 static struct clk_branch sdc1_h_clk
= {
1444 .enable_reg
= 0x2820,
1445 .enable_mask
= BIT(4),
1446 .hw
.init
= &(struct clk_init_data
){
1447 .name
= "sdc1_h_clk",
1448 .ops
= &clk_branch_ops
,
1453 static struct clk_branch sdc2_h_clk
= {
1459 .enable_reg
= 0x2840,
1460 .enable_mask
= BIT(4),
1461 .hw
.init
= &(struct clk_init_data
){
1462 .name
= "sdc2_h_clk",
1463 .ops
= &clk_branch_ops
,
1468 static struct clk_branch adm0_clk
= {
1470 .halt_check
= BRANCH_HALT_VOTED
,
1473 .enable_reg
= 0x3080,
1474 .enable_mask
= BIT(2),
1475 .hw
.init
= &(struct clk_init_data
){
1477 .ops
= &clk_branch_ops
,
1482 static struct clk_branch adm0_pbus_clk
= {
1486 .halt_check
= BRANCH_HALT_VOTED
,
1489 .enable_reg
= 0x3080,
1490 .enable_mask
= BIT(3),
1491 .hw
.init
= &(struct clk_init_data
){
1492 .name
= "adm0_pbus_clk",
1493 .ops
= &clk_branch_ops
,
1498 static struct clk_branch pmic_arb0_h_clk
= {
1500 .halt_check
= BRANCH_HALT_VOTED
,
1503 .enable_reg
= 0x3080,
1504 .enable_mask
= BIT(8),
1505 .hw
.init
= &(struct clk_init_data
){
1506 .name
= "pmic_arb0_h_clk",
1507 .ops
= &clk_branch_ops
,
1512 static struct clk_branch pmic_arb1_h_clk
= {
1514 .halt_check
= BRANCH_HALT_VOTED
,
1517 .enable_reg
= 0x3080,
1518 .enable_mask
= BIT(9),
1519 .hw
.init
= &(struct clk_init_data
){
1520 .name
= "pmic_arb1_h_clk",
1521 .ops
= &clk_branch_ops
,
1526 static struct clk_branch pmic_ssbi2_clk
= {
1528 .halt_check
= BRANCH_HALT_VOTED
,
1531 .enable_reg
= 0x3080,
1532 .enable_mask
= BIT(7),
1533 .hw
.init
= &(struct clk_init_data
){
1534 .name
= "pmic_ssbi2_clk",
1535 .ops
= &clk_branch_ops
,
1540 static struct clk_branch rpm_msg_ram_h_clk
= {
1544 .halt_check
= BRANCH_HALT_VOTED
,
1547 .enable_reg
= 0x3080,
1548 .enable_mask
= BIT(6),
1549 .hw
.init
= &(struct clk_init_data
){
1550 .name
= "rpm_msg_ram_h_clk",
1551 .ops
= &clk_branch_ops
,
1556 static struct clk_branch ebi2_clk
= {
1562 .enable_reg
= 0x2664,
1563 .enable_mask
= BIT(6) | BIT(4),
1564 .hw
.init
= &(struct clk_init_data
){
1566 .ops
= &clk_branch_ops
,
1571 static struct clk_branch ebi2_aon_clk
= {
1575 .enable_reg
= 0x2664,
1576 .enable_mask
= BIT(8),
1577 .hw
.init
= &(struct clk_init_data
){
1578 .name
= "ebi2_aon_clk",
1579 .ops
= &clk_branch_ops
,
1584 static struct clk_hw
*gcc_mdm9615_hws
[] = {
1588 static struct clk_regmap
*gcc_mdm9615_clks
[] = {
1589 [PLL0
] = &pll0
.clkr
,
1590 [PLL0_VOTE
] = &pll0_vote
,
1591 [PLL4_VOTE
] = &pll4_vote
,
1592 [PLL8
] = &pll8
.clkr
,
1593 [PLL8_VOTE
] = &pll8_vote
,
1594 [PLL14
] = &pll14
.clkr
,
1595 [PLL14_VOTE
] = &pll14_vote
,
1596 [GSBI1_UART_SRC
] = &gsbi1_uart_src
.clkr
,
1597 [GSBI1_UART_CLK
] = &gsbi1_uart_clk
.clkr
,
1598 [GSBI2_UART_SRC
] = &gsbi2_uart_src
.clkr
,
1599 [GSBI2_UART_CLK
] = &gsbi2_uart_clk
.clkr
,
1600 [GSBI3_UART_SRC
] = &gsbi3_uart_src
.clkr
,
1601 [GSBI3_UART_CLK
] = &gsbi3_uart_clk
.clkr
,
1602 [GSBI4_UART_SRC
] = &gsbi4_uart_src
.clkr
,
1603 [GSBI4_UART_CLK
] = &gsbi4_uart_clk
.clkr
,
1604 [GSBI5_UART_SRC
] = &gsbi5_uart_src
.clkr
,
1605 [GSBI5_UART_CLK
] = &gsbi5_uart_clk
.clkr
,
1606 [GSBI1_QUP_SRC
] = &gsbi1_qup_src
.clkr
,
1607 [GSBI1_QUP_CLK
] = &gsbi1_qup_clk
.clkr
,
1608 [GSBI2_QUP_SRC
] = &gsbi2_qup_src
.clkr
,
1609 [GSBI2_QUP_CLK
] = &gsbi2_qup_clk
.clkr
,
1610 [GSBI3_QUP_SRC
] = &gsbi3_qup_src
.clkr
,
1611 [GSBI3_QUP_CLK
] = &gsbi3_qup_clk
.clkr
,
1612 [GSBI4_QUP_SRC
] = &gsbi4_qup_src
.clkr
,
1613 [GSBI4_QUP_CLK
] = &gsbi4_qup_clk
.clkr
,
1614 [GSBI5_QUP_SRC
] = &gsbi5_qup_src
.clkr
,
1615 [GSBI5_QUP_CLK
] = &gsbi5_qup_clk
.clkr
,
1616 [GP0_SRC
] = &gp0_src
.clkr
,
1617 [GP0_CLK
] = &gp0_clk
.clkr
,
1618 [GP1_SRC
] = &gp1_src
.clkr
,
1619 [GP1_CLK
] = &gp1_clk
.clkr
,
1620 [GP2_SRC
] = &gp2_src
.clkr
,
1621 [GP2_CLK
] = &gp2_clk
.clkr
,
1622 [PMEM_A_CLK
] = &pmem_clk
.clkr
,
1623 [PRNG_SRC
] = &prng_src
.clkr
,
1624 [PRNG_CLK
] = &prng_clk
.clkr
,
1625 [SDC1_SRC
] = &sdc1_src
.clkr
,
1626 [SDC1_CLK
] = &sdc1_clk
.clkr
,
1627 [SDC2_SRC
] = &sdc2_src
.clkr
,
1628 [SDC2_CLK
] = &sdc2_clk
.clkr
,
1629 [USB_HS1_XCVR_SRC
] = &usb_hs1_xcvr_src
.clkr
,
1630 [USB_HS1_XCVR_CLK
] = &usb_hs1_xcvr_clk
.clkr
,
1631 [USB_HS1_SYSTEM_CLK_SRC
] = &usb_hs1_system_src
.clkr
,
1632 [USB_HS1_SYSTEM_CLK
] = &usb_hs1_system_clk
.clkr
,
1633 [USB_HSIC_XCVR_FS_SRC
] = &usb_hsic_xcvr_fs_src
.clkr
,
1634 [USB_HSIC_XCVR_FS_CLK
] = &usb_hsic_xcvr_fs_clk
.clkr
,
1635 [USB_HSIC_SYSTEM_CLK_SRC
] = &usb_hsic_system_src
.clkr
,
1636 [USB_HSIC_SYSTEM_CLK
] = &usb_hsic_system_clk
.clkr
,
1637 [USB_HSIC_HSIC_CLK_SRC
] = &usb_hsic_hsic_src
.clkr
,
1638 [USB_HSIC_HSIC_CLK
] = &usb_hsic_hsic_clk
.clkr
,
1639 [USB_HSIC_HSIO_CAL_CLK
] = &usb_hsic_hsio_cal_clk
.clkr
,
1640 [CE1_CORE_CLK
] = &ce1_core_clk
.clkr
,
1641 [CE1_H_CLK
] = &ce1_h_clk
.clkr
,
1642 [DMA_BAM_H_CLK
] = &dma_bam_h_clk
.clkr
,
1643 [GSBI1_H_CLK
] = &gsbi1_h_clk
.clkr
,
1644 [GSBI2_H_CLK
] = &gsbi2_h_clk
.clkr
,
1645 [GSBI3_H_CLK
] = &gsbi3_h_clk
.clkr
,
1646 [GSBI4_H_CLK
] = &gsbi4_h_clk
.clkr
,
1647 [GSBI5_H_CLK
] = &gsbi5_h_clk
.clkr
,
1648 [USB_HS1_H_CLK
] = &usb_hs1_h_clk
.clkr
,
1649 [USB_HSIC_H_CLK
] = &usb_hsic_h_clk
.clkr
,
1650 [SDC1_H_CLK
] = &sdc1_h_clk
.clkr
,
1651 [SDC2_H_CLK
] = &sdc2_h_clk
.clkr
,
1652 [ADM0_CLK
] = &adm0_clk
.clkr
,
1653 [ADM0_PBUS_CLK
] = &adm0_pbus_clk
.clkr
,
1654 [PMIC_ARB0_H_CLK
] = &pmic_arb0_h_clk
.clkr
,
1655 [PMIC_ARB1_H_CLK
] = &pmic_arb1_h_clk
.clkr
,
1656 [PMIC_SSBI2_CLK
] = &pmic_ssbi2_clk
.clkr
,
1657 [RPM_MSG_RAM_H_CLK
] = &rpm_msg_ram_h_clk
.clkr
,
1658 [EBI2_CLK
] = &ebi2_clk
.clkr
,
1659 [EBI2_AON_CLK
] = &ebi2_aon_clk
.clkr
,
1662 static const struct qcom_reset_map gcc_mdm9615_resets
[] = {
1663 [DMA_BAM_RESET
] = { 0x25c0, 7 },
1664 [CE1_H_RESET
] = { 0x2720, 7 },
1665 [CE1_CORE_RESET
] = { 0x2724, 7 },
1666 [SDC1_RESET
] = { 0x2830 },
1667 [SDC2_RESET
] = { 0x2850 },
1668 [ADM0_C2_RESET
] = { 0x220c, 4 },
1669 [ADM0_C1_RESET
] = { 0x220c, 3 },
1670 [ADM0_C0_RESET
] = { 0x220c, 2 },
1671 [ADM0_PBUS_RESET
] = { 0x220c, 1 },
1672 [ADM0_RESET
] = { 0x220c },
1673 [USB_HS1_RESET
] = { 0x2910 },
1674 [USB_HSIC_RESET
] = { 0x2934 },
1675 [GSBI1_RESET
] = { 0x29dc },
1676 [GSBI2_RESET
] = { 0x29fc },
1677 [GSBI3_RESET
] = { 0x2a1c },
1678 [GSBI4_RESET
] = { 0x2a3c },
1679 [GSBI5_RESET
] = { 0x2a5c },
1680 [PDM_RESET
] = { 0x2CC0, 12 },
1683 static const struct regmap_config gcc_mdm9615_regmap_config
= {
1687 .max_register
= 0x3660,
1691 static const struct qcom_cc_desc gcc_mdm9615_desc
= {
1692 .config
= &gcc_mdm9615_regmap_config
,
1693 .clks
= gcc_mdm9615_clks
,
1694 .num_clks
= ARRAY_SIZE(gcc_mdm9615_clks
),
1695 .resets
= gcc_mdm9615_resets
,
1696 .num_resets
= ARRAY_SIZE(gcc_mdm9615_resets
),
1697 .clk_hws
= gcc_mdm9615_hws
,
1698 .num_clk_hws
= ARRAY_SIZE(gcc_mdm9615_hws
),
1701 static const struct of_device_id gcc_mdm9615_match_table
[] = {
1702 { .compatible
= "qcom,gcc-mdm9615" },
1705 MODULE_DEVICE_TABLE(of
, gcc_mdm9615_match_table
);
1707 static int gcc_mdm9615_probe(struct platform_device
*pdev
)
1709 struct regmap
*regmap
;
1711 regmap
= qcom_cc_map(pdev
, &gcc_mdm9615_desc
);
1713 return PTR_ERR(regmap
);
1715 return qcom_cc_really_probe(pdev
, &gcc_mdm9615_desc
, regmap
);
1718 static struct platform_driver gcc_mdm9615_driver
= {
1719 .probe
= gcc_mdm9615_probe
,
1721 .name
= "gcc-mdm9615",
1722 .of_match_table
= gcc_mdm9615_match_table
,
1726 static int __init
gcc_mdm9615_init(void)
1728 return platform_driver_register(&gcc_mdm9615_driver
);
1730 core_initcall(gcc_mdm9615_init
);
1732 static void __exit
gcc_mdm9615_exit(void)
1734 platform_driver_unregister(&gcc_mdm9615_driver
);
1736 module_exit(gcc_mdm9615_exit
);
1738 MODULE_DESCRIPTION("QCOM GCC MDM9615 Driver");
1739 MODULE_LICENSE("GPL v2");
1740 MODULE_ALIAS("platform:gcc-mdm9615");