2068008_zh-CN

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

2068008_zh-CN

2068008_zh-CN

文件 drivers/clk/imx/clk-imx8ulp.c 缺少手册中的某些寄存器

请查看drivers/clk/imx/clk-imx8ulp.c 中的imx8ulp _ clk _cgc1_init、具体到第 219221 行,请参见此处

clks[IMX8ULP_CLK_AUD_CLK1] = imx_clk_hw_mux2("aud_clk1", base + 0x900, 0, 3, aud_clk1_sels, ARRAY_SIZE(aud_clk1_sels));
clks[IMX8ULP_CLK_SAI4_SEL] = imx_clk_hw_mux2("sai4_sel", base + 0x904, 0, 2, sai45_sels, ARRAY_SIZE(sai45_sels));
clks[IMX8ULP_CLK_SAI5_SEL] = imx_clk_hw_mux2("sai5_sel", base + 0x904, 8, 2, sai45_sels, ARRAY_SIZE(sai45_sels));

现在,看看 i.MX 8ULP 处理器参考手册,IMX8ULPRM (此处) , 第 7.6.1.1 节 AD_CGC 内存映射。从表中可以看到,还有两个寄存器位于0x9080x90C,没有包含在驱动程序中。

gfrung_0-1742926223968.png

不包括这些寄存器的后果是,无法通过设备树将 TPM 6 和TPM7 (我想还有 MQS1 )配置为使用 PCC 4时钟。

我在 imx8ulp.dtsi 中添加了 tpm6 tpm7 节点,并配置它们使用时钟 <& pcc4 IMX8ULP_CLK_TPM6 > <& pcc4 IMX8ULP_CLK_TPM7 >:

per_bridge4: bus@29800000 {
	tpm6: pwm@29820000 {
		compatible = "fsl,imx7ulp-pwm";
		reg = <0x29820000 0x1000>;
		interrupts = ;
		clocks = <&pcc4 IMX8ULP_CLK_TPM6>;
		assigned-clocks = <&pcc4 IMX8ULP_CLK_TPM6>;
		assigned-clock-parents = <&cgc1 IMX8ULP_CLK_FROSC_DIV2>;
		assigned-clock-rates = <48000000>;
		#pwm-cells = <3>;
		status = "disabled";
	};

	tpm7: pwm@29830000 {
		compatible = "fsl,imx7ulp-pwm";
		reg = <0x29830000 0x1000>;
		interrupts = ;
		clocks = <&pcc4 IMX8ULP_CLK_TPM7>;
		assigned-clocks = <&pcc4 IMX8ULP_CLK_TPM7>;
		assigned-clock-parents = <&cgc1 IMX8ULP_CLK_FROSC_DIV2>;
		assigned-clock-rates = <48000000>;
		#pwm-cells = <3>;
		status = "disabled";
	};
};

但是,由于 TPM6_7CLK CGC1 寄存器 0x908)的默认值为 0x 00000000 ,因此 TPM6CLK TPM7CLK 都配置为使用 AUD_PLL_CLK1,即由音频 PLL (PLL3PFD1DIV1) 生成的音频时钟,而不是我通过设备树选择的 PCC 4 时钟。

我通过调用writel来明确设置寄存器0x908,从而解决了这个问题。

static int imx8ulp_clk_cgc1_init(struct platform_device *pdev)
{
	...

	/* There is a register called TPM6_7CLK at offset 0x908 that is not set by
	   this driver.  By default, it is equal to 0x00000000, which causes TPM6
	   and TPM7 to use as their clock source an "Audio clock generated from the
	   Audio PLL in AD - PLL3PFD1DIV1", rather than the main reference clock.
	   By setting this register to 0x00000303, the main reference clock is used
	   for both TPM6 and TPM7.  See IMX8ULPRM, the "i.MX 8ULP Processor
	   Reference Manual", section "Clock Generation and Control (CGC1)" for
	   more information on this register. */
	writel(0x00000303, base + 0x908);

	imx_check_clk_hws(clks, clk_data->num);

	return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data);
}

虽然这现在可以解决我的问题,但如果有办法通过设备树正确设置这个时钟配置,那就太好了,但这需要 cl k-imx8ulp.c时钟驱动器来配置该寄存器。

感谢您花时间调查此事!

i.MX8ULPLinuxRe: File drivers/clk/imx/clk-imx8ulp.c is missing some registers from the manual@Manuel_Salas

我明白这个还没有添加到本周一(2025-07-21)的最新 lf-6.6.52-2.2.1 内核版本中 —— 有计划在树和/或上游发布这个或类似的补丁吗?

谢谢
Re: File drivers/clk/imx/clk-imx8ulp.c is missing some registers from the manual

你好@gfrung

希望你一切都好。

请尝试使用所附的补丁。


顺祝商祺!

萨拉斯

Tags (1)
No ratings
Version history
Last update:
‎11-21-2025 09:48 AM
Updated by: