Skip to content

Commit

Permalink
Merge branch 'for-3.6' of git://gitorious.org/linux-pwm/linux-pwm
Browse files Browse the repository at this point in the history
Pull PWM subsystem from Thierry Reding:
 "The new PWM subsystem aims at collecting all implementations of the
  legacy PWM API and to eventually replace it completely.

  The subsystem has been in development for over half a year now and
  many drivers have already been converted.  It has been in linux-next
  for a couple of weeks and there have been no major issues so I think
  it is ready for inclusion in your tree."

Arnd Bergmann <[email protected]>:
 "Very much Ack on the new subsystem.  It uses the interface
  declarations as the previously separate pwm drivers, so nothing
  changes for now in the drivers using it, although it enables us to
  change those more easily in the future if we want to.

  This work is also one of the missing pieces that are required to
  eventually build ARM kernels for multiple platforms, which is
  currently prohibited (amongs other things) by the fact that you cannot
  have more than one driver exporting the pwm functions."

Tested-and-acked-by: Alexandre Courbot <[email protected]>
Acked-by: Mark Brown <[email protected]>
Acked-by: Philip, Avinash <[email protected]> # TI's AM33xx platforms
Acked-By: Alexandre Pereira da Silva <[email protected]> # LPC32XX
Acked-by: Arnd Bergmann <[email protected]>
Acked-by: Sachin Kamat <[email protected]>

Fix up trivial conflicts with other cleanups and DT updates.

* 'for-3.6' of git://gitorious.org/linux-pwm/linux-pwm: (36 commits)
  pwm: pwm-tiehrpwm: PWM driver support for EHRPWM
  pwm: pwm-tiecap: PWM driver support for ECAP APWM
  pwm: fix used-uninitialized warning in pwm_get()
  pwm: add lpc32xx PWM support
  pwm_backlight: pass correct brightness to callback
  pwm: Use pr_* functions in pwm-samsung.c file
  pwm: Convert pwm-samsung to use devm_* APIs
  pwm: Convert pwm-tegra to use devm_clk_get()
  pwm: pwm-mxs: Return proper error if pwmchip_remove() fails
  pwm: pwm-bfin: Return proper error if pwmchip_remove() fails
  pwm: pxa: Propagate pwmchip_remove() error
  pwm: Convert pwm-pxa to use devm_* APIs
  pwm: Convert pwm-vt8500 to use devm_* APIs
  pwm: Convert pwm-imx to use devm_* APIs
  pwm: Conflict with legacy PWM API
  pwm: pwm-mxs: add pinctrl support
  pwm: pwm-mxs: use devm_* managed functions
  pwm: pwm-mxs: use global reset function stmp_reset_block
  pwm: pwm-mxs: encode soc name in compatible string
  pwm: Take over maintainership of the PWM subsystem
  ...
  • Loading branch information
torvalds committed Jul 30, 2012
2 parents a410963 + 19891b2 commit 9ec9716
Show file tree
Hide file tree
Showing 44 changed files with 3,308 additions and 1,007 deletions.
12 changes: 12 additions & 0 deletions Documentation/devicetree/bindings/pwm/lpc32xx-pwm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
LPC32XX PWM controller

Required properties:
- compatible: should be "nxp,lpc3220-pwm"
- reg: physical base address and length of the controller's registers

Examples:

pwm@0x4005C000 {
compatible = "nxp,lpc3220-pwm";
reg = <0x4005C000 0x8>;
};
17 changes: 17 additions & 0 deletions Documentation/devicetree/bindings/pwm/mxs-pwm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Freescale MXS PWM controller

Required properties:
- compatible: should be "fsl,imx23-pwm"
- reg: physical base address and length of the controller's registers
- #pwm-cells: should be 2. The first cell specifies the per-chip index
of the PWM to use and the second cell is the duty cycle in nanoseconds.
- fsl,pwm-number: the number of PWM devices

Example:

pwm: pwm@80064000 {
compatible = "fsl,imx28-pwm", "fsl,imx23-pwm";
reg = <0x80064000 2000>;
#pwm-cells = <2>;
fsl,pwm-number = <8>;
};
18 changes: 18 additions & 0 deletions Documentation/devicetree/bindings/pwm/nvidia,tegra20-pwm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Tegra SoC PWFM controller

Required properties:
- compatible: should be one of:
- "nvidia,tegra20-pwm"
- "nvidia,tegra30-pwm"
- reg: physical base address and length of the controller's registers
- #pwm-cells: On Tegra the number of cells used to specify a PWM is 2. The
first cell specifies the per-chip index of the PWM to use and the second
cell is the duty cycle in nanoseconds.

Example:

pwm: pwm@7000a000 {
compatible = "nvidia,tegra20-pwm";
reg = <0x7000a000 0x100>;
#pwm-cells = <2>;
};
57 changes: 57 additions & 0 deletions Documentation/devicetree/bindings/pwm/pwm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Specifying PWM information for devices
======================================

1) PWM user nodes
-----------------

PWM users should specify a list of PWM devices that they want to use
with a property containing a 'pwm-list':

pwm-list ::= <single-pwm> [pwm-list]
single-pwm ::= <pwm-phandle> <pwm-specifier>
pwm-phandle : phandle to PWM controller node
pwm-specifier : array of #pwm-cells specifying the given PWM
(controller specific)

PWM properties should be named "pwms". The exact meaning of each pwms
property must be documented in the device tree binding for each device.
An optional property "pwm-names" may contain a list of strings to label
each of the PWM devices listed in the "pwms" property. If no "pwm-names"
property is given, the name of the user node will be used as fallback.

Drivers for devices that use more than a single PWM device can use the
"pwm-names" property to map the name of the PWM device requested by the
pwm_get() call to an index into the list given by the "pwms" property.

The following example could be used to describe a PWM-based backlight
device:

pwm: pwm {
#pwm-cells = <2>;
};

[...]

bl: backlight {
pwms = <&pwm 0 5000000>;
pwm-names = "backlight";
};

pwm-specifier typically encodes the chip-relative PWM number and the PWM
period in nanoseconds. Note that in the example above, specifying the
"pwm-names" is redundant because the name "backlight" would be used as
fallback anyway.

2) PWM controller nodes
-----------------------

PWM controller nodes must specify the number of cells used for the
specifier using the '#pwm-cells' property.

An example PWM controller might look like this:

pwm: pwm@7000a000 {
compatible = "nvidia,tegra20-pwm";
reg = <0x7000a000 0x100>;
#pwm-cells = <2>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
pwm-backlight bindings

Required properties:
- compatible: "pwm-backlight"
- pwms: OF device-tree PWM specification (see PWM binding[0])
- brightness-levels: Array of distinct brightness levels. Typically these
are in the range from 0 to 255, but any range starting at 0 will do.
The actual brightness level (PWM duty cycle) will be interpolated
from these values. 0 means a 0% duty cycle (darkest/off), while the
last value in the array represents a 100% duty cycle (brightest).
- default-brightness-level: the default brightness level (index into the
array defined by the "brightness-levels" property)

Optional properties:
- pwm-names: a list of names for the PWM devices specified in the
"pwms" property (see PWM binding[0])

[0]: Documentation/devicetree/bindings/pwm/pwm.txt

Example:

backlight {
compatible = "pwm-backlight";
pwms = <&pwm 0 5000000>;

brightness-levels = <0 4 8 16 32 64 128 255>;
default-brightness-level = <6>;
};
76 changes: 76 additions & 0 deletions Documentation/pwm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
Pulse Width Modulation (PWM) interface

This provides an overview about the Linux PWM interface

PWMs are commonly used for controlling LEDs, fans or vibrators in
cell phones. PWMs with a fixed purpose have no need implementing
the Linux PWM API (although they could). However, PWMs are often
found as discrete devices on SoCs which have no fixed purpose. It's
up to the board designer to connect them to LEDs or fans. To provide
this kind of flexibility the generic PWM API exists.

Identifying PWMs
----------------

Users of the legacy PWM API use unique IDs to refer to PWM devices.

Instead of referring to a PWM device via its unique ID, board setup code
should instead register a static mapping that can be used to match PWM
consumers to providers, as given in the following example:

static struct pwm_lookup board_pwm_lookup[] = {
PWM_LOOKUP("tegra-pwm", 0, "pwm-backlight", NULL),
};

static void __init board_init(void)
{
...
pwm_add_table(board_pwm_lookup, ARRAY_SIZE(board_pwm_lookup));
...
}

Using PWMs
----------

Legacy users can request a PWM device using pwm_request() and free it
after usage with pwm_free().

New users should use the pwm_get() function and pass to it the consumer
device or a consumer name. pwm_put() is used to free the PWM device.

After being requested a PWM has to be configured using:

int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns);

To start/stop toggling the PWM output use pwm_enable()/pwm_disable().

Implementing a PWM driver
-------------------------

Currently there are two ways to implement pwm drivers. Traditionally
there only has been the barebone API meaning that each driver has
to implement the pwm_*() functions itself. This means that it's impossible
to have multiple PWM drivers in the system. For this reason it's mandatory
for new drivers to use the generic PWM framework.

A new PWM controller/chip can be added using pwmchip_add() and removed
again with pwmchip_remove(). pwmchip_add() takes a filled in struct
pwm_chip as argument which provides a description of the PWM chip, the
number of PWM devices provider by the chip and the chip-specific
implementation of the supported PWM operations to the framework.

Locking
-------

The PWM core list manipulations are protected by a mutex, so pwm_request()
and pwm_free() may not be called from an atomic context. Currently the
PWM core does not enforce any locking to pwm_enable(), pwm_disable() and
pwm_config(), so the calling context is currently driver specific. This
is an issue derived from the former barebone API and should be fixed soon.

Helpers
-------

Currently a PWM can only be configured with period_ns and duty_ns. For several
use cases freq_hz and duty_percent might be better. Instead of calculating
this in your driver please consider adding appropriate helpers to the framework.
12 changes: 12 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -5526,6 +5526,18 @@ S: Maintained
F: Documentation/video4linux/README.pvrusb2
F: drivers/media/video/pvrusb2/

PWM SUBSYSTEM
M: Thierry Reding <[email protected]>
L: [email protected]
S: Maintained
W: http://gitorious.org/linux-pwm
T: git git://gitorious.org/linux-pwm/linux-pwm.git
F: Documentation/pwm.txt
F: Documentation/devicetree/bindings/pwm/
F: include/linux/pwm.h
F: include/linux/of_pwm.h
F: drivers/pwm/

PXA2xx/PXA3xx SUPPORT
M: Eric Miao <[email protected]>
M: Russell King <[email protected]>
Expand Down
1 change: 0 additions & 1 deletion arch/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,6 @@ config ARCH_VT8500
select ARCH_HAS_CPUFREQ
select GENERIC_CLOCKEVENTS
select ARCH_REQUIRE_GPIOLIB
select HAVE_PWM
help
Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip.

Expand Down
6 changes: 6 additions & 0 deletions arch/arm/boot/dts/tegra20.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@
status = "disabled";
};

pwm {
compatible = "nvidia,tegra20-pwm";
reg = <0x7000a000 0x100>;
#pwm-cells = <2>;
};

i2c@7000c000 {
compatible = "nvidia,tegra20-i2c";
reg = <0x7000c000 0x100>;
Expand Down
6 changes: 6 additions & 0 deletions arch/arm/boot/dts/tegra30.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@
status = "disabled";
};

pwm {
compatible = "nvidia,tegra30-pwm", "nvidia,tegra20-pwm";
reg = <0x7000a000 0x100>;
#pwm-cells = <2>;
};

i2c@7000c000 {
compatible = "nvidia,tegra30-i2c", "nvidia,tegra20-i2c";
reg = <0x7000c000 0x100>;
Expand Down
3 changes: 2 additions & 1 deletion arch/arm/mach-tegra/board-dt-tegra20.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ struct of_dev_auxdata tegra20_auxdata_lookup[] __initdata = {
&tegra_ehci2_pdata),
OF_DEV_AUXDATA("nvidia,tegra20-ehci", TEGRA_USB3_BASE, "tegra-ehci.2",
&tegra_ehci3_pdata),
OF_DEV_AUXDATA("nvidia,tegra20-apbdma", 0x6000a000, "tegra-apbdma", NULL),
OF_DEV_AUXDATA("nvidia,tegra20-apbdma", TEGRA_APB_DMA_BASE, "tegra-apbdma", NULL),
OF_DEV_AUXDATA("nvidia,tegra20-pwm", TEGRA_PWFM_BASE, "tegra-pwm", NULL),
{}
};

Expand Down
3 changes: 3 additions & 0 deletions arch/arm/mach-tegra/board-dt-tegra30.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include <asm/mach/arch.h>
#include <asm/hardware/gic.h>

#include <mach/iomap.h>

#include "board.h"
#include "clock.h"

Expand All @@ -48,6 +50,7 @@ struct of_dev_auxdata tegra30_auxdata_lookup[] __initdata = {
OF_DEV_AUXDATA("nvidia,tegra20-i2c", 0x7000D000, "tegra-i2c.4", NULL),
OF_DEV_AUXDATA("nvidia,tegra30-ahub", 0x70080000, "tegra30-ahub", NULL),
OF_DEV_AUXDATA("nvidia,tegra30-apbdma", 0x6000a000, "tegra-apbdma", NULL),
OF_DEV_AUXDATA("nvidia,tegra30-pwm", TEGRA_PWFM_BASE, "tegra-pwm", NULL),
{}
};

Expand Down
2 changes: 0 additions & 2 deletions arch/arm/mach-vt8500/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ obj-$(CONFIG_VTWM_VERSION_WM8505) += devices-wm8505.o

obj-$(CONFIG_MACH_BV07) += bv07.o
obj-$(CONFIG_MACH_WM8505_7IN_NETBOOK) += wm8505_7in.o

obj-$(CONFIG_HAVE_PWM) += pwm.o
Loading

0 comments on commit 9ec9716

Please sign in to comment.