Lines Matching full:counter

4 Generic Counter Interface
10 Counter devices are prevalent among a diverse spectrum of industries.
13 resolve the issue of duplicate code found among existing counter device
14 drivers by introducing a generic counter interface for consumption. The
15 Generic Counter interface enables drivers to support and expose a common
16 set of components and functionality present in counter devices.
21 Counter devices can vary greatly in design, but regardless of whether
23 counter devices consist of a core set of components. This core set of
24 components, shared by all counter devices, is what forms the essence of
25 the Generic Counter interface.
27 There are three core components to a counter:
30 Stream of data to be evaluated by the counter.
41 evaluated by the counter to determine the count data; e.g. a quadrature
42 signal output line of a rotary encoder. Not all counter devices provide
45 When the Signal data is available for user access, the Generic Counter
64 count data. The Generic Counter interface provides the following
80 A counter is defined as a set of input signals associated with count
83 context of the Generic Counter interface, a counter consists of Counts
94 Counter interface represents the count data as a natural number.
97 for the count data. The Generic Counter interface provides the following
143 The most basic counter device may be expressed as a single Count
145 a counter device which simply accumulates a count of rising edges on a
161 voltage input line. In summary, the counter device existence and
166 A counter device is not limited to a single Signal; in fact, in theory
168 quadrature encoder counter device can keep track of position based on
188 encoder counter device; the Count, Signals, and Synapses simply
192 mode conditions. For example, a quadrature encoder counter device
220 respective physical sources. This allows the user of a counter to
229 Driver authors may utilize the Generic Counter interface in their code
230 by including the include/linux/counter.h header file. This header file
232 for defining a counter device.
234 .. kernel-doc:: include/linux/counter.h
237 .. kernel-doc:: drivers/counter/counter-core.c
240 .. kernel-doc:: drivers/counter/counter-chrdev.c
246 To support a counter device, a driver must first allocate the available
247 Counter Signals via counter_signal structures. These Signals should
249 allocated counter_device structure before the Counter is registered to
252 Counter Counts may be allocated via counter_count structures, and
253 respective Counter Signal associations (Synapses) made via
258 before the Counter is registered to the system.
271 The struct counter_comp structure is used to define counter extensions
276 "``*_write``" members can then be set by the counter device driver with
282 the provided macros for standard Counter subsystem attributes in order
283 to maintain a consistent interface for userspace. For example, a counter
304 int count_direction_read(struct counter_device *counter,
307 int count_enable_read(struct counter_device *counter,
309 int count_enable_write(struct counter_device *counter,
311 int count_ceiling_read(struct counter_device *counter,
313 int count_ceiling_write(struct counter_device *counter,
324 /sys/bus/counter/devices/counterX/signalY/invert
332 /sys/bus/counter/devices/counterX/countY/enable
340 /sys/bus/counter/devices/counterX/error_overtemp
345 Counter drivers pass and take data natively (i.e. ``u8``, ``u64``, etc.)
346 and the shared counter module handles the translation between the sysfs
348 counter drivers, and enables a Generic Counter chrdev interface via a
351 A high-level view of how a count value is passed down from a counter
353 registered to the Counter core component for use by the Counter
359 | Counter device driver |
370 | Counter core |
385 | Counter sysfs | | Counter chrdev |
388 | standard Counter | | standard Counter |
392 Thereafter, data can be transferred directly between the Counter device
393 driver and Counter userspace interface::
398 / Counter device \
409 | Counter device driver |
425 | Counter sysfs | | Counter chrdev |
428 | standard Counter | | standard Counter |
448 | `/sys/bus/counter/devices/counterX/countY/count` |
455 Counter device driver
457 Communicates with the hardware device to read/write data; e.g. counter
460 Counter core
462 Registers the counter device driver to the system so that the respective
465 Counter sysfs
467 Translates counter data to the standard Counter sysfs interface format
470 Please refer to the ``Documentation/ABI/testing/sysfs-bus-counter`` file
471 for a detailed breakdown of the available Generic Counter interface
474 Counter chrdev
476 Translates Counter events to the standard Counter character device; data
477 is transferred via standard character device read calls, while Counter
483 Several sysfs attributes are generated by the Generic Counter interface,
484 and reside under the ``/sys/bus/counter/devices/counterX`` directory,
485 where ``X`` is to the respective counter device id. Please see
486 ``Documentation/ABI/testing/sysfs-bus-counter`` for detailed information
487 on each Generic Counter interface sysfs attribute.
490 the Generic Counter paradigm Counts, Signals, and Synapses of respective
491 counter devices.
493 Counter Character Device
496 Counter character device nodes are created under the ``/dev`` directory
497 as ``counterX``, where ``X`` is the respective counter device id.
498 Defines for the standard Counter data types are exposed via the
499 userspace ``include/uapi/linux/counter.h`` file.
501 Counter events
503 Counter device drivers can support Counter events by utilizing the
506 void counter_push_event(struct counter_device *const counter, const u8 event,
511 called, the Counter data associated with the respective event is
515 Counter events can be configured by users to report various Counter
516 data of interest. This can be conceptualized as a list of Counter
535 When ``counter_push_event(counter, COUNTER_EVENT_INDEX, 1)`` is called
544 Userspace applications can configure Counter events via ioctl operations
545 on the Counter character device node. There following ioctl codes are
546 supported and provided by the ``linux/counter.h`` userspace header file:
554 To configure events to gather Counter data, users first populate a
556 and the information for the desired Counter component from which to
560 Note that an event can be watched without gathering Counter data by
562 ``COUNTER_COMPONENT_NONE``. With this configuration the Counter
567 The ``COUNTER_ADD_WATCH_IOCTL`` command will buffer these Counter
569 may be used to activate these Counter watches.
572 calling ``poll`` first) on the Counter character device node to retrieve