18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#include <linux/clk-provider.h>
78c2ecf20Sopenharmony_ci#include <linux/module.h>
88c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
98c2ecf20Sopenharmony_ci#include <linux/regmap.h>
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <dt-bindings/clock/qcom,gpucc-sm8250.h>
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include "common.h"
148c2ecf20Sopenharmony_ci#include "clk-alpha-pll.h"
158c2ecf20Sopenharmony_ci#include "clk-branch.h"
168c2ecf20Sopenharmony_ci#include "clk-pll.h"
178c2ecf20Sopenharmony_ci#include "clk-rcg.h"
188c2ecf20Sopenharmony_ci#include "clk-regmap.h"
198c2ecf20Sopenharmony_ci#include "reset.h"
208c2ecf20Sopenharmony_ci#include "gdsc.h"
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define CX_GMU_CBCR_SLEEP_MASK		0xf
238c2ecf20Sopenharmony_ci#define CX_GMU_CBCR_SLEEP_SHIFT		4
248c2ecf20Sopenharmony_ci#define CX_GMU_CBCR_WAKE_MASK		0xf
258c2ecf20Sopenharmony_ci#define CX_GMU_CBCR_WAKE_SHIFT		8
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_cienum {
288c2ecf20Sopenharmony_ci	P_BI_TCXO,
298c2ecf20Sopenharmony_ci	P_CORE_BI_PLL_TEST_SE,
308c2ecf20Sopenharmony_ci	P_GPLL0_OUT_MAIN,
318c2ecf20Sopenharmony_ci	P_GPLL0_OUT_MAIN_DIV,
328c2ecf20Sopenharmony_ci	P_GPU_CC_PLL0_OUT_MAIN,
338c2ecf20Sopenharmony_ci	P_GPU_CC_PLL1_OUT_MAIN,
348c2ecf20Sopenharmony_ci};
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_cistatic struct pll_vco lucid_vco[] = {
378c2ecf20Sopenharmony_ci	{ 249600000, 2000000000, 0 },
388c2ecf20Sopenharmony_ci};
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_cistatic const struct alpha_pll_config gpu_cc_pll1_config = {
418c2ecf20Sopenharmony_ci	.l = 0x1a,
428c2ecf20Sopenharmony_ci	.alpha = 0xaaa,
438c2ecf20Sopenharmony_ci	.config_ctl_val = 0x20485699,
448c2ecf20Sopenharmony_ci	.config_ctl_hi_val = 0x00002261,
458c2ecf20Sopenharmony_ci	.config_ctl_hi1_val = 0x029a699c,
468c2ecf20Sopenharmony_ci	.user_ctl_val = 0x00000000,
478c2ecf20Sopenharmony_ci	.user_ctl_hi_val = 0x00000805,
488c2ecf20Sopenharmony_ci	.user_ctl_hi1_val = 0x00000000,
498c2ecf20Sopenharmony_ci};
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_cistatic struct clk_alpha_pll gpu_cc_pll1 = {
528c2ecf20Sopenharmony_ci	.offset = 0x100,
538c2ecf20Sopenharmony_ci	.vco_table = lucid_vco,
548c2ecf20Sopenharmony_ci	.num_vco = ARRAY_SIZE(lucid_vco),
558c2ecf20Sopenharmony_ci	.regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_LUCID],
568c2ecf20Sopenharmony_ci	.clkr = {
578c2ecf20Sopenharmony_ci		.hw.init = &(struct clk_init_data){
588c2ecf20Sopenharmony_ci			.name = "gpu_cc_pll1",
598c2ecf20Sopenharmony_ci			.parent_data =  &(const struct clk_parent_data){
608c2ecf20Sopenharmony_ci				.fw_name = "bi_tcxo",
618c2ecf20Sopenharmony_ci			},
628c2ecf20Sopenharmony_ci			.num_parents = 1,
638c2ecf20Sopenharmony_ci			.ops = &clk_alpha_pll_lucid_ops,
648c2ecf20Sopenharmony_ci		},
658c2ecf20Sopenharmony_ci	},
668c2ecf20Sopenharmony_ci};
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_cistatic const struct parent_map gpu_cc_parent_map_0[] = {
698c2ecf20Sopenharmony_ci	{ P_BI_TCXO, 0 },
708c2ecf20Sopenharmony_ci	{ P_GPU_CC_PLL1_OUT_MAIN, 3 },
718c2ecf20Sopenharmony_ci	{ P_GPLL0_OUT_MAIN, 5 },
728c2ecf20Sopenharmony_ci	{ P_GPLL0_OUT_MAIN_DIV, 6 },
738c2ecf20Sopenharmony_ci};
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_cistatic const struct clk_parent_data gpu_cc_parent_data_0[] = {
768c2ecf20Sopenharmony_ci	{ .fw_name = "bi_tcxo" },
778c2ecf20Sopenharmony_ci	{ .hw = &gpu_cc_pll1.clkr.hw },
788c2ecf20Sopenharmony_ci	{ .fw_name = "gcc_gpu_gpll0_clk_src" },
798c2ecf20Sopenharmony_ci	{ .fw_name = "gcc_gpu_gpll0_div_clk_src" },
808c2ecf20Sopenharmony_ci};
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_cistatic const struct freq_tbl ftbl_gpu_cc_gmu_clk_src[] = {
838c2ecf20Sopenharmony_ci	F(19200000, P_BI_TCXO, 1, 0, 0),
848c2ecf20Sopenharmony_ci	F(200000000, P_GPLL0_OUT_MAIN_DIV, 1.5, 0, 0),
858c2ecf20Sopenharmony_ci	F(500000000, P_GPU_CC_PLL1_OUT_MAIN, 1, 0, 0),
868c2ecf20Sopenharmony_ci	{ }
878c2ecf20Sopenharmony_ci};
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_cistatic struct clk_rcg2 gpu_cc_gmu_clk_src = {
908c2ecf20Sopenharmony_ci	.cmd_rcgr = 0x1120,
918c2ecf20Sopenharmony_ci	.mnd_width = 0,
928c2ecf20Sopenharmony_ci	.hid_width = 5,
938c2ecf20Sopenharmony_ci	.parent_map = gpu_cc_parent_map_0,
948c2ecf20Sopenharmony_ci	.freq_tbl = ftbl_gpu_cc_gmu_clk_src,
958c2ecf20Sopenharmony_ci	.clkr.hw.init = &(struct clk_init_data){
968c2ecf20Sopenharmony_ci		.name = "gpu_cc_gmu_clk_src",
978c2ecf20Sopenharmony_ci		.parent_data = gpu_cc_parent_data_0,
988c2ecf20Sopenharmony_ci		.num_parents = ARRAY_SIZE(gpu_cc_parent_data_0),
998c2ecf20Sopenharmony_ci		.flags = CLK_SET_RATE_PARENT,
1008c2ecf20Sopenharmony_ci		.ops = &clk_rcg2_ops,
1018c2ecf20Sopenharmony_ci	},
1028c2ecf20Sopenharmony_ci};
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_cistatic struct clk_branch gpu_cc_ahb_clk = {
1058c2ecf20Sopenharmony_ci	.halt_reg = 0x1078,
1068c2ecf20Sopenharmony_ci	.halt_check = BRANCH_HALT_DELAY,
1078c2ecf20Sopenharmony_ci	.clkr = {
1088c2ecf20Sopenharmony_ci		.enable_reg = 0x1078,
1098c2ecf20Sopenharmony_ci		.enable_mask = BIT(0),
1108c2ecf20Sopenharmony_ci		.hw.init = &(struct clk_init_data){
1118c2ecf20Sopenharmony_ci			.name = "gpu_cc_ahb_clk",
1128c2ecf20Sopenharmony_ci			.ops = &clk_branch2_ops,
1138c2ecf20Sopenharmony_ci		},
1148c2ecf20Sopenharmony_ci	},
1158c2ecf20Sopenharmony_ci};
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_cistatic struct clk_branch gpu_cc_crc_ahb_clk = {
1188c2ecf20Sopenharmony_ci	.halt_reg = 0x107c,
1198c2ecf20Sopenharmony_ci	.halt_check = BRANCH_HALT_VOTED,
1208c2ecf20Sopenharmony_ci	.clkr = {
1218c2ecf20Sopenharmony_ci		.enable_reg = 0x107c,
1228c2ecf20Sopenharmony_ci		.enable_mask = BIT(0),
1238c2ecf20Sopenharmony_ci		.hw.init = &(struct clk_init_data){
1248c2ecf20Sopenharmony_ci			.name = "gpu_cc_crc_ahb_clk",
1258c2ecf20Sopenharmony_ci			.ops = &clk_branch2_ops,
1268c2ecf20Sopenharmony_ci		},
1278c2ecf20Sopenharmony_ci	},
1288c2ecf20Sopenharmony_ci};
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_cistatic struct clk_branch gpu_cc_cx_apb_clk = {
1318c2ecf20Sopenharmony_ci	.halt_reg = 0x1088,
1328c2ecf20Sopenharmony_ci	.halt_check = BRANCH_HALT_VOTED,
1338c2ecf20Sopenharmony_ci	.clkr = {
1348c2ecf20Sopenharmony_ci		.enable_reg = 0x1088,
1358c2ecf20Sopenharmony_ci		.enable_mask = BIT(0),
1368c2ecf20Sopenharmony_ci		.hw.init = &(struct clk_init_data){
1378c2ecf20Sopenharmony_ci			.name = "gpu_cc_cx_apb_clk",
1388c2ecf20Sopenharmony_ci			.ops = &clk_branch2_ops,
1398c2ecf20Sopenharmony_ci		},
1408c2ecf20Sopenharmony_ci	},
1418c2ecf20Sopenharmony_ci};
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_cistatic struct clk_branch gpu_cc_cx_gmu_clk = {
1448c2ecf20Sopenharmony_ci	.halt_reg = 0x1098,
1458c2ecf20Sopenharmony_ci	.halt_check = BRANCH_HALT,
1468c2ecf20Sopenharmony_ci	.clkr = {
1478c2ecf20Sopenharmony_ci		.enable_reg = 0x1098,
1488c2ecf20Sopenharmony_ci		.enable_mask = BIT(0),
1498c2ecf20Sopenharmony_ci		.hw.init = &(struct clk_init_data){
1508c2ecf20Sopenharmony_ci			.name = "gpu_cc_cx_gmu_clk",
1518c2ecf20Sopenharmony_ci			.parent_data =  &(const struct clk_parent_data){
1528c2ecf20Sopenharmony_ci				.hw = &gpu_cc_gmu_clk_src.clkr.hw,
1538c2ecf20Sopenharmony_ci			},
1548c2ecf20Sopenharmony_ci			.num_parents = 1,
1558c2ecf20Sopenharmony_ci			.flags = CLK_SET_RATE_PARENT,
1568c2ecf20Sopenharmony_ci			.ops = &clk_branch2_ops,
1578c2ecf20Sopenharmony_ci		},
1588c2ecf20Sopenharmony_ci	},
1598c2ecf20Sopenharmony_ci};
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_cistatic struct clk_branch gpu_cc_cx_snoc_dvm_clk = {
1628c2ecf20Sopenharmony_ci	.halt_reg = 0x108c,
1638c2ecf20Sopenharmony_ci	.halt_check = BRANCH_HALT_VOTED,
1648c2ecf20Sopenharmony_ci	.clkr = {
1658c2ecf20Sopenharmony_ci		.enable_reg = 0x108c,
1668c2ecf20Sopenharmony_ci		.enable_mask = BIT(0),
1678c2ecf20Sopenharmony_ci		.hw.init = &(struct clk_init_data){
1688c2ecf20Sopenharmony_ci			.name = "gpu_cc_cx_snoc_dvm_clk",
1698c2ecf20Sopenharmony_ci			.ops = &clk_branch2_ops,
1708c2ecf20Sopenharmony_ci		},
1718c2ecf20Sopenharmony_ci	},
1728c2ecf20Sopenharmony_ci};
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_cistatic struct clk_branch gpu_cc_cxo_aon_clk = {
1758c2ecf20Sopenharmony_ci	.halt_reg = 0x1004,
1768c2ecf20Sopenharmony_ci	.halt_check = BRANCH_HALT_VOTED,
1778c2ecf20Sopenharmony_ci	.clkr = {
1788c2ecf20Sopenharmony_ci		.enable_reg = 0x1004,
1798c2ecf20Sopenharmony_ci		.enable_mask = BIT(0),
1808c2ecf20Sopenharmony_ci		.hw.init = &(struct clk_init_data){
1818c2ecf20Sopenharmony_ci			.name = "gpu_cc_cxo_aon_clk",
1828c2ecf20Sopenharmony_ci			.ops = &clk_branch2_ops,
1838c2ecf20Sopenharmony_ci		},
1848c2ecf20Sopenharmony_ci	},
1858c2ecf20Sopenharmony_ci};
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_cistatic struct clk_branch gpu_cc_cxo_clk = {
1888c2ecf20Sopenharmony_ci	.halt_reg = 0x109c,
1898c2ecf20Sopenharmony_ci	.halt_check = BRANCH_HALT,
1908c2ecf20Sopenharmony_ci	.clkr = {
1918c2ecf20Sopenharmony_ci		.enable_reg = 0x109c,
1928c2ecf20Sopenharmony_ci		.enable_mask = BIT(0),
1938c2ecf20Sopenharmony_ci		.hw.init = &(struct clk_init_data){
1948c2ecf20Sopenharmony_ci			.name = "gpu_cc_cxo_clk",
1958c2ecf20Sopenharmony_ci			.ops = &clk_branch2_ops,
1968c2ecf20Sopenharmony_ci		},
1978c2ecf20Sopenharmony_ci	},
1988c2ecf20Sopenharmony_ci};
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_cistatic struct clk_branch gpu_cc_gx_gmu_clk = {
2018c2ecf20Sopenharmony_ci	.halt_reg = 0x1064,
2028c2ecf20Sopenharmony_ci	.halt_check = BRANCH_HALT,
2038c2ecf20Sopenharmony_ci	.clkr = {
2048c2ecf20Sopenharmony_ci		.enable_reg = 0x1064,
2058c2ecf20Sopenharmony_ci		.enable_mask = BIT(0),
2068c2ecf20Sopenharmony_ci		.hw.init = &(struct clk_init_data){
2078c2ecf20Sopenharmony_ci			.name = "gpu_cc_gx_gmu_clk",
2088c2ecf20Sopenharmony_ci			.parent_data =  &(const struct clk_parent_data){
2098c2ecf20Sopenharmony_ci				.hw = &gpu_cc_gmu_clk_src.clkr.hw,
2108c2ecf20Sopenharmony_ci			},
2118c2ecf20Sopenharmony_ci			.num_parents = 1,
2128c2ecf20Sopenharmony_ci			.flags = CLK_SET_RATE_PARENT,
2138c2ecf20Sopenharmony_ci			.ops = &clk_branch2_ops,
2148c2ecf20Sopenharmony_ci		},
2158c2ecf20Sopenharmony_ci	},
2168c2ecf20Sopenharmony_ci};
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_cistatic struct clk_branch gpu_cc_hlos1_vote_gpu_smmu_clk = {
2198c2ecf20Sopenharmony_ci	.halt_reg = 0x5000,
2208c2ecf20Sopenharmony_ci	.halt_check = BRANCH_VOTED,
2218c2ecf20Sopenharmony_ci	.clkr = {
2228c2ecf20Sopenharmony_ci		.enable_reg = 0x5000,
2238c2ecf20Sopenharmony_ci		.enable_mask = BIT(0),
2248c2ecf20Sopenharmony_ci		.hw.init = &(struct clk_init_data){
2258c2ecf20Sopenharmony_ci			 .name = "gpu_cc_hlos1_vote_gpu_smmu_clk",
2268c2ecf20Sopenharmony_ci			 .ops = &clk_branch2_ops,
2278c2ecf20Sopenharmony_ci		},
2288c2ecf20Sopenharmony_ci	},
2298c2ecf20Sopenharmony_ci};
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_cistatic struct gdsc gpu_cx_gdsc = {
2328c2ecf20Sopenharmony_ci	.gdscr = 0x106c,
2338c2ecf20Sopenharmony_ci	.gds_hw_ctrl = 0x1540,
2348c2ecf20Sopenharmony_ci	.pd = {
2358c2ecf20Sopenharmony_ci		.name = "gpu_cx_gdsc",
2368c2ecf20Sopenharmony_ci	},
2378c2ecf20Sopenharmony_ci	.pwrsts = PWRSTS_OFF_ON,
2388c2ecf20Sopenharmony_ci	.flags = VOTABLE,
2398c2ecf20Sopenharmony_ci};
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_cistatic struct gdsc gpu_gx_gdsc = {
2428c2ecf20Sopenharmony_ci	.gdscr = 0x100c,
2438c2ecf20Sopenharmony_ci	.clamp_io_ctrl = 0x1508,
2448c2ecf20Sopenharmony_ci	.pd = {
2458c2ecf20Sopenharmony_ci		.name = "gpu_gx_gdsc",
2468c2ecf20Sopenharmony_ci		.power_on = gdsc_gx_do_nothing_enable,
2478c2ecf20Sopenharmony_ci	},
2488c2ecf20Sopenharmony_ci	.pwrsts = PWRSTS_OFF_ON,
2498c2ecf20Sopenharmony_ci	.flags = CLAMP_IO | AON_RESET | POLL_CFG_GDSCR,
2508c2ecf20Sopenharmony_ci};
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_cistatic struct clk_regmap *gpu_cc_sm8250_clocks[] = {
2538c2ecf20Sopenharmony_ci	[GPU_CC_AHB_CLK] = &gpu_cc_ahb_clk.clkr,
2548c2ecf20Sopenharmony_ci	[GPU_CC_CRC_AHB_CLK] = &gpu_cc_crc_ahb_clk.clkr,
2558c2ecf20Sopenharmony_ci	[GPU_CC_CX_APB_CLK] = &gpu_cc_cx_apb_clk.clkr,
2568c2ecf20Sopenharmony_ci	[GPU_CC_CX_GMU_CLK] = &gpu_cc_cx_gmu_clk.clkr,
2578c2ecf20Sopenharmony_ci	[GPU_CC_CX_SNOC_DVM_CLK] = &gpu_cc_cx_snoc_dvm_clk.clkr,
2588c2ecf20Sopenharmony_ci	[GPU_CC_CXO_AON_CLK] = &gpu_cc_cxo_aon_clk.clkr,
2598c2ecf20Sopenharmony_ci	[GPU_CC_CXO_CLK] = &gpu_cc_cxo_clk.clkr,
2608c2ecf20Sopenharmony_ci	[GPU_CC_GMU_CLK_SRC] = &gpu_cc_gmu_clk_src.clkr,
2618c2ecf20Sopenharmony_ci	[GPU_CC_GX_GMU_CLK] = &gpu_cc_gx_gmu_clk.clkr,
2628c2ecf20Sopenharmony_ci	[GPU_CC_PLL1] = &gpu_cc_pll1.clkr,
2638c2ecf20Sopenharmony_ci	[GPU_CC_HLOS1_VOTE_GPU_SMMU_CLK] = &gpu_cc_hlos1_vote_gpu_smmu_clk.clkr,
2648c2ecf20Sopenharmony_ci};
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_cistatic const struct qcom_reset_map gpu_cc_sm8250_resets[] = {
2678c2ecf20Sopenharmony_ci	[GPUCC_GPU_CC_ACD_BCR] = { 0x1160 },
2688c2ecf20Sopenharmony_ci	[GPUCC_GPU_CC_CX_BCR] = { 0x1068 },
2698c2ecf20Sopenharmony_ci	[GPUCC_GPU_CC_GFX3D_AON_BCR] = { 0x10a0 },
2708c2ecf20Sopenharmony_ci	[GPUCC_GPU_CC_GMU_BCR] = { 0x111c },
2718c2ecf20Sopenharmony_ci	[GPUCC_GPU_CC_GX_BCR] = { 0x1008 },
2728c2ecf20Sopenharmony_ci	[GPUCC_GPU_CC_XO_BCR] = { 0x1000 },
2738c2ecf20Sopenharmony_ci};
2748c2ecf20Sopenharmony_ci
2758c2ecf20Sopenharmony_cistatic struct gdsc *gpu_cc_sm8250_gdscs[] = {
2768c2ecf20Sopenharmony_ci	[GPU_CX_GDSC] = &gpu_cx_gdsc,
2778c2ecf20Sopenharmony_ci	[GPU_GX_GDSC] = &gpu_gx_gdsc,
2788c2ecf20Sopenharmony_ci};
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_cistatic const struct regmap_config gpu_cc_sm8250_regmap_config = {
2818c2ecf20Sopenharmony_ci	.reg_bits = 32,
2828c2ecf20Sopenharmony_ci	.reg_stride = 4,
2838c2ecf20Sopenharmony_ci	.val_bits = 32,
2848c2ecf20Sopenharmony_ci	.max_register = 0x8008,
2858c2ecf20Sopenharmony_ci	.fast_io = true,
2868c2ecf20Sopenharmony_ci};
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_cistatic const struct qcom_cc_desc gpu_cc_sm8250_desc = {
2898c2ecf20Sopenharmony_ci	.config = &gpu_cc_sm8250_regmap_config,
2908c2ecf20Sopenharmony_ci	.clks = gpu_cc_sm8250_clocks,
2918c2ecf20Sopenharmony_ci	.num_clks = ARRAY_SIZE(gpu_cc_sm8250_clocks),
2928c2ecf20Sopenharmony_ci	.resets = gpu_cc_sm8250_resets,
2938c2ecf20Sopenharmony_ci	.num_resets = ARRAY_SIZE(gpu_cc_sm8250_resets),
2948c2ecf20Sopenharmony_ci	.gdscs = gpu_cc_sm8250_gdscs,
2958c2ecf20Sopenharmony_ci	.num_gdscs = ARRAY_SIZE(gpu_cc_sm8250_gdscs),
2968c2ecf20Sopenharmony_ci};
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_cistatic const struct of_device_id gpu_cc_sm8250_match_table[] = {
2998c2ecf20Sopenharmony_ci	{ .compatible = "qcom,sm8250-gpucc" },
3008c2ecf20Sopenharmony_ci	{ }
3018c2ecf20Sopenharmony_ci};
3028c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, gpu_cc_sm8250_match_table);
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_cistatic int gpu_cc_sm8250_probe(struct platform_device *pdev)
3058c2ecf20Sopenharmony_ci{
3068c2ecf20Sopenharmony_ci	struct regmap *regmap;
3078c2ecf20Sopenharmony_ci	unsigned int value, mask;
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci	regmap = qcom_cc_map(pdev, &gpu_cc_sm8250_desc);
3108c2ecf20Sopenharmony_ci	if (IS_ERR(regmap))
3118c2ecf20Sopenharmony_ci		return PTR_ERR(regmap);
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci	clk_lucid_pll_configure(&gpu_cc_pll1, regmap, &gpu_cc_pll1_config);
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_ci	/*
3168c2ecf20Sopenharmony_ci	 * Configure gpu_cc_cx_gmu_clk with recommended
3178c2ecf20Sopenharmony_ci	 * wakeup/sleep settings
3188c2ecf20Sopenharmony_ci	 */
3198c2ecf20Sopenharmony_ci	mask = CX_GMU_CBCR_WAKE_MASK << CX_GMU_CBCR_WAKE_SHIFT;
3208c2ecf20Sopenharmony_ci	mask |= CX_GMU_CBCR_SLEEP_MASK << CX_GMU_CBCR_SLEEP_SHIFT;
3218c2ecf20Sopenharmony_ci	value = 0xf << CX_GMU_CBCR_WAKE_SHIFT | 0xf << CX_GMU_CBCR_SLEEP_SHIFT;
3228c2ecf20Sopenharmony_ci	regmap_update_bits(regmap, 0x1098, mask, value);
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_ci	return qcom_cc_really_probe(pdev, &gpu_cc_sm8250_desc, regmap);
3258c2ecf20Sopenharmony_ci}
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_cistatic struct platform_driver gpu_cc_sm8250_driver = {
3288c2ecf20Sopenharmony_ci	.probe = gpu_cc_sm8250_probe,
3298c2ecf20Sopenharmony_ci	.driver = {
3308c2ecf20Sopenharmony_ci		.name = "sm8250-gpucc",
3318c2ecf20Sopenharmony_ci		.of_match_table = gpu_cc_sm8250_match_table,
3328c2ecf20Sopenharmony_ci	},
3338c2ecf20Sopenharmony_ci};
3348c2ecf20Sopenharmony_ci
3358c2ecf20Sopenharmony_cistatic int __init gpu_cc_sm8250_init(void)
3368c2ecf20Sopenharmony_ci{
3378c2ecf20Sopenharmony_ci	return platform_driver_register(&gpu_cc_sm8250_driver);
3388c2ecf20Sopenharmony_ci}
3398c2ecf20Sopenharmony_cisubsys_initcall(gpu_cc_sm8250_init);
3408c2ecf20Sopenharmony_ci
3418c2ecf20Sopenharmony_cistatic void __exit gpu_cc_sm8250_exit(void)
3428c2ecf20Sopenharmony_ci{
3438c2ecf20Sopenharmony_ci	platform_driver_unregister(&gpu_cc_sm8250_driver);
3448c2ecf20Sopenharmony_ci}
3458c2ecf20Sopenharmony_cimodule_exit(gpu_cc_sm8250_exit);
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("QTI GPU_CC SM8250 Driver");
3488c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2");
349