Re: [PATCH 2/6] clk: qcom: Add GPU clock controller driver for SM6125

From: Bjorn Andersson
Date: Thu Jan 26 2023 - 13:22:52 EST


On Thu, Jan 26, 2023 at 03:40:29PM +0100, Konrad Dybcio wrote:
> diff --git a/drivers/clk/qcom/gpucc-sm6125.c b/drivers/clk/qcom/gpucc-sm6125.c
[..]
> +static int gpu_cc_sm6125_probe(struct platform_device *pdev)
> +{
> + struct regmap *regmap;
> + unsigned int value, mask;
> +
> + regmap = qcom_cc_map(pdev, &gpu_cc_sm6125_desc);
> + if (IS_ERR(regmap))
> + return PTR_ERR(regmap);
> +
> + clk_alpha_pll_configure(&gpu_cc_pll0_out_aux2, regmap, &gpu_pll0_config);
> + clk_alpha_pll_configure(&gpu_cc_pll1_out_aux2, regmap, &gpu_pll1_config);
> +
> + /* Recommended WAKEUP/SLEEP settings for the gpu_cc_cx_gmu_clk */
> + mask = CX_GMU_CBCR_WAKE_MASK << CX_GMU_CBCR_WAKE_SHIFT;
> + mask |= CX_GMU_CBCR_SLEEP_MASK << CX_GMU_CBCR_SLEEP_SHIFT;
> + value = 0xf << CX_GMU_CBCR_WAKE_SHIFT | 0xf << CX_GMU_CBCR_SLEEP_SHIFT;

Perhaps I'm missing something here, but isn't mask == value after this?

Feels like this could be written cleaner using FIELD_PREP(), or perhaps
even moved to a helper function, so that we don't need to open code this
if it's needed in other places?

> + regmap_update_bits(regmap, gpu_cc_cx_gmu_clk.clkr.enable_reg, mask, value);
> +
> + /* Set up PERIPH/MEM retain on the GPU core clock */
> + regmap_update_bits(regmap, gpu_cc_gx_gfx3d_clk.halt_reg,
> + (BIT(14) | BIT(13)), (BIT(14) | BIT(13)));

You don't need the extra parenthesis here.

> +
> + return qcom_cc_really_probe(pdev, &gpu_cc_sm6125_desc, regmap);
> +}
> +
> +static struct platform_driver gpu_cc_sm6125_driver = {
> + .probe = gpu_cc_sm6125_probe,
> + .driver = {
> + .name = "gpucc-sm6125",
> + .of_match_table = gpu_cc_sm6125_match_table,
> + },
> +};
> +
> +static int __init gpu_cc_sm6125_init(void)
> +{
> + return platform_driver_register(&gpu_cc_sm6125_driver);
> +}
> +subsys_initcall(gpu_cc_sm6125_init);

You don't need GPU at subsys, module_platform_driver() should be
sufficient (and =m in defconfig).

Thanks,
Bjorn