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

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

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

Jump to solution
4,389 Views
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.

Labels (1)
0 Kudos
Reply
1 Solution
4,308 Views
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.

View solution in original post

0 Kudos
Reply
7 Replies
4,328 Views
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 Kudos
Reply
4,309 Views
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 Kudos
Reply
4,262 Views
wendy-liu
Contributor II

Thanks a lot !!! It works well!

4,366 Views
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 Kudos
Reply
4,341 Views
wendy-liu
Contributor II

ok, I will show it for you.

node TPM7,8 are added by myself.

0 Kudos
Reply
4,066 Views
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 Kudos
Reply
4,066 Views
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 Kudos
Reply