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.

AM5728: How to enable ecap input?

Part Number: AM5728

Hello,

I'm trying to use ecap to count input changes. The TRM doesn't have enough information. I can't find an existing linux driver for ecap interrupts. I also can't access the hardware directly.  I've tried reading most of the ecap registers using devmem2 and they all report "bus error" and show a crash on the console. (For example, try reading PWMSS_ECAP_PID with "devmem2 0x4844215C")

Is there any documentation or example code available?

Thanks,

Scott

  • Hi Scott,

    There is a driver already in linux: drivers/pwm/pwm-tiecap.c.

    Have you already looked at that? Can you give more details about what exactly you
    want to accomplish with PWM?

    - Keerthy

  • Hi Keerthy,

    Yes, I've seen that driver.  However, I don't want to output PWM. I need to count input changes.

    Based on the TRM, eCAP input can count both rising and falling edge changes. That is what I need.

    Is there any documentation or example code available?

    Thanks,

    Scott

  • Hi Scott,

    Thanks for the details. I now understand the intent. As you have observed the Linux
    SDK does not support the input event counting part. It's only the PWM supported.
    I checked with the PWM expert and apparently no use case thus far has required

    However some quick googling i could find some non upstreamed code that is here:

    https://linux-arm-kernel.infradead.narkive.com/zeEA4MIa/patch-v3-0-6-iio-pulse-capture-support-for-ti-ecap

    Also the newer SoCs have some more documentation related to ECAP use cases:

    http://www.ti.com/lit/ug/spruil1a/spruil1a.pdf

    Page: 11690
    12.4.1.5 ECAP Use Cases

    Hope this helps you.


    Regards,
    Keerthy

  • Hi Keerthy,

    That first link to pulse input using eCap would be useful, but I can't find the source files. (Multiple web searches show patches - not the whole files)

    Do you know where to find the complete files?

    Also, when trying to access the eCap registers at the command prompt ("devmem2 0x4844215C") I get a bus error. Apparently something has marked the eCap registers as kernel access only. Do you know how to change the eCap registers so they are accessible from user space? If I can access the eCap registers I can manipulate them directly without needing a driver.

    Thanks,

    Scott

  • Hi Scott,

    Are you particular on using 0x4844215C i.e PWMSS3_ECAP or you
    could try with PWMSS2_ECAP as well?

    Because i am able to access those registers from user space:

    devmem2 0x48440100
    /dev/mem opened.
    Memory mapped at address 0xb6f89000.
    Read at address 0x48440100 (0xb6f89100): 0x00000000
    root@am57xx-evm:~# devmem2 0x48440154
    /dev/mem opened.
    Memory mapped at address 0xb6f09000.
    Read at address 0x48440154 (0xb6f09154): 0x00000000

    The other 2 instances i am figuring out a way to get you access in user space.

    Could you try with PWMSS2_ECAP aka 0x48440100 register space?

    Regards,
    Keerthy

  • ecap.tarHello Scott,

    Please apply the attached patches in the tar ball.

    Basically:

    extract the tar and do:

    git am ecap/0001-arm-dts-ti-am57xx-evm-common.dtso.patch
    git am ecap/0002-pwm-pwm-tiehrpwm.c-Enable-clocks-in-probe.patch

    The reason for the abort when you accessed using devmem2 tool was that the clocks were
    disabled. I have cooked up the above patches to enable pwm1/3 in DT and also to enable
    clocks in probe of pwm.

    Now you can access the registers of pwm1/3 from user space.

    Note: Pwm2 is used by backlight and hence was accessible as mentioned in the earlier mail.

    If this unblocks you please resolve the thread.

    Thanks,
    Keerthy