Skip to contentSkip to conversation

Add IIO support for counter devices

PATCH Superseded William Breathitt Gray 2 participants 6 messages Sep 14, 2016 – Sep 15, 2016 IIO

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add IIO support for counter devices

Changes in v2:
- New IIO constants have been reduced to three: IIO_COUNT, IIO_INDEX, and IIO_CHAN_INFO_PRESET
- 104-QUAD-8 specific flags, modes, and configurations have been broken out and exposed via ext_info elements

This patchset adds new IIO channel type and info constants to facilitate support for counter devices. In addition, a new "counter" subdirectory is created to house drivers for these counter devices.

Quadrature encoders, such as rotary encoders and linear encoders, are devices which are capable of encoding the relative position and direction of motion of a shaft. This patch introduces the counter subdirectory and several IIO constants for supporting quadrature encoder counter devices.

IIO_COUNT: Current count (main data provided by the counter device)
IIO_INDEX: Set high when index input is at active level
IIO_CHAN_INFO_PRESET: Counter preset value

Specifically, this patchset introduces a driver to support the ACCES 104-QUAD-8 device, a general purpose quadrature encoder counter/interface board capable of monitoring the outputs of eight encoders.

William Breathitt Gray (2):
iio: Implement counter channel type and info constants
iio: 104-quad-8: Add IIO support for the ACCES 104-QUAD-8

 MAINTAINERS                      |   6 +
 drivers/iio/Kconfig              |   1 +
 drivers/iio/Makefile             |   1 +
 drivers/iio/counter/104-quad-8.c | 697 +++++++++++++++++++++++++++++++++++++++
 drivers/iio/counter/Kconfig      |  22 ++
 drivers/iio/counter/Makefile     |   7 +
 drivers/iio/industrialio-core.c  |   3 +
 include/linux/iio/iio.h          |   1 +
 include/uapi/linux/iio/types.h   |   2 +
 9 files changed, 740 insertions(+)
 create mode 100644 drivers/iio/counter/104-quad-8.c
 create mode 100644 drivers/iio/counter/Kconfig
 create mode 100644 drivers/iio/counter/Makefile
Signature · 1 line
2.7.3
#1 lore raw

PATCH v2 1/2 iio: Implement counter channel type and info constants

Quadrature encoders, such as rotary encoders and linear encoders, are devices which are capable of encoding the relative position and direction of motion of a shaft. This patch introduces the counter subdirectory and several IIO constants for supporting quadrature encoder counter devices.

IIO_COUNT: Current count (main data provided by the counter device)
IIO_INDEX: Set high when index input is at active level
IIO_CHAN_INFO_PRESET: Counter preset value

---
 drivers/iio/Kconfig             | 1 +
 drivers/iio/Makefile            | 1 +
 drivers/iio/counter/Kconfig     | 8 ++++++++
 drivers/iio/counter/Makefile    | 6 ++++++
 drivers/iio/industrialio-core.c | 3 +++
 include/linux/iio/iio.h         | 1 +
 include/uapi/linux/iio/types.h  | 2 ++
 7 files changed, 22 insertions(+)
 create mode 100644 drivers/iio/counter/Kconfig
 create mode 100644 drivers/iio/counter/Makefile
drivers/iio/Kconfig +1 -0
index 6743b18..574d1fb 100644
@@ -73,6 +73,7 @@ source "drivers/iio/adc/Kconfig"
 source "drivers/iio/amplifiers/Kconfig"
 source "drivers/iio/chemical/Kconfig"
 source "drivers/iio/common/Kconfig"
+source "drivers/iio/counter/Kconfig"
 source "drivers/iio/dac/Kconfig"
 source "drivers/iio/dummy/Kconfig"
 source "drivers/iio/frequency/Kconfig"
drivers/iio/Makefile +1 -0
index 87e4c43..77b2000 100644
@@ -18,6 +18,7 @@ obj-y += amplifiers/
 obj-y += buffer/
 obj-y += chemical/
 obj-y += common/
+obj-y += counter/
 obj-y += dac/
 obj-y += dummy/
 obj-y += gyro/
drivers/iio/counter/Kconfig new file +8 -0
new file mode 100644
index 0000000..95a7a0df
@@ -0,0 +1,8 @@
+#
+# Counter devices
+#
+# When adding new entries keep the list in alphabetical order
+
+menu "Counters"
+
+endmenu
drivers/iio/counter/Makefile new file +6 -0
new file mode 100644
index 0000000..c4dfa50
@@ -0,0 +1,6 @@
+#
+# Makefile for IIO counter devices
+#
+
+# When adding new entries keep the list in alphabetical order
+
drivers/iio/industrialio-core.c +3 -0
index 0528a0c..42d8c8b 100644
@@ -81,6 +81,8 @@ static const char * const iio_chan_type_name_spec[] = {
 	[IIO_PH] = "ph",
 	[IIO_UVINDEX] = "uvindex",
 	[IIO_ELECTRICALCONDUCTIVITY] = "electricalconductivity",
+	[IIO_COUNT] = "count",
+	[IIO_INDEX] = "index",
 };
 
 static const char * const iio_modifier_names[] = {
@@ -151,6 +153,7 @@ static const char * const iio_chan_info_postfix[] = {
 	[IIO_CHAN_INFO_DEBOUNCE_TIME] = "debounce_time",
 	[IIO_CHAN_INFO_CALIBEMISSIVITY] = "calibemissivity",
 	[IIO_CHAN_INFO_OVERSAMPLING_RATIO] = "oversampling_ratio",
+	[IIO_CHAN_INFO_PRESET] = "preset",
 };
 
 /**
include/linux/iio/iio.h +1 -0
index b4a0679..7dc86d1 100644
@@ -46,6 +46,7 @@ enum iio_chan_info_enum {
 	IIO_CHAN_INFO_DEBOUNCE_TIME,
 	IIO_CHAN_INFO_CALIBEMISSIVITY,
 	IIO_CHAN_INFO_OVERSAMPLING_RATIO,
+	IIO_CHAN_INFO_PRESET,
 };
 
 enum iio_shared_by {
include/uapi/linux/iio/types.h +2 -0
index 22e5e58..e54d14a 100644
@@ -40,6 +40,8 @@ enum iio_chan_type {
 	IIO_PH,
 	IIO_UVINDEX,
 	IIO_ELECTRICALCONDUCTIVITY,
+	IIO_COUNT,
+	IIO_INDEX,
 };
 
 enum iio_modifier {
Signature · 1 line
2.7.3
#5 lore raw

PATCH v2 2/2 iio: 104-quad-8: Add IIO support for the ACCES 104-QUAD-8

In reply to William Breathitt Gray

The ACCES 104-QUAD-8 is a general purpose quadrature encoder counter/interface board. The 104-QUAD-8 is capable of monitoring the outputs of eight encoders via four on-board LSI/CSI LS7266R1 24-bit dual-axis quadrature counter chips. Core functions handled by the LS7266R1, such as direction and total count, are available.

Performing a write to a counter's IIO_CHAN_INFO_RAW sets the counter and also clears the counter's respective clearable flags (BORROW, CARRY, COMPARE, SIGN, and ERROR). Interrupts are not supported by this driver.

This driver adds IIO support for the ACCES 104-QUAD-8 and ACCES 104-QUAD-4. The base port addresses for the devices may be configured via the base array module parameter.

---
 MAINTAINERS                      |   6 +
 drivers/iio/counter/104-quad-8.c | 697 +++++++++++++++++++++++++++++++++++++++
 drivers/iio/counter/Kconfig      |  14 +
 drivers/iio/counter/Makefile     |   1 +
 4 files changed, 718 insertions(+)
 create mode 100644 drivers/iio/counter/104-quad-8.c
MAINTAINERS +6 -0
index 6f0ff72..759a2ea 100644
@@ -255,6 +255,12 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/gpio/gpio-104-idio-16.c
 
+ACCES 104-QUAD-8 IIO DRIVER
+M:	William Breathitt Gray <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/iio/counter/104-quad-8.c
+
 ACENIC DRIVER
 M:	Jes Sorensen <[email protected]>
 L:	[email protected]
drivers/iio/counter/104-quad-8.c new file +697 -0

697 lines not on this page · raw message

drivers/iio/counter/Kconfig +14 -0
index 95a7a0df..887021e 100644
@@ -5,4 +5,18 @@
 
 menu "Counters"
 
+config 104_QUAD_8
+	tristate "ACCES 104-QUAD-8 driver"
+	depends on X86 && ISA_BUS_API
+	help
+	  Say yes here to build support for the ACCES 104-QUAD-8 quadrature
+	  encoder counter/interface device family (104-QUAD-8, 104-QUAD-4).
+
+	  Performing a write to a counter's IIO_CHAN_INFO_RAW sets the counter and
+	  also clears the counter's respective clearable flags (BORROW, CARRY,
+	  COMPARE, SIGN, and ERROR). Interrupts are not supported by this driver.
+
+	  The base port addresses for the devices may be configured via the base
+	  array module parameter.
+
 endmenu
drivers/iio/counter/Makefile +1 -0
index c4dfa50..007e884 100644
@@ -4,3 +4,4 @@
 
 # When adding new entries keep the list in alphabetical order
 
+obj-$(CONFIG_104_QUAD_8)	+= 104-quad-8.o
Signature · 1 line
2.7.3
#2 lore raw

Re: [PATCH v2 1/2] iio: Implement counter channel type and info constants

In reply to William Breathitt Gray
reproduce:

Hi William,

[auto build test ERROR on iio/togreg]
[also build test ERROR on v4.8-rc6 next-20160915]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information]

url:    https://github.com/0day-ci/linux/commits/William-Breathitt-Gray/Add-IIO-support-for-counter-devices/20160915-032651
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
config: x86_64-randconfig-s1-09151924 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

Note: the linux-review/William-Breathitt-Gray/Add-IIO-support-for-counter-devices/20160915-032651 HEAD 9dfaeb5dd7e5fffaedaaaa34c80c7790ed346b72 builds fine.
It only hurts bisectibility.

All errors (new ones prefixed by >>):

>> ld: cannot find drivers/iio/counter/built-in.o: No such file or directory

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#3 lore raw

Re: [PATCH v2 1/2] iio: Implement counter channel type and info constants

Quoted 19 lines · kbuild test robot

Hi William,

[auto build test ERROR on iio/togreg]
[also build test ERROR on v4.8-rc6 next-20160915]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information]

url:    https://github.com/0day-ci/linux/commits/William-Breathitt-Gray/Add-IIO-support-for-counter-devices/20160915-032651
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
config: x86_64-randconfig-s1-09151924 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
       # save the attached .config to linux build tree
       make ARCH=x86_64 

Note: the linux-review/William-Breathitt-Gray/Add-IIO-support-for-counter-devices/20160915-032651 HEAD 9dfaeb5dd7e5fffaedaaaa34c80c7790ed346b72 builds fine.
It only hurts bisectibility.

Quoted 7 lines

All errors (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

ld: cannot find drivers/iio/counter/built-in.o: No such file or directory

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

I moved the creation of the "counter" subdirectory to this first patch, but the 104-QUAD-8 driver is only added in the subsequent patch; effectively, the non-populated Makefile in this patch leads to the error.

I'll submit version 3 of this patchset with the "counter" subdirectory introduced in the same patch as the 104-QUAD-8 driver. That should resolve this issue.

William Breathitt Gray

#4 lore raw

Re: [PATCH v2 1/2] iio: Implement counter channel type and info constants

In reply to William Breathitt Gray
reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…

Hi William,

[auto build test ERROR on iio/togreg]
[also build test ERROR on v4.8-rc6 next-20160915]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information]

url:    https://github.com/0day-ci/linux/commits/William-Breathitt-Gray/Add-IIO-support-for-counter-devices/20160915-032651
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 5.4.0-6) 5.4.0 20160609

reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm

Note: the linux-review/William-Breathitt-Gray/Add-IIO-support-for-counter-devices/20160915-032651 HEAD 9dfaeb5dd7e5fffaedaaaa34c80c7790ed346b72 builds fine.
It only hurts bisectibility.

All errors (new ones prefixed by >>):

>> arm-linux-gnueabi-ld: cannot find drivers/iio/counter/built-in.o: No such file or directory

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation