This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM6548: ehrpwm

Part Number: AM6548
Other Parts Discussed in Thread: AM3352

Tool/software: Linux

Dear TI

SDK:evm-05.01.00.11

I want to use Ehrpwm on the AM6548 board.

I config dts like below

ehrpwm0: pwm@3000000 {
compatible = "ti,am654-ehrpwm", "ti,am3352-ehrpwm";
#pwm-cells = <3>;
reg = <0x0 0x3000000 0x0 0x42>;
power-domains = <&k3_pds 40>;
clocks = <&k3_clks 40 0>;
        clock-names = "tbclk","fck";
         status = "disabled";
};

&ehrpwm0 {
    pinctrl-names = "default";
    pinctrl-0 = <&ehrpwm0_pins_default>;
    status = "okay";
};

But  in the linux command

root@am65xx-evm:~# dmesg | grep pwm                                                                                
[    1.528055] ERROR: could not get clock /soc0/pwm@3000000:fck(1)                                                 
[    1.533996] ehrpwm 3000000.pwm: failed to get clock                                                             
[    1.538894] ehrpwm: probe of 3000000.pwm failed with error -2  

Failed to get clock.can not probe the driver.

could you help me find what's the problem?

And now whether AM6548 could support use ehrpwm or not? if it could, could you give me some guidelines how to use ehrpwm on the AM6548

  • Hi Asura,

    ehrpwm should be available to use.

    It seems to me you have some problems with these lines:

    clocks = <&k3_clks 40 0>;
    clock-names = "tbclk" , "fck";

    In your first line, you have only one clock described, while on the next line you have two clock signals: tbclk and fck

    I would suggest you to add one more clock in "clocks = <&k3_clks 40 0>;" line. See for example some DTS clock entries from k3-am6.dtsi

    dss: dss@04a00000 {
    clocks = <&k3_clks 67 1>,
    <&k3_clks 216 1>,
    <&k3_clks 67 2>;
    clock-names = "fck", "vp1", "vp2";


    sdhci0: sdhci@0 {
    clocks = <&k3_clks 47 0>, <&k3_clks 47 1>;
    clock-names = "clk_ahb", "clk_xin";

    sdhci1: sdhci@0 {
    clocks = <&k3_clks 48 0>, <&k3_clks 48 1>;
    clock-names = "clk_ahb", "clk_xin";

    gpu: gpu@7000000 {
    clocks = <&k3_clks 65 0>, <&k3_clks 65 1>,
    <&k3_clks 65 2>, <&k3_clks 65 3>;
    clock-names = "mem_clk", "hyd_clk",
    "sgx_clk", "sys_clk";


    Regards,
    Pavel
  • Dear Pavel

    Actually, in the document  downloads.ti.com/.../clocks.html

    I find the description like this

    Through this ,I can find the device id equal 40 ,and there is only one clock exists,the clock ID is zero.

    So I try to modify the dts like this 

    clock-names = "tbclk" or clock-names="fck"

    ehrpwm0: pwm@3000000 {
    compatible = "ti,am654-ehrpwm", "ti,am3352-ehrpwm";
    #pwm-cells = <3>;
    reg = <0x0 0x3000000 0x0 0x42>;
    power-domains = <&k3_pds 40>;
    clocks = <&k3_clks 40 0>;
            clock-names = "tbclk";
             status = "disabled";
    };

    it's just the same result that can not probe the pwm driver correctly.

    Could you help me provide the rightly ehrpwm dts configuration.

    thanks a lot

    Asura

  • Asura,

    Please try with the below update and report back the result.

    ehrpwm0: pwm@3000000 {
    compatible = "ti,am654-ehrpwm", "ti,am3352-ehrpwm";
    #pwm-cells = <3>;
    reg = <0x0 0x03000000 0x0 0x42>;
    power-domains = <&k3_pds 40>;
    clocks = <&k3_clks 40 0>;
    clock-names = "fck";
    status = "disabled";
    };

    It seems that only fck (MAIN_SYSCLK0/4) is available to be enabled through DTS.

    Regarding CTRL_MMR0 tbclk, you need to enable this in driver file (pwm-tiehrpwm.c), you need to use register CTRLMMR_EPWM0_CTRL/0x00104140.

    See for example how CTRLMMR_OLDI_DAT0_IO_CTRL/0x001041E0 register is used in below files:

    linux-4.14.67/drivers/gpu/drm/tidss/tidss_dispc7.h
    linux-4.14.67/drivers/gpu/drm/tidss/tidss_dispc7.c

    Regards,
    Pavel

  • hi Paval

    I have tried this dts configuration ago。I have tried clock-names with fck or tbclk。It  also failed to get the clock。

    can I think the ehrpwm actually is not ready for the am6548 in the lastest sdk?

    or there is something wrong when I configure ethrpwm in the dts。

  • Asura,

    Your DTS file seems to be correct, I do not see errors in below DTS code regarding AM65x ehrpwm:

    ehrpwm0: pwm@3000000 {
    compatible = "ti,am654-ehrpwm", "ti,am3352-ehrpwm";
    #pwm-cells = <3>;
    reg = <0x0 0x03000000 0x0 0x42>;
    power-domains = <&k3_pds 40>;
    clocks = <&k3_clks 40 0>;
    clock-names = "fck";
    status = "disabled";
    };

    &ehrpwm0 {
    pinctrl-names = "default";
    pinctrl-0 = <&ehrpwm0_pins_default>;
    status = "okay";
    };


    But seems that EHRPWM is not supported in PSDK 5.1 and I am not sure how much effort it will take to enable it by yourself.

    Regards,
    Pavel
  • hi pavel
    in the ehrpwm driver,I found that maybe there need both fck and tbclk clock。But in the document,there is only one clock id。is the am3352 ethpwm driver not suit for the am6548?
  • Asura,

    Yes, seems that ehrpwm driver (pwm-tiehrpwm.c) currently do not support am65x device, check below doc:

    linux-4.14.67/Documentation/devicetree/bindings/pwm/pwm-tiehrpwm.txt

    Also this ehrpwm driver is not enabled by default in the arch/arm64/configs/ti_sdk_arm64_release_defconfig, CONFIG_PWM_TIEHRPWM is not set.

    Regards,
    Pavel
  • To confirm, we do not currently support ehrpwm on AM65x. I will submit a request for the software team to look into it in 2019.

    Regards,
    Nick
  • Asura,

    If you have no more questions related to the subject, please close/verify/resolve this thread.

    Regards,
    Pavel