1013804a7SKonrad Dybcio // SPDX-License-Identifier: GPL-2.0-only 2013804a7SKonrad Dybcio /* 3013804a7SKonrad Dybcio * Copyright (c) 2021, The Linux Foundation. All rights reserved. 4013804a7SKonrad Dybcio * Copyright (c) 2021, Konrad Dybcio <konrad.dybcio@somainline.org> 5013804a7SKonrad Dybcio */ 6013804a7SKonrad Dybcio 7013804a7SKonrad Dybcio #include <linux/clk-provider.h> 8013804a7SKonrad Dybcio #include <linux/module.h> 9013804a7SKonrad Dybcio #include <linux/platform_device.h> 10013804a7SKonrad Dybcio #include <linux/regmap.h> 11013804a7SKonrad Dybcio 12013804a7SKonrad Dybcio #include <dt-bindings/clock/qcom,gpucc-sm6350.h> 13013804a7SKonrad Dybcio 14013804a7SKonrad Dybcio #include "common.h" 15013804a7SKonrad Dybcio #include "clk-alpha-pll.h" 16013804a7SKonrad Dybcio #include "clk-branch.h" 17013804a7SKonrad Dybcio #include "clk-rcg.h" 18013804a7SKonrad Dybcio #include "clk-regmap.h" 19013804a7SKonrad Dybcio #include "reset.h" 20013804a7SKonrad Dybcio #include "gdsc.h" 21013804a7SKonrad Dybcio 22013804a7SKonrad Dybcio #define CX_GMU_CBCR_SLEEP_MASK 0xF 23013804a7SKonrad Dybcio #define CX_GMU_CBCR_SLEEP_SHIFT 4 24013804a7SKonrad Dybcio #define CX_GMU_CBCR_WAKE_MASK 0xF 25013804a7SKonrad Dybcio #define CX_GMU_CBCR_WAKE_SHIFT 8 26013804a7SKonrad Dybcio 27013804a7SKonrad Dybcio enum { 28*f6f89d19SKonrad Dybcio DT_BI_TCXO, 29*f6f89d19SKonrad Dybcio DT_GPLL0_OUT_MAIN, 30*f6f89d19SKonrad Dybcio DT_GPLL0_OUT_MAIN_DIV, 31*f6f89d19SKonrad Dybcio }; 32*f6f89d19SKonrad Dybcio 33*f6f89d19SKonrad Dybcio enum { 34013804a7SKonrad Dybcio P_BI_TCXO, 35013804a7SKonrad Dybcio P_GPLL0_OUT_MAIN, 36013804a7SKonrad Dybcio P_GPLL0_OUT_MAIN_DIV, 37013804a7SKonrad Dybcio P_GPU_CC_PLL0_OUT_MAIN, 38013804a7SKonrad Dybcio P_GPU_CC_PLL0_OUT_ODD, 39013804a7SKonrad Dybcio P_GPU_CC_PLL1_OUT_EVEN, 40013804a7SKonrad Dybcio P_GPU_CC_PLL1_OUT_MAIN, 41013804a7SKonrad Dybcio P_GPU_CC_PLL1_OUT_ODD, 42013804a7SKonrad Dybcio P_CRC_DIV, 43013804a7SKonrad Dybcio }; 44013804a7SKonrad Dybcio 45013804a7SKonrad Dybcio static const struct pll_vco fabia_vco[] = { 46013804a7SKonrad Dybcio { 249600000, 2000000000, 0 }, 47013804a7SKonrad Dybcio }; 48013804a7SKonrad Dybcio 49013804a7SKonrad Dybcio /* 506MHz Configuration*/ 50013804a7SKonrad Dybcio static const struct alpha_pll_config gpu_cc_pll0_config = { 51013804a7SKonrad Dybcio .l = 0x1A, 52013804a7SKonrad Dybcio .alpha = 0x5AAA, 53013804a7SKonrad Dybcio .config_ctl_val = 0x20485699, 54013804a7SKonrad Dybcio .config_ctl_hi_val = 0x00002067, 55013804a7SKonrad Dybcio .test_ctl_val = 0x40000000, 56013804a7SKonrad Dybcio .test_ctl_hi_val = 0x00000002, 57013804a7SKonrad Dybcio .user_ctl_val = 0x00000001, 58013804a7SKonrad Dybcio .user_ctl_hi_val = 0x00004805, 59013804a7SKonrad Dybcio }; 60013804a7SKonrad Dybcio 61013804a7SKonrad Dybcio static struct clk_alpha_pll gpu_cc_pll0 = { 62013804a7SKonrad Dybcio .offset = 0x0, 63013804a7SKonrad Dybcio .vco_table = fabia_vco, 64013804a7SKonrad Dybcio .num_vco = ARRAY_SIZE(fabia_vco), 65013804a7SKonrad Dybcio .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], 66013804a7SKonrad Dybcio .clkr = { 67013804a7SKonrad Dybcio .hw.init = &(struct clk_init_data){ 68013804a7SKonrad Dybcio .name = "gpu_cc_pll0", 69013804a7SKonrad Dybcio .parent_data = &(const struct clk_parent_data){ 70*f6f89d19SKonrad Dybcio .index = DT_BI_TCXO, 71013804a7SKonrad Dybcio .fw_name = "bi_tcxo", 72013804a7SKonrad Dybcio }, 73013804a7SKonrad Dybcio .num_parents = 1, 74013804a7SKonrad Dybcio .ops = &clk_alpha_pll_fabia_ops, 75013804a7SKonrad Dybcio }, 76013804a7SKonrad Dybcio }, 77013804a7SKonrad Dybcio }; 78013804a7SKonrad Dybcio 79013804a7SKonrad Dybcio static struct clk_fixed_factor crc_div = { 80013804a7SKonrad Dybcio .mult = 1, 81013804a7SKonrad Dybcio .div = 2, 82013804a7SKonrad Dybcio .hw.init = &(struct clk_init_data){ 83013804a7SKonrad Dybcio .name = "crc_div", 84013804a7SKonrad Dybcio .parent_hws = (const struct clk_hw*[]){ 85013804a7SKonrad Dybcio &gpu_cc_pll0.clkr.hw, 86013804a7SKonrad Dybcio }, 87013804a7SKonrad Dybcio .num_parents = 1, 88013804a7SKonrad Dybcio .flags = CLK_SET_RATE_PARENT, 89013804a7SKonrad Dybcio .ops = &clk_fixed_factor_ops, 90013804a7SKonrad Dybcio }, 91013804a7SKonrad Dybcio }; 92013804a7SKonrad Dybcio 93013804a7SKonrad Dybcio /* 514MHz Configuration*/ 94013804a7SKonrad Dybcio static const struct alpha_pll_config gpu_cc_pll1_config = { 95013804a7SKonrad Dybcio .l = 0x1A, 96013804a7SKonrad Dybcio .alpha = 0xC555, 97013804a7SKonrad Dybcio .config_ctl_val = 0x20485699, 98013804a7SKonrad Dybcio .config_ctl_hi_val = 0x00002067, 99013804a7SKonrad Dybcio .test_ctl_val = 0x40000000, 100013804a7SKonrad Dybcio .test_ctl_hi_val = 0x00000002, 101013804a7SKonrad Dybcio .user_ctl_val = 0x00000001, 102013804a7SKonrad Dybcio .user_ctl_hi_val = 0x00004805, 103013804a7SKonrad Dybcio }; 104013804a7SKonrad Dybcio 105013804a7SKonrad Dybcio static struct clk_alpha_pll gpu_cc_pll1 = { 106013804a7SKonrad Dybcio .offset = 0x100, 107013804a7SKonrad Dybcio .vco_table = fabia_vco, 108013804a7SKonrad Dybcio .num_vco = ARRAY_SIZE(fabia_vco), 109013804a7SKonrad Dybcio .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], 110013804a7SKonrad Dybcio .clkr = { 111013804a7SKonrad Dybcio .hw.init = &(struct clk_init_data){ 112013804a7SKonrad Dybcio .name = "gpu_cc_pll1", 113013804a7SKonrad Dybcio .parent_data = &(const struct clk_parent_data){ 114*f6f89d19SKonrad Dybcio .index = DT_BI_TCXO, 115013804a7SKonrad Dybcio .fw_name = "bi_tcxo", 116013804a7SKonrad Dybcio }, 117013804a7SKonrad Dybcio .num_parents = 1, 118013804a7SKonrad Dybcio .ops = &clk_alpha_pll_fabia_ops, 119013804a7SKonrad Dybcio }, 120013804a7SKonrad Dybcio }, 121013804a7SKonrad Dybcio }; 122013804a7SKonrad Dybcio 123013804a7SKonrad Dybcio static const struct parent_map gpu_cc_parent_map_0[] = { 124013804a7SKonrad Dybcio { P_BI_TCXO, 0 }, 125013804a7SKonrad Dybcio { P_GPU_CC_PLL0_OUT_MAIN, 1 }, 126013804a7SKonrad Dybcio { P_GPU_CC_PLL1_OUT_MAIN, 3 }, 127013804a7SKonrad Dybcio { P_GPLL0_OUT_MAIN, 5 }, 128013804a7SKonrad Dybcio { P_GPLL0_OUT_MAIN_DIV, 6 }, 129013804a7SKonrad Dybcio }; 130013804a7SKonrad Dybcio 131013804a7SKonrad Dybcio static const struct clk_parent_data gpu_cc_parent_data_0[] = { 132*f6f89d19SKonrad Dybcio { .index = DT_BI_TCXO, .fw_name = "bi_tcxo" }, 133013804a7SKonrad Dybcio { .hw = &gpu_cc_pll0.clkr.hw }, 134013804a7SKonrad Dybcio { .hw = &gpu_cc_pll1.clkr.hw }, 135*f6f89d19SKonrad Dybcio { .index = DT_GPLL0_OUT_MAIN, .fw_name = "gcc_gpu_gpll0_clk" }, 136*f6f89d19SKonrad Dybcio { .index = DT_GPLL0_OUT_MAIN_DIV, .fw_name = "gcc_gpu_gpll0_div_clk" }, 137013804a7SKonrad Dybcio }; 138013804a7SKonrad Dybcio 139013804a7SKonrad Dybcio static const struct parent_map gpu_cc_parent_map_1[] = { 140013804a7SKonrad Dybcio { P_BI_TCXO, 0 }, 141013804a7SKonrad Dybcio { P_CRC_DIV, 1 }, 142013804a7SKonrad Dybcio { P_GPU_CC_PLL0_OUT_ODD, 2 }, 143013804a7SKonrad Dybcio { P_GPU_CC_PLL1_OUT_EVEN, 3 }, 144013804a7SKonrad Dybcio { P_GPU_CC_PLL1_OUT_ODD, 4 }, 145013804a7SKonrad Dybcio { P_GPLL0_OUT_MAIN, 5 }, 146013804a7SKonrad Dybcio }; 147013804a7SKonrad Dybcio 148013804a7SKonrad Dybcio static const struct clk_parent_data gpu_cc_parent_data_1[] = { 149*f6f89d19SKonrad Dybcio { .index = DT_BI_TCXO, .fw_name = "bi_tcxo" }, 150013804a7SKonrad Dybcio { .hw = &crc_div.hw }, 151013804a7SKonrad Dybcio { .hw = &gpu_cc_pll0.clkr.hw }, 152013804a7SKonrad Dybcio { .hw = &gpu_cc_pll1.clkr.hw }, 153013804a7SKonrad Dybcio { .hw = &gpu_cc_pll1.clkr.hw }, 154*f6f89d19SKonrad Dybcio { .index = DT_GPLL0_OUT_MAIN, .fw_name = "gcc_gpu_gpll0_clk" }, 155013804a7SKonrad Dybcio }; 156013804a7SKonrad Dybcio 157013804a7SKonrad Dybcio static const struct freq_tbl ftbl_gpu_cc_gmu_clk_src[] = { 158013804a7SKonrad Dybcio F(200000000, P_GPLL0_OUT_MAIN_DIV, 1.5, 0, 0), 159013804a7SKonrad Dybcio { } 160013804a7SKonrad Dybcio }; 161013804a7SKonrad Dybcio 162013804a7SKonrad Dybcio static struct clk_rcg2 gpu_cc_gmu_clk_src = { 163013804a7SKonrad Dybcio .cmd_rcgr = 0x1120, 164013804a7SKonrad Dybcio .mnd_width = 0, 165013804a7SKonrad Dybcio .hid_width = 5, 166013804a7SKonrad Dybcio .parent_map = gpu_cc_parent_map_0, 167013804a7SKonrad Dybcio .freq_tbl = ftbl_gpu_cc_gmu_clk_src, 168013804a7SKonrad Dybcio .clkr.hw.init = &(struct clk_init_data){ 169013804a7SKonrad Dybcio .name = "gpu_cc_gmu_clk_src", 170013804a7SKonrad Dybcio .parent_data = gpu_cc_parent_data_0, 171013804a7SKonrad Dybcio .num_parents = ARRAY_SIZE(gpu_cc_parent_data_0), 172013804a7SKonrad Dybcio .flags = CLK_SET_RATE_PARENT, 173013804a7SKonrad Dybcio .ops = &clk_rcg2_ops, 174013804a7SKonrad Dybcio }, 175013804a7SKonrad Dybcio }; 176013804a7SKonrad Dybcio 177013804a7SKonrad Dybcio static const struct freq_tbl ftbl_gpu_cc_gx_gfx3d_clk_src[] = { 178013804a7SKonrad Dybcio F(253000000, P_CRC_DIV, 1, 0, 0), 179013804a7SKonrad Dybcio F(355000000, P_CRC_DIV, 1, 0, 0), 180013804a7SKonrad Dybcio F(430000000, P_CRC_DIV, 1, 0, 0), 181013804a7SKonrad Dybcio F(565000000, P_CRC_DIV, 1, 0, 0), 182013804a7SKonrad Dybcio F(650000000, P_CRC_DIV, 1, 0, 0), 183013804a7SKonrad Dybcio F(800000000, P_CRC_DIV, 1, 0, 0), 184013804a7SKonrad Dybcio F(825000000, P_CRC_DIV, 1, 0, 0), 185013804a7SKonrad Dybcio F(850000000, P_CRC_DIV, 1, 0, 0), 186013804a7SKonrad Dybcio { } 187013804a7SKonrad Dybcio }; 188013804a7SKonrad Dybcio 189013804a7SKonrad Dybcio static struct clk_rcg2 gpu_cc_gx_gfx3d_clk_src = { 190013804a7SKonrad Dybcio .cmd_rcgr = 0x101c, 191013804a7SKonrad Dybcio .mnd_width = 0, 192013804a7SKonrad Dybcio .hid_width = 5, 193013804a7SKonrad Dybcio .parent_map = gpu_cc_parent_map_1, 194013804a7SKonrad Dybcio .freq_tbl = ftbl_gpu_cc_gx_gfx3d_clk_src, 195013804a7SKonrad Dybcio .clkr.hw.init = &(struct clk_init_data){ 196013804a7SKonrad Dybcio .name = "gpu_cc_gx_gfx3d_clk_src", 197013804a7SKonrad Dybcio .parent_data = gpu_cc_parent_data_1, 198013804a7SKonrad Dybcio .num_parents = ARRAY_SIZE(gpu_cc_parent_data_1), 199013804a7SKonrad Dybcio .flags = CLK_SET_RATE_PARENT, 200013804a7SKonrad Dybcio .ops = &clk_rcg2_ops, 201013804a7SKonrad Dybcio }, 202013804a7SKonrad Dybcio }; 203013804a7SKonrad Dybcio 204013804a7SKonrad Dybcio static struct clk_branch gpu_cc_acd_ahb_clk = { 205013804a7SKonrad Dybcio .halt_reg = 0x1168, 206013804a7SKonrad Dybcio .halt_check = BRANCH_HALT, 207013804a7SKonrad Dybcio .clkr = { 208013804a7SKonrad Dybcio .enable_reg = 0x1168, 209013804a7SKonrad Dybcio .enable_mask = BIT(0), 210013804a7SKonrad Dybcio .hw.init = &(struct clk_init_data){ 211013804a7SKonrad Dybcio .name = "gpu_cc_acd_ahb_clk", 212013804a7SKonrad Dybcio .ops = &clk_branch2_ops, 213013804a7SKonrad Dybcio }, 214013804a7SKonrad Dybcio }, 215013804a7SKonrad Dybcio }; 216013804a7SKonrad Dybcio 217013804a7SKonrad Dybcio static struct clk_branch gpu_cc_acd_cxo_clk = { 218013804a7SKonrad Dybcio .halt_reg = 0x1164, 219013804a7SKonrad Dybcio .halt_check = BRANCH_HALT, 220013804a7SKonrad Dybcio .clkr = { 221013804a7SKonrad Dybcio .enable_reg = 0x1164, 222013804a7SKonrad Dybcio .enable_mask = BIT(0), 223013804a7SKonrad Dybcio .hw.init = &(struct clk_init_data){ 224013804a7SKonrad Dybcio .name = "gpu_cc_acd_cxo_clk", 225013804a7SKonrad Dybcio .ops = &clk_branch2_ops, 226013804a7SKonrad Dybcio }, 227013804a7SKonrad Dybcio }, 228013804a7SKonrad Dybcio }; 229013804a7SKonrad Dybcio 230013804a7SKonrad Dybcio static struct clk_branch gpu_cc_ahb_clk = { 231013804a7SKonrad Dybcio .halt_reg = 0x1078, 232013804a7SKonrad Dybcio .halt_check = BRANCH_HALT_DELAY, 233013804a7SKonrad Dybcio .clkr = { 234013804a7SKonrad Dybcio .enable_reg = 0x1078, 235013804a7SKonrad Dybcio .enable_mask = BIT(0), 236013804a7SKonrad Dybcio .hw.init = &(struct clk_init_data){ 237013804a7SKonrad Dybcio .name = "gpu_cc_ahb_clk", 238013804a7SKonrad Dybcio .flags = CLK_IS_CRITICAL, 239013804a7SKonrad Dybcio .ops = &clk_branch2_ops, 240013804a7SKonrad Dybcio }, 241013804a7SKonrad Dybcio }, 242013804a7SKonrad Dybcio }; 243013804a7SKonrad Dybcio 244013804a7SKonrad Dybcio static struct clk_branch gpu_cc_crc_ahb_clk = { 245013804a7SKonrad Dybcio .halt_reg = 0x107c, 246013804a7SKonrad Dybcio .halt_check = BRANCH_HALT_DELAY, 247013804a7SKonrad Dybcio .clkr = { 248013804a7SKonrad Dybcio .enable_reg = 0x107c, 249013804a7SKonrad Dybcio .enable_mask = BIT(0), 250013804a7SKonrad Dybcio .hw.init = &(struct clk_init_data){ 251013804a7SKonrad Dybcio .name = "gpu_cc_crc_ahb_clk", 252013804a7SKonrad Dybcio .ops = &clk_branch2_ops, 253013804a7SKonrad Dybcio }, 254013804a7SKonrad Dybcio }, 255013804a7SKonrad Dybcio }; 256013804a7SKonrad Dybcio 257013804a7SKonrad Dybcio static struct clk_branch gpu_cc_cx_gfx3d_clk = { 258013804a7SKonrad Dybcio .halt_reg = 0x10a4, 259013804a7SKonrad Dybcio .halt_check = BRANCH_HALT_DELAY, 260013804a7SKonrad Dybcio .clkr = { 261013804a7SKonrad Dybcio .enable_reg = 0x10a4, 262013804a7SKonrad Dybcio .enable_mask = BIT(0), 263013804a7SKonrad Dybcio .hw.init = &(struct clk_init_data){ 264013804a7SKonrad Dybcio .name = "gpu_cc_cx_gfx3d_clk", 265013804a7SKonrad Dybcio .parent_hws = (const struct clk_hw*[]){ 266013804a7SKonrad Dybcio &gpu_cc_gx_gfx3d_clk_src.clkr.hw, 267013804a7SKonrad Dybcio }, 268013804a7SKonrad Dybcio .num_parents = 1, 269013804a7SKonrad Dybcio .flags = CLK_SET_RATE_PARENT, 270013804a7SKonrad Dybcio .ops = &clk_branch2_ops, 271013804a7SKonrad Dybcio }, 272013804a7SKonrad Dybcio }, 273013804a7SKonrad Dybcio }; 274013804a7SKonrad Dybcio 275013804a7SKonrad Dybcio static struct clk_branch gpu_cc_cx_gfx3d_slv_clk = { 276013804a7SKonrad Dybcio .halt_reg = 0x10a8, 277013804a7SKonrad Dybcio .halt_check = BRANCH_HALT_DELAY, 278013804a7SKonrad Dybcio .clkr = { 279013804a7SKonrad Dybcio .enable_reg = 0x10a8, 280013804a7SKonrad Dybcio .enable_mask = BIT(0), 281013804a7SKonrad Dybcio .hw.init = &(struct clk_init_data){ 282013804a7SKonrad Dybcio .name = "gpu_cc_cx_gfx3d_slv_clk", 283013804a7SKonrad Dybcio .parent_hws = (const struct clk_hw*[]){ 284013804a7SKonrad Dybcio &gpu_cc_gx_gfx3d_clk_src.clkr.hw, 285013804a7SKonrad Dybcio }, 286013804a7SKonrad Dybcio .num_parents = 1, 287013804a7SKonrad Dybcio .flags = CLK_SET_RATE_PARENT, 288013804a7SKonrad Dybcio .ops = &clk_branch2_ops, 289013804a7SKonrad Dybcio }, 290013804a7SKonrad Dybcio }, 291013804a7SKonrad Dybcio }; 292013804a7SKonrad Dybcio 293013804a7SKonrad Dybcio static struct clk_branch gpu_cc_cx_gmu_clk = { 294013804a7SKonrad Dybcio .halt_reg = 0x1098, 295013804a7SKonrad Dybcio .halt_check = BRANCH_HALT, 296013804a7SKonrad Dybcio .clkr = { 297013804a7SKonrad Dybcio .enable_reg = 0x1098, 298013804a7SKonrad Dybcio .enable_mask = BIT(0), 299013804a7SKonrad Dybcio .hw.init = &(struct clk_init_data){ 300013804a7SKonrad Dybcio .name = "gpu_cc_cx_gmu_clk", 301013804a7SKonrad Dybcio .parent_hws = (const struct clk_hw*[]){ 302013804a7SKonrad Dybcio &gpu_cc_gmu_clk_src.clkr.hw, 303013804a7SKonrad Dybcio }, 304013804a7SKonrad Dybcio .num_parents = 1, 305013804a7SKonrad Dybcio .flags = CLK_SET_RATE_PARENT, 306013804a7SKonrad Dybcio .ops = &clk_branch2_ops, 307013804a7SKonrad Dybcio }, 308013804a7SKonrad Dybcio }, 309013804a7SKonrad Dybcio }; 310013804a7SKonrad Dybcio 311013804a7SKonrad Dybcio static struct clk_branch gpu_cc_cx_snoc_dvm_clk = { 312013804a7SKonrad Dybcio .halt_reg = 0x108c, 313013804a7SKonrad Dybcio .halt_check = BRANCH_HALT_DELAY, 314013804a7SKonrad Dybcio .clkr = { 315013804a7SKonrad Dybcio .enable_reg = 0x108c, 316013804a7SKonrad Dybcio .enable_mask = BIT(0), 317013804a7SKonrad Dybcio .hw.init = &(struct clk_init_data){ 318013804a7SKonrad Dybcio .name = "gpu_cc_cx_snoc_dvm_clk", 319013804a7SKonrad Dybcio .ops = &clk_branch2_ops, 320013804a7SKonrad Dybcio }, 321013804a7SKonrad Dybcio }, 322013804a7SKonrad Dybcio }; 323013804a7SKonrad Dybcio 324013804a7SKonrad Dybcio static struct clk_branch gpu_cc_cxo_aon_clk = { 325013804a7SKonrad Dybcio .halt_reg = 0x1004, 326013804a7SKonrad Dybcio .halt_check = BRANCH_HALT_DELAY, 327013804a7SKonrad Dybcio .clkr = { 328013804a7SKonrad Dybcio .enable_reg = 0x1004, 329013804a7SKonrad Dybcio .enable_mask = BIT(0), 330013804a7SKonrad Dybcio .hw.init = &(struct clk_init_data){ 331013804a7SKonrad Dybcio .name = "gpu_cc_cxo_aon_clk", 332013804a7SKonrad Dybcio .ops = &clk_branch2_ops, 333013804a7SKonrad Dybcio }, 334013804a7SKonrad Dybcio }, 335013804a7SKonrad Dybcio }; 336013804a7SKonrad Dybcio 337013804a7SKonrad Dybcio static struct clk_branch gpu_cc_cxo_clk = { 338013804a7SKonrad Dybcio .halt_reg = 0x109c, 339013804a7SKonrad Dybcio .halt_check = BRANCH_HALT, 340013804a7SKonrad Dybcio .clkr = { 341013804a7SKonrad Dybcio .enable_reg = 0x109c, 342013804a7SKonrad Dybcio .enable_mask = BIT(0), 343013804a7SKonrad Dybcio .hw.init = &(struct clk_init_data){ 344013804a7SKonrad Dybcio .name = "gpu_cc_cxo_clk", 345013804a7SKonrad Dybcio .ops = &clk_branch2_ops, 346013804a7SKonrad Dybcio }, 347013804a7SKonrad Dybcio }, 348013804a7SKonrad Dybcio }; 349013804a7SKonrad Dybcio 350013804a7SKonrad Dybcio static struct clk_branch gpu_cc_gx_cxo_clk = { 351013804a7SKonrad Dybcio .halt_reg = 0x1060, 352013804a7SKonrad Dybcio .halt_check = BRANCH_HALT, 353013804a7SKonrad Dybcio .clkr = { 354013804a7SKonrad Dybcio .enable_reg = 0x1060, 355013804a7SKonrad Dybcio .enable_mask = BIT(0), 356013804a7SKonrad Dybcio .hw.init = &(struct clk_init_data){ 357013804a7SKonrad Dybcio .name = "gpu_cc_gx_cxo_clk", 358013804a7SKonrad Dybcio .ops = &clk_branch2_ops, 359013804a7SKonrad Dybcio }, 360013804a7SKonrad Dybcio }, 361013804a7SKonrad Dybcio }; 362013804a7SKonrad Dybcio 363013804a7SKonrad Dybcio static struct clk_branch gpu_cc_gx_gfx3d_clk = { 364013804a7SKonrad Dybcio .halt_reg = 0x1054, 365013804a7SKonrad Dybcio .halt_check = BRANCH_HALT_SKIP, 366013804a7SKonrad Dybcio .clkr = { 367013804a7SKonrad Dybcio .enable_reg = 0x1054, 368013804a7SKonrad Dybcio .enable_mask = BIT(0), 369013804a7SKonrad Dybcio .hw.init = &(struct clk_init_data){ 370013804a7SKonrad Dybcio .name = "gpu_cc_gx_gfx3d_clk", 371013804a7SKonrad Dybcio .parent_hws = (const struct clk_hw*[]){ 372013804a7SKonrad Dybcio &gpu_cc_gx_gfx3d_clk_src.clkr.hw, 373013804a7SKonrad Dybcio }, 374013804a7SKonrad Dybcio .num_parents = 1, 375013804a7SKonrad Dybcio .flags = CLK_SET_RATE_PARENT, 376013804a7SKonrad Dybcio .ops = &clk_branch2_ops, 377013804a7SKonrad Dybcio }, 378013804a7SKonrad Dybcio }, 379013804a7SKonrad Dybcio }; 380013804a7SKonrad Dybcio 381013804a7SKonrad Dybcio static struct clk_branch gpu_cc_gx_gmu_clk = { 382013804a7SKonrad Dybcio .halt_reg = 0x1064, 383013804a7SKonrad Dybcio .halt_check = BRANCH_HALT, 384013804a7SKonrad Dybcio .clkr = { 385013804a7SKonrad Dybcio .enable_reg = 0x1064, 386013804a7SKonrad Dybcio .enable_mask = BIT(0), 387013804a7SKonrad Dybcio .hw.init = &(struct clk_init_data){ 388013804a7SKonrad Dybcio .name = "gpu_cc_gx_gmu_clk", 389013804a7SKonrad Dybcio .parent_hws = (const struct clk_hw*[]){ 390013804a7SKonrad Dybcio &gpu_cc_gmu_clk_src.clkr.hw, 391013804a7SKonrad Dybcio }, 392013804a7SKonrad Dybcio .num_parents = 1, 393013804a7SKonrad Dybcio .flags = CLK_SET_RATE_PARENT, 394013804a7SKonrad Dybcio .ops = &clk_branch2_ops, 395013804a7SKonrad Dybcio }, 396013804a7SKonrad Dybcio }, 397013804a7SKonrad Dybcio }; 398013804a7SKonrad Dybcio 399013804a7SKonrad Dybcio static struct clk_branch gpu_cc_gx_vsense_clk = { 400013804a7SKonrad Dybcio .halt_reg = 0x1058, 401013804a7SKonrad Dybcio .halt_check = BRANCH_HALT_DELAY, 402013804a7SKonrad Dybcio .clkr = { 403013804a7SKonrad Dybcio .enable_reg = 0x1058, 404013804a7SKonrad Dybcio .enable_mask = BIT(0), 405013804a7SKonrad Dybcio .hw.init = &(struct clk_init_data){ 406013804a7SKonrad Dybcio .name = "gpu_cc_gx_vsense_clk", 407013804a7SKonrad Dybcio .ops = &clk_branch2_ops, 408013804a7SKonrad Dybcio }, 409013804a7SKonrad Dybcio }, 410013804a7SKonrad Dybcio }; 411013804a7SKonrad Dybcio 412013804a7SKonrad Dybcio static struct gdsc gpu_cx_gdsc = { 413013804a7SKonrad Dybcio .gdscr = 0x106c, 414013804a7SKonrad Dybcio .gds_hw_ctrl = 0x1540, 415013804a7SKonrad Dybcio .pd = { 416013804a7SKonrad Dybcio .name = "gpu_cx_gdsc", 417013804a7SKonrad Dybcio }, 418013804a7SKonrad Dybcio .pwrsts = PWRSTS_OFF_ON, 419013804a7SKonrad Dybcio .flags = VOTABLE, 420013804a7SKonrad Dybcio }; 421013804a7SKonrad Dybcio 422013804a7SKonrad Dybcio static struct gdsc gpu_gx_gdsc = { 423013804a7SKonrad Dybcio .gdscr = 0x100c, 424013804a7SKonrad Dybcio .clamp_io_ctrl = 0x1508, 425013804a7SKonrad Dybcio .pd = { 426013804a7SKonrad Dybcio .name = "gpu_gx_gdsc", 427013804a7SKonrad Dybcio .power_on = gdsc_gx_do_nothing_enable, 428013804a7SKonrad Dybcio }, 429013804a7SKonrad Dybcio .pwrsts = PWRSTS_OFF_ON, 430013804a7SKonrad Dybcio .flags = CLAMP_IO | POLL_CFG_GDSCR, 431013804a7SKonrad Dybcio }; 432013804a7SKonrad Dybcio 433013804a7SKonrad Dybcio static struct clk_hw *gpu_cc_sm6350_hws[] = { 434013804a7SKonrad Dybcio [GPU_CC_CRC_DIV] = &crc_div.hw, 435013804a7SKonrad Dybcio }; 436013804a7SKonrad Dybcio 437013804a7SKonrad Dybcio static struct clk_regmap *gpu_cc_sm6350_clocks[] = { 438013804a7SKonrad Dybcio [GPU_CC_ACD_AHB_CLK] = &gpu_cc_acd_ahb_clk.clkr, 439013804a7SKonrad Dybcio [GPU_CC_ACD_CXO_CLK] = &gpu_cc_acd_cxo_clk.clkr, 440013804a7SKonrad Dybcio [GPU_CC_AHB_CLK] = &gpu_cc_ahb_clk.clkr, 441013804a7SKonrad Dybcio [GPU_CC_CRC_AHB_CLK] = &gpu_cc_crc_ahb_clk.clkr, 442013804a7SKonrad Dybcio [GPU_CC_CX_GFX3D_CLK] = &gpu_cc_cx_gfx3d_clk.clkr, 443013804a7SKonrad Dybcio [GPU_CC_CX_GFX3D_SLV_CLK] = &gpu_cc_cx_gfx3d_slv_clk.clkr, 444013804a7SKonrad Dybcio [GPU_CC_CX_GMU_CLK] = &gpu_cc_cx_gmu_clk.clkr, 445013804a7SKonrad Dybcio [GPU_CC_CX_SNOC_DVM_CLK] = &gpu_cc_cx_snoc_dvm_clk.clkr, 446013804a7SKonrad Dybcio [GPU_CC_CXO_AON_CLK] = &gpu_cc_cxo_aon_clk.clkr, 447013804a7SKonrad Dybcio [GPU_CC_CXO_CLK] = &gpu_cc_cxo_clk.clkr, 448013804a7SKonrad Dybcio [GPU_CC_GMU_CLK_SRC] = &gpu_cc_gmu_clk_src.clkr, 449013804a7SKonrad Dybcio [GPU_CC_GX_CXO_CLK] = &gpu_cc_gx_cxo_clk.clkr, 450013804a7SKonrad Dybcio [GPU_CC_GX_GFX3D_CLK] = &gpu_cc_gx_gfx3d_clk.clkr, 451013804a7SKonrad Dybcio [GPU_CC_GX_GFX3D_CLK_SRC] = &gpu_cc_gx_gfx3d_clk_src.clkr, 452013804a7SKonrad Dybcio [GPU_CC_GX_GMU_CLK] = &gpu_cc_gx_gmu_clk.clkr, 453013804a7SKonrad Dybcio [GPU_CC_GX_VSENSE_CLK] = &gpu_cc_gx_vsense_clk.clkr, 454013804a7SKonrad Dybcio [GPU_CC_PLL0] = &gpu_cc_pll0.clkr, 455013804a7SKonrad Dybcio [GPU_CC_PLL1] = &gpu_cc_pll1.clkr, 456013804a7SKonrad Dybcio }; 457013804a7SKonrad Dybcio 458013804a7SKonrad Dybcio static struct gdsc *gpu_cc_sm6350_gdscs[] = { 459013804a7SKonrad Dybcio [GPU_CX_GDSC] = &gpu_cx_gdsc, 460013804a7SKonrad Dybcio [GPU_GX_GDSC] = &gpu_gx_gdsc, 461013804a7SKonrad Dybcio }; 462013804a7SKonrad Dybcio 463013804a7SKonrad Dybcio static const struct regmap_config gpu_cc_sm6350_regmap_config = { 464013804a7SKonrad Dybcio .reg_bits = 32, 465013804a7SKonrad Dybcio .reg_stride = 4, 466013804a7SKonrad Dybcio .val_bits = 32, 467013804a7SKonrad Dybcio .max_register = 0x8008, 468013804a7SKonrad Dybcio .fast_io = true, 469013804a7SKonrad Dybcio }; 470013804a7SKonrad Dybcio 471013804a7SKonrad Dybcio static const struct qcom_cc_desc gpu_cc_sm6350_desc = { 472013804a7SKonrad Dybcio .config = &gpu_cc_sm6350_regmap_config, 473013804a7SKonrad Dybcio .clk_hws = gpu_cc_sm6350_hws, 474013804a7SKonrad Dybcio .num_clk_hws = ARRAY_SIZE(gpu_cc_sm6350_hws), 475013804a7SKonrad Dybcio .clks = gpu_cc_sm6350_clocks, 476013804a7SKonrad Dybcio .num_clks = ARRAY_SIZE(gpu_cc_sm6350_clocks), 477013804a7SKonrad Dybcio .gdscs = gpu_cc_sm6350_gdscs, 478013804a7SKonrad Dybcio .num_gdscs = ARRAY_SIZE(gpu_cc_sm6350_gdscs), 479013804a7SKonrad Dybcio }; 480013804a7SKonrad Dybcio 481013804a7SKonrad Dybcio static const struct of_device_id gpu_cc_sm6350_match_table[] = { 482013804a7SKonrad Dybcio { .compatible = "qcom,sm6350-gpucc" }, 483013804a7SKonrad Dybcio { } 484013804a7SKonrad Dybcio }; 485013804a7SKonrad Dybcio MODULE_DEVICE_TABLE(of, gpu_cc_sm6350_match_table); 486013804a7SKonrad Dybcio 487013804a7SKonrad Dybcio static int gpu_cc_sm6350_probe(struct platform_device *pdev) 488013804a7SKonrad Dybcio { 489013804a7SKonrad Dybcio struct regmap *regmap; 490013804a7SKonrad Dybcio unsigned int value, mask; 491013804a7SKonrad Dybcio 492013804a7SKonrad Dybcio regmap = qcom_cc_map(pdev, &gpu_cc_sm6350_desc); 493013804a7SKonrad Dybcio if (IS_ERR(regmap)) 494013804a7SKonrad Dybcio return PTR_ERR(regmap); 495013804a7SKonrad Dybcio 496013804a7SKonrad Dybcio clk_fabia_pll_configure(&gpu_cc_pll0, regmap, &gpu_cc_pll0_config); 497013804a7SKonrad Dybcio clk_fabia_pll_configure(&gpu_cc_pll1, regmap, &gpu_cc_pll1_config); 498013804a7SKonrad Dybcio 499013804a7SKonrad Dybcio /* Configure gpu_cc_cx_gmu_clk with recommended wakeup/sleep settings */ 500013804a7SKonrad Dybcio mask = CX_GMU_CBCR_WAKE_MASK << CX_GMU_CBCR_WAKE_SHIFT; 501013804a7SKonrad Dybcio mask |= CX_GMU_CBCR_SLEEP_MASK << CX_GMU_CBCR_SLEEP_SHIFT; 502013804a7SKonrad Dybcio value = 0xF << CX_GMU_CBCR_WAKE_SHIFT | 0xF << CX_GMU_CBCR_SLEEP_SHIFT; 503013804a7SKonrad Dybcio regmap_update_bits(regmap, 0x1098, mask, value); 504013804a7SKonrad Dybcio 505013804a7SKonrad Dybcio return qcom_cc_really_probe(pdev, &gpu_cc_sm6350_desc, regmap); 506013804a7SKonrad Dybcio } 507013804a7SKonrad Dybcio 508013804a7SKonrad Dybcio static struct platform_driver gpu_cc_sm6350_driver = { 509013804a7SKonrad Dybcio .probe = gpu_cc_sm6350_probe, 510013804a7SKonrad Dybcio .driver = { 511013804a7SKonrad Dybcio .name = "sm6350-gpucc", 512013804a7SKonrad Dybcio .of_match_table = gpu_cc_sm6350_match_table, 513013804a7SKonrad Dybcio }, 514013804a7SKonrad Dybcio }; 515013804a7SKonrad Dybcio 516013804a7SKonrad Dybcio static int __init gpu_cc_sm6350_init(void) 517013804a7SKonrad Dybcio { 518013804a7SKonrad Dybcio return platform_driver_register(&gpu_cc_sm6350_driver); 519013804a7SKonrad Dybcio } 520013804a7SKonrad Dybcio core_initcall(gpu_cc_sm6350_init); 521013804a7SKonrad Dybcio 522013804a7SKonrad Dybcio static void __exit gpu_cc_sm6350_exit(void) 523013804a7SKonrad Dybcio { 524013804a7SKonrad Dybcio platform_driver_unregister(&gpu_cc_sm6350_driver); 525013804a7SKonrad Dybcio } 526013804a7SKonrad Dybcio module_exit(gpu_cc_sm6350_exit); 527013804a7SKonrad Dybcio 528013804a7SKonrad Dybcio MODULE_DESCRIPTION("QTI GPU_CC LAGOON Driver"); 529013804a7SKonrad Dybcio MODULE_LICENSE("GPL v2"); 530