How to configure the clock source of TPM in iMX8ULP dts?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How to configure the clock source of TPM in iMX8ULP dts?

跳至解决方案
4,390 次查看
wendy-liu
Contributor II

Dear all,

    I want to enable TPM4,7,8 on iMX8ULP,but the dts doesn't have device note.

    So, I add TPM8 device node by myself.

    But during probe, the kernel crashes.

    Therefore, how to configure the clock source of TPM?

    log and dts are as below.

标签 (1)
0 项奖励
回复
1 解答
4,309 次查看
AldoG
NXP TechSupport
NXP TechSupport

Hello,

Thank you for the update, please try by not commenting the assigned-clock-rates & clock-names properties in the tpm node.

Also, please enable the clock to be configured early on ATF:

https://github.com/nxp-imx/imx-atf/blob/lf-6.6.36-2.1.0/plat/imx/imx8ulp/imx8ulp_bl31_setup.c#L68

void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
u_register_t arg2, u_register_t arg3)
{
static console_t console;

+ /* config the TPM7 clock */
+ mmio_write_32(IMX_CGC1_BASE + 0x908, 0x300);
+

/* config the TPM5 clock */
mmio_write_32(IMX_PCC3_BASE + 0xd0, 0x92000000);
mmio_write_32(IMX_PCC3_BASE + 0xd0, 0xd2000000);

Please try it and let me know of your results.

Best regards/Saludos,
Aldo.

在原帖中查看解决方案

0 项奖励
回复
7 回复数
4,329 次查看
wendy-liu
Contributor II

Hello!

Here are some updates  I'd like to share with you.

Fortunately, I enable TPM7 CH5(PTF25) successfully, but there is no output waveform.

my device node  :

+tpm7: tpm@29830000 {
+ //compatible = "fsl,imx8ulp-tpm", "fsl,imx7ulp-tpm";
+ compatible = "fsl,imx7ulp-pwm";
+ reg = <0x29830000 0x10000>;
+ //interrupts = <GIC_SPI 87 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&pcc4 IMX8ULP_CLK_TPM7>, <&pcc4 IMX8ULP_CLK_TPM7>;
+ assigned-clocks = <&pcc4 IMX8ULP_CLK_TPM7>;
+ assigned-clock-parents = <&cgc1 IMX8ULP_CLK_FROSC_DIV2>;
+ //assigned-clock-rates = <48000000>;
+ //clock-names = "ipg", "per";
+ status = "okay";
+};

+&tpm7 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_tpm7>;
+ #pwm-cells = <3>;
+};

pinctrl_tpm7: tpm7grp {
                fsl,pins = <
                        MX8ULP_PAD_PTF25__TPM7_CH5      0x2
                >;
};
 
my commands :
root@imx8ulp-lpddr4-evk:/sys/class/pwm/pwmchip8# echo 5 > export
root@imx8ulp-lpddr4-evk:/sys/class/pwm/pwmchip8# cd pwm5/
root@imx8ulp-lpddr4-evk:/sys/class/pwm/pwmchip8/pwm5# echo 400000 > period
root@imx8ulp-lpddr4-evk:/sys/class/pwm/pwmchip8/pwm5# echo 200000 > duty_cycle
root@imx8ulp-lpddr4-evk:/sys/class/pwm/pwmchip8/pwm5# echo 1 > enable
root@imx8ulp-lpddr4-evk:/sys/class/pwm/pwmchip8/pwm5#
0 项奖励
回复
4,310 次查看
AldoG
NXP TechSupport
NXP TechSupport

Hello,

Thank you for the update, please try by not commenting the assigned-clock-rates & clock-names properties in the tpm node.

Also, please enable the clock to be configured early on ATF:

https://github.com/nxp-imx/imx-atf/blob/lf-6.6.36-2.1.0/plat/imx/imx8ulp/imx8ulp_bl31_setup.c#L68

void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
u_register_t arg2, u_register_t arg3)
{
static console_t console;

+ /* config the TPM7 clock */
+ mmio_write_32(IMX_CGC1_BASE + 0x908, 0x300);
+

/* config the TPM5 clock */
mmio_write_32(IMX_PCC3_BASE + 0xd0, 0x92000000);
mmio_write_32(IMX_PCC3_BASE + 0xd0, 0xd2000000);

Please try it and let me know of your results.

Best regards/Saludos,
Aldo.

0 项奖励
回复
4,263 次查看
wendy-liu
Contributor II

Thanks a lot !!! It works well!

4,367 次查看
AldoG
NXP TechSupport
NXP TechSupport

Hello,

Could you share the full device tree that you are using?
Also, the node you have added seems to be incomplete that may be part of the reason as to why it does fail to boot correctly.

Best regards/Saludos,
Aldo.

0 项奖励
回复
4,342 次查看
wendy-liu
Contributor II

ok, I will show it for you.

node TPM7,8 are added by myself.

0 项奖励
回复
4,067 次查看
wendy-liu
Contributor II

I successfully enable pwm signal of TPM7 CH5(PTF25), but there is no output waveform

 

tpm7: tpm@29830000 {
//compatible = "fsl,imx8ulp-tpm", "fsl,imx7ulp-tpm";
compatible = "fsl,imx7ulp-pwm";
reg = <0x29830000 0x10000>;
//interrupts = <GIC_SPI 87 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&pcc4 IMX8ULP_CLK_TPM7>, <&pcc4 IMX8ULP_CLK_TPM7>;
assigned-clocks = <&pcc4 IMX8ULP_CLK_TPM7>;
assigned-clock-parents = <&cgc1 IMX8ULP_CLK_FROSC_DIV2>;
//assigned-clock-rates = <48000000>;
//clock-names = "ipg", "per";
status = "okay";
};

&tpm7 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_tpm7>;
#pwm-cells = <3>;
};

pinctrl_tpm7: tpm7grp {
fsl,pins = <
MX8ULP_PAD_PTF25__TPM7_CH5 0x2
>;
};

root@imx8ulp-lpddr4-evk:/sys/class/pwm/pwmchip8/pwm5# echo 400000 > period
root@imx8ulp-lpddr4-evk:/sys/class/pwm/pwmchip8/pwm5# echo 200000 > duty_cycle
root@imx8ulp-lpddr4-evk:/sys/class/pwm/pwmchip8/pwm5# echo 1 > enable

0 项奖励
回复
4,067 次查看
wendy-liu
Contributor II

Now, the kernel starts normally.But when I enable PWM channal, it will report an error!

root@imx8ulp-lpddr4-evk:/sys/class/pwm/pwmchip8/pwm5# echo 100000 > period
root@imx8ulp-lpddr4-evk:/sys/class/pwm/pwmchip8/pwm5# echo 50000 > duty_cycle
root@imx8ulp-lpddr4-evk:/sys/class/pwm/pwmchip8/pwm5# echo 1 > enable
-sh: echo: write error: Timer expired

0 项奖励
回复