Skip to contentSkip to conversation

counter: new TI eQEP driver

PATCH In review David Lechner 7 participants 15 messages Sep 1, 2019 – Oct 17, 2019

Subsystems (5)
Device tree bindings IIO PWM Counter +1 more subsystems
lore
Share & tools
lore

David Lechner

author reviewer
#0 lore raw

v3 cover counter: new TI eQEP driver

This series adds device tree bindings and a new counter driver for the Texas Instruments Enhanced Quadrature Encoder Pulse (eQEP).

As mentioned in one of the commit messages, to start with, the driver only supports reading the current counter value and setting the min/max values. Other features can be added as the counter subsystem gains support for them.

v3 changes:
- Minor changes to device tree bindings (style and generic node name)
- Drop action in initializer
- Fix ordering of pm runtime disable
v2 changes:
- New patch to move TI PWMSS driver from drivers/pwm/ to drivers/bus/
- Device tree bindings converted to .yaml format
- Device tree clock renamed from "fck" to "sysclkout"
- Dropped unused index and strobe signals from counter driver
- Added synapses and actions to counter driver
- Fixed base in of kstrtouint()
- Clarifications in commit messages

This series has been tested on a BeagleBone Blue with the following script:

#!/usr/bin/env python3

from os import path
from time import sleep

COUNTER_PATH = '/sys/bus/counter/devices'
COUNTERS = ['counter0', 'counter1', 'counter2']
COUNT0 = 'count0'
COUNT = 'count'
FUNCTION = 'function'
CEILING = 'ceiling'
FLOOR = 'floor'
ENABLE = 'enable'

cnts = []

for c in COUNTERS:
function_path = path.join(COUNTER_PATH, c, COUNT0, FUNCTION) with open(function_path, 'w') as f:
f.write('quadrature x4')
floor_path = path.join(COUNTER_PATH, c, COUNT0, FLOOR) with open(floor_path, 'w') as f:
f.write(str(0))
ceiling_path = path.join(COUNTER_PATH, c, COUNT0, CEILING) with open(ceiling_path, 'w') as f:
f.write(str(0xffffffff))
enable_path = path.join(COUNTER_PATH, c, COUNT0, ENABLE) with open(enable_path, 'w') as f:
f.write('1')

cnt_path = path.join(COUNTER_PATH, c, COUNT0, COUNT) cnts.append(open(cnt_path, 'r'))

while True:

    for c in cnts:
        c.seek(0)
        val = int(c.read())
        if val >= 0x80000000:
            val -= 0x100000000
        print(val, end=' ')
    print()
    sleep(1)

David Lechner (6):
bus/ti-pwmss: move TI PWMSS driver from PWM to bus subsystem
dt-bindings: counter: new bindings for TI eQEP
counter: new TI eQEP driver
ARM: dts: am33xx: Add nodes for eQEP
ARM: dts: am335x-boneblue: Enable eQEP
ARM: dts: am335x-boneblue: Use of am335x-osd335x-common.dtsi

 .../devicetree/bindings/counter/ti-eqep.yaml  |  50 ++
 MAINTAINERS                                   |   6 +
 arch/arm/boot/dts/am335x-boneblue.dts         | 146 +++---
 arch/arm/boot/dts/am33xx-l4.dtsi              |  27 +
 drivers/bus/Kconfig                           |   9 +
 drivers/bus/Makefile                          |   1 +
 drivers/{pwm/pwm-tipwmss.c => bus/ti-pwmss.c} |   0
 drivers/counter/Kconfig                       |  11 +
 drivers/counter/Makefile                      |   1 +
 drivers/counter/ti-eqep.c                     | 473 ++++++++++++++++++
 drivers/pwm/Kconfig                           |   9 -
 drivers/pwm/Makefile                          |   1 -
 12 files changed, 634 insertions(+), 100 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/counter/ti-eqep.yaml
 rename drivers/{pwm/pwm-tipwmss.c => bus/ti-pwmss.c} (100%)
 create mode 100644 drivers/counter/ti-eqep.c
Signature · 1 line
2.17.1
author reviewer
#1 lore raw

PATCH v3 1/6 bus/ti-pwmss: move TI PWMSS driver from PWM to bus subsystem

The TI PWMSS driver is a simple bus driver for providing power power management for the PWM peripherals on TI AM33xx SoCs, namely eCAP, eHRPWM and eQEP. The eQEP is a counter rather than a PWM, so it does not make sense to have the bus driver in the PWM subsystem since the PWMSS is not exclusive to PWM devices.

---

v3 changes:
- none
v2 changes:
- new patch

 drivers/bus/Kconfig                           | 9 +++++++++
 drivers/bus/Makefile                          | 1 +
 drivers/{pwm/pwm-tipwmss.c => bus/ti-pwmss.c} | 0
 drivers/pwm/Kconfig                           | 9 ---------
 drivers/pwm/Makefile                          | 1 -
 5 files changed, 10 insertions(+), 10 deletions(-)
 rename drivers/{pwm/pwm-tipwmss.c => bus/ti-pwmss.c} (100%)
drivers/bus/Kconfig +9 -0
index 1851112ccc29..4eeb15839ce0 100644
@@ -140,6 +140,15 @@ config TEGRA_GMI
 	  Driver for the Tegra Generic Memory Interface bus which can be used
 	  to attach devices such as NOR, UART, FPGA and more.
 
+config  TI_PWMSS
+	bool
+	default y if (ARCH_OMAP2PLUS) && (PWM_TIECAP || PWM_TIEHRPWM)
+	help
+	  PWM Subsystem driver support for AM33xx SOC.
+
+	  PWM submodules require PWM config space access from submodule
+	  drivers and require common parent driver support.
+
 config TI_SYSC
 	bool "TI sysc interconnect target module driver"
 	depends on ARCH_OMAP2PLUS
drivers/bus/Makefile +1 -0
index ca300b1914ce..a2d13cf4a877 100644
@@ -26,6 +26,7 @@ obj-$(CONFIG_SUNXI_RSB)		+= sunxi-rsb.o
 obj-$(CONFIG_SIMPLE_PM_BUS)	+= simple-pm-bus.o
 obj-$(CONFIG_TEGRA_ACONNECT)	+= tegra-aconnect.o
 obj-$(CONFIG_TEGRA_GMI)		+= tegra-gmi.o
+obj-$(CONFIG_TI_PWMSS)		+= ti-pwmss.o
 obj-$(CONFIG_TI_SYSC)		+= ti-sysc.o
 obj-$(CONFIG_TS_NBUS)		+= ts-nbus.o
 obj-$(CONFIG_UNIPHIER_SYSTEM_BUS)	+= uniphier-system-bus.o
drivers/bus/ti-pwmss.c renamed from drivers/pwm/pwm-tipwmss.c +0 -0
similarity index 100%
rename from drivers/pwm/pwm-tipwmss.c
rename to drivers/bus/ti-pwmss.c
drivers/pwm/Kconfig +0 -9
index a7e57516959e..300396564769 100644
@@ -497,15 +497,6 @@ config  PWM_TIEHRPWM
 	  To compile this driver as a module, choose M here: the module
 	  will be called pwm-tiehrpwm.
 
-config  PWM_TIPWMSS
-	bool
-	default y if (ARCH_OMAP2PLUS) && (PWM_TIECAP || PWM_TIEHRPWM)
-	help
-	  PWM Subsystem driver support for AM33xx SOC.
-
-	  PWM submodules require PWM config space access from submodule
-	  drivers and require common parent driver support.
-
 config PWM_TWL
 	tristate "TWL4030/6030 PWM support"
 	depends on TWL4030_CORE
drivers/pwm/Makefile +0 -1
index 76b555b51887..f67eb6e9294d 100644
@@ -49,7 +49,6 @@ obj-$(CONFIG_PWM_SUN4I)		+= pwm-sun4i.o
 obj-$(CONFIG_PWM_TEGRA)		+= pwm-tegra.o
 obj-$(CONFIG_PWM_TIECAP)	+= pwm-tiecap.o
 obj-$(CONFIG_PWM_TIEHRPWM)	+= pwm-tiehrpwm.o
-obj-$(CONFIG_PWM_TIPWMSS)	+= pwm-tipwmss.o
 obj-$(CONFIG_PWM_TWL)		+= pwm-twl.o
 obj-$(CONFIG_PWM_TWL_LED)	+= pwm-twl-led.o
 obj-$(CONFIG_PWM_VT8500)	+= pwm-vt8500.o
Signature · 1 line
2.17.1
Acked-by on v3 1/6
#2 lore raw

Re: [PATCH v3 1/6] bus/ti-pwmss: move TI PWMSS driver from PWM to bus subsystem

Quoted 14 lines · David Lechner

The TI PWMSS driver is a simple bus driver for providing power power management for the PWM peripherals on TI AM33xx SoCs, namely eCAP, eHRPWM and eQEP. The eQEP is a counter rather than a PWM, so it does not make sense to have the bus driver in the PWM subsystem since the PWMSS is not exclusive to PWM devices.

---

v3 changes:
- none
v2 changes:
- new patch

Quoted 7 lines
 drivers/bus/Kconfig                           | 9 +++++++++
 drivers/bus/Makefile                          | 1 +
 drivers/{pwm/pwm-tipwmss.c => bus/ti-pwmss.c} | 0
 drivers/pwm/Kconfig                           | 9 ---------
 drivers/pwm/Makefile                          | 1 -
 5 files changed, 10 insertions(+), 10 deletions(-)
 rename drivers/{pwm/pwm-tipwmss.c => bus/ti-pwmss.c} (100%)
#3 lore raw

Re: [PATCH v3 1/6] bus/ti-pwmss: move TI PWMSS driver from PWM to bus subsystem

Quoted 23 lines · On Mon, 2 Sep 2019 17:02:45 +0200 Thierry Reding <[email protected]>…
Quoted 14 lines · David Lechner

The TI PWMSS driver is a simple bus driver for providing power power management for the PWM peripherals on TI AM33xx SoCs, namely eCAP, eHRPWM and eQEP. The eQEP is a counter rather than a PWM, so it does not make sense to have the bus driver in the PWM subsystem since the PWMSS is not exclusive to PWM devices.

---

v3 changes:
- none
v2 changes:
- new patch

Quoted 7 lines
 drivers/bus/Kconfig                           | 9 +++++++++
 drivers/bus/Makefile                          | 1 +
 drivers/{pwm/pwm-tipwmss.c => bus/ti-pwmss.c} | 0
 drivers/pwm/Kconfig                           | 9 ---------
 drivers/pwm/Makefile                          | 1 -
 5 files changed, 10 insertions(+), 10 deletions(-)
 rename drivers/{pwm/pwm-tipwmss.c => bus/ti-pwmss.c} (100%)  
Quoted 1 line

Do we need an immutable branch for these precursor patches to the driver addition? It's not going to make 5.4 via my tree as cutting it too fine so we'll be in the position of holding these in a non obvious tree for a whole cycle.

Thanks,

Jonathan

#4 lore raw

Re: [PATCH v3 1/6] bus/ti-pwmss: move TI PWMSS driver from PWM to bus subsystem

Quoted 26 lines · Jonathan Cameron
Quoted 23 lines · On Mon, 2 Sep 2019 17:02:45 +0200 Thierry Reding <[email protected]>…
Quoted 21 lines · David Lechner

The TI PWMSS driver is a simple bus driver for providing power power management for the PWM peripherals on TI AM33xx SoCs, namely eCAP, eHRPWM and eQEP. The eQEP is a counter rather than a PWM, so it does not make sense to have the bus driver in the PWM subsystem since the PWMSS is not exclusive to PWM devices.

---

v3 changes:
- none
v2 changes:
- new patch

 drivers/bus/Kconfig                           | 9 +++++++++
 drivers/bus/Makefile                          | 1 +
 drivers/{pwm/pwm-tipwmss.c => bus/ti-pwmss.c} | 0
 drivers/pwm/Kconfig                           | 9 ---------
 drivers/pwm/Makefile                          | 1 -
 5 files changed, 10 insertions(+), 10 deletions(-)
 rename drivers/{pwm/pwm-tipwmss.c => bus/ti-pwmss.c} (100%)  
Quoted 6 lines
Quoted 1 line

Do we need an immutable branch for these precursor patches to the driver addition? It's not going to make 5.4 via my tree as cutting it too fine so we'll be in the position of holding these in a non obvious tree for a whole cycle.

Sure an immutable branch would be nice in case of unlikely dts file conflicts. And yeah no need to try to rush to v5.4.

Regards,

Tony

maintainer
#5 lore raw

Re: [PATCH v3 1/6] bus/ti-pwmss: move TI PWMSS driver from PWM to bus subsystem

Quoted 34 lines · On Sun, 8 Sep 2019 12:44:48 -0700 Tony Lindgren <[email protected]> wrote:
Quoted 26 lines · Jonathan Cameron
Quoted 23 lines · On Mon, 2 Sep 2019 17:02:45 +0200 Thierry Reding <[email protected]>…
Quoted 21 lines · David Lechner

The TI PWMSS driver is a simple bus driver for providing power power management for the PWM peripherals on TI AM33xx SoCs, namely eCAP, eHRPWM and eQEP. The eQEP is a counter rather than a PWM, so it does not make sense to have the bus driver in the PWM subsystem since the PWMSS is not exclusive to PWM devices.

---

v3 changes:
- none
v2 changes:
- new patch

 drivers/bus/Kconfig                           | 9 +++++++++
 drivers/bus/Makefile                          | 1 +
 drivers/{pwm/pwm-tipwmss.c => bus/ti-pwmss.c} | 0
 drivers/pwm/Kconfig                           | 9 ---------
 drivers/pwm/Makefile                          | 1 -
 5 files changed, 10 insertions(+), 10 deletions(-)
 rename drivers/{pwm/pwm-tipwmss.c => bus/ti-pwmss.c} (100%)    
Quoted 6 lines
Quoted 1 line

Do we need an immutable branch for these precursor patches to the driver addition? It's not going to make 5.4 via my tree as cutting it too fine so we'll be in the position of holding these in a non obvious tree for a whole cycle.

Quoted 6 lines

Sure an immutable branch would be nice in case of unlikely dts file conflicts. And yeah no need to try to rush to v5.4.

Regards,

Tony

immutable branch created based on 5.4-rc1 at:
https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/log/?h=ib-ti-eqep-5.4-rc1

I'll pull it into IIO in a few minutes as have one more of these to do at the same time. Includes patches 1-4 of this series.

Thanks,

Jonathan

author reviewer
#6 lore raw

PATCH v3 2/6 dt-bindings: counter: new bindings for TI eQEP

In reply to David Lechner

This documents device tree binding for the Texas Instruments Enhanced Quadrature Encoder Pulse (eQEP) Module found in various TI SoCs.

---

v3 changes:
- fixed style issues
- fixed generic node name
- (was suggested to drop descriptions since there is only one interrupt and one clock, but I opted to keep them anyway)
v2 changes:
- convert to .yaml format
- rename clock to "sysclkout"

 .../devicetree/bindings/counter/ti-eqep.yaml  | 50 +++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/counter/ti-eqep.yaml
Documentation/devicetree/bindings/counter/ti-eqep.yaml new file +50 -0
new file mode 100644
index 000000000000..85f1ff83afe7
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/counter/ti-eqep.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Texas Instruments Enhanced Quadrature Encoder Pulse (eQEP) Module
+
+maintainers:
+  - David Lechner <[email protected]>
+
+properties:
+  compatible:
+    const: ti,am3352-eqep
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    description: The eQEP event interrupt
+    maxItems: 1
+
+  clocks:
+    description: The clock that determines the SYSCLKOUT rate for the eQEP
+      peripheral.
+    maxItems: 1
+
+  clock-names:
+    const: sysclkout
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+
+additionalProperties: false
+
+examples:
+  - |
+    eqep0: counter@180 {
+        compatible = "ti,am3352-eqep";
+        reg = <0x180 0x80>;
+        clocks = <&l4ls_gclk>;
+        clock-names = "sysclkout";
+        interrupts = <79>;
+    };
+
+...
Signature · 1 line
2.17.1
maintainer Reviewed-by on v3 2/6
#7 lore raw

Re: [PATCH v3 2/6] dt-bindings: counter: new bindings for TI eQEP

Quoted 15 lines · David Lechner

This documents device tree binding for the Texas Instruments Enhanced Quadrature Encoder Pulse (eQEP) Module found in various TI SoCs.

---

v3 changes:
- fixed style issues
- fixed generic node name
- (was suggested to drop descriptions since there is only one interrupt and one clock, but I opted to keep them anyway)
v2 changes:
- convert to .yaml format
- rename clock to "sysclkout"

Quoted 4 lines
 .../devicetree/bindings/counter/ti-eqep.yaml  | 50 +++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/counter/ti-eqep.yaml
author reviewer
#8 lore raw

PATCH v3 3/6 counter: new TI eQEP driver

In reply to David Lechner

This adds a new counter driver for the Texas Instruments Enhanced Quadrature Encoder Pulse (eQEP) module.

Only very basic functionality is currently implemented - only enough to be able to read the position. The actual device has many more features which can be added to the driver on an as-needed basis.

It is not possible to read the QEPA/B signal values in hardware, so that feature is omitted.

The TI_PWMSS kernel option is selected in Kconfig to enable the parent bus, which is needed for power management.

---

v3 changes:
- Fixed ordering of pm runtime disable
- Added comment explaining where pm runtime is handled
- Dropped initialization of .action in ti_eqep_position_synapses v2 changes:
- Dropped unused index and strobe signals
- Added synapses and actions
- Fixed base in of kstrtouint()
- Clarifications in commit message

 MAINTAINERS               |   6 +
 drivers/bus/Kconfig       |   2 +-
 drivers/counter/Kconfig   |  11 +
 drivers/counter/Makefile  |   1 +
 drivers/counter/ti-eqep.c | 473 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 492 insertions(+), 1 deletion(-)
 create mode 100644 drivers/counter/ti-eqep.c
MAINTAINERS +6 -0
index 783569e3c4b4..53c28d52964c 100644
@@ -16014,6 +16014,12 @@ S:	Maintained
 F:	drivers/media/platform/davinci/
 F:	include/media/davinci/
 
+TI ENHANCED QUADRATURE ENCODER PULSE (eQEP) DRIVER
+R:	David Lechner <[email protected]>
+L:	[email protected]
+F:	Documentation/devicetree/bindings/counter/ti-eqep.yaml
+F:	drivers/counter/ti-eqep.c
+
 TI ETHERNET SWITCH DRIVER (CPSW)
 R:	Grygorii Strashko <[email protected]>
 L:	[email protected]
drivers/bus/Kconfig +1 -1
index 4eeb15839ce0..04db7fce4604 100644
@@ -142,7 +142,7 @@ config TEGRA_GMI
 
 config  TI_PWMSS
 	bool
-	default y if (ARCH_OMAP2PLUS) && (PWM_TIECAP || PWM_TIEHRPWM)
+	default y if (ARCH_OMAP2PLUS) && (PWM_TIECAP || PWM_TIEHRPWM || TI_EQEP)
 	help
 	  PWM Subsystem driver support for AM33xx SOC.
 
drivers/counter/Kconfig +11 -0
index 2967d0a9ff91..c80fa76bb531 100644
@@ -49,6 +49,17 @@ config STM32_LPTIMER_CNT
 	  To compile this driver as a module, choose M here: the
 	  module will be called stm32-lptimer-cnt.
 
+config TI_EQEP
+	tristate "TI eQEP counter driver"
+	depends on (SOC_AM33XX || COMPILE_TEST)
+	select REGMAP_MMIO
+	help
+	  Select this option to enable the Texas Instruments Enhanced Quadrature
+	  Encoder Pulse (eQEP) counter driver.
+
+	  To compile this driver as a module, choose M here: the module will be
+	  called ti-eqep.
+
 config FTM_QUADDEC
 	tristate "Flex Timer Module Quadrature decoder driver"
 	depends on HAS_IOMEM && OF
drivers/counter/Makefile +1 -0
index 40d35522937d..55142d1f4c43 100644
@@ -8,4 +8,5 @@ obj-$(CONFIG_COUNTER) += counter.o
 obj-$(CONFIG_104_QUAD_8)	+= 104-quad-8.o
 obj-$(CONFIG_STM32_TIMER_CNT)	+= stm32-timer-cnt.o
 obj-$(CONFIG_STM32_LPTIMER_CNT)	+= stm32-lptimer-cnt.o
+obj-$(CONFIG_TI_EQEP)		+= ti-eqep.o
 obj-$(CONFIG_FTM_QUADDEC)	+= ftm-quaddec.o
drivers/counter/ti-eqep.c new file +473 -0

473 lines not on this page · raw message

Signature · 1 line
2.17.1
author reviewer
#9 lore raw

PATCH v3 4/6 ARM: dts: am33xx: Add nodes for eQEP

In reply to David Lechner

This adds new nodes for the Texas Instruments Enhanced Quadrature Encoder Pulse (eQEP) module in the PWM subsystem on AM33XX.

---

v3 changes:
- rename eqep@ to counter@
v2 changes:
- clocks renamed to "sysclkout"

 arch/arm/boot/dts/am33xx-l4.dtsi | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
arch/arm/boot/dts/am33xx-l4.dtsi +27 -0
index 3b1fb2ba4dff..8dd5fd9eb862 100644
@@ -1908,6 +1908,15 @@
 					status = "disabled";
 				};
 
+				eqep0: counter@180 {
+					compatible = "ti,am3352-eqep";
+					reg = <0x180 0x80>;
+					clocks = <&l4ls_gclk>;
+					clock-names = "sysclkout";
+					interrupts = <79>;
+					status = "disabled";
+				};
+
 				ehrpwm0: pwm@200 {
 					compatible = "ti,am3352-ehrpwm",
 						     "ti,am33xx-ehrpwm";
@@ -1961,6 +1970,15 @@
 					status = "disabled";
 				};
 
+				eqep1: counter@180 {
+					compatible = "ti,am3352-eqep";
+					reg = <0x180 0x80>;
+					clocks = <&l4ls_gclk>;
+					clock-names = "sysclkout";
+					interrupts = <88>;
+					status = "disabled";
+				};
+
 				ehrpwm1: pwm@200 {
 					compatible = "ti,am3352-ehrpwm",
 						     "ti,am33xx-ehrpwm";
@@ -2014,6 +2032,15 @@
 					status = "disabled";
 				};
 
+				eqep2: counter@180 {
+					compatible = "ti,am3352-eqep";
+					reg = <0x180 0x80>;
+					clocks = <&l4ls_gclk>;
+					clock-names = "sysclkout";
+					interrupts = <89>;
+					status = "disabled";
+				};
+
 				ehrpwm2: pwm@200 {
 					compatible = "ti,am3352-ehrpwm",
 						     "ti,am33xx-ehrpwm";
Signature · 1 line
2.17.1
author reviewer
#10 lore raw

PATCH v3 5/6 ARM: dts: am335x-boneblue: Enable eQEP

In reply to David Lechner

This enables the Enhanced Quadrature Encoder Pulse (eQEP) module for connectors E1, E2 and E3 on BeagleBone Blue.

---

v3 changes:
- none
v2 changes:
- none

 arch/arm/boot/dts/am335x-boneblue.dts | 54 +++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
arch/arm/boot/dts/am335x-boneblue.dts +54 -0
index 0257576d5d16..df3978ce061c 100644
@@ -258,6 +258,30 @@
 			AM33XX_PADCONF(AM335X_PIN_MII1_RXD0, PIN_OUTPUT, MUX_MODE7)		/* (M16) gmii1_rxd0.gpio2[21] */
 		>;
 	};
+
+	/* E1 */
+	eqep0_pins: pinmux_eqep0_pins {
+		pinctrl-single,pins = <
+			AM33XX_PADCONF(AM335X_PIN_MCASP0_AXR0, PIN_INPUT, MUX_MODE1)		/* (B12) mcasp0_aclkr.eQEP0A_in */
+			AM33XX_PADCONF(AM335X_PIN_MCASP0_FSR, PIN_INPUT, MUX_MODE1)		/* (C13) mcasp0_fsr.eQEP0B_in */
+		>;
+	};
+
+	/* E2 */
+	eqep1_pins: pinmux_eqep1_pins {
+		pinctrl-single,pins = <
+			AM33XX_PADCONF(AM335X_PIN_LCD_DATA12, PIN_INPUT, MUX_MODE2)		/* (V2) lcd_data12.eQEP1A_in */
+			AM33XX_PADCONF(AM335X_PIN_LCD_DATA13, PIN_INPUT, MUX_MODE2)		/* (V3) lcd_data13.eQEP1B_in */
+		>;
+	};
+
+	/* E3 */
+	eqep2_pins: pinmux_eqep2_pins {
+		pinctrl-single,pins = <
+			AM33XX_PADCONF(AM335X_PIN_GPMC_AD12, PIN_INPUT, MUX_MODE4)		/* (T12) gpmc_ad12.eQEP2A_in */
+			AM33XX_PADCONF(AM335X_PIN_GPMC_AD13, PIN_INPUT, MUX_MODE4)		/* (R12) gpmc_ad13.eQEP2B_in */
+		>;
+	};
 };
 
 &uart0 {
@@ -530,3 +554,33 @@
 		line-name = "LS_BUF_EN";
 	};
 };
+
+&epwmss0 {
+	status = "okay";
+};
+
+&eqep0 {
+	status = "okay";
+	pinctrl-names = "default";
+	pinctrl-0 = <&eqep0_pins>;
+};
+
+&epwmss1 {
+	status = "okay";
+};
+
+&eqep1 {
+	status = "okay";
+	pinctrl-names = "default";
+	pinctrl-0 = <&eqep1_pins>;
+};
+
+&epwmss2 {
+	status = "okay";
+};
+
+&eqep2 {
+	status = "okay";
+	pinctrl-names = "default";
+	pinctrl-0 = <&eqep2_pins>;
+};
Signature · 1 line
2.17.1
author reviewer
#11 lore raw
In reply to David Lechner
Quoted 3 lines · David Lechner

This series adds device tree bindings and a new counter driver for the Texas Instruments Enhanced Quadrature Encoder Pulse (eQEP).

...

Quoted 8 lines

David Lechner (6):
bus/ti-pwmss: move TI PWMSS driver from PWM to bus subsystem
dt-bindings: counter: new bindings for TI eQEP
counter: new TI eQEP driver
ARM: dts: am33xx: Add nodes for eQEP
ARM: dts: am335x-boneblue: Enable eQEP
ARM: dts: am335x-boneblue: Use of am335x-osd335x-common.dtsi

In case anyone notices, this series only has 5 patches, not 6. "ARM: dts:
am335x-boneblue: Use of am335x-osd335x-common.dtsi" is unrelated and was submitted separately.

#12 lore raw
In reply to David Lechner
Quoted 73 lines · David Lechner

This series adds device tree bindings and a new counter driver for the Texas Instruments Enhanced Quadrature Encoder Pulse (eQEP).

As mentioned in one of the commit messages, to start with, the driver only supports reading the current counter value and setting the min/max values. Other features can be added as the counter subsystem gains support for them.

v3 changes:
- Minor changes to device tree bindings (style and generic node name)
- Drop action in initializer
- Fix ordering of pm runtime disable
v2 changes:
- New patch to move TI PWMSS driver from drivers/pwm/ to drivers/bus/
- Device tree bindings converted to .yaml format
- Device tree clock renamed from "fck" to "sysclkout"
- Dropped unused index and strobe signals from counter driver
- Added synapses and actions to counter driver
- Fixed base in of kstrtouint()
- Clarifications in commit messages

This series has been tested on a BeagleBone Blue with the following script:

#!/usr/bin/env python3

from os import path
from time import sleep

COUNTER_PATH = '/sys/bus/counter/devices'
COUNTERS = ['counter0', 'counter1', 'counter2']
COUNT0 = 'count0'
COUNT = 'count'
FUNCTION = 'function'
CEILING = 'ceiling'
FLOOR = 'floor'
ENABLE = 'enable'

cnts = []

for c in COUNTERS:
function_path = path.join(COUNTER_PATH, c, COUNT0, FUNCTION) with open(function_path, 'w') as f:
f.write('quadrature x4')
floor_path = path.join(COUNTER_PATH, c, COUNT0, FLOOR) with open(floor_path, 'w') as f:
f.write(str(0))
ceiling_path = path.join(COUNTER_PATH, c, COUNT0, CEILING) with open(ceiling_path, 'w') as f:
f.write(str(0xffffffff))
enable_path = path.join(COUNTER_PATH, c, COUNT0, ENABLE) with open(enable_path, 'w') as f:
f.write('1')

cnt_path = path.join(COUNTER_PATH, c, COUNT0, COUNT) cnts.append(open(cnt_path, 'r'))

while True:

    for c in cnts:
        c.seek(0)
        val = int(c.read())
        if val >= 0x80000000:
            val -= 0x100000000
        print(val, end=' ')
    print()
    sleep(1)

David Lechner (6):
bus/ti-pwmss: move TI PWMSS driver from PWM to bus subsystem
dt-bindings: counter: new bindings for TI eQEP
counter: new TI eQEP driver
ARM: dts: am33xx: Add nodes for eQEP
ARM: dts: am335x-boneblue: Enable eQEP
ARM: dts: am335x-boneblue: Use of am335x-osd335x-common.dtsi

Quoted 19 lines
 .../devicetree/bindings/counter/ti-eqep.yaml  |  50 ++
 MAINTAINERS                                   |   6 +
 arch/arm/boot/dts/am335x-boneblue.dts         | 146 +++---
 arch/arm/boot/dts/am33xx-l4.dtsi              |  27 +
 drivers/bus/Kconfig                           |   9 +
 drivers/bus/Makefile                          |   1 +
 drivers/{pwm/pwm-tipwmss.c => bus/ti-pwmss.c} |   0
 drivers/counter/Kconfig                       |  11 +
 drivers/counter/Makefile                      |   1 +
 drivers/counter/ti-eqep.c                     | 473 ++++++++++++++++++
 drivers/pwm/Kconfig                           |   9 -
 drivers/pwm/Makefile                          |   1 -
 12 files changed, 634 insertions(+), 100 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/counter/ti-eqep.yaml
 rename drivers/{pwm/pwm-tipwmss.c => bus/ti-pwmss.c} (100%)
 create mode 100644 drivers/counter/ti-eqep.c
Signature · 1 line
2.17.1

I'm satisfied with this version of the patchset.

Jonathan, if you have no objections please pick up this up so that it can make it to the 5.4 merge window coming in soon. Alternatively, I can merge it into my repository instead and hold it for a while longer there, if you prefer that route.

Thank you,

William Breathitt Gray

Acked-by
#13 lore raw
Quoted 7 lines · William Breathitt Gray
Quoted 6 lines · David Lechner

This series adds device tree bindings and a new counter driver for the Texas Instruments Enhanced Quadrature Encoder Pulse (eQEP).

As mentioned in one of the commit messages, to start with, the driver only supports reading the current counter value and setting the min/max values. Other features can be added as the counter subsystem gains support for them.

...

Quoted 8 lines

I'm satisfied with this version of the patchset.

Jonathan, if you have no objections please pick up this up so that it can make it to the 5.4 merge window coming in soon. Alternatively, I can merge it into my repository instead and hold it for a while longer there, if you prefer that route.

Looks good to me too:

maintainer
#14 lore raw
Quoted 14 lines · On Thu, 5 Sep 2019 07:10:53 -0700 Tony Lindgren <[email protected]> wrote:
Quoted 7 lines · William Breathitt Gray
Quoted 6 lines · David Lechner

This series adds device tree bindings and a new counter driver for the Texas Instruments Enhanced Quadrature Encoder Pulse (eQEP).

As mentioned in one of the commit messages, to start with, the driver only supports reading the current counter value and setting the min/max values. Other features can be added as the counter subsystem gains support for them.

...

Quoted 4 lines

I'm satisfied with this version of the patchset.

Quoted 8 lines
Quoted 4 lines

Jonathan, if you have no objections please pick up this up so that it can make it to the 5.4 merge window coming in soon. Alternatively, I can merge it into my repository instead and hold it for a while longer there, if you prefer that route.

Looks good to me too:

Sorry, too close to the likely opening of the 5.4 merge window for it to go via IIO this cycle (unless there is a significant delay for some reason!) I'm happy to queue it up for 5.5 but before I do this, see replies to patch 1 about whether an immutable branch is needed as we are going across multiple trees.

Thanks,

Jonathan