From 8ad1b3539df5fc9be243e910acf8bf5a8468c23b Mon Sep 17 00:00:00 2001
From: Jason Kridner <jkridner@beagleboard.org>
Date: Fri, 6 Oct 2023 14:09:49 -0400
Subject: [PATCH] cape: fix counter entry

---
 boards/capes/cape-interface-spec.rst | 109 +++++++++++++--------------
 1 file changed, 52 insertions(+), 57 deletions(-)

diff --git a/boards/capes/cape-interface-spec.rst b/boards/capes/cape-interface-spec.rst
index b05a58b3..12f7b40e 100644
--- a/boards/capes/cape-interface-spec.rst
+++ b/boards/capes/cape-interface-spec.rst
@@ -42,7 +42,7 @@ More details can be found in :ref:`bone-methodology`.
 .. |L| replace:: :ref:`L <bone-lcd>`
 .. |M| replace:: :ref:`M <bone-mmc>`
 .. |P| replace:: :ref:`P <bone-pru>`
-.. |Q| replace:: :ref:`Q <bone-capture>`
+.. |Q| replace:: :ref:`Q <bone-counter>`
 .. |S| replace:: :ref:`S <bone-spi>`
 .. |U| replace:: :ref:`U <bone-uart>`
 .. |Y| replace:: :ref:`Y <bone-ecap>`
@@ -86,7 +86,7 @@ More details can be found in :ref:`bone-methodology`.
 	+-------------------+-----+------+---------------------+---+------------------+-----+------+-----------------+
 	| PWR BUT           | 9   | 10   | RESET               |   | |D| |C|          | 9   | 10   | |D| |C|         |
 	+-------------------+-----+------+---------------------+---+------------------+-----+------+-----------------+
-	| |D| |U|           | 11  | 12   | |D|                 |   | |D| |P|          | 11  | 12   | |D| |Q| |P|     |
+	| |D| |U|           | 11  | 12   | |D|                 |   | |D| |Q| |P|      | 11  | 12   | |D| |Q| |P|     |
 	+-------------------+-----+------+---------------------+---+------------------+-----+------+-----------------+
 	| |D| |U|           | 13  | 14   | |D| |E|             |   | |D| |E|          | 13  | 14   | |D|             |
 	+-------------------+-----+------+---------------------+---+------------------+-----+------+-----------------+
@@ -116,7 +116,7 @@ More details can be found in :ref:`bone-methodology`.
 	+-------------------+-----+------+---------------------+---+------------------+-----+------+-----------------+
 	| |A|               | 39  | 40   | |A|                 |   | |D| |L| |P|      | 39  | 40   | |D| |L| |P|     |
 	+-------------------+-----+------+---------------------+---+------------------+-----+------+-----------------+
-	| |D| |P|           | 41  | 42   | |D| |Q| |S| |U| |P| |   | |D| |L| |P|      | 41  | 42   | |D| |L| |P|     |
+	| |D| |P|           | 41  | 42   | |D| |Q| |S| |U| |P| |   | |D| |L| |P| |Q|  | 41  | 42   | |D| |L| |P| |Q| |
 	+-------------------+-----+------+---------------------+---+------------------+-----+------+-----------------+
 	| GND               | 43  | 44   | GND                 |   | |D| |L| |P|      | 43  | 44   | |D| |L| |P|     |
 	+-------------------+-----+------+---------------------+---+------------------+-----+------+-----------------+
@@ -166,7 +166,7 @@ and other properties defined in the
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
 	| PWR BUT           | 9   | 10   | RESET            |     | D C3r      | 9   | 10   | D C3t      |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| D U4r             | 11  | 12   | D                |     | D P0o      | 11  | 12   | D Q2a P0o  |
+	| D U4r             | 11  | 12   | D                |     | D P0o Q2b  | 11  | 12   | D Q2a P0o  |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
 	| D U4t             | 13  | 14   | D E1a            |     | D E2b      | 13  | 14   | D          |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
@@ -196,7 +196,7 @@ and other properties defined in the
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
 	| |A| 0             | 39  | 40   | |A| 1            |     | D L P1     | 39  | 40   | D L P1     |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| D P0              | 41  | 42   | D Q0a S11 U3t P0 |     | D L P1     | 41  | 42   | D L P1     |
+	| D P0              | 41  | 42   | D Q0a S11 U3t P0 |     | D L P1 Q4a | 41  | 42   | D L P1 Q4b |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
 	| GND               | 43  | 44   | GND              |     | D L P1     | 43  | 44   | D L P1     |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
@@ -551,7 +551,7 @@ UART bone bus nodes allow creating compatible overlays for Black, AI and AI-64.
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
 	|                   | 19  | 20   |                  |     |            | 19  | 20   |            |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| 2 TX              | 21  | 22   | 2 RX             |     |            | 21  | 22   |            |
+	| 2 TX              | 21  | 22   | 2 RX             |     |            | 21  | 22   | 7 RX       |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
 	|                   | 23  | 24   | 1 TX             |     |            | 23  | 24   |            |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
@@ -864,86 +864,81 @@ TIMER PWM bone bus uses ti,omap-dmtimer-pwm driver, and timer nodes that allow c
 	| /sys/bus/platform/devices/bone_timer_pwm_5/  | P9.22       | -      | timer15  | `BONE-TIMER_PWM_5.dts <https://github.com/lorforlinux/bb.org-overlays/blob/bone_timer/src/arm/BONE-TIMER_PWM_5.dts>`_   |
 	+----------------------------------------------+-------------+--------+----------+-------------------------------------------------------------------------------------------------------------------------+
 
-.. _bone-capture:
+.. _bone-counter:
 
-eQEP
-****
+Counter
+*******
+
+A counter function for quadrature encoders is implemented with the EQEP peripheral.
+
+.. todo::
+
+   Additional quadrature encoders can be implemented in PRU firmware.
 
-.. table:: eQEP pins
+.. table:: Counter pins
 
 	+---------------------------------------------------+-----+--------------------------------------+
 	| .. centered:: P9                                  |     |    .. centered:: P8                  |
 	+===================+=====+======+==================+=====+============+=====+======+============+
 	|   Functions       | odd | even |    Functions     |     | Functions  | odd | even | Functions  |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| USB D+            | E1  | E2   | USB D-           |     |            |     |      |            |
-	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| 5V OUT            | E3  | E4   | GND              |     |            |     |      |            |
+	|                   | 11  | 12   |                  |     | 2 B        | 11  | 12   | 2 A        |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| GND               | 1   | 2    | GND              |     | GND        | 1   | 2    | GND        |
-	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| 3V3 OUT           | 3   | 4    | 3V3 OUT          |     | D M        | 3   | 4    | D M        |
-	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| 5V IN             | 5   | 6    | 5V IN            |     | D M C4t    | 5   | 6    | D M C4r    |
-	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| 5V OUT            | 7   | 8    | 5V OUT           |     | D C2r      | 7   | 8    | D C2t      |
-	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| PWR BUT           | 9   | 10   | RESET            |     | D C3r      | 9   | 10   | D C3t      |
+	|                   | 13  | 14   |                  |     |            | 13  | 14   |            |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| D U4r             | 11  | 12   | D                |     | D P0o      | 11  | 12   | D Q2a P0o  |
+	|                   | 15  | 16   |                  |     | 3 B        | 15  | 16   | 3 A        |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| D U4t             | 13  | 14   | D E1a            |     | D E2b      | 13  | 14   | D          |
-	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| D                 | 15  | 16   | D E1b            |     | D P0i      | 15  | 16   | D P0i      |
-	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| D I1c S00         | 17  | 18   | D I1d S0o        |     | D          | 17  | 18   | D          |
+	|                   | 17  | 18   |                  |     |            | 17  | 18   |            |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| C0r D I2c         | 19  | 20   | C0t D I2d        |     | D E2a      | 19  | 20   | D M P1     |
+	|                   | 19  | 20   |                  |     |            | 19  | 20   |            |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| D E0b S0i U2t     | 21  | 22   | D E0a S0c U2r    |     | D M P1     | 21  | 22   | D M Q2b    |
+	|                   | 21  | 22   |                  |     |            | 21  | 22   |            |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| D S01             | 23  | 24   | C1r D I3c U1t    |     | D M        | 23  | 24   | D M        |
+	|                   | 23  | 24   |                  |     |            | 23  | 24   |            |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| D P0              | 25  | 26   | C1t D I3d U1r    |     | D M        | 25  | 26   | D          |
+	|                   | 25  | 26   |                  |     |            | 25  | 26   |            |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| D P0 Q0b          | 27  | 28   | D P0 S10         |     | D L P1     | 27  | 28   | D L P1 U6r |
+	| 0 B               | 27  | 28   |                  |     |            | 27  | 28   |            |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| D E S1i P0        | 29  | 30   | D P0 S1o         |     | D L P1 U6t | 29  | 30   | D L P1     |
+	|                   | 29  | 30   |                  |     |            | 29  | 30   |            |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| D E S1c P0        | 31  | 32   | ADC VDD          |     | D L        | 31  | 32   | D L        |
+	|                   | 31  | 32   |                  |     |            | 31  | 32   |            |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| |A| 4             | 33  | 34   | ADC GND          |     | D L Q1b    | 33  | 34   | D E L      |
+	|                   | 33  | 34   |                  |     | 1 B        | 33  | 34   |            |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| |A| 6             | 35  | 36   | |A| 5            |     | D L Q1a    | 35  | 36   | D E L      |
+	|                   | 35  | 36   |                  |     | 1 A        | 35  | 36   |            |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| |A| 2             | 37  | 38   | |A| 3            |     | D L U5t    | 37  | 38   | D L U5r    |
+	|                   | 37  | 38   |                  |     |            | 37  | 38   |            |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| |A| 0             | 39  | 40   | |A| 1            |     | D L P1     | 39  | 40   | D L P1     |
+	|                   | 39  | 40   |                  |     |            | 39  | 40   |            |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| D P0              | 41  | 42   | D Q0a S11 U3t P0 |     | D L P1     | 41  | 42   | D L P1     |
+	|                   | 41  | 42   | 0 A              |     |            | 41  | 42   |            |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| GND               | 43  | 44   | GND              |     | D L P1     | 43  | 44   | D L P1     |
+	|                   | 43  | 44   |                  |     |            | 43  | 44   |            |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
-	| GND               | 45  | 46   | GND              |     | D E L P1   | 45  | 46   | D E L P1   |
+	|                   | 45  | 46   |                  |     |            | 45  | 46   |            |
 	+-------------------+-----+------+------------------+-----+------------+-----+------+------------+
 
 On BeagleBone's without an eQEP on specific pins, consider using the PRU to perform a software counter function.
 
-.. table:: Bone eQEP
-
-	+----------------------+--------+--------+--------+--------+--------+-------------------------------+-------------------------------+----------+
-	| Bone bus             | Black  | AI     | AI-64  | A      | B      | strobe                        | index                         | overlay  |
-	+======================+========+========+========+========+========+===============================+===============================+==========+
-	| /dev/bone/counter/0  | eQEP0  | eQEP2  | eQEP0  | P9.42  | P9.27  | - Black/AI-64: P9.25          | - Black/AI-64: P9.41          |          |
-	|                      |        |        |        |        |        | - AI: P8.06                   | - AI: P8.05                   |          |
-	+----------------------+--------+--------+--------+--------+--------+-------------------------------+-------------------------------+----------+
-	| /dev/bone/counter/1  | eQEP1  | eQEP0  | eQEP1  | P8.35  | P8.33  | - Black/AI-64: P8.32          | - Black/AI-64: P8.31          |          |
-	|                      |        |        |        |        |        | - AI: P9.21                   | - AI: ‒                       |          |
-	+----------------------+--------+--------+--------+--------+--------+-------------------------------+-------------------------------+----------+
-	| /dev/bone/counter/2  | eQEP2  | eQEP1  | ‒      | P8.12  | P8.22  | - Black: P8.15                | - Black: P8.16                |          |
-	|                      |        |        |        |        |        | - AI: P8.18                   | - AI: P9.15                   |          |
-	+----------------------+--------+--------+--------+--------+--------+-------------------------------+-------------------------------+----------+
-
+.. table:: Counter port mapping
+
+	+----------------------+----------------+-------+-------+-------+-------+-------+----------------------+----------------------+---------------+
+	| SYSFS link           | DT symbol      | Black | AI    | AI-64 | A     | B     | STRB                 | INDX                 | Overlay       |
+	+======================+================+=======+=======+=======+=======+==============================+======================+===============+
+	| /dev/bone/counter/0  | bone_counter_0 | eQEP0 | eQEP2 | eQEP0 | P9.42 | P9.27 | - Black/AI-64: P9.25 | - Black/AI-64: P9.41 | BONE-COUNTER0 |
+	|                      |                |       |       |       |       |       | - AI: P8.06          | - AI: P8.05          |               |
+	+----------------------+----------------+-------+-------+-------+-------+-------+----------------------+----------------------+---------------+
+	| /dev/bone/counter/1  | bone_counter_1 | eQEP1 | eQEP0 | eQEP1 | P8.35 | P8.33 | - Black/AI-64: P8.32 | - Black/AI-64: P8.31 | BONE-COUNTER1 |
+	|                      |                |       |       |       |       |       | - AI: P9.21          | - AI: ‒              |               |
+	+----------------------+----------------+-------+-------+-------+-------+-------+----------------------+----------------------+---------------+
+	| /dev/bone/counter/2  | bone_counter_2 | eQEP2 | eQEP1 | ‒     | P8.12 | P8.11 | - Black: P8.15       | - Black: P8.16       | BONE-COUNTER2 |
+	|                      |                |       |       |       |       |       | - AI: P8.18          | - AI: P9.15          |               |
+	+----------------------+----------------+-------+-------+-------+-------+-------+----------------------+----------------------+---------------+
+	| /dev/bone/counter/3  | bone_counter_3 | eQEP2 | ‒     | ‒     | P8.41 | P8.42 | - Black: P8.40       | - Black: P8.39       | BONE-COUNTER3 |
+	+----------------------+----------------+-------+-------+-------+-------+-------+----------------------+----------------------+---------------+
+	| /dev/bone/counter/4  | bone_counter_4 | ‒     | ‒     | ‒     | P8.16 | P8.15 |                      |                      | BONE-COUNTER4 |
+	+----------------------+----------------+-------+-------+-------+-------+-------+----------------------+----------------------+---------------+
 
 
 .. _bone-ecap:
-- 
GitLab