All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <felipe.balbi@linux.intel.com>
To: William Breathitt Gray <vilhelm.gray@gmail.com>
Cc: linux-iio@vger.kernel.org
Subject: Re: [RFC/PATCH] counter: introduce support for Intel QEP Encoder
Date: Tue, 17 Sep 2019 15:07:40 +0300	[thread overview]
Message-ID: <87a7b3ceib.fsf@gmail.com> (raw)
In-Reply-To: <20190917114403.GA8368@icarus>

[-- Attachment #1: Type: text/plain, Size: 6312 bytes --]


Hi William,

William Breathitt Gray <vilhelm.gray@gmail.com> writes:

> On Mon, Sep 16, 2019 at 12:34:31PM +0300, Felipe Balbi wrote:
>> Add support for Intel PSE Quadrature Encoder
>> 
>> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
>> ---
>> 
>> Hi William,
>> 
>> Here's a first cut of the ported driver. Note that this is really an RFC as
>> there's still quite a bit I don't fully understand. I've left some of my old
>> sysfs files in there just to keep track of which features I'm still missing.
>
> Hi Felipe,

before anything, thanks for the extensive background on the ideas of the
framework :-) Much appreciated

> That is understandable since this is an RFC; I expect in your final
> version those sysfs files will be Counter subsystem extension
> attributes.
>
> For reference, the existing Counter subsystem attributes are documented
> in the Documentation/ABI/testing/sysfs-bus-counter file. If you have any
> new attributes specific to the Intel QEP driver, add them as a new
> Documentation/ABI/testing/sysfs-bus-counter-intel-qep file.

Will do, thanks

>> If understood this correctly, I should add noise filtering as a signal
>> extension, right? Same for Input Swap.
>
> Determining the type of extension to create is a matter of scope.
>
> * Signal extensions are attributes which expose information/control
>   specific to a Signal. These types of attributes will exist under a
>   Signal's directory in sysfs.
>
>   For example, if have an invert feature for a Signal, you can have a
>   Signal extension called "invert" that toggles that feature:
>   /sys/bus/counter/devices/counterX/signalY/invert
>
> * Count extensions are attributes which expose information/control
>   specific to a Count. These type of attributes will exist under a
>   Count's directory in sysfs.
>
>   For example, if you want to pause/unpause a Count from updating, you
>   could have a Count extension called "enable" that toggles such:
>   /sys/bus/counter/devices/counterX/countY/enable
>
> * Device extensions are attributes which expose information/control
>   non-specific to a particular Count or Signal. This is where you would
>   put your global features or other miscellanous functionality.
>
>   For example, if your device has an overtemp sensor, you could report
>   the chip overheated via a device extension called "error_overtemp":
>   /sys/bus/counter/devices/counterX/error_overtemp

This clarifies a lot of my doubts.

> I'm not very familiar with the Intel QEP features, so I'll need your
> help clarifying some of it for me. I'm assuming "noise filtering" is
> a feature you can enable per individual Signal (is this correct?). If
> so, then it would be implemented as a Signal extension, maybe as a
> /sys/bus/counter/devices/counterX/signalY/noise_filter_enable file.
> Otherwise, it would be a device attribute if it enables noise filtering
> over all Signals.

The device, at least as is right now, has a single counter. It's a bit
difficult to decide whether the noise filter is global or per count :-)
I'll assume it to be per count as that would allow extension in case a
future version comes out with more than one counter. What do you think?

> Is "Input Swap" swapping the Phase A and Phase B signal lines for each
> Count? If so, this would be a Count extension if you can configure it
> per Count; otherwise a device extension if it's globally enabled for all
> Counts.

Yeah, it swaps A and B signals. Again, with a single count, difficult to
decide on global vs per-count.

> If you're still having trouble figuring out which type of extension to
> use, give me a simple breakdown of the features you are trying to
> support with these attributes and I should be able to specify which type
> works best for each.
>  
>> How should we handle the reset mode of the device? And mode of operation?
>
> Is "reset mode" specifying the condition that causes a Count's count to
> be reset back to a value of 0? If so, I assume "index" means an active
> level on the index line will reset the count; does "maximum" mean the
> index line is ignored and the reset operation is simply activated once
> the ceiling is reached? As well, I'm assuming this is a global
> configuration for all counts.

This seems more logical to be global, yes. The other thing this QEP
controller has is that we can configure the maximum count value. By
default it's UINT_MAX (0xffffffff) but it could be less and that's
configurable. So I'm assuming I would have a "maximum_count" device
extension in this case.

> If my assumptions are correct here, then this behavior can be exposed
> by creating two device extensions: "preset" and "preset_enable"; these
> should be based on the existing two same-named Count attributes (see the
> Documentation/ABI/testing/sysfs-bus-counter file).
>
> * /sys/bus/counter/devices/counterX/preset
>   For the Intel QEP, this will be a read-only that always report "0".
>
> * /sys/bus/counter/devices/counterX/preset_enable
>   Assuming "maximum" is just equivalent to ignoring index, preset_enable
>   can toggle between the two modes as a simple boolean: "1" = "index"
>   and "0" = "maximum".

Understood. This will be nice from userspace point of view.

>   If I assumed incorrectly, please let me know and we can discuss the
>   possibility of a new attribute (perhaps "preset_mode").
>
> Take a look inside 104-quad-8.c to see how it handles index lines and
> reseting the counts; "preset" and "preset_enable" extensions are
> specified in the quad8_count_ext array.
>
>> If you have any ideas, let me know.
>> 
>> cheers
>
> Since I expect a good amount of this code to change once the extensions
> are added, I'll hold off on a more in-depth code review until we get it
> closer to what it'll actually look like. From skimming the code in this
> RFC, it seems like you have the core Counter subsystem functions and
> structures use correct, so I think it'll be the implementations of the
> extensions that we'll be focusing on.

Cool, thanks a lot. I'll start moving some more of those private sysfs
files to extensions.

Again, thanks for the background information. Helps a lot.

cheers

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2019-09-17 12:07 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-16  9:34 [RFC/PATCH] counter: introduce support for Intel QEP Encoder Felipe Balbi
2019-09-17 11:46 ` William Breathitt Gray
2019-09-17 12:07   ` Felipe Balbi [this message]
2019-09-17 13:02     ` William Breathitt Gray
2019-09-19  8:03   ` [RFC/PATCH 1/2] counter: add support for Quadrature x4 with swapped inputs Felipe Balbi
2019-09-19  8:03     ` [RFC/PATCHv2 2/2] counter: introduce support for Intel QEP Encoder Felipe Balbi
2019-09-22 23:35       ` William Breathitt Gray
2019-09-24  9:46         ` Felipe Balbi
2019-09-24 11:32           ` William Breathitt Gray
2019-09-24 11:35             ` Felipe Balbi
2019-10-01  9:32               ` [PATCH v3 1/2] counter: add support for Quadrature x4 with swapped inputs Felipe Balbi
2019-10-01  9:32                 ` [PATCH v3 2/2] counter: introduce support for Intel QEP Encoder Felipe Balbi
2019-10-02 18:11                   ` William Breathitt Gray
2019-10-02 16:37                 ` [PATCH v3 1/2] counter: add support for Quadrature x4 with swapped inputs William Breathitt Gray
2019-10-03 12:38             ` [RFC/PATCHv2 2/2] counter: introduce support for Intel QEP Encoder Jonathan Cameron
2019-09-24 21:46         ` David Lechner
2019-09-28 21:33           ` William Breathitt Gray
2019-09-30  5:22             ` Felipe Balbi
2019-10-02  0:34               ` William Breathitt Gray
2019-10-03 13:14                 ` Jonathan Cameron
2019-10-16 20:20                   ` William Breathitt Gray
2019-10-17 12:29                     ` Jonathan Cameron
2019-09-24 11:37     ` [RFC/PATCH 1/2] counter: add support for Quadrature x4 with swapped inputs William Breathitt Gray

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a7b3ceib.fsf@gmail.com \
    --to=felipe.balbi@linux.intel.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=vilhelm.gray@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.