mbox series

[v3,0/6] counter: new TI eQEP driver

Message ID 20190901225827.12301-1-david@lechnology.com
Headers show
Series counter: new TI eQEP driver | expand

Message

David Lechner Sept. 1, 2019, 10:58 p.m. UTC
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

Comments

David Lechner Sept. 2, 2019, 2:17 p.m. UTC | #1
On 9/1/19 5:58 PM, David Lechner wrote:
> This series adds device tree bindings and a new counter driver for the Texas
> Instruments Enhanced Quadrature Encoder Pulse (eQEP).
> 

...

> 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.
Thierry Reding Sept. 2, 2019, 3:02 p.m. UTC | #2
On Sun, Sep 01, 2019 at 05:58:22PM -0500, David Lechner wrote:
> 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.
> 
> Signed-off-by: David Lechner <david@lechnology.com>
> ---
> 
> 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%)

Acked-by: Thierry Reding <thierry.reding@gmail.com>
William Breathitt Gray Sept. 5, 2019, 1:37 p.m. UTC | #3
On Sun, Sep 01, 2019 at 05:58:21PM -0500, David Lechner wrote:
> 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
> 
> -- 
> 2.17.1

I'm satisfied with this version of the patchset.

Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>

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
Tony Lindgren Sept. 5, 2019, 2:10 p.m. UTC | #4
* William Breathitt Gray <vilhelm.gray@gmail.com> [190905 13:38]:
> On Sun, Sep 01, 2019 at 05:58:21PM -0500, David Lechner wrote:
> > 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.
...

> I'm satisfied with this version of the patchset.
> 
> Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
> 
> 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:

Acked-by: Tony Lindgren <tony@atomide.com>
Jonathan Cameron Sept. 8, 2019, 11:15 a.m. UTC | #5
On Mon, 2 Sep 2019 17:02:45 +0200
Thierry Reding <thierry.reding@gmail.com> wrote:

> On Sun, Sep 01, 2019 at 05:58:22PM -0500, David Lechner wrote:
> > 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.
> > 
> > Signed-off-by: David Lechner <david@lechnology.com>
> > ---
> > 
> > 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%)  
> 
> Acked-by: Thierry Reding <thierry.reding@gmail.com>

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
Jonathan Cameron Sept. 8, 2019, 11:16 a.m. UTC | #6
On Thu, 5 Sep 2019 07:10:53 -0700
Tony Lindgren <tony@atomide.com> wrote:

> * William Breathitt Gray <vilhelm.gray@gmail.com> [190905 13:38]:
> > On Sun, Sep 01, 2019 at 05:58:21PM -0500, David Lechner wrote:  
> > > 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.  
> ...
> 
> > I'm satisfied with this version of the patchset.
> > 
> > Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
> > 
> > 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:
> 
> Acked-by: Tony Lindgren <tony@atomide.com>

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
Tony Lindgren Sept. 8, 2019, 7:44 p.m. UTC | #7
* Jonathan Cameron <jic23@jic23.retrosnub.co.uk> [190908 11:16]:
> On Mon, 2 Sep 2019 17:02:45 +0200
> Thierry Reding <thierry.reding@gmail.com> wrote:
> 
> > On Sun, Sep 01, 2019 at 05:58:22PM -0500, David Lechner wrote:
> > > 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.
> > > 
> > > Signed-off-by: David Lechner <david@lechnology.com>
> > > ---
> > > 
> > > 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%)  
> > 
> > Acked-by: Thierry Reding <thierry.reding@gmail.com>
> 
> 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
Jonathan Cameron Oct. 17, 2019, 8:58 p.m. UTC | #8
On Sun, 8 Sep 2019 12:44:48 -0700
Tony Lindgren <tony@atomide.com> wrote:

> * Jonathan Cameron <jic23@jic23.retrosnub.co.uk> [190908 11:16]:
> > On Mon, 2 Sep 2019 17:02:45 +0200
> > Thierry Reding <thierry.reding@gmail.com> wrote:
> >   
> > > On Sun, Sep 01, 2019 at 05:58:22PM -0500, David Lechner wrote:  
> > > > 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.
> > > > 
> > > > Signed-off-by: David Lechner <david@lechnology.com>
> > > > ---
> > > > 
> > > > 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%)    
> > > 
> > > Acked-by: Thierry Reding <thierry.reding@gmail.com>  
> > 
> > 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
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