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/clk-provider.h>
15 #include <linux/regmap.h>
16 #include <linux/reset-controller.h>
18 #include <dt-bindings/clock/qcom,gcc-mdm9615.h>
19 #include <dt-bindings/reset/qcom,gcc-mdm9615.h>
22 #include "clk-regmap.h"
25 #include "clk-branch.h"
39 static const struct parent_map gcc_cxo_map
[] = {
43 static const struct clk_parent_data gcc_cxo
[] = {
44 { .index
= DT_CXO
, .name
= "cxo_board" },
47 static struct clk_pll pll0
= {
55 .clkr
.hw
.init
= &(struct clk_init_data
){
57 .parent_data
= gcc_cxo
,
58 .num_parents
= ARRAY_SIZE(gcc_cxo
),
63 static struct clk_regmap pll0_vote
= {
65 .enable_mask
= BIT(0),
66 .hw
.init
= &(struct clk_init_data
){
68 .parent_hws
= (const struct clk_hw
*[]) {
72 .ops
= &clk_pll_vote_ops
,
76 static struct clk_regmap pll4_vote
= {
78 .enable_mask
= BIT(4),
79 .hw
.init
= &(struct clk_init_data
){
81 .parent_data
= &(const struct clk_parent_data
) {
82 .index
= DT_PLL4
, .name
= "pll4",
85 .ops
= &clk_pll_vote_ops
,
89 static struct clk_pll pll8
= {
97 .clkr
.hw
.init
= &(struct clk_init_data
){
99 .parent_data
= gcc_cxo
,
100 .num_parents
= ARRAY_SIZE(gcc_cxo
),
105 static struct clk_regmap pll8_vote
= {
106 .enable_reg
= 0x34c0,
107 .enable_mask
= BIT(8),
108 .hw
.init
= &(struct clk_init_data
){
110 .parent_hws
= (const struct clk_hw
*[]) {
114 .ops
= &clk_pll_vote_ops
,
118 static struct clk_pll pll14
= {
122 .config_reg
= 0x31d4,
124 .status_reg
= 0x31d8,
126 .clkr
.hw
.init
= &(struct clk_init_data
){
128 .parent_data
= gcc_cxo
,
129 .num_parents
= ARRAY_SIZE(gcc_cxo
),
134 static struct clk_regmap pll14_vote
= {
135 .enable_reg
= 0x34c0,
136 .enable_mask
= BIT(11),
137 .hw
.init
= &(struct clk_init_data
){
138 .name
= "pll14_vote",
139 .parent_hws
= (const struct clk_hw
*[]) {
143 .ops
= &clk_pll_vote_ops
,
147 static const struct parent_map gcc_cxo_pll8_map
[] = {
152 static const struct clk_parent_data gcc_cxo_pll8
[] = {
153 { .index
= DT_CXO
, .name
= "cxo_board" },
154 { .hw
= &pll8_vote
.hw
},
157 static const struct parent_map gcc_cxo_pll14_map
[] = {
162 static const struct clk_parent_data gcc_cxo_pll14
[] = {
163 { .index
= DT_CXO
, .name
= "cxo_board" },
164 { .hw
= &pll14_vote
.hw
},
167 static const struct freq_tbl clk_tbl_gsbi_uart
[] = {
168 { 1843200, P_PLL8
, 2, 6, 625 },
169 { 3686400, P_PLL8
, 2, 12, 625 },
170 { 7372800, P_PLL8
, 2, 24, 625 },
171 { 14745600, P_PLL8
, 2, 48, 625 },
172 { 16000000, P_PLL8
, 4, 1, 6 },
173 { 24000000, P_PLL8
, 4, 1, 4 },
174 { 32000000, P_PLL8
, 4, 1, 3 },
175 { 40000000, P_PLL8
, 1, 5, 48 },
176 { 46400000, P_PLL8
, 1, 29, 240 },
177 { 48000000, P_PLL8
, 4, 1, 2 },
178 { 51200000, P_PLL8
, 1, 2, 15 },
179 { 56000000, P_PLL8
, 1, 7, 48 },
180 { 58982400, P_PLL8
, 1, 96, 625 },
181 { 64000000, P_PLL8
, 2, 1, 3 },
185 static struct clk_rcg gsbi1_uart_src
= {
190 .mnctr_reset_bit
= 7,
191 .mnctr_mode_shift
= 5,
202 .parent_map
= gcc_cxo_pll8_map
,
204 .freq_tbl
= clk_tbl_gsbi_uart
,
206 .enable_reg
= 0x29d4,
207 .enable_mask
= BIT(11),
208 .hw
.init
= &(struct clk_init_data
){
209 .name
= "gsbi1_uart_src",
210 .parent_data
= gcc_cxo_pll8
,
211 .num_parents
= ARRAY_SIZE(gcc_cxo_pll8
),
213 .flags
= CLK_SET_PARENT_GATE
,
218 static struct clk_branch gsbi1_uart_clk
= {
222 .enable_reg
= 0x29d4,
223 .enable_mask
= BIT(9),
224 .hw
.init
= &(struct clk_init_data
){
225 .name
= "gsbi1_uart_clk",
226 .parent_hws
= (const struct clk_hw
*[]) {
227 &gsbi1_uart_src
.clkr
.hw
,
230 .ops
= &clk_branch_ops
,
231 .flags
= CLK_SET_RATE_PARENT
,
236 static struct clk_rcg gsbi2_uart_src
= {
241 .mnctr_reset_bit
= 7,
242 .mnctr_mode_shift
= 5,
253 .parent_map
= gcc_cxo_pll8_map
,
255 .freq_tbl
= clk_tbl_gsbi_uart
,
257 .enable_reg
= 0x29f4,
258 .enable_mask
= BIT(11),
259 .hw
.init
= &(struct clk_init_data
){
260 .name
= "gsbi2_uart_src",
261 .parent_data
= gcc_cxo_pll8
,
262 .num_parents
= ARRAY_SIZE(gcc_cxo_pll8
),
264 .flags
= CLK_SET_PARENT_GATE
,
269 static struct clk_branch gsbi2_uart_clk
= {
273 .enable_reg
= 0x29f4,
274 .enable_mask
= BIT(9),
275 .hw
.init
= &(struct clk_init_data
){
276 .name
= "gsbi2_uart_clk",
277 .parent_hws
= (const struct clk_hw
*[]) {
278 &gsbi2_uart_src
.clkr
.hw
,
281 .ops
= &clk_branch_ops
,
282 .flags
= CLK_SET_RATE_PARENT
,
287 static struct clk_rcg gsbi3_uart_src
= {
292 .mnctr_reset_bit
= 7,
293 .mnctr_mode_shift
= 5,
304 .parent_map
= gcc_cxo_pll8_map
,
306 .freq_tbl
= clk_tbl_gsbi_uart
,
308 .enable_reg
= 0x2a14,
309 .enable_mask
= BIT(11),
310 .hw
.init
= &(struct clk_init_data
){
311 .name
= "gsbi3_uart_src",
312 .parent_data
= gcc_cxo_pll8
,
313 .num_parents
= ARRAY_SIZE(gcc_cxo_pll8
),
315 .flags
= CLK_SET_PARENT_GATE
,
320 static struct clk_branch gsbi3_uart_clk
= {
324 .enable_reg
= 0x2a14,
325 .enable_mask
= BIT(9),
326 .hw
.init
= &(struct clk_init_data
){
327 .name
= "gsbi3_uart_clk",
328 .parent_hws
= (const struct clk_hw
*[]) {
329 &gsbi3_uart_src
.clkr
.hw
,
332 .ops
= &clk_branch_ops
,
333 .flags
= CLK_SET_RATE_PARENT
,
338 static struct clk_rcg gsbi4_uart_src
= {
343 .mnctr_reset_bit
= 7,
344 .mnctr_mode_shift
= 5,
355 .parent_map
= gcc_cxo_pll8_map
,
357 .freq_tbl
= clk_tbl_gsbi_uart
,
359 .enable_reg
= 0x2a34,
360 .enable_mask
= BIT(11),
361 .hw
.init
= &(struct clk_init_data
){
362 .name
= "gsbi4_uart_src",
363 .parent_data
= gcc_cxo_pll8
,
364 .num_parents
= ARRAY_SIZE(gcc_cxo_pll8
),
366 .flags
= CLK_SET_PARENT_GATE
,
371 static struct clk_branch gsbi4_uart_clk
= {
375 .enable_reg
= 0x2a34,
376 .enable_mask
= BIT(9),
377 .hw
.init
= &(struct clk_init_data
){
378 .name
= "gsbi4_uart_clk",
379 .parent_hws
= (const struct clk_hw
*[]) {
380 &gsbi4_uart_src
.clkr
.hw
,
383 .ops
= &clk_branch_ops
,
384 .flags
= CLK_SET_RATE_PARENT
,
389 static struct clk_rcg gsbi5_uart_src
= {
394 .mnctr_reset_bit
= 7,
395 .mnctr_mode_shift
= 5,
406 .parent_map
= gcc_cxo_pll8_map
,
408 .freq_tbl
= clk_tbl_gsbi_uart
,
410 .enable_reg
= 0x2a54,
411 .enable_mask
= BIT(11),
412 .hw
.init
= &(struct clk_init_data
){
413 .name
= "gsbi5_uart_src",
414 .parent_data
= gcc_cxo_pll8
,
415 .num_parents
= ARRAY_SIZE(gcc_cxo_pll8
),
417 .flags
= CLK_SET_PARENT_GATE
,
422 static struct clk_branch gsbi5_uart_clk
= {
426 .enable_reg
= 0x2a54,
427 .enable_mask
= BIT(9),
428 .hw
.init
= &(struct clk_init_data
){
429 .name
= "gsbi5_uart_clk",
430 .parent_hws
= (const struct clk_hw
*[]) {
431 &gsbi5_uart_src
.clkr
.hw
,
434 .ops
= &clk_branch_ops
,
435 .flags
= CLK_SET_RATE_PARENT
,
440 static const struct freq_tbl clk_tbl_gsbi_qup
[] = {
441 { 960000, P_CXO
, 4, 1, 5 },
442 { 4800000, P_CXO
, 4, 0, 1 },
443 { 9600000, P_CXO
, 2, 0, 1 },
444 { 15060000, P_PLL8
, 1, 2, 51 },
445 { 24000000, P_PLL8
, 4, 1, 4 },
446 { 25600000, P_PLL8
, 1, 1, 15 },
447 { 48000000, P_PLL8
, 4, 1, 2 },
448 { 51200000, P_PLL8
, 1, 2, 15 },
452 static struct clk_rcg gsbi1_qup_src
= {
457 .mnctr_reset_bit
= 7,
458 .mnctr_mode_shift
= 5,
469 .parent_map
= gcc_cxo_pll8_map
,
471 .freq_tbl
= clk_tbl_gsbi_qup
,
473 .enable_reg
= 0x29cc,
474 .enable_mask
= BIT(11),
475 .hw
.init
= &(struct clk_init_data
){
476 .name
= "gsbi1_qup_src",
477 .parent_data
= gcc_cxo_pll8
,
478 .num_parents
= ARRAY_SIZE(gcc_cxo_pll8
),
480 .flags
= CLK_SET_PARENT_GATE
,
485 static struct clk_branch gsbi1_qup_clk
= {
489 .enable_reg
= 0x29cc,
490 .enable_mask
= BIT(9),
491 .hw
.init
= &(struct clk_init_data
){
492 .name
= "gsbi1_qup_clk",
493 .parent_hws
= (const struct clk_hw
*[]) {
494 &gsbi1_qup_src
.clkr
.hw
,
497 .ops
= &clk_branch_ops
,
498 .flags
= CLK_SET_RATE_PARENT
,
503 static struct clk_rcg gsbi2_qup_src
= {
508 .mnctr_reset_bit
= 7,
509 .mnctr_mode_shift
= 5,
520 .parent_map
= gcc_cxo_pll8_map
,
522 .freq_tbl
= clk_tbl_gsbi_qup
,
524 .enable_reg
= 0x29ec,
525 .enable_mask
= BIT(11),
526 .hw
.init
= &(struct clk_init_data
){
527 .name
= "gsbi2_qup_src",
528 .parent_data
= gcc_cxo_pll8
,
529 .num_parents
= ARRAY_SIZE(gcc_cxo_pll8
),
531 .flags
= CLK_SET_PARENT_GATE
,
536 static struct clk_branch gsbi2_qup_clk
= {
540 .enable_reg
= 0x29ec,
541 .enable_mask
= BIT(9),
542 .hw
.init
= &(struct clk_init_data
){
543 .name
= "gsbi2_qup_clk",
544 .parent_hws
= (const struct clk_hw
*[]) {
545 &gsbi2_qup_src
.clkr
.hw
,
548 .ops
= &clk_branch_ops
,
549 .flags
= CLK_SET_RATE_PARENT
,
554 static struct clk_rcg gsbi3_qup_src
= {
559 .mnctr_reset_bit
= 7,
560 .mnctr_mode_shift
= 5,
571 .parent_map
= gcc_cxo_pll8_map
,
573 .freq_tbl
= clk_tbl_gsbi_qup
,
575 .enable_reg
= 0x2a0c,
576 .enable_mask
= BIT(11),
577 .hw
.init
= &(struct clk_init_data
){
578 .name
= "gsbi3_qup_src",
579 .parent_data
= gcc_cxo_pll8
,
580 .num_parents
= ARRAY_SIZE(gcc_cxo_pll8
),
582 .flags
= CLK_SET_PARENT_GATE
,
587 static struct clk_branch gsbi3_qup_clk
= {
591 .enable_reg
= 0x2a0c,
592 .enable_mask
= BIT(9),
593 .hw
.init
= &(struct clk_init_data
){
594 .name
= "gsbi3_qup_clk",
595 .parent_hws
= (const struct clk_hw
*[]) {
596 &gsbi3_qup_src
.clkr
.hw
,
599 .ops
= &clk_branch_ops
,
600 .flags
= CLK_SET_RATE_PARENT
,
605 static struct clk_rcg gsbi4_qup_src
= {
610 .mnctr_reset_bit
= 7,
611 .mnctr_mode_shift
= 5,
622 .parent_map
= gcc_cxo_pll8_map
,
624 .freq_tbl
= clk_tbl_gsbi_qup
,
626 .enable_reg
= 0x2a2c,
627 .enable_mask
= BIT(11),
628 .hw
.init
= &(struct clk_init_data
){
629 .name
= "gsbi4_qup_src",
630 .parent_data
= gcc_cxo_pll8
,
631 .num_parents
= ARRAY_SIZE(gcc_cxo_pll8
),
633 .flags
= CLK_SET_PARENT_GATE
,
638 static struct clk_branch gsbi4_qup_clk
= {
642 .enable_reg
= 0x2a2c,
643 .enable_mask
= BIT(9),
644 .hw
.init
= &(struct clk_init_data
){
645 .name
= "gsbi4_qup_clk",
646 .parent_hws
= (const struct clk_hw
*[]) {
647 &gsbi4_qup_src
.clkr
.hw
,
650 .ops
= &clk_branch_ops
,
651 .flags
= CLK_SET_RATE_PARENT
,
656 static struct clk_rcg gsbi5_qup_src
= {
661 .mnctr_reset_bit
= 7,
662 .mnctr_mode_shift
= 5,
673 .parent_map
= gcc_cxo_pll8_map
,
675 .freq_tbl
= clk_tbl_gsbi_qup
,
677 .enable_reg
= 0x2a4c,
678 .enable_mask
= BIT(11),
679 .hw
.init
= &(struct clk_init_data
){
680 .name
= "gsbi5_qup_src",
681 .parent_data
= gcc_cxo_pll8
,
682 .num_parents
= ARRAY_SIZE(gcc_cxo_pll8
),
684 .flags
= CLK_SET_PARENT_GATE
,
689 static struct clk_branch gsbi5_qup_clk
= {
693 .enable_reg
= 0x2a4c,
694 .enable_mask
= BIT(9),
695 .hw
.init
= &(struct clk_init_data
){
696 .name
= "gsbi5_qup_clk",
697 .parent_hws
= (const struct clk_hw
*[]) {
698 &gsbi5_qup_src
.clkr
.hw
,
701 .ops
= &clk_branch_ops
,
702 .flags
= CLK_SET_RATE_PARENT
,
707 static const struct freq_tbl clk_tbl_gp
[] = {
708 { 9600000, P_CXO
, 2, 0, 0 },
709 { 19200000, P_CXO
, 1, 0, 0 },
713 static struct clk_rcg gp0_src
= {
718 .mnctr_reset_bit
= 7,
719 .mnctr_mode_shift
= 5,
730 .parent_map
= gcc_cxo_map
,
732 .freq_tbl
= clk_tbl_gp
,
734 .enable_reg
= 0x2d24,
735 .enable_mask
= BIT(11),
736 .hw
.init
= &(struct clk_init_data
){
738 .parent_data
= gcc_cxo
,
739 .num_parents
= ARRAY_SIZE(gcc_cxo
),
741 .flags
= CLK_SET_PARENT_GATE
,
746 static struct clk_branch gp0_clk
= {
750 .enable_reg
= 0x2d24,
751 .enable_mask
= BIT(9),
752 .hw
.init
= &(struct clk_init_data
){
754 .parent_hws
= (const struct clk_hw
*[]) {
758 .ops
= &clk_branch_ops
,
759 .flags
= CLK_SET_RATE_PARENT
,
764 static struct clk_rcg gp1_src
= {
769 .mnctr_reset_bit
= 7,
770 .mnctr_mode_shift
= 5,
781 .parent_map
= gcc_cxo_map
,
783 .freq_tbl
= clk_tbl_gp
,
785 .enable_reg
= 0x2d44,
786 .enable_mask
= BIT(11),
787 .hw
.init
= &(struct clk_init_data
){
789 .parent_data
= gcc_cxo
,
790 .num_parents
= ARRAY_SIZE(gcc_cxo
),
792 .flags
= CLK_SET_RATE_GATE
,
797 static struct clk_branch gp1_clk
= {
801 .enable_reg
= 0x2d44,
802 .enable_mask
= BIT(9),
803 .hw
.init
= &(struct clk_init_data
){
805 .parent_hws
= (const struct clk_hw
*[]) {
809 .ops
= &clk_branch_ops
,
810 .flags
= CLK_SET_RATE_PARENT
,
815 static struct clk_rcg gp2_src
= {
820 .mnctr_reset_bit
= 7,
821 .mnctr_mode_shift
= 5,
832 .parent_map
= gcc_cxo_map
,
834 .freq_tbl
= clk_tbl_gp
,
836 .enable_reg
= 0x2d64,
837 .enable_mask
= BIT(11),
838 .hw
.init
= &(struct clk_init_data
){
840 .parent_data
= gcc_cxo
,
841 .num_parents
= ARRAY_SIZE(gcc_cxo
),
843 .flags
= CLK_SET_RATE_GATE
,
848 static struct clk_branch gp2_clk
= {
852 .enable_reg
= 0x2d64,
853 .enable_mask
= BIT(9),
854 .hw
.init
= &(struct clk_init_data
){
856 .parent_hws
= (const struct clk_hw
*[]) {
860 .ops
= &clk_branch_ops
,
861 .flags
= CLK_SET_RATE_PARENT
,
866 static struct clk_branch pmem_clk
= {
872 .enable_reg
= 0x25a0,
873 .enable_mask
= BIT(4),
874 .hw
.init
= &(struct clk_init_data
){
876 .ops
= &clk_branch_ops
,
881 static struct clk_rcg prng_src
= {
889 .parent_map
= gcc_cxo_pll8_map
,
892 .hw
.init
= &(struct clk_init_data
){
894 .parent_data
= gcc_cxo_pll8
,
895 .num_parents
= ARRAY_SIZE(gcc_cxo_pll8
),
901 static struct clk_branch prng_clk
= {
903 .halt_check
= BRANCH_HALT_VOTED
,
906 .enable_reg
= 0x3080,
907 .enable_mask
= BIT(10),
908 .hw
.init
= &(struct clk_init_data
){
910 .parent_hws
= (const struct clk_hw
*[]) {
914 .ops
= &clk_branch_ops
,
919 static const struct freq_tbl clk_tbl_sdc
[] = {
920 { 144000, P_CXO
, 1, 1, 133 },
921 { 400000, P_PLL8
, 4, 1, 240 },
922 { 16000000, P_PLL8
, 4, 1, 6 },
923 { 17070000, P_PLL8
, 1, 2, 45 },
924 { 20210000, P_PLL8
, 1, 1, 19 },
925 { 24000000, P_PLL8
, 4, 1, 4 },
926 { 38400000, P_PLL8
, 2, 1, 5 },
927 { 48000000, P_PLL8
, 4, 1, 2 },
928 { 64000000, P_PLL8
, 3, 1, 2 },
929 { 76800000, P_PLL8
, 1, 1, 5 },
933 static struct clk_rcg sdc1_src
= {
938 .mnctr_reset_bit
= 7,
939 .mnctr_mode_shift
= 5,
950 .parent_map
= gcc_cxo_pll8_map
,
952 .freq_tbl
= clk_tbl_sdc
,
954 .enable_reg
= 0x282c,
955 .enable_mask
= BIT(11),
956 .hw
.init
= &(struct clk_init_data
){
958 .parent_data
= gcc_cxo_pll8
,
959 .num_parents
= ARRAY_SIZE(gcc_cxo_pll8
),
965 static struct clk_branch sdc1_clk
= {
969 .enable_reg
= 0x282c,
970 .enable_mask
= BIT(9),
971 .hw
.init
= &(struct clk_init_data
){
973 .parent_hws
= (const struct clk_hw
*[]) {
977 .ops
= &clk_branch_ops
,
978 .flags
= CLK_SET_RATE_PARENT
,
983 static struct clk_rcg sdc2_src
= {
988 .mnctr_reset_bit
= 7,
989 .mnctr_mode_shift
= 5,
1000 .parent_map
= gcc_cxo_pll8_map
,
1002 .freq_tbl
= clk_tbl_sdc
,
1004 .enable_reg
= 0x284c,
1005 .enable_mask
= BIT(11),
1006 .hw
.init
= &(struct clk_init_data
){
1008 .parent_data
= gcc_cxo_pll8
,
1009 .num_parents
= ARRAY_SIZE(gcc_cxo_pll8
),
1010 .ops
= &clk_rcg_ops
,
1015 static struct clk_branch sdc2_clk
= {
1019 .enable_reg
= 0x284c,
1020 .enable_mask
= BIT(9),
1021 .hw
.init
= &(struct clk_init_data
){
1023 .parent_hws
= (const struct clk_hw
*[]) {
1027 .ops
= &clk_branch_ops
,
1028 .flags
= CLK_SET_RATE_PARENT
,
1033 static const struct freq_tbl clk_tbl_usb
[] = {
1034 { 60000000, P_PLL8
, 1, 5, 32 },
1038 static struct clk_rcg usb_hs1_xcvr_src
= {
1043 .mnctr_reset_bit
= 7,
1044 .mnctr_mode_shift
= 5,
1055 .parent_map
= gcc_cxo_pll8_map
,
1057 .freq_tbl
= clk_tbl_usb
,
1059 .enable_reg
= 0x290c,
1060 .enable_mask
= BIT(11),
1061 .hw
.init
= &(struct clk_init_data
){
1062 .name
= "usb_hs1_xcvr_src",
1063 .parent_data
= gcc_cxo_pll8
,
1064 .num_parents
= ARRAY_SIZE(gcc_cxo_pll8
),
1065 .ops
= &clk_rcg_ops
,
1066 .flags
= CLK_SET_RATE_GATE
,
1071 static struct clk_branch usb_hs1_xcvr_clk
= {
1075 .enable_reg
= 0x290c,
1076 .enable_mask
= BIT(9),
1077 .hw
.init
= &(struct clk_init_data
){
1078 .name
= "usb_hs1_xcvr_clk",
1079 .parent_hws
= (const struct clk_hw
*[]) {
1080 &usb_hs1_xcvr_src
.clkr
.hw
,
1083 .ops
= &clk_branch_ops
,
1084 .flags
= CLK_SET_RATE_PARENT
,
1089 static struct clk_rcg usb_hsic_xcvr_fs_src
= {
1094 .mnctr_reset_bit
= 7,
1095 .mnctr_mode_shift
= 5,
1106 .parent_map
= gcc_cxo_pll8_map
,
1108 .freq_tbl
= clk_tbl_usb
,
1110 .enable_reg
= 0x2928,
1111 .enable_mask
= BIT(11),
1112 .hw
.init
= &(struct clk_init_data
){
1113 .name
= "usb_hsic_xcvr_fs_src",
1114 .parent_data
= gcc_cxo_pll8
,
1115 .num_parents
= ARRAY_SIZE(gcc_cxo_pll8
),
1116 .ops
= &clk_rcg_ops
,
1117 .flags
= CLK_SET_RATE_GATE
,
1122 static struct clk_branch usb_hsic_xcvr_fs_clk
= {
1126 .enable_reg
= 0x2928,
1127 .enable_mask
= BIT(9),
1128 .hw
.init
= &(struct clk_init_data
){
1129 .name
= "usb_hsic_xcvr_fs_clk",
1130 .parent_hws
= (const struct clk_hw
*[]) {
1131 &usb_hsic_xcvr_fs_src
.clkr
.hw
,
1134 .ops
= &clk_branch_ops
,
1135 .flags
= CLK_SET_RATE_PARENT
,
1140 static const struct freq_tbl clk_tbl_usb_hs1_system
[] = {
1141 { 60000000, P_PLL8
, 1, 5, 32 },
1145 static struct clk_rcg usb_hs1_system_src
= {
1150 .mnctr_reset_bit
= 7,
1151 .mnctr_mode_shift
= 5,
1162 .parent_map
= gcc_cxo_pll8_map
,
1164 .freq_tbl
= clk_tbl_usb_hs1_system
,
1166 .enable_reg
= 0x36a4,
1167 .enable_mask
= BIT(11),
1168 .hw
.init
= &(struct clk_init_data
){
1169 .name
= "usb_hs1_system_src",
1170 .parent_data
= gcc_cxo_pll8
,
1171 .num_parents
= ARRAY_SIZE(gcc_cxo_pll8
),
1172 .ops
= &clk_rcg_ops
,
1173 .flags
= CLK_SET_RATE_GATE
,
1178 static struct clk_branch usb_hs1_system_clk
= {
1182 .enable_reg
= 0x36a4,
1183 .enable_mask
= BIT(9),
1184 .hw
.init
= &(struct clk_init_data
){
1185 .parent_hws
= (const struct clk_hw
*[]) {
1186 &usb_hs1_system_src
.clkr
.hw
,
1189 .name
= "usb_hs1_system_clk",
1190 .ops
= &clk_branch_ops
,
1191 .flags
= CLK_SET_RATE_PARENT
| CLK_IGNORE_UNUSED
,
1196 static const struct freq_tbl clk_tbl_usb_hsic_system
[] = {
1197 { 64000000, P_PLL8
, 1, 1, 6 },
1201 static struct clk_rcg usb_hsic_system_src
= {
1206 .mnctr_reset_bit
= 7,
1207 .mnctr_mode_shift
= 5,
1218 .parent_map
= gcc_cxo_pll8_map
,
1220 .freq_tbl
= clk_tbl_usb_hsic_system
,
1222 .enable_reg
= 0x2b58,
1223 .enable_mask
= BIT(11),
1224 .hw
.init
= &(struct clk_init_data
){
1225 .name
= "usb_hsic_system_src",
1226 .parent_data
= gcc_cxo_pll8
,
1227 .num_parents
= ARRAY_SIZE(gcc_cxo_pll8
),
1228 .ops
= &clk_rcg_ops
,
1229 .flags
= CLK_SET_RATE_GATE
,
1234 static struct clk_branch usb_hsic_system_clk
= {
1238 .enable_reg
= 0x2b58,
1239 .enable_mask
= BIT(9),
1240 .hw
.init
= &(struct clk_init_data
){
1241 .parent_hws
= (const struct clk_hw
*[]) {
1242 &usb_hsic_system_src
.clkr
.hw
,
1245 .name
= "usb_hsic_system_clk",
1246 .ops
= &clk_branch_ops
,
1247 .flags
= CLK_SET_RATE_PARENT
,
1252 static const struct freq_tbl clk_tbl_usb_hsic_hsic
[] = {
1253 { 48000000, P_PLL14
, 1, 0, 0 },
1257 static struct clk_rcg usb_hsic_hsic_src
= {
1262 .mnctr_reset_bit
= 7,
1263 .mnctr_mode_shift
= 5,
1274 .parent_map
= gcc_cxo_pll14_map
,
1276 .freq_tbl
= clk_tbl_usb_hsic_hsic
,
1278 .enable_reg
= 0x2b50,
1279 .enable_mask
= BIT(11),
1280 .hw
.init
= &(struct clk_init_data
){
1281 .name
= "usb_hsic_hsic_src",
1282 .parent_data
= gcc_cxo_pll14
,
1283 .num_parents
= ARRAY_SIZE(gcc_cxo_pll14
),
1284 .ops
= &clk_rcg_ops
,
1285 .flags
= CLK_SET_RATE_GATE
,
1290 static struct clk_branch usb_hsic_hsic_clk
= {
1291 .halt_check
= BRANCH_HALT_DELAY
,
1293 .enable_reg
= 0x2b50,
1294 .enable_mask
= BIT(9),
1295 .hw
.init
= &(struct clk_init_data
){
1296 .parent_hws
= (const struct clk_hw
*[]) {
1297 &usb_hsic_hsic_src
.clkr
.hw
,
1300 .name
= "usb_hsic_hsic_clk",
1301 .ops
= &clk_branch_ops
,
1302 .flags
= CLK_SET_RATE_PARENT
,
1307 static struct clk_branch usb_hsic_hsio_cal_clk
= {
1311 .enable_reg
= 0x2b48,
1312 .enable_mask
= BIT(0),
1313 .hw
.init
= &(struct clk_init_data
){
1314 .parent_data
= gcc_cxo
,
1315 .num_parents
= ARRAY_SIZE(gcc_cxo
),
1316 .name
= "usb_hsic_hsio_cal_clk",
1317 .ops
= &clk_branch_ops
,
1322 static struct clk_branch ce1_core_clk
= {
1328 .enable_reg
= 0x2724,
1329 .enable_mask
= BIT(4),
1330 .hw
.init
= &(struct clk_init_data
){
1331 .name
= "ce1_core_clk",
1332 .ops
= &clk_branch_ops
,
1337 static struct clk_branch ce1_h_clk
= {
1341 .enable_reg
= 0x2720,
1342 .enable_mask
= BIT(4),
1343 .hw
.init
= &(struct clk_init_data
){
1344 .name
= "ce1_h_clk",
1345 .ops
= &clk_branch_ops
,
1350 static struct clk_branch dma_bam_h_clk
= {
1356 .enable_reg
= 0x25c0,
1357 .enable_mask
= BIT(4),
1358 .hw
.init
= &(struct clk_init_data
){
1359 .name
= "dma_bam_h_clk",
1360 .ops
= &clk_branch_ops
,
1365 static struct clk_branch gsbi1_h_clk
= {
1371 .enable_reg
= 0x29c0,
1372 .enable_mask
= BIT(4),
1373 .hw
.init
= &(struct clk_init_data
){
1374 .name
= "gsbi1_h_clk",
1375 .ops
= &clk_branch_ops
,
1380 static struct clk_branch gsbi2_h_clk
= {
1386 .enable_reg
= 0x29e0,
1387 .enable_mask
= BIT(4),
1388 .hw
.init
= &(struct clk_init_data
){
1389 .name
= "gsbi2_h_clk",
1390 .ops
= &clk_branch_ops
,
1395 static struct clk_branch gsbi3_h_clk
= {
1401 .enable_reg
= 0x2a00,
1402 .enable_mask
= BIT(4),
1403 .hw
.init
= &(struct clk_init_data
){
1404 .name
= "gsbi3_h_clk",
1405 .ops
= &clk_branch_ops
,
1410 static struct clk_branch gsbi4_h_clk
= {
1416 .enable_reg
= 0x2a20,
1417 .enable_mask
= BIT(4),
1418 .hw
.init
= &(struct clk_init_data
){
1419 .name
= "gsbi4_h_clk",
1420 .ops
= &clk_branch_ops
,
1425 static struct clk_branch gsbi5_h_clk
= {
1431 .enable_reg
= 0x2a40,
1432 .enable_mask
= BIT(4),
1433 .hw
.init
= &(struct clk_init_data
){
1434 .name
= "gsbi5_h_clk",
1435 .ops
= &clk_branch_ops
,
1440 static struct clk_branch usb_hs1_h_clk
= {
1446 .enable_reg
= 0x2900,
1447 .enable_mask
= BIT(4),
1448 .hw
.init
= &(struct clk_init_data
){
1449 .name
= "usb_hs1_h_clk",
1450 .ops
= &clk_branch_ops
,
1455 static struct clk_branch usb_hsic_h_clk
= {
1459 .enable_reg
= 0x2920,
1460 .enable_mask
= BIT(4),
1461 .hw
.init
= &(struct clk_init_data
){
1462 .name
= "usb_hsic_h_clk",
1463 .ops
= &clk_branch_ops
,
1468 static struct clk_branch sdc1_h_clk
= {
1474 .enable_reg
= 0x2820,
1475 .enable_mask
= BIT(4),
1476 .hw
.init
= &(struct clk_init_data
){
1477 .name
= "sdc1_h_clk",
1478 .ops
= &clk_branch_ops
,
1483 static struct clk_branch sdc2_h_clk
= {
1489 .enable_reg
= 0x2840,
1490 .enable_mask
= BIT(4),
1491 .hw
.init
= &(struct clk_init_data
){
1492 .name
= "sdc2_h_clk",
1493 .ops
= &clk_branch_ops
,
1498 static struct clk_branch adm0_clk
= {
1500 .halt_check
= BRANCH_HALT_VOTED
,
1503 .enable_reg
= 0x3080,
1504 .enable_mask
= BIT(2),
1505 .hw
.init
= &(struct clk_init_data
){
1507 .ops
= &clk_branch_ops
,
1512 static struct clk_branch adm0_pbus_clk
= {
1516 .halt_check
= BRANCH_HALT_VOTED
,
1519 .enable_reg
= 0x3080,
1520 .enable_mask
= BIT(3),
1521 .hw
.init
= &(struct clk_init_data
){
1522 .name
= "adm0_pbus_clk",
1523 .ops
= &clk_branch_ops
,
1528 static struct clk_branch pmic_arb0_h_clk
= {
1530 .halt_check
= BRANCH_HALT_VOTED
,
1533 .enable_reg
= 0x3080,
1534 .enable_mask
= BIT(8),
1535 .hw
.init
= &(struct clk_init_data
){
1536 .name
= "pmic_arb0_h_clk",
1537 .ops
= &clk_branch_ops
,
1542 static struct clk_branch pmic_arb1_h_clk
= {
1544 .halt_check
= BRANCH_HALT_VOTED
,
1547 .enable_reg
= 0x3080,
1548 .enable_mask
= BIT(9),
1549 .hw
.init
= &(struct clk_init_data
){
1550 .name
= "pmic_arb1_h_clk",
1551 .ops
= &clk_branch_ops
,
1556 static struct clk_branch pmic_ssbi2_clk
= {
1558 .halt_check
= BRANCH_HALT_VOTED
,
1561 .enable_reg
= 0x3080,
1562 .enable_mask
= BIT(7),
1563 .hw
.init
= &(struct clk_init_data
){
1564 .name
= "pmic_ssbi2_clk",
1565 .ops
= &clk_branch_ops
,
1570 static struct clk_branch rpm_msg_ram_h_clk
= {
1574 .halt_check
= BRANCH_HALT_VOTED
,
1577 .enable_reg
= 0x3080,
1578 .enable_mask
= BIT(6),
1579 .hw
.init
= &(struct clk_init_data
){
1580 .name
= "rpm_msg_ram_h_clk",
1581 .ops
= &clk_branch_ops
,
1586 static struct clk_branch ebi2_clk
= {
1592 .enable_reg
= 0x2664,
1593 .enable_mask
= BIT(6) | BIT(4),
1594 .hw
.init
= &(struct clk_init_data
){
1596 .ops
= &clk_branch_ops
,
1601 static struct clk_branch ebi2_aon_clk
= {
1605 .enable_reg
= 0x2664,
1606 .enable_mask
= BIT(8),
1607 .hw
.init
= &(struct clk_init_data
){
1608 .name
= "ebi2_aon_clk",
1609 .ops
= &clk_branch_ops
,
1614 static struct clk_regmap
*gcc_mdm9615_clks
[] = {
1615 [PLL0
] = &pll0
.clkr
,
1616 [PLL0_VOTE
] = &pll0_vote
,
1617 [PLL4_VOTE
] = &pll4_vote
,
1618 [PLL8
] = &pll8
.clkr
,
1619 [PLL8_VOTE
] = &pll8_vote
,
1620 [PLL14
] = &pll14
.clkr
,
1621 [PLL14_VOTE
] = &pll14_vote
,
1622 [GSBI1_UART_SRC
] = &gsbi1_uart_src
.clkr
,
1623 [GSBI1_UART_CLK
] = &gsbi1_uart_clk
.clkr
,
1624 [GSBI2_UART_SRC
] = &gsbi2_uart_src
.clkr
,
1625 [GSBI2_UART_CLK
] = &gsbi2_uart_clk
.clkr
,
1626 [GSBI3_UART_SRC
] = &gsbi3_uart_src
.clkr
,
1627 [GSBI3_UART_CLK
] = &gsbi3_uart_clk
.clkr
,
1628 [GSBI4_UART_SRC
] = &gsbi4_uart_src
.clkr
,
1629 [GSBI4_UART_CLK
] = &gsbi4_uart_clk
.clkr
,
1630 [GSBI5_UART_SRC
] = &gsbi5_uart_src
.clkr
,
1631 [GSBI5_UART_CLK
] = &gsbi5_uart_clk
.clkr
,
1632 [GSBI1_QUP_SRC
] = &gsbi1_qup_src
.clkr
,
1633 [GSBI1_QUP_CLK
] = &gsbi1_qup_clk
.clkr
,
1634 [GSBI2_QUP_SRC
] = &gsbi2_qup_src
.clkr
,
1635 [GSBI2_QUP_CLK
] = &gsbi2_qup_clk
.clkr
,
1636 [GSBI3_QUP_SRC
] = &gsbi3_qup_src
.clkr
,
1637 [GSBI3_QUP_CLK
] = &gsbi3_qup_clk
.clkr
,
1638 [GSBI4_QUP_SRC
] = &gsbi4_qup_src
.clkr
,
1639 [GSBI4_QUP_CLK
] = &gsbi4_qup_clk
.clkr
,
1640 [GSBI5_QUP_SRC
] = &gsbi5_qup_src
.clkr
,
1641 [GSBI5_QUP_CLK
] = &gsbi5_qup_clk
.clkr
,
1642 [GP0_SRC
] = &gp0_src
.clkr
,
1643 [GP0_CLK
] = &gp0_clk
.clkr
,
1644 [GP1_SRC
] = &gp1_src
.clkr
,
1645 [GP1_CLK
] = &gp1_clk
.clkr
,
1646 [GP2_SRC
] = &gp2_src
.clkr
,
1647 [GP2_CLK
] = &gp2_clk
.clkr
,
1648 [PMEM_A_CLK
] = &pmem_clk
.clkr
,
1649 [PRNG_SRC
] = &prng_src
.clkr
,
1650 [PRNG_CLK
] = &prng_clk
.clkr
,
1651 [SDC1_SRC
] = &sdc1_src
.clkr
,
1652 [SDC1_CLK
] = &sdc1_clk
.clkr
,
1653 [SDC2_SRC
] = &sdc2_src
.clkr
,
1654 [SDC2_CLK
] = &sdc2_clk
.clkr
,
1655 [USB_HS1_XCVR_SRC
] = &usb_hs1_xcvr_src
.clkr
,
1656 [USB_HS1_XCVR_CLK
] = &usb_hs1_xcvr_clk
.clkr
,
1657 [USB_HS1_SYSTEM_CLK_SRC
] = &usb_hs1_system_src
.clkr
,
1658 [USB_HS1_SYSTEM_CLK
] = &usb_hs1_system_clk
.clkr
,
1659 [USB_HSIC_XCVR_FS_SRC
] = &usb_hsic_xcvr_fs_src
.clkr
,
1660 [USB_HSIC_XCVR_FS_CLK
] = &usb_hsic_xcvr_fs_clk
.clkr
,
1661 [USB_HSIC_SYSTEM_CLK_SRC
] = &usb_hsic_system_src
.clkr
,
1662 [USB_HSIC_SYSTEM_CLK
] = &usb_hsic_system_clk
.clkr
,
1663 [USB_HSIC_HSIC_CLK_SRC
] = &usb_hsic_hsic_src
.clkr
,
1664 [USB_HSIC_HSIC_CLK
] = &usb_hsic_hsic_clk
.clkr
,
1665 [USB_HSIC_HSIO_CAL_CLK
] = &usb_hsic_hsio_cal_clk
.clkr
,
1666 [CE1_CORE_CLK
] = &ce1_core_clk
.clkr
,
1667 [CE1_H_CLK
] = &ce1_h_clk
.clkr
,
1668 [DMA_BAM_H_CLK
] = &dma_bam_h_clk
.clkr
,
1669 [GSBI1_H_CLK
] = &gsbi1_h_clk
.clkr
,
1670 [GSBI2_H_CLK
] = &gsbi2_h_clk
.clkr
,
1671 [GSBI3_H_CLK
] = &gsbi3_h_clk
.clkr
,
1672 [GSBI4_H_CLK
] = &gsbi4_h_clk
.clkr
,
1673 [GSBI5_H_CLK
] = &gsbi5_h_clk
.clkr
,
1674 [USB_HS1_H_CLK
] = &usb_hs1_h_clk
.clkr
,
1675 [USB_HSIC_H_CLK
] = &usb_hsic_h_clk
.clkr
,
1676 [SDC1_H_CLK
] = &sdc1_h_clk
.clkr
,
1677 [SDC2_H_CLK
] = &sdc2_h_clk
.clkr
,
1678 [ADM0_CLK
] = &adm0_clk
.clkr
,
1679 [ADM0_PBUS_CLK
] = &adm0_pbus_clk
.clkr
,
1680 [PMIC_ARB0_H_CLK
] = &pmic_arb0_h_clk
.clkr
,
1681 [PMIC_ARB1_H_CLK
] = &pmic_arb1_h_clk
.clkr
,
1682 [PMIC_SSBI2_CLK
] = &pmic_ssbi2_clk
.clkr
,
1683 [RPM_MSG_RAM_H_CLK
] = &rpm_msg_ram_h_clk
.clkr
,
1684 [EBI2_CLK
] = &ebi2_clk
.clkr
,
1685 [EBI2_AON_CLK
] = &ebi2_aon_clk
.clkr
,
1688 static const struct qcom_reset_map gcc_mdm9615_resets
[] = {
1689 [DMA_BAM_RESET
] = { 0x25c0, 7 },
1690 [CE1_H_RESET
] = { 0x2720, 7 },
1691 [CE1_CORE_RESET
] = { 0x2724, 7 },
1692 [SDC1_RESET
] = { 0x2830 },
1693 [SDC2_RESET
] = { 0x2850 },
1694 [ADM0_C2_RESET
] = { 0x220c, 4 },
1695 [ADM0_C1_RESET
] = { 0x220c, 3 },
1696 [ADM0_C0_RESET
] = { 0x220c, 2 },
1697 [ADM0_PBUS_RESET
] = { 0x220c, 1 },
1698 [ADM0_RESET
] = { 0x220c },
1699 [USB_HS1_RESET
] = { 0x2910 },
1700 [USB_HSIC_RESET
] = { 0x2934 },
1701 [GSBI1_RESET
] = { 0x29dc },
1702 [GSBI2_RESET
] = { 0x29fc },
1703 [GSBI3_RESET
] = { 0x2a1c },
1704 [GSBI4_RESET
] = { 0x2a3c },
1705 [GSBI5_RESET
] = { 0x2a5c },
1706 [PDM_RESET
] = { 0x2CC0, 12 },
1709 static const struct regmap_config gcc_mdm9615_regmap_config
= {
1713 .max_register
= 0x3660,
1717 static const struct qcom_cc_desc gcc_mdm9615_desc
= {
1718 .config
= &gcc_mdm9615_regmap_config
,
1719 .clks
= gcc_mdm9615_clks
,
1720 .num_clks
= ARRAY_SIZE(gcc_mdm9615_clks
),
1721 .resets
= gcc_mdm9615_resets
,
1722 .num_resets
= ARRAY_SIZE(gcc_mdm9615_resets
),
1725 static const struct of_device_id gcc_mdm9615_match_table
[] = {
1726 { .compatible
= "qcom,gcc-mdm9615" },
1729 MODULE_DEVICE_TABLE(of
, gcc_mdm9615_match_table
);
1731 static int gcc_mdm9615_probe(struct platform_device
*pdev
)
1733 struct regmap
*regmap
;
1735 regmap
= qcom_cc_map(pdev
, &gcc_mdm9615_desc
);
1737 return PTR_ERR(regmap
);
1739 return qcom_cc_really_probe(&pdev
->dev
, &gcc_mdm9615_desc
, regmap
);
1742 static struct platform_driver gcc_mdm9615_driver
= {
1743 .probe
= gcc_mdm9615_probe
,
1745 .name
= "gcc-mdm9615",
1746 .of_match_table
= gcc_mdm9615_match_table
,
1750 static int __init
gcc_mdm9615_init(void)
1752 return platform_driver_register(&gcc_mdm9615_driver
);
1754 core_initcall(gcc_mdm9615_init
);
1756 static void __exit
gcc_mdm9615_exit(void)
1758 platform_driver_unregister(&gcc_mdm9615_driver
);
1760 module_exit(gcc_mdm9615_exit
);
1762 MODULE_DESCRIPTION("QCOM GCC MDM9615 Driver");
1763 MODULE_LICENSE("GPL v2");
1764 MODULE_ALIAS("platform:gcc-mdm9615");