18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2019, Jeffrey Hugo
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#include <linux/kernel.h>
78c2ecf20Sopenharmony_ci#include <linux/bitops.h>
88c2ecf20Sopenharmony_ci#include <linux/err.h>
98c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
108c2ecf20Sopenharmony_ci#include <linux/module.h>
118c2ecf20Sopenharmony_ci#include <linux/of.h>
128c2ecf20Sopenharmony_ci#include <linux/of_device.h>
138c2ecf20Sopenharmony_ci#include <linux/clk-provider.h>
148c2ecf20Sopenharmony_ci#include <linux/regmap.h>
158c2ecf20Sopenharmony_ci#include <linux/reset-controller.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#include <dt-bindings/clock/qcom,gpucc-msm8998.h>
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#include "common.h"
208c2ecf20Sopenharmony_ci#include "clk-regmap.h"
218c2ecf20Sopenharmony_ci#include "clk-regmap-divider.h"
228c2ecf20Sopenharmony_ci#include "clk-alpha-pll.h"
238c2ecf20Sopenharmony_ci#include "clk-rcg.h"
248c2ecf20Sopenharmony_ci#include "clk-branch.h"
258c2ecf20Sopenharmony_ci#include "reset.h"
268c2ecf20Sopenharmony_ci#include "gdsc.h"
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_cienum {
298c2ecf20Sopenharmony_ci	P_XO,
308c2ecf20Sopenharmony_ci	P_GPLL0,
318c2ecf20Sopenharmony_ci	P_GPUPLL0_OUT_EVEN,
328c2ecf20Sopenharmony_ci};
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci/* Instead of going directly to the block, XO is routed through this branch */
358c2ecf20Sopenharmony_cistatic struct clk_branch gpucc_cxo_clk = {
368c2ecf20Sopenharmony_ci	.halt_reg = 0x1020,
378c2ecf20Sopenharmony_ci	.clkr = {
388c2ecf20Sopenharmony_ci		.enable_reg = 0x1020,
398c2ecf20Sopenharmony_ci		.enable_mask = BIT(0),
408c2ecf20Sopenharmony_ci		.hw.init = &(struct clk_init_data){
418c2ecf20Sopenharmony_ci			.name = "gpucc_cxo_clk",
428c2ecf20Sopenharmony_ci			.parent_data = &(const struct clk_parent_data){
438c2ecf20Sopenharmony_ci				.fw_name = "xo",
448c2ecf20Sopenharmony_ci				.name = "xo"
458c2ecf20Sopenharmony_ci			},
468c2ecf20Sopenharmony_ci			.num_parents = 1,
478c2ecf20Sopenharmony_ci			.ops = &clk_branch2_ops,
488c2ecf20Sopenharmony_ci			.flags = CLK_IS_CRITICAL,
498c2ecf20Sopenharmony_ci		},
508c2ecf20Sopenharmony_ci	},
518c2ecf20Sopenharmony_ci};
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_cistatic const struct clk_div_table post_div_table_fabia_even[] = {
548c2ecf20Sopenharmony_ci	{ 0x0, 1 },
558c2ecf20Sopenharmony_ci	{ 0x1, 2 },
568c2ecf20Sopenharmony_ci	{ 0x3, 4 },
578c2ecf20Sopenharmony_ci	{ 0x7, 8 },
588c2ecf20Sopenharmony_ci	{ }
598c2ecf20Sopenharmony_ci};
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_cistatic struct clk_alpha_pll gpupll0 = {
628c2ecf20Sopenharmony_ci	.offset = 0x0,
638c2ecf20Sopenharmony_ci	.regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA],
648c2ecf20Sopenharmony_ci	.clkr.hw.init = &(struct clk_init_data){
658c2ecf20Sopenharmony_ci		.name = "gpupll0",
668c2ecf20Sopenharmony_ci		.parent_hws = (const struct clk_hw *[]){ &gpucc_cxo_clk.clkr.hw },
678c2ecf20Sopenharmony_ci		.num_parents = 1,
688c2ecf20Sopenharmony_ci		.ops = &clk_alpha_pll_fixed_fabia_ops,
698c2ecf20Sopenharmony_ci	},
708c2ecf20Sopenharmony_ci};
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_cistatic struct clk_alpha_pll_postdiv gpupll0_out_even = {
738c2ecf20Sopenharmony_ci	.offset = 0x0,
748c2ecf20Sopenharmony_ci	.post_div_shift = 8,
758c2ecf20Sopenharmony_ci	.post_div_table = post_div_table_fabia_even,
768c2ecf20Sopenharmony_ci	.num_post_div = ARRAY_SIZE(post_div_table_fabia_even),
778c2ecf20Sopenharmony_ci	.width = 4,
788c2ecf20Sopenharmony_ci	.regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA],
798c2ecf20Sopenharmony_ci	.clkr.hw.init = &(struct clk_init_data){
808c2ecf20Sopenharmony_ci		.name = "gpupll0_out_even",
818c2ecf20Sopenharmony_ci		.parent_hws = (const struct clk_hw *[]){ &gpupll0.clkr.hw },
828c2ecf20Sopenharmony_ci		.num_parents = 1,
838c2ecf20Sopenharmony_ci		.ops = &clk_alpha_pll_postdiv_fabia_ops,
848c2ecf20Sopenharmony_ci	},
858c2ecf20Sopenharmony_ci};
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_cistatic const struct parent_map gpu_xo_gpll0_map[] = {
888c2ecf20Sopenharmony_ci	{ P_XO, 0 },
898c2ecf20Sopenharmony_ci	{ P_GPLL0, 5 },
908c2ecf20Sopenharmony_ci};
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_cistatic const struct clk_parent_data gpu_xo_gpll0[] = {
938c2ecf20Sopenharmony_ci	{ .hw = &gpucc_cxo_clk.clkr.hw },
948c2ecf20Sopenharmony_ci	{ .fw_name = "gpll0", .name = "gpll0" },
958c2ecf20Sopenharmony_ci};
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_cistatic const struct parent_map gpu_xo_gpupll0_map[] = {
988c2ecf20Sopenharmony_ci	{ P_XO, 0 },
998c2ecf20Sopenharmony_ci	{ P_GPUPLL0_OUT_EVEN, 1 },
1008c2ecf20Sopenharmony_ci};
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_cistatic const struct clk_parent_data gpu_xo_gpupll0[] = {
1038c2ecf20Sopenharmony_ci	{ .hw = &gpucc_cxo_clk.clkr.hw },
1048c2ecf20Sopenharmony_ci	{ .hw = &gpupll0_out_even.clkr.hw },
1058c2ecf20Sopenharmony_ci};
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_cistatic const struct freq_tbl ftbl_rbcpr_clk_src[] = {
1088c2ecf20Sopenharmony_ci	F(19200000, P_XO, 1, 0, 0),
1098c2ecf20Sopenharmony_ci	F(50000000, P_GPLL0, 12, 0, 0),
1108c2ecf20Sopenharmony_ci	{ }
1118c2ecf20Sopenharmony_ci};
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_cistatic struct clk_rcg2 rbcpr_clk_src = {
1148c2ecf20Sopenharmony_ci	.cmd_rcgr = 0x1030,
1158c2ecf20Sopenharmony_ci	.hid_width = 5,
1168c2ecf20Sopenharmony_ci	.parent_map = gpu_xo_gpll0_map,
1178c2ecf20Sopenharmony_ci	.freq_tbl = ftbl_rbcpr_clk_src,
1188c2ecf20Sopenharmony_ci	.clkr.hw.init = &(struct clk_init_data){
1198c2ecf20Sopenharmony_ci		.name = "rbcpr_clk_src",
1208c2ecf20Sopenharmony_ci		.parent_data = gpu_xo_gpll0,
1218c2ecf20Sopenharmony_ci		.num_parents = 2,
1228c2ecf20Sopenharmony_ci		.ops = &clk_rcg2_ops,
1238c2ecf20Sopenharmony_ci	},
1248c2ecf20Sopenharmony_ci};
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_cistatic const struct freq_tbl ftbl_gfx3d_clk_src[] = {
1278c2ecf20Sopenharmony_ci	{ .src = P_GPUPLL0_OUT_EVEN, .pre_div = 3 },
1288c2ecf20Sopenharmony_ci	{ }
1298c2ecf20Sopenharmony_ci};
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_cistatic struct clk_rcg2 gfx3d_clk_src = {
1328c2ecf20Sopenharmony_ci	.cmd_rcgr = 0x1070,
1338c2ecf20Sopenharmony_ci	.hid_width = 5,
1348c2ecf20Sopenharmony_ci	.parent_map = gpu_xo_gpupll0_map,
1358c2ecf20Sopenharmony_ci	.freq_tbl = ftbl_gfx3d_clk_src,
1368c2ecf20Sopenharmony_ci	.clkr.hw.init = &(struct clk_init_data){
1378c2ecf20Sopenharmony_ci		.name = "gfx3d_clk_src",
1388c2ecf20Sopenharmony_ci		.parent_data = gpu_xo_gpupll0,
1398c2ecf20Sopenharmony_ci		.num_parents = 2,
1408c2ecf20Sopenharmony_ci		.ops = &clk_rcg2_ops,
1418c2ecf20Sopenharmony_ci		.flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE,
1428c2ecf20Sopenharmony_ci	},
1438c2ecf20Sopenharmony_ci};
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_cistatic const struct freq_tbl ftbl_rbbmtimer_clk_src[] = {
1468c2ecf20Sopenharmony_ci	F(19200000, P_XO, 1, 0, 0),
1478c2ecf20Sopenharmony_ci	{ }
1488c2ecf20Sopenharmony_ci};
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_cistatic struct clk_rcg2 rbbmtimer_clk_src = {
1518c2ecf20Sopenharmony_ci	.cmd_rcgr = 0x10b0,
1528c2ecf20Sopenharmony_ci	.hid_width = 5,
1538c2ecf20Sopenharmony_ci	.parent_map = gpu_xo_gpll0_map,
1548c2ecf20Sopenharmony_ci	.freq_tbl = ftbl_rbbmtimer_clk_src,
1558c2ecf20Sopenharmony_ci	.clkr.hw.init = &(struct clk_init_data){
1568c2ecf20Sopenharmony_ci		.name = "rbbmtimer_clk_src",
1578c2ecf20Sopenharmony_ci		.parent_data = gpu_xo_gpll0,
1588c2ecf20Sopenharmony_ci		.num_parents = 2,
1598c2ecf20Sopenharmony_ci		.ops = &clk_rcg2_ops,
1608c2ecf20Sopenharmony_ci	},
1618c2ecf20Sopenharmony_ci};
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_cistatic const struct freq_tbl ftbl_gfx3d_isense_clk_src[] = {
1648c2ecf20Sopenharmony_ci	F(19200000, P_XO, 1, 0, 0),
1658c2ecf20Sopenharmony_ci	F(40000000, P_GPLL0, 15, 0, 0),
1668c2ecf20Sopenharmony_ci	F(200000000, P_GPLL0, 3, 0, 0),
1678c2ecf20Sopenharmony_ci	F(300000000, P_GPLL0, 2, 0, 0),
1688c2ecf20Sopenharmony_ci	{ }
1698c2ecf20Sopenharmony_ci};
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_cistatic struct clk_rcg2 gfx3d_isense_clk_src = {
1728c2ecf20Sopenharmony_ci	.cmd_rcgr = 0x1100,
1738c2ecf20Sopenharmony_ci	.hid_width = 5,
1748c2ecf20Sopenharmony_ci	.parent_map = gpu_xo_gpll0_map,
1758c2ecf20Sopenharmony_ci	.freq_tbl = ftbl_gfx3d_isense_clk_src,
1768c2ecf20Sopenharmony_ci	.clkr.hw.init = &(struct clk_init_data){
1778c2ecf20Sopenharmony_ci		.name = "gfx3d_isense_clk_src",
1788c2ecf20Sopenharmony_ci		.parent_data = gpu_xo_gpll0,
1798c2ecf20Sopenharmony_ci		.num_parents = 2,
1808c2ecf20Sopenharmony_ci		.ops = &clk_rcg2_ops,
1818c2ecf20Sopenharmony_ci	},
1828c2ecf20Sopenharmony_ci};
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_cistatic struct clk_branch rbcpr_clk = {
1858c2ecf20Sopenharmony_ci	.halt_reg = 0x1054,
1868c2ecf20Sopenharmony_ci	.clkr = {
1878c2ecf20Sopenharmony_ci		.enable_reg = 0x1054,
1888c2ecf20Sopenharmony_ci		.enable_mask = BIT(0),
1898c2ecf20Sopenharmony_ci		.hw.init = &(struct clk_init_data){
1908c2ecf20Sopenharmony_ci			.name = "rbcpr_clk",
1918c2ecf20Sopenharmony_ci			.parent_hws = (const struct clk_hw *[]){ &rbcpr_clk_src.clkr.hw },
1928c2ecf20Sopenharmony_ci			.num_parents = 1,
1938c2ecf20Sopenharmony_ci			.ops = &clk_branch2_ops,
1948c2ecf20Sopenharmony_ci			.flags = CLK_SET_RATE_PARENT,
1958c2ecf20Sopenharmony_ci		},
1968c2ecf20Sopenharmony_ci	},
1978c2ecf20Sopenharmony_ci};
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_cistatic struct clk_branch gfx3d_clk = {
2008c2ecf20Sopenharmony_ci	.halt_reg = 0x1098,
2018c2ecf20Sopenharmony_ci	.clkr = {
2028c2ecf20Sopenharmony_ci		.enable_reg = 0x1098,
2038c2ecf20Sopenharmony_ci		.enable_mask = BIT(0),
2048c2ecf20Sopenharmony_ci		.hw.init = &(struct clk_init_data){
2058c2ecf20Sopenharmony_ci			.name = "gfx3d_clk",
2068c2ecf20Sopenharmony_ci			.parent_hws = (const struct clk_hw *[]){ &gfx3d_clk_src.clkr.hw },
2078c2ecf20Sopenharmony_ci			.num_parents = 1,
2088c2ecf20Sopenharmony_ci			.ops = &clk_branch2_ops,
2098c2ecf20Sopenharmony_ci			.flags = CLK_SET_RATE_PARENT,
2108c2ecf20Sopenharmony_ci		},
2118c2ecf20Sopenharmony_ci	},
2128c2ecf20Sopenharmony_ci};
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_cistatic struct clk_branch rbbmtimer_clk = {
2158c2ecf20Sopenharmony_ci	.halt_reg = 0x10d0,
2168c2ecf20Sopenharmony_ci	.clkr = {
2178c2ecf20Sopenharmony_ci		.enable_reg = 0x10d0,
2188c2ecf20Sopenharmony_ci		.enable_mask = BIT(0),
2198c2ecf20Sopenharmony_ci		.hw.init = &(struct clk_init_data){
2208c2ecf20Sopenharmony_ci			.name = "rbbmtimer_clk",
2218c2ecf20Sopenharmony_ci			.parent_hws = (const struct clk_hw *[]){ &rbbmtimer_clk_src.clkr.hw },
2228c2ecf20Sopenharmony_ci			.num_parents = 1,
2238c2ecf20Sopenharmony_ci			.ops = &clk_branch2_ops,
2248c2ecf20Sopenharmony_ci			.flags = CLK_SET_RATE_PARENT,
2258c2ecf20Sopenharmony_ci		},
2268c2ecf20Sopenharmony_ci	},
2278c2ecf20Sopenharmony_ci};
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_cistatic struct clk_branch gfx3d_isense_clk = {
2308c2ecf20Sopenharmony_ci	.halt_reg = 0x1124,
2318c2ecf20Sopenharmony_ci	.clkr = {
2328c2ecf20Sopenharmony_ci		.enable_reg = 0x1124,
2338c2ecf20Sopenharmony_ci		.enable_mask = BIT(0),
2348c2ecf20Sopenharmony_ci		.hw.init = &(struct clk_init_data){
2358c2ecf20Sopenharmony_ci			.name = "gfx3d_isense_clk",
2368c2ecf20Sopenharmony_ci			.parent_hws = (const struct clk_hw *[]){ &gfx3d_isense_clk_src.clkr.hw },
2378c2ecf20Sopenharmony_ci			.num_parents = 1,
2388c2ecf20Sopenharmony_ci			.ops = &clk_branch2_ops,
2398c2ecf20Sopenharmony_ci		},
2408c2ecf20Sopenharmony_ci	},
2418c2ecf20Sopenharmony_ci};
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_cistatic struct gdsc gpu_cx_gdsc = {
2448c2ecf20Sopenharmony_ci	.gdscr = 0x1004,
2458c2ecf20Sopenharmony_ci	.gds_hw_ctrl = 0x1008,
2468c2ecf20Sopenharmony_ci	.pd = {
2478c2ecf20Sopenharmony_ci		.name = "gpu_cx",
2488c2ecf20Sopenharmony_ci	},
2498c2ecf20Sopenharmony_ci	.pwrsts = PWRSTS_OFF_ON,
2508c2ecf20Sopenharmony_ci	.flags = VOTABLE,
2518c2ecf20Sopenharmony_ci};
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_cistatic struct gdsc gpu_gx_gdsc = {
2548c2ecf20Sopenharmony_ci	.gdscr = 0x1094,
2558c2ecf20Sopenharmony_ci	.clamp_io_ctrl = 0x130,
2568c2ecf20Sopenharmony_ci	.resets = (unsigned int []){ GPU_GX_BCR },
2578c2ecf20Sopenharmony_ci	.reset_count = 1,
2588c2ecf20Sopenharmony_ci	.cxcs = (unsigned int []){ 0x1098 },
2598c2ecf20Sopenharmony_ci	.cxc_count = 1,
2608c2ecf20Sopenharmony_ci	.pd = {
2618c2ecf20Sopenharmony_ci		.name = "gpu_gx",
2628c2ecf20Sopenharmony_ci	},
2638c2ecf20Sopenharmony_ci	.parent = &gpu_cx_gdsc.pd,
2648c2ecf20Sopenharmony_ci	.pwrsts = PWRSTS_OFF_ON | PWRSTS_RET,
2658c2ecf20Sopenharmony_ci	.flags = CLAMP_IO | SW_RESET | AON_RESET | NO_RET_PERIPH,
2668c2ecf20Sopenharmony_ci};
2678c2ecf20Sopenharmony_ci
2688c2ecf20Sopenharmony_cistatic struct clk_regmap *gpucc_msm8998_clocks[] = {
2698c2ecf20Sopenharmony_ci	[GPUPLL0] = &gpupll0.clkr,
2708c2ecf20Sopenharmony_ci	[GPUPLL0_OUT_EVEN] = &gpupll0_out_even.clkr,
2718c2ecf20Sopenharmony_ci	[RBCPR_CLK_SRC] = &rbcpr_clk_src.clkr,
2728c2ecf20Sopenharmony_ci	[GFX3D_CLK_SRC] = &gfx3d_clk_src.clkr,
2738c2ecf20Sopenharmony_ci	[RBBMTIMER_CLK_SRC] = &rbbmtimer_clk_src.clkr,
2748c2ecf20Sopenharmony_ci	[GFX3D_ISENSE_CLK_SRC] = &gfx3d_isense_clk_src.clkr,
2758c2ecf20Sopenharmony_ci	[RBCPR_CLK] = &rbcpr_clk.clkr,
2768c2ecf20Sopenharmony_ci	[GFX3D_CLK] = &gfx3d_clk.clkr,
2778c2ecf20Sopenharmony_ci	[RBBMTIMER_CLK] = &rbbmtimer_clk.clkr,
2788c2ecf20Sopenharmony_ci	[GFX3D_ISENSE_CLK] = &gfx3d_isense_clk.clkr,
2798c2ecf20Sopenharmony_ci	[GPUCC_CXO_CLK] = &gpucc_cxo_clk.clkr,
2808c2ecf20Sopenharmony_ci};
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_cistatic struct gdsc *gpucc_msm8998_gdscs[] = {
2838c2ecf20Sopenharmony_ci	[GPU_CX_GDSC] = &gpu_cx_gdsc,
2848c2ecf20Sopenharmony_ci	[GPU_GX_GDSC] = &gpu_gx_gdsc,
2858c2ecf20Sopenharmony_ci};
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_cistatic const struct qcom_reset_map gpucc_msm8998_resets[] = {
2888c2ecf20Sopenharmony_ci	[GPU_CX_BCR] = { 0x1000 },
2898c2ecf20Sopenharmony_ci	[RBCPR_BCR] = { 0x1050 },
2908c2ecf20Sopenharmony_ci	[GPU_GX_BCR] = { 0x1090 },
2918c2ecf20Sopenharmony_ci	[GPU_ISENSE_BCR] = { 0x1120 },
2928c2ecf20Sopenharmony_ci};
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_cistatic const struct regmap_config gpucc_msm8998_regmap_config = {
2958c2ecf20Sopenharmony_ci	.reg_bits	= 32,
2968c2ecf20Sopenharmony_ci	.reg_stride	= 4,
2978c2ecf20Sopenharmony_ci	.val_bits	= 32,
2988c2ecf20Sopenharmony_ci	.max_register	= 0x9000,
2998c2ecf20Sopenharmony_ci	.fast_io	= true,
3008c2ecf20Sopenharmony_ci};
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_cistatic const struct qcom_cc_desc gpucc_msm8998_desc = {
3038c2ecf20Sopenharmony_ci	.config = &gpucc_msm8998_regmap_config,
3048c2ecf20Sopenharmony_ci	.clks = gpucc_msm8998_clocks,
3058c2ecf20Sopenharmony_ci	.num_clks = ARRAY_SIZE(gpucc_msm8998_clocks),
3068c2ecf20Sopenharmony_ci	.resets = gpucc_msm8998_resets,
3078c2ecf20Sopenharmony_ci	.num_resets = ARRAY_SIZE(gpucc_msm8998_resets),
3088c2ecf20Sopenharmony_ci	.gdscs = gpucc_msm8998_gdscs,
3098c2ecf20Sopenharmony_ci	.num_gdscs = ARRAY_SIZE(gpucc_msm8998_gdscs),
3108c2ecf20Sopenharmony_ci};
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_cistatic const struct of_device_id gpucc_msm8998_match_table[] = {
3138c2ecf20Sopenharmony_ci	{ .compatible = "qcom,msm8998-gpucc" },
3148c2ecf20Sopenharmony_ci	{ }
3158c2ecf20Sopenharmony_ci};
3168c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, gpucc_msm8998_match_table);
3178c2ecf20Sopenharmony_ci
3188c2ecf20Sopenharmony_cistatic int gpucc_msm8998_probe(struct platform_device *pdev)
3198c2ecf20Sopenharmony_ci{
3208c2ecf20Sopenharmony_ci	struct regmap *regmap;
3218c2ecf20Sopenharmony_ci
3228c2ecf20Sopenharmony_ci	regmap = qcom_cc_map(pdev, &gpucc_msm8998_desc);
3238c2ecf20Sopenharmony_ci	if (IS_ERR(regmap))
3248c2ecf20Sopenharmony_ci		return PTR_ERR(regmap);
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_ci	/* force periph logic on to avoid perf counter corruption */
3278c2ecf20Sopenharmony_ci	regmap_write_bits(regmap, gfx3d_clk.clkr.enable_reg, BIT(13), BIT(13));
3288c2ecf20Sopenharmony_ci	/* tweak droop detector (GPUCC_GPU_DD_WRAP_CTRL) to reduce leakage */
3298c2ecf20Sopenharmony_ci	regmap_write_bits(regmap, gfx3d_clk.clkr.enable_reg, BIT(0), BIT(0));
3308c2ecf20Sopenharmony_ci
3318c2ecf20Sopenharmony_ci	return qcom_cc_really_probe(pdev, &gpucc_msm8998_desc, regmap);
3328c2ecf20Sopenharmony_ci}
3338c2ecf20Sopenharmony_ci
3348c2ecf20Sopenharmony_cistatic struct platform_driver gpucc_msm8998_driver = {
3358c2ecf20Sopenharmony_ci	.probe		= gpucc_msm8998_probe,
3368c2ecf20Sopenharmony_ci	.driver		= {
3378c2ecf20Sopenharmony_ci		.name	= "gpucc-msm8998",
3388c2ecf20Sopenharmony_ci		.of_match_table = gpucc_msm8998_match_table,
3398c2ecf20Sopenharmony_ci	},
3408c2ecf20Sopenharmony_ci};
3418c2ecf20Sopenharmony_cimodule_platform_driver(gpucc_msm8998_driver);
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("QCOM GPUCC MSM8998 Driver");
3448c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2");
345