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>
23 #include <linux/math64.h>
24 #include <linux/delay.h>
25 #include <linux/clk.h>
27 #include <dt-bindings/clock/qcom,gcc-ipq4019.h>
30 #include "clk-regmap.h"
32 #include "clk-branch.h"
34 #include "clk-regmap-divider.h"
36 #define to_clk_regmap_div(_hw) container_of(to_clk_regmap(_hw),\
37 struct clk_regmap_div, clkr)
39 #define to_clk_fepll(_hw) container_of(to_clk_regmap_div(_hw),\
40 struct clk_fepll, cdiv)
54 * struct clk_fepll_vco - vco feedback divider corresponds for FEPLL clocks
55 * @fdbkdiv_shift: lowest bit for FDBKDIV
56 * @fdbkdiv_width: number of bits in FDBKDIV
57 * @refclkdiv_shift: lowest bit for REFCLKDIV
58 * @refclkdiv_width: number of bits in REFCLKDIV
59 * @reg: PLL_DIV register address
61 struct clk_fepll_vco
{
70 * struct clk_fepll - clk divider corresponds to FEPLL clocks
71 * @fixed_div: fixed divider value if divider is fixed
72 * @parent_map: map from software's parent index to hardware's src_sel field
73 * @cdiv: divider values for PLL_DIV
74 * @pll_vco: vco feedback divider
75 * @div_table: mapping for actual divider value to register divider value
76 * in case of non fixed divider
77 * @freq_tbl: frequency table
82 struct clk_regmap_div cdiv
;
83 const struct clk_fepll_vco
*pll_vco
;
84 const struct clk_div_table
*div_table
;
85 const struct freq_tbl
*freq_tbl
;
88 static struct parent_map gcc_xo_200_500_map
[] = {
94 static const char * const gcc_xo_200_500
[] = {
100 static struct parent_map gcc_xo_200_map
[] = {
105 static const char * const gcc_xo_200
[] = {
110 static struct parent_map gcc_xo_200_spi_map
[] = {
115 static const char * const gcc_xo_200_spi
[] = {
120 static struct parent_map gcc_xo_sdcc1_500_map
[] = {
126 static const char * const gcc_xo_sdcc1_500
[] = {
132 static struct parent_map gcc_xo_wcss2g_map
[] = {
134 { P_FEPLLWCSS2G
, 1 },
137 static const char * const gcc_xo_wcss2g
[] = {
142 static struct parent_map gcc_xo_wcss5g_map
[] = {
144 { P_FEPLLWCSS5G
, 1 },
147 static const char * const gcc_xo_wcss5g
[] = {
152 static struct parent_map gcc_xo_125_dly_map
[] = {
154 { P_FEPLL125DLY
, 1 },
157 static const char * const gcc_xo_125_dly
[] = {
162 static struct parent_map gcc_xo_ddr_500_200_map
[] = {
170 * Contains index for safe clock during APSS freq change.
171 * fepll500 is being used as safe clock so initialize it
172 * with its index in parents list gcc_xo_ddr_500_200.
174 static const int gcc_ipq4019_cpu_safe_parent
= 2;
175 static const char * const gcc_xo_ddr_500_200
[] = {
182 static const struct freq_tbl ftbl_gcc_audio_pwm_clk
[] = {
183 F(48000000, P_XO
, 1, 0, 0),
184 F(200000000, P_FEPLL200
, 1, 0, 0),
188 static struct clk_rcg2 audio_clk_src
= {
191 .parent_map
= gcc_xo_200_map
,
192 .freq_tbl
= ftbl_gcc_audio_pwm_clk
,
193 .clkr
.hw
.init
= &(struct clk_init_data
){
194 .name
= "audio_clk_src",
195 .parent_names
= gcc_xo_200
,
197 .ops
= &clk_rcg2_ops
,
202 static struct clk_branch gcc_audio_ahb_clk
= {
205 .enable_reg
= 0x1b010,
206 .enable_mask
= BIT(0),
207 .hw
.init
= &(struct clk_init_data
){
208 .name
= "gcc_audio_ahb_clk",
209 .parent_names
= (const char *[]){
212 .flags
= CLK_SET_RATE_PARENT
,
214 .ops
= &clk_branch2_ops
,
219 static struct clk_branch gcc_audio_pwm_clk
= {
222 .enable_reg
= 0x1b00C,
223 .enable_mask
= BIT(0),
224 .hw
.init
= &(struct clk_init_data
){
225 .name
= "gcc_audio_pwm_clk",
226 .parent_names
= (const char *[]){
229 .flags
= CLK_SET_RATE_PARENT
,
231 .ops
= &clk_branch2_ops
,
236 static const struct freq_tbl ftbl_gcc_blsp1_qup1_2_i2c_apps_clk
[] = {
237 F(19050000, P_FEPLL200
, 10.5, 1, 1),
241 static struct clk_rcg2 blsp1_qup1_i2c_apps_clk_src
= {
244 .parent_map
= gcc_xo_200_map
,
245 .freq_tbl
= ftbl_gcc_blsp1_qup1_2_i2c_apps_clk
,
246 .clkr
.hw
.init
= &(struct clk_init_data
){
247 .name
= "blsp1_qup1_i2c_apps_clk_src",
248 .parent_names
= gcc_xo_200
,
250 .ops
= &clk_rcg2_ops
,
254 static struct clk_branch gcc_blsp1_qup1_i2c_apps_clk
= {
257 .enable_reg
= 0x2008,
258 .enable_mask
= BIT(0),
259 .hw
.init
= &(struct clk_init_data
){
260 .name
= "gcc_blsp1_qup1_i2c_apps_clk",
261 .parent_names
= (const char *[]){
262 "blsp1_qup1_i2c_apps_clk_src",
265 .ops
= &clk_branch2_ops
,
266 .flags
= CLK_SET_RATE_PARENT
,
271 static struct clk_rcg2 blsp1_qup2_i2c_apps_clk_src
= {
274 .parent_map
= gcc_xo_200_map
,
275 .freq_tbl
= ftbl_gcc_blsp1_qup1_2_i2c_apps_clk
,
276 .clkr
.hw
.init
= &(struct clk_init_data
){
277 .name
= "blsp1_qup2_i2c_apps_clk_src",
278 .parent_names
= gcc_xo_200
,
280 .ops
= &clk_rcg2_ops
,
284 static struct clk_branch gcc_blsp1_qup2_i2c_apps_clk
= {
287 .enable_reg
= 0x3010,
288 .enable_mask
= BIT(0),
289 .hw
.init
= &(struct clk_init_data
){
290 .name
= "gcc_blsp1_qup2_i2c_apps_clk",
291 .parent_names
= (const char *[]){
292 "blsp1_qup2_i2c_apps_clk_src",
295 .ops
= &clk_branch2_ops
,
296 .flags
= CLK_SET_RATE_PARENT
,
301 static const struct freq_tbl ftbl_gcc_blsp1_qup1_2_spi_apps_clk
[] = {
302 F(960000, P_XO
, 12, 1, 4),
303 F(4800000, P_XO
, 1, 1, 10),
304 F(9600000, P_XO
, 1, 1, 5),
305 F(15000000, P_XO
, 1, 1, 3),
306 F(19200000, P_XO
, 1, 2, 5),
307 F(24000000, P_XO
, 1, 1, 2),
308 F(48000000, P_XO
, 1, 0, 0),
312 static struct clk_rcg2 blsp1_qup1_spi_apps_clk_src
= {
316 .parent_map
= gcc_xo_200_spi_map
,
317 .freq_tbl
= ftbl_gcc_blsp1_qup1_2_spi_apps_clk
,
318 .clkr
.hw
.init
= &(struct clk_init_data
){
319 .name
= "blsp1_qup1_spi_apps_clk_src",
320 .parent_names
= gcc_xo_200_spi
,
322 .ops
= &clk_rcg2_ops
,
326 static struct clk_branch gcc_blsp1_qup1_spi_apps_clk
= {
329 .enable_reg
= 0x2004,
330 .enable_mask
= BIT(0),
331 .hw
.init
= &(struct clk_init_data
){
332 .name
= "gcc_blsp1_qup1_spi_apps_clk",
333 .parent_names
= (const char *[]){
334 "blsp1_qup1_spi_apps_clk_src",
337 .ops
= &clk_branch2_ops
,
338 .flags
= CLK_SET_RATE_PARENT
,
343 static struct clk_rcg2 blsp1_qup2_spi_apps_clk_src
= {
347 .freq_tbl
= ftbl_gcc_blsp1_qup1_2_spi_apps_clk
,
348 .parent_map
= gcc_xo_200_spi_map
,
349 .clkr
.hw
.init
= &(struct clk_init_data
){
350 .name
= "blsp1_qup2_spi_apps_clk_src",
351 .parent_names
= gcc_xo_200_spi
,
353 .ops
= &clk_rcg2_ops
,
357 static struct clk_branch gcc_blsp1_qup2_spi_apps_clk
= {
360 .enable_reg
= 0x300c,
361 .enable_mask
= BIT(0),
362 .hw
.init
= &(struct clk_init_data
){
363 .name
= "gcc_blsp1_qup2_spi_apps_clk",
364 .parent_names
= (const char *[]){
365 "blsp1_qup2_spi_apps_clk_src",
368 .ops
= &clk_branch2_ops
,
369 .flags
= CLK_SET_RATE_PARENT
,
374 static const struct freq_tbl ftbl_gcc_blsp1_uart1_2_apps_clk
[] = {
375 F(1843200, P_FEPLL200
, 1, 144, 15625),
376 F(3686400, P_FEPLL200
, 1, 288, 15625),
377 F(7372800, P_FEPLL200
, 1, 576, 15625),
378 F(14745600, P_FEPLL200
, 1, 1152, 15625),
379 F(16000000, P_FEPLL200
, 1, 2, 25),
380 F(24000000, P_XO
, 1, 1, 2),
381 F(32000000, P_FEPLL200
, 1, 4, 25),
382 F(40000000, P_FEPLL200
, 1, 1, 5),
383 F(46400000, P_FEPLL200
, 1, 29, 125),
384 F(48000000, P_XO
, 1, 0, 0),
388 static struct clk_rcg2 blsp1_uart1_apps_clk_src
= {
392 .freq_tbl
= ftbl_gcc_blsp1_uart1_2_apps_clk
,
393 .parent_map
= gcc_xo_200_spi_map
,
394 .clkr
.hw
.init
= &(struct clk_init_data
){
395 .name
= "blsp1_uart1_apps_clk_src",
396 .parent_names
= gcc_xo_200_spi
,
398 .ops
= &clk_rcg2_ops
,
402 static struct clk_branch gcc_blsp1_uart1_apps_clk
= {
405 .enable_reg
= 0x203c,
406 .enable_mask
= BIT(0),
407 .hw
.init
= &(struct clk_init_data
){
408 .name
= "gcc_blsp1_uart1_apps_clk",
409 .parent_names
= (const char *[]){
410 "blsp1_uart1_apps_clk_src",
412 .flags
= CLK_SET_RATE_PARENT
,
414 .ops
= &clk_branch2_ops
,
419 static struct clk_rcg2 blsp1_uart2_apps_clk_src
= {
423 .freq_tbl
= ftbl_gcc_blsp1_uart1_2_apps_clk
,
424 .parent_map
= gcc_xo_200_spi_map
,
425 .clkr
.hw
.init
= &(struct clk_init_data
){
426 .name
= "blsp1_uart2_apps_clk_src",
427 .parent_names
= gcc_xo_200_spi
,
429 .ops
= &clk_rcg2_ops
,
433 static struct clk_branch gcc_blsp1_uart2_apps_clk
= {
436 .enable_reg
= 0x302c,
437 .enable_mask
= BIT(0),
438 .hw
.init
= &(struct clk_init_data
){
439 .name
= "gcc_blsp1_uart2_apps_clk",
440 .parent_names
= (const char *[]){
441 "blsp1_uart2_apps_clk_src",
444 .ops
= &clk_branch2_ops
,
445 .flags
= CLK_SET_RATE_PARENT
,
450 static const struct freq_tbl ftbl_gcc_gp_clk
[] = {
451 F(1250000, P_FEPLL200
, 1, 16, 0),
452 F(2500000, P_FEPLL200
, 1, 8, 0),
453 F(5000000, P_FEPLL200
, 1, 4, 0),
457 static struct clk_rcg2 gp1_clk_src
= {
461 .freq_tbl
= ftbl_gcc_gp_clk
,
462 .parent_map
= gcc_xo_200_map
,
463 .clkr
.hw
.init
= &(struct clk_init_data
){
464 .name
= "gp1_clk_src",
465 .parent_names
= gcc_xo_200
,
467 .ops
= &clk_rcg2_ops
,
471 static struct clk_branch gcc_gp1_clk
= {
474 .enable_reg
= 0x8000,
475 .enable_mask
= BIT(0),
476 .hw
.init
= &(struct clk_init_data
){
477 .name
= "gcc_gp1_clk",
478 .parent_names
= (const char *[]){
482 .ops
= &clk_branch2_ops
,
483 .flags
= CLK_SET_RATE_PARENT
,
488 static struct clk_rcg2 gp2_clk_src
= {
492 .freq_tbl
= ftbl_gcc_gp_clk
,
493 .parent_map
= gcc_xo_200_map
,
494 .clkr
.hw
.init
= &(struct clk_init_data
){
495 .name
= "gp2_clk_src",
496 .parent_names
= gcc_xo_200
,
498 .ops
= &clk_rcg2_ops
,
502 static struct clk_branch gcc_gp2_clk
= {
505 .enable_reg
= 0x9000,
506 .enable_mask
= BIT(0),
507 .hw
.init
= &(struct clk_init_data
){
508 .name
= "gcc_gp2_clk",
509 .parent_names
= (const char *[]){
513 .ops
= &clk_branch2_ops
,
514 .flags
= CLK_SET_RATE_PARENT
,
519 static struct clk_rcg2 gp3_clk_src
= {
523 .freq_tbl
= ftbl_gcc_gp_clk
,
524 .parent_map
= gcc_xo_200_map
,
525 .clkr
.hw
.init
= &(struct clk_init_data
){
526 .name
= "gp3_clk_src",
527 .parent_names
= gcc_xo_200
,
529 .ops
= &clk_rcg2_ops
,
533 static struct clk_branch gcc_gp3_clk
= {
536 .enable_reg
= 0xa000,
537 .enable_mask
= BIT(0),
538 .hw
.init
= &(struct clk_init_data
){
539 .name
= "gcc_gp3_clk",
540 .parent_names
= (const char *[]){
544 .ops
= &clk_branch2_ops
,
545 .flags
= CLK_SET_RATE_PARENT
,
550 static const struct freq_tbl ftbl_gcc_sdcc1_apps_clk
[] = {
551 F(144000, P_XO
, 1, 3, 240),
552 F(400000, P_XO
, 1, 1, 0),
553 F(20000000, P_FEPLL500
, 1, 1, 25),
554 F(25000000, P_FEPLL500
, 1, 1, 20),
555 F(50000000, P_FEPLL500
, 1, 1, 10),
556 F(100000000, P_FEPLL500
, 1, 1, 5),
557 F(192000000, P_DDRPLL
, 1, 0, 0),
561 static struct clk_rcg2 sdcc1_apps_clk_src
= {
564 .freq_tbl
= ftbl_gcc_sdcc1_apps_clk
,
565 .parent_map
= gcc_xo_sdcc1_500_map
,
566 .clkr
.hw
.init
= &(struct clk_init_data
){
567 .name
= "sdcc1_apps_clk_src",
568 .parent_names
= gcc_xo_sdcc1_500
,
570 .ops
= &clk_rcg2_ops
,
571 .flags
= CLK_SET_RATE_PARENT
,
575 static const struct freq_tbl ftbl_gcc_apps_clk
[] = {
576 F(48000000, P_XO
, 1, 0, 0),
577 F(200000000, P_FEPLL200
, 1, 0, 0),
578 F(384000000, P_DDRPLLAPSS
, 1, 0, 0),
579 F(413000000, P_DDRPLLAPSS
, 1, 0, 0),
580 F(448000000, P_DDRPLLAPSS
, 1, 0, 0),
581 F(488000000, P_DDRPLLAPSS
, 1, 0, 0),
582 F(500000000, P_FEPLL500
, 1, 0, 0),
583 F(512000000, P_DDRPLLAPSS
, 1, 0, 0),
584 F(537000000, P_DDRPLLAPSS
, 1, 0, 0),
585 F(565000000, P_DDRPLLAPSS
, 1, 0, 0),
586 F(597000000, P_DDRPLLAPSS
, 1, 0, 0),
587 F(632000000, P_DDRPLLAPSS
, 1, 0, 0),
588 F(672000000, P_DDRPLLAPSS
, 1, 0, 0),
589 F(716000000, P_DDRPLLAPSS
, 1, 0, 0),
593 static struct clk_rcg2 apps_clk_src
= {
596 .freq_tbl
= ftbl_gcc_apps_clk
,
597 .parent_map
= gcc_xo_ddr_500_200_map
,
598 .clkr
.hw
.init
= &(struct clk_init_data
){
599 .name
= "apps_clk_src",
600 .parent_names
= gcc_xo_ddr_500_200
,
602 .ops
= &clk_rcg2_ops
,
603 .flags
= CLK_SET_RATE_PARENT
,
607 static const struct freq_tbl ftbl_gcc_apps_ahb_clk
[] = {
608 F(48000000, P_XO
, 1, 0, 0),
609 F(100000000, P_FEPLL200
, 2, 0, 0),
613 static struct clk_rcg2 apps_ahb_clk_src
= {
616 .parent_map
= gcc_xo_200_500_map
,
617 .freq_tbl
= ftbl_gcc_apps_ahb_clk
,
618 .clkr
.hw
.init
= &(struct clk_init_data
){
619 .name
= "apps_ahb_clk_src",
620 .parent_names
= gcc_xo_200_500
,
622 .ops
= &clk_rcg2_ops
,
626 static struct clk_branch gcc_apss_ahb_clk
= {
628 .halt_check
= BRANCH_HALT_VOTED
,
630 .enable_reg
= 0x6000,
631 .enable_mask
= BIT(14),
632 .hw
.init
= &(struct clk_init_data
){
633 .name
= "gcc_apss_ahb_clk",
634 .parent_names
= (const char *[]){
638 .ops
= &clk_branch2_ops
,
639 .flags
= CLK_SET_RATE_PARENT
,
644 static struct clk_branch gcc_blsp1_ahb_clk
= {
646 .halt_check
= BRANCH_HALT_VOTED
,
648 .enable_reg
= 0x6000,
649 .enable_mask
= BIT(10),
650 .hw
.init
= &(struct clk_init_data
){
651 .name
= "gcc_blsp1_ahb_clk",
652 .parent_names
= (const char *[]){
656 .ops
= &clk_branch2_ops
,
661 static struct clk_branch gcc_dcd_xo_clk
= {
664 .enable_reg
= 0x2103c,
665 .enable_mask
= BIT(0),
666 .hw
.init
= &(struct clk_init_data
){
667 .name
= "gcc_dcd_xo_clk",
668 .parent_names
= (const char *[]){
672 .ops
= &clk_branch2_ops
,
677 static struct clk_branch gcc_boot_rom_ahb_clk
= {
680 .enable_reg
= 0x1300c,
681 .enable_mask
= BIT(0),
682 .hw
.init
= &(struct clk_init_data
){
683 .name
= "gcc_boot_rom_ahb_clk",
684 .parent_names
= (const char *[]){
688 .ops
= &clk_branch2_ops
,
689 .flags
= CLK_SET_RATE_PARENT
,
694 static struct clk_branch gcc_crypto_ahb_clk
= {
696 .halt_check
= BRANCH_HALT_VOTED
,
698 .enable_reg
= 0x6000,
699 .enable_mask
= BIT(0),
700 .hw
.init
= &(struct clk_init_data
){
701 .name
= "gcc_crypto_ahb_clk",
702 .parent_names
= (const char *[]){
706 .ops
= &clk_branch2_ops
,
711 static struct clk_branch gcc_crypto_axi_clk
= {
713 .halt_check
= BRANCH_HALT_VOTED
,
715 .enable_reg
= 0x6000,
716 .enable_mask
= BIT(1),
717 .hw
.init
= &(struct clk_init_data
){
718 .name
= "gcc_crypto_axi_clk",
719 .parent_names
= (const char *[]){
723 .ops
= &clk_branch2_ops
,
728 static struct clk_branch gcc_crypto_clk
= {
730 .halt_check
= BRANCH_HALT_VOTED
,
732 .enable_reg
= 0x6000,
733 .enable_mask
= BIT(2),
734 .hw
.init
= &(struct clk_init_data
){
735 .name
= "gcc_crypto_clk",
736 .parent_names
= (const char *[]){
740 .ops
= &clk_branch2_ops
,
745 static struct clk_branch gcc_ess_clk
= {
748 .enable_reg
= 0x12010,
749 .enable_mask
= BIT(0),
750 .hw
.init
= &(struct clk_init_data
){
751 .name
= "gcc_ess_clk",
752 .parent_names
= (const char *[]){
753 "fephy_125m_dly_clk_src",
756 .ops
= &clk_branch2_ops
,
757 .flags
= CLK_SET_RATE_PARENT
,
762 static struct clk_branch gcc_imem_axi_clk
= {
764 .halt_check
= BRANCH_HALT_VOTED
,
766 .enable_reg
= 0x6000,
767 .enable_mask
= BIT(17),
768 .hw
.init
= &(struct clk_init_data
){
769 .name
= "gcc_imem_axi_clk",
770 .parent_names
= (const char *[]){
774 .ops
= &clk_branch2_ops
,
779 static struct clk_branch gcc_imem_cfg_ahb_clk
= {
782 .enable_reg
= 0xe008,
783 .enable_mask
= BIT(0),
784 .hw
.init
= &(struct clk_init_data
){
785 .name
= "gcc_imem_cfg_ahb_clk",
786 .parent_names
= (const char *[]){
790 .ops
= &clk_branch2_ops
,
795 static struct clk_branch gcc_pcie_ahb_clk
= {
798 .enable_reg
= 0x1d00c,
799 .enable_mask
= BIT(0),
800 .hw
.init
= &(struct clk_init_data
){
801 .name
= "gcc_pcie_ahb_clk",
802 .parent_names
= (const char *[]){
806 .ops
= &clk_branch2_ops
,
811 static struct clk_branch gcc_pcie_axi_m_clk
= {
814 .enable_reg
= 0x1d004,
815 .enable_mask
= BIT(0),
816 .hw
.init
= &(struct clk_init_data
){
817 .name
= "gcc_pcie_axi_m_clk",
818 .parent_names
= (const char *[]){
822 .ops
= &clk_branch2_ops
,
827 static struct clk_branch gcc_pcie_axi_s_clk
= {
830 .enable_reg
= 0x1d008,
831 .enable_mask
= BIT(0),
832 .hw
.init
= &(struct clk_init_data
){
833 .name
= "gcc_pcie_axi_s_clk",
834 .parent_names
= (const char *[]){
838 .ops
= &clk_branch2_ops
,
843 static struct clk_branch gcc_prng_ahb_clk
= {
845 .halt_check
= BRANCH_HALT_VOTED
,
847 .enable_reg
= 0x6000,
848 .enable_mask
= BIT(8),
849 .hw
.init
= &(struct clk_init_data
){
850 .name
= "gcc_prng_ahb_clk",
851 .parent_names
= (const char *[]){
855 .ops
= &clk_branch2_ops
,
860 static struct clk_branch gcc_qpic_ahb_clk
= {
863 .enable_reg
= 0x1c008,
864 .enable_mask
= BIT(0),
865 .hw
.init
= &(struct clk_init_data
){
866 .name
= "gcc_qpic_ahb_clk",
867 .parent_names
= (const char *[]){
871 .ops
= &clk_branch2_ops
,
876 static struct clk_branch gcc_qpic_clk
= {
879 .enable_reg
= 0x1c004,
880 .enable_mask
= BIT(0),
881 .hw
.init
= &(struct clk_init_data
){
882 .name
= "gcc_qpic_clk",
883 .parent_names
= (const char *[]){
887 .ops
= &clk_branch2_ops
,
892 static struct clk_branch gcc_sdcc1_ahb_clk
= {
895 .enable_reg
= 0x18010,
896 .enable_mask
= BIT(0),
897 .hw
.init
= &(struct clk_init_data
){
898 .name
= "gcc_sdcc1_ahb_clk",
899 .parent_names
= (const char *[]){
903 .ops
= &clk_branch2_ops
,
908 static struct clk_branch gcc_sdcc1_apps_clk
= {
911 .enable_reg
= 0x1800c,
912 .enable_mask
= BIT(0),
913 .hw
.init
= &(struct clk_init_data
){
914 .name
= "gcc_sdcc1_apps_clk",
915 .parent_names
= (const char *[]){
916 "sdcc1_apps_clk_src",
919 .ops
= &clk_branch2_ops
,
920 .flags
= CLK_SET_RATE_PARENT
,
925 static struct clk_branch gcc_tlmm_ahb_clk
= {
927 .halt_check
= BRANCH_HALT_VOTED
,
929 .enable_reg
= 0x6000,
930 .enable_mask
= BIT(5),
931 .hw
.init
= &(struct clk_init_data
){
932 .name
= "gcc_tlmm_ahb_clk",
933 .parent_names
= (const char *[]){
937 .ops
= &clk_branch2_ops
,
942 static struct clk_branch gcc_usb2_master_clk
= {
945 .enable_reg
= 0x1e00c,
946 .enable_mask
= BIT(0),
947 .hw
.init
= &(struct clk_init_data
){
948 .name
= "gcc_usb2_master_clk",
949 .parent_names
= (const char *[]){
953 .ops
= &clk_branch2_ops
,
958 static struct clk_branch gcc_usb2_sleep_clk
= {
961 .enable_reg
= 0x1e010,
962 .enable_mask
= BIT(0),
963 .hw
.init
= &(struct clk_init_data
){
964 .name
= "gcc_usb2_sleep_clk",
965 .parent_names
= (const char *[]){
969 .ops
= &clk_branch2_ops
,
974 static struct clk_branch gcc_usb2_mock_utmi_clk
= {
977 .enable_reg
= 0x1e014,
978 .enable_mask
= BIT(0),
979 .hw
.init
= &(struct clk_init_data
){
980 .name
= "gcc_usb2_mock_utmi_clk",
981 .parent_names
= (const char *[]){
982 "usb30_mock_utmi_clk_src",
985 .ops
= &clk_branch2_ops
,
986 .flags
= CLK_SET_RATE_PARENT
,
991 static const struct freq_tbl ftbl_gcc_usb30_mock_utmi_clk
[] = {
992 F(2000000, P_FEPLL200
, 10, 0, 0),
996 static struct clk_rcg2 usb30_mock_utmi_clk_src
= {
999 .parent_map
= gcc_xo_200_map
,
1000 .freq_tbl
= ftbl_gcc_usb30_mock_utmi_clk
,
1001 .clkr
.hw
.init
= &(struct clk_init_data
){
1002 .name
= "usb30_mock_utmi_clk_src",
1003 .parent_names
= gcc_xo_200
,
1005 .ops
= &clk_rcg2_ops
,
1009 static struct clk_branch gcc_usb3_master_clk
= {
1010 .halt_reg
= 0x1e028,
1012 .enable_reg
= 0x1e028,
1013 .enable_mask
= BIT(0),
1014 .hw
.init
= &(struct clk_init_data
){
1015 .name
= "gcc_usb3_master_clk",
1016 .parent_names
= (const char *[]){
1020 .ops
= &clk_branch2_ops
,
1025 static struct clk_branch gcc_usb3_sleep_clk
= {
1026 .halt_reg
= 0x1e02C,
1028 .enable_reg
= 0x1e02C,
1029 .enable_mask
= BIT(0),
1030 .hw
.init
= &(struct clk_init_data
){
1031 .name
= "gcc_usb3_sleep_clk",
1032 .parent_names
= (const char *[]){
1033 "gcc_sleep_clk_src",
1036 .ops
= &clk_branch2_ops
,
1041 static struct clk_branch gcc_usb3_mock_utmi_clk
= {
1042 .halt_reg
= 0x1e030,
1044 .enable_reg
= 0x1e030,
1045 .enable_mask
= BIT(0),
1046 .hw
.init
= &(struct clk_init_data
){
1047 .name
= "gcc_usb3_mock_utmi_clk",
1048 .parent_names
= (const char *[]){
1049 "usb30_mock_utmi_clk_src",
1052 .ops
= &clk_branch2_ops
,
1053 .flags
= CLK_SET_RATE_PARENT
,
1058 static const struct freq_tbl ftbl_gcc_fephy_dly_clk
[] = {
1059 F(125000000, P_FEPLL125DLY
, 1, 0, 0),
1063 static struct clk_rcg2 fephy_125m_dly_clk_src
= {
1064 .cmd_rcgr
= 0x12000,
1066 .parent_map
= gcc_xo_125_dly_map
,
1067 .freq_tbl
= ftbl_gcc_fephy_dly_clk
,
1068 .clkr
.hw
.init
= &(struct clk_init_data
){
1069 .name
= "fephy_125m_dly_clk_src",
1070 .parent_names
= gcc_xo_125_dly
,
1072 .ops
= &clk_rcg2_ops
,
1077 static const struct freq_tbl ftbl_gcc_wcss2g_clk
[] = {
1078 F(48000000, P_XO
, 1, 0, 0),
1079 F(250000000, P_FEPLLWCSS2G
, 1, 0, 0),
1083 static struct clk_rcg2 wcss2g_clk_src
= {
1084 .cmd_rcgr
= 0x1f000,
1086 .freq_tbl
= ftbl_gcc_wcss2g_clk
,
1087 .parent_map
= gcc_xo_wcss2g_map
,
1088 .clkr
.hw
.init
= &(struct clk_init_data
){
1089 .name
= "wcss2g_clk_src",
1090 .parent_names
= gcc_xo_wcss2g
,
1092 .ops
= &clk_rcg2_ops
,
1093 .flags
= CLK_SET_RATE_PARENT
,
1097 static struct clk_branch gcc_wcss2g_clk
= {
1098 .halt_reg
= 0x1f00C,
1100 .enable_reg
= 0x1f00C,
1101 .enable_mask
= BIT(0),
1102 .hw
.init
= &(struct clk_init_data
){
1103 .name
= "gcc_wcss2g_clk",
1104 .parent_names
= (const char *[]){
1108 .ops
= &clk_branch2_ops
,
1109 .flags
= CLK_SET_RATE_PARENT
,
1114 static struct clk_branch gcc_wcss2g_ref_clk
= {
1115 .halt_reg
= 0x1f00C,
1117 .enable_reg
= 0x1f00C,
1118 .enable_mask
= BIT(0),
1119 .hw
.init
= &(struct clk_init_data
){
1120 .name
= "gcc_wcss2g_ref_clk",
1121 .parent_names
= (const char *[]){
1125 .ops
= &clk_branch2_ops
,
1126 .flags
= CLK_SET_RATE_PARENT
,
1131 static struct clk_branch gcc_wcss2g_rtc_clk
= {
1132 .halt_reg
= 0x1f010,
1134 .enable_reg
= 0x1f010,
1135 .enable_mask
= BIT(0),
1136 .hw
.init
= &(struct clk_init_data
){
1137 .name
= "gcc_wcss2g_rtc_clk",
1138 .parent_names
= (const char *[]){
1139 "gcc_sleep_clk_src",
1142 .ops
= &clk_branch2_ops
,
1147 static const struct freq_tbl ftbl_gcc_wcss5g_clk
[] = {
1148 F(48000000, P_XO
, 1, 0, 0),
1149 F(250000000, P_FEPLLWCSS5G
, 1, 0, 0),
1153 static struct clk_rcg2 wcss5g_clk_src
= {
1154 .cmd_rcgr
= 0x20000,
1156 .parent_map
= gcc_xo_wcss5g_map
,
1157 .freq_tbl
= ftbl_gcc_wcss5g_clk
,
1158 .clkr
.hw
.init
= &(struct clk_init_data
){
1159 .name
= "wcss5g_clk_src",
1160 .parent_names
= gcc_xo_wcss5g
,
1162 .ops
= &clk_rcg2_ops
,
1166 static struct clk_branch gcc_wcss5g_clk
= {
1167 .halt_reg
= 0x2000c,
1169 .enable_reg
= 0x2000c,
1170 .enable_mask
= BIT(0),
1171 .hw
.init
= &(struct clk_init_data
){
1172 .name
= "gcc_wcss5g_clk",
1173 .parent_names
= (const char *[]){
1177 .ops
= &clk_branch2_ops
,
1178 .flags
= CLK_SET_RATE_PARENT
,
1183 static struct clk_branch gcc_wcss5g_ref_clk
= {
1184 .halt_reg
= 0x2000c,
1186 .enable_reg
= 0x2000c,
1187 .enable_mask
= BIT(0),
1188 .hw
.init
= &(struct clk_init_data
){
1189 .name
= "gcc_wcss5g_ref_clk",
1190 .parent_names
= (const char *[]){
1194 .ops
= &clk_branch2_ops
,
1195 .flags
= CLK_SET_RATE_PARENT
,
1200 static struct clk_branch gcc_wcss5g_rtc_clk
= {
1201 .halt_reg
= 0x20010,
1203 .enable_reg
= 0x20010,
1204 .enable_mask
= BIT(0),
1205 .hw
.init
= &(struct clk_init_data
){
1206 .name
= "gcc_wcss5g_rtc_clk",
1207 .parent_names
= (const char *[]){
1208 "gcc_sleep_clk_src",
1211 .ops
= &clk_branch2_ops
,
1212 .flags
= CLK_SET_RATE_PARENT
,
1217 /* Calculates the VCO rate for FEPLL. */
1218 static u64
clk_fepll_vco_calc_rate(struct clk_fepll
*pll_div
,
1219 unsigned long parent_rate
)
1221 const struct clk_fepll_vco
*pll_vco
= pll_div
->pll_vco
;
1222 u32 fdbkdiv
, refclkdiv
, cdiv
;
1225 regmap_read(pll_div
->cdiv
.clkr
.regmap
, pll_vco
->reg
, &cdiv
);
1226 refclkdiv
= (cdiv
>> pll_vco
->refclkdiv_shift
) &
1227 (BIT(pll_vco
->refclkdiv_width
) - 1);
1228 fdbkdiv
= (cdiv
>> pll_vco
->fdbkdiv_shift
) &
1229 (BIT(pll_vco
->fdbkdiv_width
) - 1);
1231 vco
= parent_rate
/ refclkdiv
;
1238 static const struct clk_fepll_vco gcc_apss_ddrpll_vco
= {
1239 .fdbkdiv_shift
= 16,
1241 .refclkdiv_shift
= 24,
1242 .refclkdiv_width
= 5,
1246 static const struct clk_fepll_vco gcc_fepll_vco
= {
1247 .fdbkdiv_shift
= 16,
1249 .refclkdiv_shift
= 24,
1250 .refclkdiv_width
= 5,
1255 * Round rate function for APSS CPU PLL Clock divider.
1256 * It looks up the frequency table and returns the next higher frequency
1257 * supported in hardware.
1259 static long clk_cpu_div_round_rate(struct clk_hw
*hw
, unsigned long rate
,
1260 unsigned long *p_rate
)
1262 struct clk_fepll
*pll
= to_clk_fepll(hw
);
1263 struct clk_hw
*p_hw
;
1264 const struct freq_tbl
*f
;
1266 f
= qcom_find_freq(pll
->freq_tbl
, rate
);
1270 p_hw
= clk_hw_get_parent_by_index(hw
, f
->src
);
1271 *p_rate
= clk_hw_get_rate(p_hw
);
1277 * Clock set rate function for APSS CPU PLL Clock divider.
1278 * It looks up the frequency table and updates the PLL divider to corresponding
1281 static int clk_cpu_div_set_rate(struct clk_hw
*hw
, unsigned long rate
,
1282 unsigned long parent_rate
)
1284 struct clk_fepll
*pll
= to_clk_fepll(hw
);
1285 const struct freq_tbl
*f
;
1289 f
= qcom_find_freq(pll
->freq_tbl
, rate
);
1293 mask
= (BIT(pll
->cdiv
.width
) - 1) << pll
->cdiv
.shift
;
1294 ret
= regmap_update_bits(pll
->cdiv
.clkr
.regmap
,
1295 pll
->cdiv
.reg
, mask
,
1296 f
->pre_div
<< pll
->cdiv
.shift
);
1298 * There is no status bit which can be checked for successful CPU
1299 * divider update operation so using delay for the same.
1307 * Clock frequency calculation function for APSS CPU PLL Clock divider.
1308 * This clock divider is nonlinear so this function calculates the actual
1309 * divider and returns the output frequency by dividing VCO Frequency
1310 * with this actual divider value.
1312 static unsigned long
1313 clk_cpu_div_recalc_rate(struct clk_hw
*hw
,
1314 unsigned long parent_rate
)
1316 struct clk_fepll
*pll
= to_clk_fepll(hw
);
1320 regmap_read(pll
->cdiv
.clkr
.regmap
, pll
->cdiv
.reg
, &cdiv
);
1321 cdiv
= (cdiv
>> pll
->cdiv
.shift
) & (BIT(pll
->cdiv
.width
) - 1);
1324 * Some dividers have value in 0.5 fraction so multiply both VCO
1325 * frequency(parent_rate) and pre_div with 2 to make integer
1329 pre_div
= (cdiv
+ 1) * 2;
1331 pre_div
= cdiv
+ 12;
1333 rate
= clk_fepll_vco_calc_rate(pll
, parent_rate
) * 2;
1334 do_div(rate
, pre_div
);
1339 static const struct clk_ops clk_regmap_cpu_div_ops
= {
1340 .round_rate
= clk_cpu_div_round_rate
,
1341 .set_rate
= clk_cpu_div_set_rate
,
1342 .recalc_rate
= clk_cpu_div_recalc_rate
,
1345 static const struct freq_tbl ftbl_apss_ddr_pll
[] = {
1346 { 384000000, P_XO
, 0xd, 0, 0 },
1347 { 413000000, P_XO
, 0xc, 0, 0 },
1348 { 448000000, P_XO
, 0xb, 0, 0 },
1349 { 488000000, P_XO
, 0xa, 0, 0 },
1350 { 512000000, P_XO
, 0x9, 0, 0 },
1351 { 537000000, P_XO
, 0x8, 0, 0 },
1352 { 565000000, P_XO
, 0x7, 0, 0 },
1353 { 597000000, P_XO
, 0x6, 0, 0 },
1354 { 632000000, P_XO
, 0x5, 0, 0 },
1355 { 672000000, P_XO
, 0x4, 0, 0 },
1356 { 716000000, P_XO
, 0x3, 0, 0 },
1357 { 768000000, P_XO
, 0x2, 0, 0 },
1358 { 823000000, P_XO
, 0x1, 0, 0 },
1359 { 896000000, P_XO
, 0x0, 0, 0 },
1363 static struct clk_fepll gcc_apss_cpu_plldiv_clk
= {
1364 .cdiv
.reg
= 0x2e020,
1368 .enable_reg
= 0x2e000,
1369 .enable_mask
= BIT(0),
1370 .hw
.init
= &(struct clk_init_data
){
1371 .name
= "ddrpllapss",
1372 .parent_names
= (const char *[]){
1376 .ops
= &clk_regmap_cpu_div_ops
,
1379 .freq_tbl
= ftbl_apss_ddr_pll
,
1380 .pll_vco
= &gcc_apss_ddrpll_vco
,
1383 /* Calculates the rate for PLL divider.
1384 * If the divider value is not fixed then it gets the actual divider value
1385 * from divider table. Then, it calculate the clock rate by dividing the
1386 * parent rate with actual divider value.
1388 static unsigned long
1389 clk_regmap_clk_div_recalc_rate(struct clk_hw
*hw
,
1390 unsigned long parent_rate
)
1392 struct clk_fepll
*pll
= to_clk_fepll(hw
);
1393 u32 cdiv
, pre_div
= 1;
1395 const struct clk_div_table
*clkt
;
1397 if (pll
->fixed_div
) {
1398 pre_div
= pll
->fixed_div
;
1400 regmap_read(pll
->cdiv
.clkr
.regmap
, pll
->cdiv
.reg
, &cdiv
);
1401 cdiv
= (cdiv
>> pll
->cdiv
.shift
) & (BIT(pll
->cdiv
.width
) - 1);
1403 for (clkt
= pll
->div_table
; clkt
->div
; clkt
++) {
1404 if (clkt
->val
== cdiv
)
1405 pre_div
= clkt
->div
;
1409 rate
= clk_fepll_vco_calc_rate(pll
, parent_rate
);
1410 do_div(rate
, pre_div
);
1415 static const struct clk_ops clk_fepll_div_ops
= {
1416 .recalc_rate
= clk_regmap_clk_div_recalc_rate
,
1419 static struct clk_fepll gcc_apss_sdcc_clk
= {
1422 .hw
.init
= &(struct clk_init_data
){
1423 .name
= "ddrpllsdcc",
1424 .parent_names
= (const char *[]){
1428 .ops
= &clk_fepll_div_ops
,
1431 .pll_vco
= &gcc_apss_ddrpll_vco
,
1434 static struct clk_fepll gcc_fepll125_clk
= {
1437 .hw
.init
= &(struct clk_init_data
){
1439 .parent_names
= (const char *[]){
1443 .ops
= &clk_fepll_div_ops
,
1446 .pll_vco
= &gcc_fepll_vco
,
1449 static struct clk_fepll gcc_fepll125dly_clk
= {
1452 .hw
.init
= &(struct clk_init_data
){
1453 .name
= "fepll125dly",
1454 .parent_names
= (const char *[]){
1458 .ops
= &clk_fepll_div_ops
,
1461 .pll_vco
= &gcc_fepll_vco
,
1464 static struct clk_fepll gcc_fepll200_clk
= {
1467 .hw
.init
= &(struct clk_init_data
){
1469 .parent_names
= (const char *[]){
1473 .ops
= &clk_fepll_div_ops
,
1476 .pll_vco
= &gcc_fepll_vco
,
1479 static struct clk_fepll gcc_fepll500_clk
= {
1482 .hw
.init
= &(struct clk_init_data
){
1484 .parent_names
= (const char *[]){
1488 .ops
= &clk_fepll_div_ops
,
1491 .pll_vco
= &gcc_fepll_vco
,
1494 static const struct clk_div_table fepllwcss_clk_div_table
[] = {
1502 static struct clk_fepll gcc_fepllwcss2g_clk
= {
1503 .cdiv
.reg
= 0x2f020,
1507 .hw
.init
= &(struct clk_init_data
){
1508 .name
= "fepllwcss2g",
1509 .parent_names
= (const char *[]){
1513 .ops
= &clk_fepll_div_ops
,
1516 .div_table
= fepllwcss_clk_div_table
,
1517 .pll_vco
= &gcc_fepll_vco
,
1520 static struct clk_fepll gcc_fepllwcss5g_clk
= {
1521 .cdiv
.reg
= 0x2f020,
1525 .hw
.init
= &(struct clk_init_data
){
1526 .name
= "fepllwcss5g",
1527 .parent_names
= (const char *[]){
1531 .ops
= &clk_fepll_div_ops
,
1534 .div_table
= fepllwcss_clk_div_table
,
1535 .pll_vco
= &gcc_fepll_vco
,
1538 static const struct freq_tbl ftbl_gcc_pcnoc_ahb_clk
[] = {
1539 F(48000000, P_XO
, 1, 0, 0),
1540 F(100000000, P_FEPLL200
, 2, 0, 0),
1544 static struct clk_rcg2 gcc_pcnoc_ahb_clk_src
= {
1545 .cmd_rcgr
= 0x21024,
1547 .parent_map
= gcc_xo_200_500_map
,
1548 .freq_tbl
= ftbl_gcc_pcnoc_ahb_clk
,
1549 .clkr
.hw
.init
= &(struct clk_init_data
){
1550 .name
= "gcc_pcnoc_ahb_clk_src",
1551 .parent_names
= gcc_xo_200_500
,
1553 .ops
= &clk_rcg2_ops
,
1557 static struct clk_branch pcnoc_clk_src
= {
1558 .halt_reg
= 0x21030,
1560 .enable_reg
= 0x21030,
1561 .enable_mask
= BIT(0),
1562 .hw
.init
= &(struct clk_init_data
){
1563 .name
= "pcnoc_clk_src",
1564 .parent_names
= (const char *[]){
1565 "gcc_pcnoc_ahb_clk_src",
1568 .ops
= &clk_branch2_ops
,
1569 .flags
= CLK_SET_RATE_PARENT
|
1575 static struct clk_regmap
*gcc_ipq4019_clocks
[] = {
1576 [AUDIO_CLK_SRC
] = &audio_clk_src
.clkr
,
1577 [BLSP1_QUP1_I2C_APPS_CLK_SRC
] = &blsp1_qup1_i2c_apps_clk_src
.clkr
,
1578 [BLSP1_QUP1_SPI_APPS_CLK_SRC
] = &blsp1_qup1_spi_apps_clk_src
.clkr
,
1579 [BLSP1_QUP2_I2C_APPS_CLK_SRC
] = &blsp1_qup2_i2c_apps_clk_src
.clkr
,
1580 [BLSP1_QUP2_SPI_APPS_CLK_SRC
] = &blsp1_qup2_spi_apps_clk_src
.clkr
,
1581 [BLSP1_UART1_APPS_CLK_SRC
] = &blsp1_uart1_apps_clk_src
.clkr
,
1582 [BLSP1_UART2_APPS_CLK_SRC
] = &blsp1_uart2_apps_clk_src
.clkr
,
1583 [GCC_USB3_MOCK_UTMI_CLK_SRC
] = &usb30_mock_utmi_clk_src
.clkr
,
1584 [GCC_APPS_CLK_SRC
] = &apps_clk_src
.clkr
,
1585 [GCC_APPS_AHB_CLK_SRC
] = &apps_ahb_clk_src
.clkr
,
1586 [GP1_CLK_SRC
] = &gp1_clk_src
.clkr
,
1587 [GP2_CLK_SRC
] = &gp2_clk_src
.clkr
,
1588 [GP3_CLK_SRC
] = &gp3_clk_src
.clkr
,
1589 [SDCC1_APPS_CLK_SRC
] = &sdcc1_apps_clk_src
.clkr
,
1590 [FEPHY_125M_DLY_CLK_SRC
] = &fephy_125m_dly_clk_src
.clkr
,
1591 [WCSS2G_CLK_SRC
] = &wcss2g_clk_src
.clkr
,
1592 [WCSS5G_CLK_SRC
] = &wcss5g_clk_src
.clkr
,
1593 [GCC_APSS_AHB_CLK
] = &gcc_apss_ahb_clk
.clkr
,
1594 [GCC_AUDIO_AHB_CLK
] = &gcc_audio_ahb_clk
.clkr
,
1595 [GCC_AUDIO_PWM_CLK
] = &gcc_audio_pwm_clk
.clkr
,
1596 [GCC_BLSP1_AHB_CLK
] = &gcc_blsp1_ahb_clk
.clkr
,
1597 [GCC_BLSP1_QUP1_I2C_APPS_CLK
] = &gcc_blsp1_qup1_i2c_apps_clk
.clkr
,
1598 [GCC_BLSP1_QUP1_SPI_APPS_CLK
] = &gcc_blsp1_qup1_spi_apps_clk
.clkr
,
1599 [GCC_BLSP1_QUP2_I2C_APPS_CLK
] = &gcc_blsp1_qup2_i2c_apps_clk
.clkr
,
1600 [GCC_BLSP1_QUP2_SPI_APPS_CLK
] = &gcc_blsp1_qup2_spi_apps_clk
.clkr
,
1601 [GCC_BLSP1_UART1_APPS_CLK
] = &gcc_blsp1_uart1_apps_clk
.clkr
,
1602 [GCC_BLSP1_UART2_APPS_CLK
] = &gcc_blsp1_uart2_apps_clk
.clkr
,
1603 [GCC_DCD_XO_CLK
] = &gcc_dcd_xo_clk
.clkr
,
1604 [GCC_GP1_CLK
] = &gcc_gp1_clk
.clkr
,
1605 [GCC_GP2_CLK
] = &gcc_gp2_clk
.clkr
,
1606 [GCC_GP3_CLK
] = &gcc_gp3_clk
.clkr
,
1607 [GCC_BOOT_ROM_AHB_CLK
] = &gcc_boot_rom_ahb_clk
.clkr
,
1608 [GCC_CRYPTO_AHB_CLK
] = &gcc_crypto_ahb_clk
.clkr
,
1609 [GCC_CRYPTO_AXI_CLK
] = &gcc_crypto_axi_clk
.clkr
,
1610 [GCC_CRYPTO_CLK
] = &gcc_crypto_clk
.clkr
,
1611 [GCC_ESS_CLK
] = &gcc_ess_clk
.clkr
,
1612 [GCC_IMEM_AXI_CLK
] = &gcc_imem_axi_clk
.clkr
,
1613 [GCC_IMEM_CFG_AHB_CLK
] = &gcc_imem_cfg_ahb_clk
.clkr
,
1614 [GCC_PCIE_AHB_CLK
] = &gcc_pcie_ahb_clk
.clkr
,
1615 [GCC_PCIE_AXI_M_CLK
] = &gcc_pcie_axi_m_clk
.clkr
,
1616 [GCC_PCIE_AXI_S_CLK
] = &gcc_pcie_axi_s_clk
.clkr
,
1617 [GCC_PRNG_AHB_CLK
] = &gcc_prng_ahb_clk
.clkr
,
1618 [GCC_QPIC_AHB_CLK
] = &gcc_qpic_ahb_clk
.clkr
,
1619 [GCC_QPIC_CLK
] = &gcc_qpic_clk
.clkr
,
1620 [GCC_SDCC1_AHB_CLK
] = &gcc_sdcc1_ahb_clk
.clkr
,
1621 [GCC_SDCC1_APPS_CLK
] = &gcc_sdcc1_apps_clk
.clkr
,
1622 [GCC_TLMM_AHB_CLK
] = &gcc_tlmm_ahb_clk
.clkr
,
1623 [GCC_USB2_MASTER_CLK
] = &gcc_usb2_master_clk
.clkr
,
1624 [GCC_USB2_SLEEP_CLK
] = &gcc_usb2_sleep_clk
.clkr
,
1625 [GCC_USB2_MOCK_UTMI_CLK
] = &gcc_usb2_mock_utmi_clk
.clkr
,
1626 [GCC_USB3_MASTER_CLK
] = &gcc_usb3_master_clk
.clkr
,
1627 [GCC_USB3_SLEEP_CLK
] = &gcc_usb3_sleep_clk
.clkr
,
1628 [GCC_USB3_MOCK_UTMI_CLK
] = &gcc_usb3_mock_utmi_clk
.clkr
,
1629 [GCC_WCSS2G_CLK
] = &gcc_wcss2g_clk
.clkr
,
1630 [GCC_WCSS2G_REF_CLK
] = &gcc_wcss2g_ref_clk
.clkr
,
1631 [GCC_WCSS2G_RTC_CLK
] = &gcc_wcss2g_rtc_clk
.clkr
,
1632 [GCC_WCSS5G_CLK
] = &gcc_wcss5g_clk
.clkr
,
1633 [GCC_WCSS5G_REF_CLK
] = &gcc_wcss5g_ref_clk
.clkr
,
1634 [GCC_WCSS5G_RTC_CLK
] = &gcc_wcss5g_rtc_clk
.clkr
,
1635 [GCC_SDCC_PLLDIV_CLK
] = &gcc_apss_sdcc_clk
.cdiv
.clkr
,
1636 [GCC_FEPLL125_CLK
] = &gcc_fepll125_clk
.cdiv
.clkr
,
1637 [GCC_FEPLL125DLY_CLK
] = &gcc_fepll125dly_clk
.cdiv
.clkr
,
1638 [GCC_FEPLL200_CLK
] = &gcc_fepll200_clk
.cdiv
.clkr
,
1639 [GCC_FEPLL500_CLK
] = &gcc_fepll500_clk
.cdiv
.clkr
,
1640 [GCC_FEPLL_WCSS2G_CLK
] = &gcc_fepllwcss2g_clk
.cdiv
.clkr
,
1641 [GCC_FEPLL_WCSS5G_CLK
] = &gcc_fepllwcss5g_clk
.cdiv
.clkr
,
1642 [GCC_APSS_CPU_PLLDIV_CLK
] = &gcc_apss_cpu_plldiv_clk
.cdiv
.clkr
,
1643 [GCC_PCNOC_AHB_CLK_SRC
] = &gcc_pcnoc_ahb_clk_src
.clkr
,
1644 [GCC_PCNOC_AHB_CLK
] = &pcnoc_clk_src
.clkr
,
1647 static const struct qcom_reset_map gcc_ipq4019_resets
[] = {
1648 [WIFI0_CPU_INIT_RESET
] = { 0x1f008, 5 },
1649 [WIFI0_RADIO_SRIF_RESET
] = { 0x1f008, 4 },
1650 [WIFI0_RADIO_WARM_RESET
] = { 0x1f008, 3 },
1651 [WIFI0_RADIO_COLD_RESET
] = { 0x1f008, 2 },
1652 [WIFI0_CORE_WARM_RESET
] = { 0x1f008, 1 },
1653 [WIFI0_CORE_COLD_RESET
] = { 0x1f008, 0 },
1654 [WIFI1_CPU_INIT_RESET
] = { 0x20008, 5 },
1655 [WIFI1_RADIO_SRIF_RESET
] = { 0x20008, 4 },
1656 [WIFI1_RADIO_WARM_RESET
] = { 0x20008, 3 },
1657 [WIFI1_RADIO_COLD_RESET
] = { 0x20008, 2 },
1658 [WIFI1_CORE_WARM_RESET
] = { 0x20008, 1 },
1659 [WIFI1_CORE_COLD_RESET
] = { 0x20008, 0 },
1660 [USB3_UNIPHY_PHY_ARES
] = { 0x1e038, 5 },
1661 [USB3_HSPHY_POR_ARES
] = { 0x1e038, 4 },
1662 [USB3_HSPHY_S_ARES
] = { 0x1e038, 2 },
1663 [USB2_HSPHY_POR_ARES
] = { 0x1e01c, 4 },
1664 [USB2_HSPHY_S_ARES
] = { 0x1e01c, 2 },
1665 [PCIE_PHY_AHB_ARES
] = { 0x1d010, 11 },
1666 [PCIE_AHB_ARES
] = { 0x1d010, 10 },
1667 [PCIE_PWR_ARES
] = { 0x1d010, 9 },
1668 [PCIE_PIPE_STICKY_ARES
] = { 0x1d010, 8 },
1669 [PCIE_AXI_M_STICKY_ARES
] = { 0x1d010, 7 },
1670 [PCIE_PHY_ARES
] = { 0x1d010, 6 },
1671 [PCIE_PARF_XPU_ARES
] = { 0x1d010, 5 },
1672 [PCIE_AXI_S_XPU_ARES
] = { 0x1d010, 4 },
1673 [PCIE_AXI_M_VMIDMT_ARES
] = { 0x1d010, 3 },
1674 [PCIE_PIPE_ARES
] = { 0x1d010, 2 },
1675 [PCIE_AXI_S_ARES
] = { 0x1d010, 1 },
1676 [PCIE_AXI_M_ARES
] = { 0x1d010, 0 },
1677 [ESS_RESET
] = { 0x12008, 0},
1678 [GCC_BLSP1_BCR
] = {0x01000, 0},
1679 [GCC_BLSP1_QUP1_BCR
] = {0x02000, 0},
1680 [GCC_BLSP1_UART1_BCR
] = {0x02038, 0},
1681 [GCC_BLSP1_QUP2_BCR
] = {0x03008, 0},
1682 [GCC_BLSP1_UART2_BCR
] = {0x03028, 0},
1683 [GCC_BIMC_BCR
] = {0x04000, 0},
1684 [GCC_TLMM_BCR
] = {0x05000, 0},
1685 [GCC_IMEM_BCR
] = {0x0E000, 0},
1686 [GCC_ESS_BCR
] = {0x12008, 0},
1687 [GCC_PRNG_BCR
] = {0x13000, 0},
1688 [GCC_BOOT_ROM_BCR
] = {0x13008, 0},
1689 [GCC_CRYPTO_BCR
] = {0x16000, 0},
1690 [GCC_SDCC1_BCR
] = {0x18000, 0},
1691 [GCC_SEC_CTRL_BCR
] = {0x1A000, 0},
1692 [GCC_AUDIO_BCR
] = {0x1B008, 0},
1693 [GCC_QPIC_BCR
] = {0x1C000, 0},
1694 [GCC_PCIE_BCR
] = {0x1D000, 0},
1695 [GCC_USB2_BCR
] = {0x1E008, 0},
1696 [GCC_USB2_PHY_BCR
] = {0x1E018, 0},
1697 [GCC_USB3_BCR
] = {0x1E024, 0},
1698 [GCC_USB3_PHY_BCR
] = {0x1E034, 0},
1699 [GCC_SYSTEM_NOC_BCR
] = {0x21000, 0},
1700 [GCC_PCNOC_BCR
] = {0x2102C, 0},
1701 [GCC_DCD_BCR
] = {0x21038, 0},
1702 [GCC_SNOC_BUS_TIMEOUT0_BCR
] = {0x21064, 0},
1703 [GCC_SNOC_BUS_TIMEOUT1_BCR
] = {0x2106C, 0},
1704 [GCC_SNOC_BUS_TIMEOUT2_BCR
] = {0x21074, 0},
1705 [GCC_SNOC_BUS_TIMEOUT3_BCR
] = {0x2107C, 0},
1706 [GCC_PCNOC_BUS_TIMEOUT0_BCR
] = {0x21084, 0},
1707 [GCC_PCNOC_BUS_TIMEOUT1_BCR
] = {0x2108C, 0},
1708 [GCC_PCNOC_BUS_TIMEOUT2_BCR
] = {0x21094, 0},
1709 [GCC_PCNOC_BUS_TIMEOUT3_BCR
] = {0x2109C, 0},
1710 [GCC_PCNOC_BUS_TIMEOUT4_BCR
] = {0x210A4, 0},
1711 [GCC_PCNOC_BUS_TIMEOUT5_BCR
] = {0x210AC, 0},
1712 [GCC_PCNOC_BUS_TIMEOUT6_BCR
] = {0x210B4, 0},
1713 [GCC_PCNOC_BUS_TIMEOUT7_BCR
] = {0x210BC, 0},
1714 [GCC_PCNOC_BUS_TIMEOUT8_BCR
] = {0x210C4, 0},
1715 [GCC_PCNOC_BUS_TIMEOUT9_BCR
] = {0x210CC, 0},
1716 [GCC_TCSR_BCR
] = {0x22000, 0},
1717 [GCC_MPM_BCR
] = {0x24000, 0},
1718 [GCC_SPDM_BCR
] = {0x25000, 0},
1721 static const struct regmap_config gcc_ipq4019_regmap_config
= {
1725 .max_register
= 0x2ffff,
1729 static const struct qcom_cc_desc gcc_ipq4019_desc
= {
1730 .config
= &gcc_ipq4019_regmap_config
,
1731 .clks
= gcc_ipq4019_clocks
,
1732 .num_clks
= ARRAY_SIZE(gcc_ipq4019_clocks
),
1733 .resets
= gcc_ipq4019_resets
,
1734 .num_resets
= ARRAY_SIZE(gcc_ipq4019_resets
),
1737 static const struct of_device_id gcc_ipq4019_match_table
[] = {
1738 { .compatible
= "qcom,gcc-ipq4019" },
1741 MODULE_DEVICE_TABLE(of
, gcc_ipq4019_match_table
);
1744 gcc_ipq4019_cpu_clk_notifier_fn(struct notifier_block
*nb
,
1745 unsigned long action
, void *data
)
1749 if (action
== PRE_RATE_CHANGE
)
1750 err
= clk_rcg2_ops
.set_parent(&apps_clk_src
.clkr
.hw
,
1751 gcc_ipq4019_cpu_safe_parent
);
1753 return notifier_from_errno(err
);
1756 static struct notifier_block gcc_ipq4019_cpu_clk_notifier
= {
1757 .notifier_call
= gcc_ipq4019_cpu_clk_notifier_fn
,
1760 static int gcc_ipq4019_probe(struct platform_device
*pdev
)
1764 err
= qcom_cc_probe(pdev
, &gcc_ipq4019_desc
);
1768 return clk_notifier_register(apps_clk_src
.clkr
.hw
.clk
,
1769 &gcc_ipq4019_cpu_clk_notifier
);
1772 static int gcc_ipq4019_remove(struct platform_device
*pdev
)
1774 return clk_notifier_unregister(apps_clk_src
.clkr
.hw
.clk
,
1775 &gcc_ipq4019_cpu_clk_notifier
);
1778 static struct platform_driver gcc_ipq4019_driver
= {
1779 .probe
= gcc_ipq4019_probe
,
1780 .remove
= gcc_ipq4019_remove
,
1782 .name
= "qcom,gcc-ipq4019",
1783 .of_match_table
= gcc_ipq4019_match_table
,
1787 static int __init
gcc_ipq4019_init(void)
1789 return platform_driver_register(&gcc_ipq4019_driver
);
1791 core_initcall(gcc_ipq4019_init
);
1793 static void __exit
gcc_ipq4019_exit(void)
1795 platform_driver_unregister(&gcc_ipq4019_driver
);
1797 module_exit(gcc_ipq4019_exit
);
1799 MODULE_ALIAS("platform:gcc-ipq4019");
1800 MODULE_LICENSE("GPL v2");
1801 MODULE_DESCRIPTION("QCOM GCC IPQ4019 driver");