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...
Modifications since v1:
- Fix yaml issues (id and example)
- Use regmap instead of writel/readl
- Enable/Disable clock explicitly
- Simplify power management (suspend/resume)
- Remove unnecessary using of ev_mode variable
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):
dt-binding: iio: time: add capture-tiecap.yaml
iio: time: capture-tiecap: capture driver support for ECAP
.../bindings/iio/time/capture-tiecap.yaml | 68 +++
drivers/iio/Kconfig | 1 +
drivers/iio/Makefile | 1 +
drivers/iio/time/Kconfig | 22 +
drivers/iio/time/Makefile | 6 +
drivers/iio/time/capture-tiecap.c | 521 ++++++++++++++++++
6 files changed, 619 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
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 | 68 +++++++++++++++++++
1 file changed, 68 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..5d66df90ba5d
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/time/capture-tiecap.yaml
@@ -0,0 +1,68 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/time/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:
+ - |
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+ #include <dt-bindings/soc/ti,sci_pm_domain.h>
+
+ soc {
+ #address-cells = <2>;
+ #size-cells = <2>;
+
+ bus@f0000 {
+ compatible = "simple-bus";
+ #address-cells = <2>;
+ #size-cells = <2>;
+ ranges = <0x00 0x20000000 0x00 0x20000000 0x00 0x0a008000>;
+
+ 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
On 28/07/2022 14:52, 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 | 68 +++++++++++++++++++
> 1 file changed, 68 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..5d66df90ba5d
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/time/capture-tiecap.yaml
> @@ -0,0 +1,68 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/iio/time/capture-tiecap.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
Still wrong file name.
Do not ignore comments you received. Either you implement them or you
keep the discussion going.
> +
> +title: Texas Instruments Enhanced Capture (eCAP) Module
> +
> +maintainers:
> + - Julien Panis <[email protected]>
> +
(...)
> +
> +examples:
> + - |
> + #include <dt-bindings/interrupt-controller/arm-gic.h>
> + #include <dt-bindings/soc/ti,sci_pm_domain.h>
> +
> + soc {
> + #address-cells = <2>;
> + #size-cells = <2>;
> +
> + bus@f0000 {
> + compatible = "simple-bus";
> + #address-cells = <2>;
> + #size-cells = <2>;
> + ranges = <0x00 0x20000000 0x00 0x20000000 0x00 0x0a008000>;
A bit too many nodes. Just keep one, bus or soc. Look at other examples.
Best regards,
Krzysztof
On 28/07/2022 15:38, Krzysztof Kozlowski wrote:
> On 28/07/2022 14:52, 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 | 68 +++++++++++++++++++
>> 1 file changed, 68 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..5d66df90ba5d
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/iio/time/capture-tiecap.yaml
>> @@ -0,0 +1,68 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/iio/time/capture-tiecap.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> Still wrong file name.
>
> Do not ignore comments you received. Either you implement them or you
> keep the discussion going.
Sorry, that was not intentional. I have prepared a new version which
takes into account your last comments.
Julien