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.

AM6442: Is there a Linux (A53) driver for the EQEP peripheral in AM64X

Part Number: AM6442

I saw the AM62x posting from earlier this year? Has anyone in TI did a 64 bit Linux (A53 core) driver for the EQEP periphery in AM6x ? (I am asking for AM64x)

  • Hello Jim,

    Good question. We added an EQEP driver (in SDK 9.1 I believe), and when I check SDK 9.2 I see the eqep devicetree node defined for AM62x, AM62Ax, AM62Px, and AM64x.

    However, I do NOT see any documentation in the Linux SDK docs, and the AM64x SW Build Sheet for SDK 9.2 still lists EQEP as "not enabled in Linux".

    So my assumption is that the driver exists and was tested on AM64x, and we just have not finished adding the documentation. I'll check with the developer, and file some internal tickets to get the documentation updated.

    Regards,

    Nick

  • Actually, it looks like the driver might only be available starting in SDK 9.2.

    Regards,

    Nick

  • edited May 22, 2024: the final version of the documentation has been pushed. See https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1363410/am6442-is-there-a-linux-a53-driver-for-the-eqep-peripheral-in-am64x/5210141#5210141 

    Final followup, the documentation got stalled out in the draft/review state. I'll include the source code to generate the documentation here. There might be issues, since this is not a "finished" product.

    EQEP
    ---------------------------------
    
    .. rubric:: Introduction
       :name: introduction-linux-eqep
    
    Linux has support for EQEP (enhanced Quadature Encoder Pulse).
    EQEP channels can be used to interface with rotary encoder hardware.
    
    #. AM62x SK: EQEP0: k3-am62x-sk-eqep.dtso
    #. AM62Ax SK: EQEP0: k3-am62x-sk-eqep.dtbo
    #. AM64x SK: EQEP0: k3-am642-sk.dts
    #. AM62p SK: EQEP0: k3-am62p5-sk-eqep.dtso
    
    |
    
    .. rubric:: Kernel Configuration
       :name: driver-configuration-eqep
    
    .. rubric:: Enable the eHRPWM driver
       :name: enable-the-eqep-driver
    
    .. code-block:: console
    
       Device Drivers --->
           <M> Counter support  --->
             <M> TI eQEP counter driver
    
    .. note::
    
       EQEP driver should be enabled by default as a module in TI Linux kernel.
    
    |
    
    .. rubric:: Driver Usage
       :name: driver-usage-eqep
    
    .. rubric:: Using EQEP with the sysfs interface
       :name: using-eqep-with-sysfs-interface
    
    Several sysfs attributes are generated by the Generic Counter interface, and reside under the
    /sys/bus/counter/devices/counterX directory, where X is to the respective counter device id.
    
    Please see Documentation/ABI/testing/sysfs-bus-counter for detailed information on each Generic
    Counter interface sysfs attribute.
    
    Through these sysfs attributes, programs and scripts may interact with the Generic Counter paradigm
    Counts, Signals, and Synapses of respective counter devices.
    
    -  **Example**
    
    .. code-block:: console
    
       root@am62xx-evm:/sys/bus/counter/devices/counter0/count0# echo 0xff > ceiling
       root@am62xx-evm:/sys/bus/counter/devices/counter0/count0# cat ceiling
       255
       root@am62xx-evm:/sys/bus/counter/devices/counter0/count0# echo 1 > enable
       root@am62xx-evm:/sys/bus/counter/devices/counter0/count0# cat count
    
    |
    
    **Character device nodes**
    
    Counter character device nodes are created under the /dev directory as counterX, where X is the respective counter device id.
    
    .. code-block:: console
    
       $ ls /dev/counter*
       /dev/counter0
    
    **Counter Events**
    
    Please read the Generic counter API doc to implement events:
    
    - https://docs.kernel.org/driver-api/generic-counter.html
    

    Regards,

    Nick

  • Nick: did that implementation go through some form of regression testing?

    Would it be fairly simple to take the MCU+ SDK's eqep_capture example on the R5 in FreeRTOS and morph that into Linuc on the A53?

    thanks

    Jim

  • Hello Jim,

    The code was tested on AM64x, but I am not sure exactly what tests were run. I can ask the developer if needed.

    I cannot comment on porting MCU+ SDK EQEP example to Linux. I would start with trying to run an example in Linux as per the draft documentation above, and if things do not work as expected you can ask followup questions:
    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1363410/am6442-is-there-a-linux-a53-driver-for-the-eqep-peripheral-in-am64x/5205034#5205034

    Regards,

    Nick

  • Nick - we should ask the developer to disclose what tests were run - that way you can ascertain what may be necessary and sufficient to qualify for the Linux representation to be a "finished" product in AM6x. I suspect someone from Houston Stafford (Paula Carrillo?) should be involved?

    Meanwhile I will look at the representation that you had supplied.

    thanks

    Jim

  • Hello Jim,

    Paula is focused more on the MCU+ side of things, I'll continue handling the Linux EQEP questions for now.

    The developer told me since this driver is so new, they are still working on setting up the EQEP test infrastructure for future SDK releases. I would expect that in the future, you will be able to see test outputs for the CICD snapshots here:
    https://software-dl.ti.com/cicd-report/linux/index.html?section=platform&platform=am64xx 

    They also finished merging in the EQEP driver documentation for the Linux SDK docs last night. I'll attach the updated source code here, since I'm not sure if the AM64x SDK 9.2 docs will be regenerated again in the near term, or if this update will show up for the first time in SDK 10.0 documentation:

    EQEP
    ----
    
    .. rubric:: Introduction
       :name: introduction-linux-eqep
    
    Linux has support for EQEP (Enhanced Quadature Encoder Pulse).
    EQEP channels can be used to interface with rotary encoder hardware.
    
    .. ifconfig:: CONFIG_part_variant in ('AM62X', 'AM62AX')
    
    	- AM62x SK: EQEP0: k3-am62x-sk-eqep.dtso
    
    .. ifconfig:: CONFIG_part_variant in ('AM64X')
    
    	- AM64x SK: EQEP0: k3-am642-sk.dts
    
    .. ifconfig:: CONFIG_part_variant in ('AM62PX')
    
    	- AM62p SK: EQEP0: k3-am62p5-sk-eqep.dtso
    
    .. rubric:: Kernel Configuration
       :name: driver-configuration-eqep
    
    Using menuconfig, enable the following driver:
    
    .. code-block:: console
    
       Device Drivers --->
           <M> Counter support  --->
             <M> TI eQEP counter driver
    
    .. note::
    
       EQEP driver should be enabled by default as a kernel module in TI Linux kernel.
    
    .. rubric:: Features supported in TI SDK
       :name: features-supported-eqep
    
    - position
    - overflow/underflow events
    - direction
    - unit timer
    - latched position
    - edge capture
    
    .. rubric:: Using eQEP with SYSFS interface
       :name: sysfs-interface-eqep
    
    Several sysfs attributes are generated by the Generic Counter interface, and reside under
    the :file:`/sys/bus/counter/devices/counterX` directory, where X is to the respective counter
    device id.
    
    Please see the counter sysfs documentation `upstream <https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-bus-counter>`__
    or in TI Linux kernel :file:`/Documentation/ABI/testing/sysfs-bus-counter` for detailed information on each
    generic counter interface sysfs attribute.
    
    Through these sysfs attributes, programs and scripts may interact with the Generic Counter paradigm
    Counts, Signals, and Synapses of respective counter devices.
    
    The following sysfs atributes can be found in :file:`/sys/bus/counter/devices/counterX` in TI SDK:
    
    - countY/ceiling
    - countY/count
    - countY/direction
    - countY/enable
    - countY/function
    - countY/latched_count
    - countY/signal0_action
    - countY/signal1_action
    - edge_capture_unit_enable
    - edge_capture_unit_latched_period
    - edge_capture_unit_max_period
    - edge_capture_unit_prescaler
    - latch_mode
    - unit_timer_enable
    - unit_timer_period
    - unit_timer_time
    
    .. rubric:: Character device nodes
       :name: character-device-nodes-eqep
    
    Counter character device nodes are created under the /dev directory as counterX, where X is the respective counter device id.
    
    .. code-block:: console
    
       $ ls /dev/counter*
       /dev/counter0
    
    .. rubric:: Counter Events
       :name: counter-events
    
    Please read the generic counter API `upstream <https://docs.kernel.org/driver-api/generic-counter.html>`__ or in
    TI Linux kernel :file:`/Documentation/driver-api/generic-counter.rst` documentation to implement events:
    
    .. rubric:: Test eQEP on AM62x SK
       :name: test-eqep-am62x
    
    +------------------------------------------+---------------------------------------------------------+
    | .. Image:: /images/am62x_sk_eqep.jpg     | .. Image:: /images/am62x_sk_rotary_encoder_breakout.jpg |
    |       :width: 380px                      |       :width: 380px                                     |
    |       :align: center                     |       :align: center                                    |
    +------------------------------------------+---------------------------------------------------------+
    | AM62x SK & rotary encoder breakout board | Example Diligent rotary encoder breakout board          |
    +------------------------------------------+---------------------------------------------------------+
    
    The example rotary encoder breakout board used in this example can be found `here <https://www.digikey.com/en/products/detail/digilent,-inc./410-117/4090075?>`__.
    
    The following is an example for testing eQEP using sysfs interface:
    
    .. code-block:: console
    
    	root@am62xx-evm:~# echo 0xff > /sys/bus/counter/devices/counter0/count0/ceiling 
    	root@am62xx-evm:~# cat /sys/bus/counter/devices/counter0/count0/ceiling
    	255
    	root@am62xx-evm:~# echo 1 > /sys/bus/counter/devices/counter0/count0/enable 
    	root@am62xx-evm:~# cat /sys/bus/counter/devices/counter0/count0/count
    	0
    	root@am62xx-evm:~# cat /sys/bus/counter/devices/counter0/count0/count
    	92
    	root@am62xx-evm:~# cat /sys/bus/counter/devices/counter0/count0/count
    	148
    	root@am62xx-evm:~# cat /sys/bus/counter/devices/counter0/count0/count
    	188
    	root@am62xx-evm:~# cat /sys/bus/counter/devices/counter0/count0/count
    	252
    	root@am62xx-evm:~# cat /sys/bus/counter/devices/counter0/count0/count
    	12
    
    Notice in this example that turning the rotary shaft encoder counterclockwise increases the count
    until reaching the ceiling, then wraps around to zero and starts again. Also, turning the rotary
    shaft encoder clockwise decreases the count.

    Regards,

    Nick