forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'for-3.6' of git://gitorious.org/linux-pwm/linux-pwm
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
Showing
44 changed files
with
3,308 additions
and
1,007 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
18
Documentation/devicetree/bindings/pwm/nvidia,tegra20-pwm.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | ||
}; |
28 changes: 28 additions & 0 deletions
28
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.