Skip to content

RFC Proposal for a Generic PWM Device API

Bill Gatliff linux-embedded linuxppc-dev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest6 patches 41 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6Generic PWM API implementationdrivers/pwm/pwm.c+667 -00 replies
1/6Generic PWM API implementationdrivers/pwm/pwm.c+667 -05 replies
2/6Changes to existing include/linux/pwm.h to adapt to generic PWM APIinclude/linux/pwm.h+147 -210 replies
2/6Changes to existing include/linux/pwm.h to adapt to generic PWM APIinclude/linux/pwm.h+147 -210 replies
3/6DocumentationDocumentation/pwm.txt+258 -00 replies
3/6DocumentationDocumentation/pwm.txt+258 -00 replies
4/6Driver for Atmel PWMC peripheraldrivers/pwm/atmel-pwm.c+631 -00 replies
4/6Driver for Atmel PWMC peripheraldrivers/pwm/atmel-pwm.c+631 -00 replies
5/6Install new Atmel PWMC driver in Kconfig, expunge old onearch/arm/Kconfig drivers/Makefile drivers/misc/Kconfig +4 more+34 -4190 replies
5/6Install new Atmel PWMC driver in Kconfig, expunge old onearch/arm/Kconfig drivers/Makefile drivers/misc/Kconfig +4 more+34 -4196 replies
6/6New LED driver and trigger that use PWM APIdrivers/leds/Kconfig drivers/leds/Makefile drivers/leds/leds-pwm.c +2 more+286 -70 replies
6/6New LED driver and trigger that use PWM APIdrivers/leds/Kconfig drivers/leds/Makefile drivers/leds/leds-pwm.c +2 more+286 -70 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC 0/6] Proposal for a Generic PWM Device API

This series proposes a "generic PWM" driver API.

This proposed API is motivated by the author's need to support pluggable devices; a secondary objective is to consolidate the existing PWM implementations behind an agreeable, consistent, redundancy-reducing interface.

The code included in this patch draws heavily from the existing PWM infrastructure and driver for the AT91SAM9263 PWMC. The author is grateful to Russell King, Eric Miao, David Brownell and others for providing such tall "shoulders" to stand upon. The proposed updates to that code should not be interpreted as attempts to address shortcomings, but rather to extend functionality in ways that were not originally required.

The implementation of the proposed API is structurally similar to the generic GPIO API, except that the PWM code uses platform bus_id strings instead of integers to identify devices. A configuration structure is also provided, so that the API can be extended in a source-code-compatible way to accomodate devices with features not anticipated by the current code.

Pulse width modulated signals are used in an astounding number and range of applications, and there is no "one true way" of either realizing them or employing them to accomplish real work. The current proposal attempts to provide a useful feature set for the most basic users, packaged in such a way as to allow the API to be extended in a backwards-compatible way as new needs are identified. Some of these needs have already been identified.

The proposed code has been run-tested on a Cogent CSB737 (AT91SAM9263), mated to a custom circuit that drives multiple DC motors and sensors.

Feedback is welcome!

b.g.
--
Bill Gatliff
<[email protected]>

==========================================================================

Bill Gatliff (6):
[PWM] Generic PWM API implementation
[PWM] Changes to existing pwm.h to adapt to generic PWM API [PWM] Documentation
[PWM] Driver for Atmel PWMC peripheral
[PWM] Install new Atmel PWMC driver in Kconfig, expunge old one [PWM] New LED driver and trigger that use PWM API

 Documentation/pwm.txt      |  258 +++++++++++++++++
 arch/arm/Kconfig           |    2 +
 drivers/Makefile           |    2 +
 drivers/leds/Kconfig       |   21 +-
 drivers/leds/Makefile      |    2 +
 drivers/leds/leds-pwm.c    |  141 ++++++++++
 drivers/leds/ledtrig-dim.c |   95 +++++++
 drivers/misc/Kconfig       |    9 -
 drivers/misc/Makefile      |    1 -
 drivers/misc/atmel_pwm.c   |  409 ---------------------------
 drivers/pwm/Kconfig        |   24 ++
 drivers/pwm/Makefile       |    6 +
 drivers/pwm/atmel-pwm.c    |  631 +++++++++++++++++++++++++++++++++++++++++
 drivers/pwm/pwm.c          |  667 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/pwm-led.h    |   34 +++
 include/linux/pwm.h        |  168 ++++++++++--
 16 files changed, 2023 insertions(+), 447 deletions(-)
 create mode 100644 Documentation/pwm.txt
 create mode 100644 drivers/leds/leds-pwm.c
 create mode 100644 drivers/leds/ledtrig-dim.c
 delete mode 100644 drivers/misc/atmel_pwm.c
 create mode 100644 drivers/pwm/Kconfig
 create mode 100644 drivers/pwm/Makefile
 create mode 100644 drivers/pwm/atmel-pwm.c
 create mode 100644 drivers/pwm/pwm.c
 create mode 100644 include/linux/pwm-led.h