Re: [PATCH 7/8] counter/ti-eqep: add support for edge capture unit

From: David Lechner
Date: Wed Oct 27 2021 - 13:28:54 EST


On 10/27/21 3:23 AM, William Breathitt Gray wrote:
On Sat, Oct 16, 2021 at 08:33:42PM -0500, David Lechner wrote:
This adds support for the Edge Capture Unit to the TI eQEP counter
driver. This just adds the minimum required features to measure speed
using the Unit Timer and the Edge Capture unit. Additional features can
be added in the future if needed.

This adds 4 new device-level attributes:
- edge_capture_unit_prescaler: selects a prescalar for the Counter count
coming into the Edge Capture Unit
- edge_capture_unit_max_period: selects the max time period that can be
measured by the Edge Capture Unit

What happens if a trigger occurs after the max period has elapsed; is
the latched period value invalid in that scenario?


This period is essentially selecting prescalars, so if we get rid of
the time aspect and treat everything as counts this will change a bit.

But the question is still valid. I don't recall off-hand what happens
so I will have to test it the next time I am working on this. It seems
though that I was able to somehow detect when this was the case.


- edge_capture_unit_latched_period: gets the period that was measured
when the event selected by the latch_mode attribute is triggered

Is this period value essentially the current latch count minus the
previous latch count?


No, the period is the amount of time that elapsed between counts.

static struct counter_comp ti_eqep_device_ext[] = {
+ COUNTER_COMP_DEVICE_BOOL("edge_capture_unit_enable",
+ ti_eqep_edge_capture_unit_enable_read,
+ ti_eqep_edge_capture_unit_enable_write),
+ COUNTER_COMP_DEVICE_U64("edge_capture_unit_latched_period",
+ ti_eqep_edge_capture_unit_latched_period_read,
+ NULL),
+ COUNTER_COMP_DEVICE_U64("edge_capture_unit_max_period",
+ ti_eqep_edge_capture_unit_max_period_read,
+ ti_eqep_edge_capture_unit_max_period_write),
+ COUNTER_COMP_DEVICE_ENUM("edge_capture_unit_prescaler",
+ ti_eqep_edge_capture_unit_prescaler_read,
+ ti_eqep_edge_capture_unit_prescaler_write,
+ ti_eqep_edge_capture_unit_prescaler_available),

Would it make sense for these to be Count 0 extensions so that they're
alongside the "latched_count" extension; or do these extensions also
represent values related to "latched_time" for the unit timer?


They are related to both.