Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: imx: imx8: Use clk_hw pointer for self registered clock in clk_parent_data

"acm_aud_clk0_sel" and "acm_aud_clk1_sel" are registered by this ACM
driver, but they are the parent clocks for other clocks, in order to
use assigned-clock-parents in device tree, the ".fw_name" can't be used,
need to assign the clk_hw pointer for the imx8qm_mclk_sels[],
imx8qxp_mclk_sels[], imx8dxl_mclk_sels[].

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Link: https://lore.kernel.org/r/1720600860-18866-1-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>

authored by

Shengjiu Wang and committed by
Abel Vesa
35121e9d 8400291e

+29 -9
+29 -9
drivers/clk/imx/clk-imx8-acm.c
··· 54 54 * struct imx8_acm_soc_data - soc specific data 55 55 * @sels: pointer to struct clk_imx8_acm_sel 56 56 * @num_sels: numbers of items 57 + * @mclk_sels: pointer to imx8qm/qxp/dxl_mclk_sels 57 58 */ 58 59 struct imx8_acm_soc_data { 59 60 struct clk_imx8_acm_sel *sels; 60 61 unsigned int num_sels; 62 + struct clk_parent_data *mclk_sels; 61 63 }; 62 64 63 65 /** ··· 113 111 { .fw_name = "sai6_rx_bclk" }, 114 112 }; 115 113 116 - static const struct clk_parent_data imx8qm_mclk_sels[] = { 114 + #define ACM_AUD_CLK0_SEL_INDEX 2 115 + #define ACM_AUD_CLK1_SEL_INDEX 3 116 + 117 + static struct clk_parent_data imx8qm_mclk_sels[] = { 117 118 { .fw_name = "aud_pll_div_clk0_lpcg_clk" }, 118 119 { .fw_name = "aud_pll_div_clk1_lpcg_clk" }, 119 - { .fw_name = "acm_aud_clk0_sel" }, 120 - { .fw_name = "acm_aud_clk1_sel" }, 120 + { }, /* clk_hw pointer of "acm_aud_clk0_sel" */ 121 + { }, /* clk_hw pointer of "acm_aud_clk1_sel" */ 121 122 }; 122 123 123 124 static const struct clk_parent_data imx8qm_asrc_mux_clk_sels[] = { ··· 181 176 { .fw_name = "sai4_rx_bclk" }, 182 177 }; 183 178 184 - static const struct clk_parent_data imx8qxp_mclk_sels[] = { 179 + static struct clk_parent_data imx8qxp_mclk_sels[] = { 185 180 { .fw_name = "aud_pll_div_clk0_lpcg_clk" }, 186 181 { .fw_name = "aud_pll_div_clk1_lpcg_clk" }, 187 - { .fw_name = "acm_aud_clk0_sel" }, 188 - { .fw_name = "acm_aud_clk1_sel" }, 182 + { }, /* clk_hw pointer of "acm_aud_clk0_sel" */ 183 + { }, /* clk_hw pointer of "acm_aud_clk1_sel" */ 189 184 }; 190 185 191 186 static struct clk_imx8_acm_sel imx8qxp_sels[] = { ··· 233 228 { .index = -1 }, 234 229 }; 235 230 236 - static const struct clk_parent_data imx8dxl_mclk_sels[] = { 231 + static struct clk_parent_data imx8dxl_mclk_sels[] = { 237 232 { .fw_name = "aud_pll_div_clk0_lpcg_clk" }, 238 233 { .fw_name = "aud_pll_div_clk1_lpcg_clk" }, 239 - { .fw_name = "acm_aud_clk0_sel" }, 240 - { .fw_name = "acm_aud_clk1_sel" }, 234 + { }, /* clk_hw pointer of "acm_aud_clk0_sel" */ 235 + { }, /* clk_hw pointer of "acm_aud_clk1_sel" */ 241 236 }; 242 237 243 238 static struct clk_imx8_acm_sel imx8dxl_sels[] = { ··· 380 375 imx_check_clk_hws(hws, IMX_ADMA_ACM_CLK_END); 381 376 goto err_clk_register; 382 377 } 378 + 379 + /* 380 + * The IMX_ADMA_ACM_AUD_CLK0_SEL and IMX_ADMA_ACM_AUD_CLK1_SEL are 381 + * registered first. After registration, update the clk_hw pointer 382 + * to imx8qm/qxp/dxl_mclk_sels structures. 383 + */ 384 + if (sels[i].clkid == IMX_ADMA_ACM_AUD_CLK0_SEL) 385 + priv->soc_data->mclk_sels[ACM_AUD_CLK0_SEL_INDEX].hw = 386 + hws[IMX_ADMA_ACM_AUD_CLK0_SEL]; 387 + if (sels[i].clkid == IMX_ADMA_ACM_AUD_CLK1_SEL) 388 + priv->soc_data->mclk_sels[ACM_AUD_CLK1_SEL_INDEX].hw = 389 + hws[IMX_ADMA_ACM_AUD_CLK1_SEL]; 383 390 } 384 391 385 392 ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_hw_data); ··· 423 406 static const struct imx8_acm_soc_data imx8qm_acm_data = { 424 407 .sels = imx8qm_sels, 425 408 .num_sels = ARRAY_SIZE(imx8qm_sels), 409 + .mclk_sels = imx8qm_mclk_sels, 426 410 }; 427 411 428 412 static const struct imx8_acm_soc_data imx8qxp_acm_data = { 429 413 .sels = imx8qxp_sels, 430 414 .num_sels = ARRAY_SIZE(imx8qxp_sels), 415 + .mclk_sels = imx8qxp_mclk_sels, 431 416 }; 432 417 433 418 static const struct imx8_acm_soc_data imx8dxl_acm_data = { 434 419 .sels = imx8dxl_sels, 435 420 .num_sels = ARRAY_SIZE(imx8dxl_sels), 421 + .mclk_sels = imx8dxl_mclk_sels, 436 422 }; 437 423 438 424 static const struct of_device_id imx8_acm_match[] = {