2022-07-26 07:41:43

by Julien Panis

[permalink] [raw]
Subject: [PATCH v1 0/2] ECAP support on TI AM62x SoC

The Enhanced Capture (ECAP) module can be used to timestamp events
detected on signal input pin. It can be used for time measurements
of pulse train signals.

ECAP module includes 4 timestamp capture registers. For all 4 sequenced
timestamp capture events (0->1->2->3->0->...), edge polarity (falling/rising
edge) can be selected. Moreover, input signal can be prescaled.

This driver leverages IIO subsystem to :
- select edge polarity for all 4 capture events (event mode)
- log both event index and timestamp for each capture event
Event polarity, event indexes, and timestamps give all the information
about the input pulse train. Further information can easily be computed :
period and/or duty cycle if frequency is constant, elapsed time between
pulses, etc...

Userspace commands :
cd /sys/devices/platform/bus@f0000/23120000.capture/iio\:device2/

# Configure/Enable data buffers
echo 1 > scan_elements/in_index_en
echo 1 > scan_elements/in_timestamp_en
echo 100 > buffer/length
echo 1 > buffer/enable

# Set event mode in range [0 ; 15]
# One bit for each CAPx register : 1 = falling edge / 0 = rising edge
# e.g. mode = 13 = 0xd = 0b1101
# -> falling edge for CAP1-3-4 / rising edge for CAP2
echo 13 > events/change_falling_value

# Run ECAP
echo 1 > en

# Get the number of available data
cat buffer/data_available

# Read data
hexdump -v /dev/iio\:device2

# Stop ECAP
echo 0 > en

Julien Panis (2):
iio: time: capture-tiecap: capture driver support for ECAP
dt-binding: iio: time: add capture-tiecap.yaml

.../bindings/iio/time/capture-tiecap.yaml | 53 ++
drivers/iio/Kconfig | 1 +
drivers/iio/Makefile | 1 +
drivers/iio/time/Kconfig | 22 +
drivers/iio/time/Makefile | 6 +
drivers/iio/time/capture-tiecap.c | 532 ++++++++++++++++++
6 files changed, 615 insertions(+)
create mode 100644 Documentation/devicetree/bindings/iio/time/capture-tiecap.yaml
create mode 100644 drivers/iio/time/Kconfig
create mode 100644 drivers/iio/time/Makefile
create mode 100644 drivers/iio/time/capture-tiecap.c

--
2.25.1


2022-07-26 07:42:51

by Julien Panis

[permalink] [raw]
Subject: [PATCH v1 2/2] dt-binding: iio: time: add capture-tiecap.yaml

This commit adds a YAML binding for TI ECAP used in capture operating mode.

Signed-off-by: Julien Panis <[email protected]>
---
.../bindings/iio/time/capture-tiecap.yaml | 53 +++++++++++++++++++
1 file changed, 53 insertions(+)
create mode 100644 Documentation/devicetree/bindings/iio/time/capture-tiecap.yaml

diff --git a/Documentation/devicetree/bindings/iio/time/capture-tiecap.yaml b/Documentation/devicetree/bindings/iio/time/capture-tiecap.yaml
new file mode 100644
index 000000000000..4f08e49a8506
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/time/capture-tiecap.yaml
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/capture-tiecap.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Texas Instruments Enhanced Capture (eCAP) Module
+
+maintainers:
+ - Julien Panis <[email protected]>
+
+description: |
+ The eCAP module resources can be used to capture timestamps
+ on input signal events (falling/rising edges).
+
+properties:
+ compatible:
+ const: ti,am62-ecap-capture
+
+ reg:
+ maxItems: 1
+
+ interrupts:
+ maxItems: 1
+
+ clocks:
+ maxItems: 1
+
+ clock-names:
+ const: fck
+
+ power-domains:
+ maxItems: 1
+
+required:
+ - compatible
+ - reg
+ - interrupts
+ - clocks
+ - clock-names
+
+additionalProperties: false
+
+examples:
+ - |
+ ecap0: capture@23100000 { /* eCAP in capture mode on am62x */
+ compatible = "ti,am62-ecap-capture";
+ reg = <0x00 0x23100000 0x00 0x100>;
+ interrupts = <GIC_SPI 113 IRQ_TYPE_EDGE_RISING>;
+ power-domains = <&k3_pds 51 TI_SCI_PD_EXCLUSIVE>;
+ clocks = <&k3_clks 51 0>;
+ clock-names = "fck";
+ };
--
2.25.1

2022-07-26 09:39:09

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v1 2/2] dt-binding: iio: time: add capture-tiecap.yaml

On 26/07/2022 09:25, Julien Panis wrote:
> This commit adds a YAML binding for TI ECAP used in capture operating mode.
>
> Signed-off-by: Julien Panis <[email protected]>
> ---
> .../bindings/iio/time/capture-tiecap.yaml | 53 +++++++++++++++++++
> 1 file changed, 53 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/iio/time/capture-tiecap.yaml
>
> diff --git a/Documentation/devicetree/bindings/iio/time/capture-tiecap.yaml b/Documentation/devicetree/bindings/iio/time/capture-tiecap.yaml
> new file mode 100644
> index 000000000000..4f08e49a8506
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/time/capture-tiecap.yaml

Use filename based on compatible, so:
ti,am62-ecap-capture.yaml

> @@ -0,0 +1,53 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/iio/capture-tiecap.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Texas Instruments Enhanced Capture (eCAP) Module
> +
> +maintainers:
> + - Julien Panis <[email protected]>
> +
> +description: |
> + The eCAP module resources can be used to capture timestamps
> + on input signal events (falling/rising edges).
> +
> +properties:
> + compatible:
> + const: ti,am62-ecap-capture
> +
> + reg:
> + maxItems: 1
> +
> + interrupts:
> + maxItems: 1
> +
> + clocks:
> + maxItems: 1
> +
> + clock-names:
> + const: fck
> +
> + power-domains:
> + maxItems: 1
> +
> +required:
> + - compatible
> + - reg
> + - interrupts
> + - clocks
> + - clock-names
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + ecap0: capture@23100000 { /* eCAP in capture mode on am62x */
> + compatible = "ti,am62-ecap-capture";
> + reg = <0x00 0x23100000 0x00 0x100>;
> + interrupts = <GIC_SPI 113 IRQ_TYPE_EDGE_RISING>;
> + power-domains = <&k3_pds 51 TI_SCI_PD_EXCLUSIVE>;

Does not look like you tested the bindings. Please run `make
dt_binding_check` (see
Documentation/devicetree/bindings/writing-schema.rst for instructions).

> + clocks = <&k3_clks 51 0>;
> + clock-names = "fck";
> + };


Best regards,
Krzysztof

2022-07-26 09:45:02

by Julien Panis

[permalink] [raw]
Subject: Re: [PATCH v1 2/2] dt-binding: iio: time: add capture-tiecap.yaml


On 26/07/2022 11:29, Krzysztof Kozlowski wrote:
> On 26/07/2022 09:25, Julien Panis wrote:
>> This commit adds a YAML binding for TI ECAP used in capture operating mode.
>>
>> Signed-off-by: Julien Panis <[email protected]>
>> ---
>> .../bindings/iio/time/capture-tiecap.yaml | 53 +++++++++++++++++++
>> 1 file changed, 53 insertions(+)
>> create mode 100644 Documentation/devicetree/bindings/iio/time/capture-tiecap.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/iio/time/capture-tiecap.yaml b/Documentation/devicetree/bindings/iio/time/capture-tiecap.yaml
>> new file mode 100644
>> index 000000000000..4f08e49a8506
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/iio/time/capture-tiecap.yaml
> Use filename based on compatible, so:
> ti,am62-ecap-capture.yaml
>
>> @@ -0,0 +1,53 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/iio/capture-tiecap.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Texas Instruments Enhanced Capture (eCAP) Module
>> +
>> +maintainers:
>> + - Julien Panis <[email protected]>
>> +
>> +description: |
>> + The eCAP module resources can be used to capture timestamps
>> + on input signal events (falling/rising edges).
>> +
>> +properties:
>> + compatible:
>> + const: ti,am62-ecap-capture
>> +
>> + reg:
>> + maxItems: 1
>> +
>> + interrupts:
>> + maxItems: 1
>> +
>> + clocks:
>> + maxItems: 1
>> +
>> + clock-names:
>> + const: fck
>> +
>> + power-domains:
>> + maxItems: 1
>> +
>> +required:
>> + - compatible
>> + - reg
>> + - interrupts
>> + - clocks
>> + - clock-names
>> +
>> +additionalProperties: false
>> +
>> +examples:
>> + - |
>> + ecap0: capture@23100000 { /* eCAP in capture mode on am62x */
>> + compatible = "ti,am62-ecap-capture";
>> + reg = <0x00 0x23100000 0x00 0x100>;
>> + interrupts = <GIC_SPI 113 IRQ_TYPE_EDGE_RISING>;
>> + power-domains = <&k3_pds 51 TI_SCI_PD_EXCLUSIVE>;
> Does not look like you tested the bindings. Please run `make
> dt_binding_check` (see
> Documentation/devicetree/bindings/writing-schema.rst for instructions).


I did not indeed, sorry. I thought that checkpath also checked binding.

Thank you for your feedback. I'm going to prepare a new version.


>
>> + clocks = <&k3_clks 51 0>;
>> + clock-names = "fck";
>> + };
>
> Best regards,
> Krzysztof

2022-07-26 14:33:48

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH v1 2/2] dt-binding: iio: time: add capture-tiecap.yaml

On Tue, 26 Jul 2022 09:25:53 +0200, Julien Panis wrote:
> This commit adds a YAML binding for TI ECAP used in capture operating mode.
>
> Signed-off-by: Julien Panis <[email protected]>
> ---
> .../bindings/iio/time/capture-tiecap.yaml | 53 +++++++++++++++++++
> 1 file changed, 53 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/iio/time/capture-tiecap.yaml
>

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
./Documentation/devicetree/bindings/iio/time/capture-tiecap.yaml: $id: relative path/filename doesn't match actual path or filename
expected: http://devicetree.org/schemas/iio/time/capture-tiecap.yaml#
Error: Documentation/devicetree/bindings/iio/time/capture-tiecap.example.dts:24.27-28 syntax error
FATAL ERROR: Unable to parse input tree
make[1]: *** [scripts/Makefile.lib:383: Documentation/devicetree/bindings/iio/time/capture-tiecap.example.dtb] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1404: dt_binding_check] Error 2

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/patch/

This check can fail if there are any dependencies. The base for a patch
series is generally the most recent rc1.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit.