mbox series

[v9,0/4] ECAP support on TI AM62x SoC

Message ID 20220923142437.271328-1-jpanis@baylibre.com (mailing list archive)
Headers show
Series ECAP support on TI AM62x SoC | expand

Message

Julien Panis Sept. 23, 2022, 2:24 p.m. UTC
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.

This driver leverages counter subsystem to :
- select edge polarity for all 4 capture events (event mode)
- log timestamps for each capture event
Event polarity, and CAP0/1/2/3 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...

This patchset must be applied on top of the following counter subsystem patchset :
https://lore.kernel.org/all/cover.1663693757.git.william.gray@linaro.org/

Modifications since v8 :
	- Add documentation to private driver structure
	- Add mutex to prevent IO race conditions
	- Stop counter before disabling interrupts in ecap_cnt_capture_disable() function
	- Remove returning of status in ecap_cnt_count_get/set_val() functions
	- Remove unnecessary 'return -EBUSY' in all callbacks
	- Remove unnecessary '.id = 0' in ecap_cnt_counts[]
	- Modify driver info in MAINTAINER file

Userspace commands :
	### CLOCK SIGNAL ###
	cd /sys/bus/counter/devices/counter0/signal0

	# Get frequency
	cat frequency

	### INPUT SIGNAL ###
	cd /sys/bus/counter/devices/counter0/signal1

	# Get polarity for each capture event
	cat polarity0
	cat polarity1
	cat polarity2
	cat polarity3

	# Set polarity for each capture event
	echo positive > polarity0
	echo negative > polarity1
	echo positive > polarity2
	echo negative > polarity3

	### COUNT ###
	cd /sys/bus/counter/devices/counter0/count0

	# Get ceiling (counter max value)
	cat ceiling

	# Reset number of overflows & current timebase counter value
	echo 0 > num_overflows
	echo 0 > count

	# Run ECAP
	echo 1 > enable

	# Get number of overflows & current timebase counter value
	cat num_overflows
	cat count

	# Get captured timestamps
	cat capture0
	cat capture1
	cat capture2
	cat capture3

	# Note that counter watches can also be used to get
	# data from userspace application
	# -> see tools/counter/counter_example.c

	# Pause ECAP
	echo 0 > enable

Julien Panis (4):
  dt-bindings: counter: add ti,am62-ecap-capture.yaml
  Documentation: ABI: sysfs-bus-counter: add frequency & num_overflows
    items
  counter: ti-ecap-capture: capture driver support for ECAP
  MAINTAINERS: add TI ECAP driver info

 Documentation/ABI/testing/sysfs-bus-counter   |  14 +
 .../counter/ti,am62-ecap-capture.yaml         |  61 ++
 MAINTAINERS                                   |   9 +
 drivers/counter/Kconfig                       |  15 +
 drivers/counter/Makefile                      |   1 +
 drivers/counter/ti-ecap-capture.c             | 614 ++++++++++++++++++
 6 files changed, 714 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/counter/ti,am62-ecap-capture.yaml
 create mode 100644 drivers/counter/ti-ecap-capture.c

Comments

William Breathitt Gray Sept. 23, 2022, 2:55 p.m. UTC | #1
On Fri, Sep 23, 2022 at 04:24:33PM +0200, Julien Panis wrote:
> 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.
> 
> This driver leverages counter subsystem to :
> - select edge polarity for all 4 capture events (event mode)
> - log timestamps for each capture event
> Event polarity, and CAP0/1/2/3 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...
> 
> This patchset must be applied on top of the following counter subsystem patchset :
> https://lore.kernel.org/all/cover.1663693757.git.william.gray@linaro.org/

Hello Julien,

Tentatively, this version looks good to me. Due to the amount of changes
we've made in the past week I'm going to let it sit on the list for a
while to give any lingering issues we missed a chance to be found. If
nothing pops up during that time, I expect to queue this next week and
hopefully include it with the other Counter changes in time for the 6.1
merge window.

By the way, in the future you can use the '--base' git format-patch
argument to specify the base commit (and any prereq patches) that your
series is based on: https://git-scm.com/docs/git-format-patch#_base_tree_information

That makes it clear to reviewers and maintainers where they should apply
your patchset, and should also prevent the kernel test robot from
testing against the wrong base.

William Breathitt Gray
William Breathitt Gray Sept. 27, 2022, 9:49 p.m. UTC | #2
On Fri, Sep 23, 2022 at 04:24:33PM +0200, Julien Panis wrote:
> 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.
> 
> This driver leverages counter subsystem to :
> - select edge polarity for all 4 capture events (event mode)
> - log timestamps for each capture event
> Event polarity, and CAP0/1/2/3 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...
> 
> This patchset must be applied on top of the following counter subsystem patchset :
> https://lore.kernel.org/all/cover.1663693757.git.william.gray@linaro.org/
> 
> Modifications since v8 :
> 	- Add documentation to private driver structure
> 	- Add mutex to prevent IO race conditions
> 	- Stop counter before disabling interrupts in ecap_cnt_capture_disable() function
> 	- Remove returning of status in ecap_cnt_count_get/set_val() functions
> 	- Remove unnecessary 'return -EBUSY' in all callbacks
> 	- Remove unnecessary '.id = 0' in ecap_cnt_counts[]
> 	- Modify driver info in MAINTAINER file
> 
> Userspace commands :
> 	### CLOCK SIGNAL ###
> 	cd /sys/bus/counter/devices/counter0/signal0
> 
> 	# Get frequency
> 	cat frequency
> 
> 	### INPUT SIGNAL ###
> 	cd /sys/bus/counter/devices/counter0/signal1
> 
> 	# Get polarity for each capture event
> 	cat polarity0
> 	cat polarity1
> 	cat polarity2
> 	cat polarity3
> 
> 	# Set polarity for each capture event
> 	echo positive > polarity0
> 	echo negative > polarity1
> 	echo positive > polarity2
> 	echo negative > polarity3
> 
> 	### COUNT ###
> 	cd /sys/bus/counter/devices/counter0/count0
> 
> 	# Get ceiling (counter max value)
> 	cat ceiling
> 
> 	# Reset number of overflows & current timebase counter value
> 	echo 0 > num_overflows
> 	echo 0 > count
> 
> 	# Run ECAP
> 	echo 1 > enable
> 
> 	# Get number of overflows & current timebase counter value
> 	cat num_overflows
> 	cat count
> 
> 	# Get captured timestamps
> 	cat capture0
> 	cat capture1
> 	cat capture2
> 	cat capture3
> 
> 	# Note that counter watches can also be used to get
> 	# data from userspace application
> 	# -> see tools/counter/counter_example.c
> 
> 	# Pause ECAP
> 	echo 0 > enable
> 
> Julien Panis (4):
>   dt-bindings: counter: add ti,am62-ecap-capture.yaml
>   Documentation: ABI: sysfs-bus-counter: add frequency & num_overflows
>     items
>   counter: ti-ecap-capture: capture driver support for ECAP
>   MAINTAINERS: add TI ECAP driver info
> 
>  Documentation/ABI/testing/sysfs-bus-counter   |  14 +
>  .../counter/ti,am62-ecap-capture.yaml         |  61 ++
>  MAINTAINERS                                   |   9 +
>  drivers/counter/Kconfig                       |  15 +
>  drivers/counter/Makefile                      |   1 +
>  drivers/counter/ti-ecap-capture.c             | 614 ++++++++++++++++++
>  6 files changed, 714 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/counter/ti,am62-ecap-capture.yaml
>  create mode 100644 drivers/counter/ti-ecap-capture.c
> 
> -- 
> 2.37.3

Queued for counter-next with a minor context adjustment for
sysfs-bus-counter changes.

Thanks,

William Breathitt Gray