Age | Commit message (Collapse) | Author | Files | Lines |
|
Prepare the transition to PWM atomic update by moving the enabled and
disabled state into the pwm_state struct. This way we can easily update
the whole PWM state by copying the new state in the ->state field.
Signed-off-by: Boris Brezillon <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
|
|
The PWM state, represented by its period, duty_cycle and polarity is
currently directly stored in the PWM device. Declare a pwm_state
structure embedding those field so that we can later use this struct
to atomically update all the PWM parameters at once.
All pwm_get_xxx() helpers are now implemented as wrappers around
pwm_get_state().
Signed-off-by: Boris Brezillon <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
|
|
Before the introduction of pwm_args, the core was resetting the PWM
period and polarity states to the reference values (those provided
through the DT, a PWM lookup table or hardcoded in the driver).
Now that all PWM users are correctly using pwm_args to configure their
PWM device, we can safely remove the pwm_apply_args() call in pwm_get()
and of_pwm_get().
We can also get rid of the pwm_set_period() call in pwm_apply_args(),
because PWM users are now directly using pargs->period instead of
pwm_get_period(). By doing that we avoid messing with the current PWM
period.
The only remaining bit in pwm_apply_args() is the initial polarity
setting, and it should go away when all PWM users have been patched to
use the atomic API (with this API the polarity will be set along with
other PWM arguments when configuring the PWM).
Signed-off-by: Boris Brezillon <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
|
|
PWM devices are not protected against concurrent accesses. The lock in
struct pwm_device might let PWM users think it is, but it's actually
only protecting the enabled state.
Removing this lock should be fine as long as all PWM users are aware
that accesses to the PWM device have to be serialized, which seems to be
the case for all of them except the sysfs interface. Patch the sysfs
code by adding a lock to the pwm_export struct and making sure it's
taken for all relevant accesses to the exported PWM device.
Signed-off-by: Boris Brezillon <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
|
|
Currently the PWM core mixes the current PWM state with the per-platform
reference config (specified through the PWM lookup table, DT definition
or directly hardcoded in PWM drivers).
Create a struct pwm_args to store this reference configuration, so that
PWM users can differentiate between the current and reference
configurations.
Patch all places where pwm->args should be initialized. We keep the
pwm_set_polarity/period() calls until all PWM users are patched to use
pwm_args instead of pwm_get_period/polarity().
Signed-off-by: Boris Brezillon <[email protected]>
[[email protected]: reword kerneldoc comments]
Signed-off-by: Thierry Reding <[email protected]>
|
|
The pwm_enable() function didn't clear the enabled bit if a call to the
driver's ->enable() callback returned an error. The result was that the
state of the PWM core was wrong. Clearing the bit when enable returns
an error ensures the state is properly set.
Tested-by: Jonathan Richardson <[email protected]>
Reviewed-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Jonathan Richardson <[email protected]>
[[email protected]: add missing kerneldoc for the lock]
Signed-off-by: Thierry Reding <[email protected]>
|
|
Clean up kerneldoc in preparation for including the PWM documentation in
DocBook.
Signed-off-by: Thierry Reding <[email protected]>
|
|
Remove useless tabs used for padding in structure definitions as well as
some blank lines.
Signed-off-by: Thierry Reding <[email protected]>
|
|
Some drivers are directly accessing the ->polarity field in pwm_device.
Add a helper to retrieve the current polarity so that we can easily move
this field elsewhere (required to support atomic update).
Signed-off-by: Boris Brezillon <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
|
|
The PWM argument is not modified in PWM property accessors, make it a
const argument so that the accessors can be used from sysfs.
Signed-off-by: Boris Brezillon <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
|
|
Some PWM drivers are testing the PWMF_ENABLED flag. Create a helper
function to hide the logic behind enabled test. This will allow us to
smoothly move from the current approach to an atomic PWM update
approach.
Signed-off-by: Boris Brezillon <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
|
|
Add a new function to register a PWM chip with channels that have their
initial polarity as specified by an additional parameter. This benefits
drivers of controllers that by default operate with inversed polarity
by removing the need to modify the polarity during initialization.
Signed-off-by: Tim Kryger <[email protected]>
Signed-off-by: Jonathan Richardson <[email protected]>
[[email protected]: export pwmchip_add_with_polarity()]
Signed-off-by: Thierry Reding <[email protected]>
|
|
In case some drivers are unloading, they can remove lookup tables which
they had registered during their load time to avoid redundant entries if
loaded again.
CC: Samuel Ortiz <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: Alexandre Courbot <[email protected]>
Cc: Thierry Reding <[email protected]>
Signed-off-by: Shobhit Kumar <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
|
|
Now that PWM_LOOKUP is not used anymore, modify it to initialize all the
members of struct pwm_lookup.
Signed-off-by: Alexandre Belloni <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
|
|
Add period and polarity members to struct pwm_lookup so that platforms
using the lookup table can be treated the same way as those using the
device tree.
Signed-off-by: Alexandre Belloni <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
|
|
Before we had the PWM framework we used to have a barebone PWM api. The
HAVE_PWM Kconfig symbol used to be selected by the PWM drivers to specify
the PWM API is present in the kernel. Since the last legacy driver is gone
the HAVE_PWM symbol can go aswell.
Signed-off-by: Sascha Hauer <[email protected]>
Cc: Dmitry Torokhov <[email protected]>
Cc: Eric Miao <[email protected]>
Cc: Haojian Zhuang <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Thierry Reding <[email protected]>
Cc: [email protected]
Cc: Russell King <[email protected]>
Cc: Ralf Baechle <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
|
|
Add a simple sysfs interface to the generic PWM framework.
/sys/class/pwm/
`-- pwmchipN/ for each PWM chip
|-- export (w/o) ask the kernel to export a PWM channel
|-- npwm (r/o) number of PWM channels in this PWM chip
|-- pwmX/ for each exported PWM channel
| |-- duty_cycle (r/w) duty cycle (in nanoseconds)
| |-- enable (r/w) enable/disable PWM
| |-- period (r/w) period (in nanoseconds)
| `-- polarity (r/w) polarity of PWM (normal/inversed)
`-- unexport (w/o) return a PWM channel to the kernel
Based on work by Lars Poeschel.
Signed-off-by: H Hartley Sweeten <[email protected]>
Cc: Thierry Reding <[email protected]>
Cc: Lars Poeschel <[email protected]>
Cc: Ryan Mallon <[email protected]>
Cc: Rob Landley <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
|
|
Pull PWM changes from Thierry Reding:
"A new driver has been added to support the PWM mode of the timer
counter blocks found on Atmel AT91 SoCs. The VT8500 driver now
supports changing the PWM signal polarity and the TI drivers (EHRPWM
and ECAP) gained suspend and resume functionality.
User drivers can now query the core for whether access to a PWM device
will sleep (if the PWM chip is on a slow bus such as I2C or SPI).
The pwm-backlight driver now handles the backlight BL_CORE_FBBLANK
state in addition to the FB layer's blanking states.
To round things off, a few fixes and cleanups are also included"
* tag 'for-3.9-rc1' of git://gitorious.org/linux-pwm/linux-pwm:
pwm: twl: Use to_twl() instead of container_of()
pwm: tegra: assume CONFIG_OF
pwm_backlight: Validate dft_brightness in main probe function
pwm: Export pwm_{set,get}_chip_data()
pwm: Make Kconfig entries more consistent
pwm: Add can_sleep property to drivers
pwm: Add pwm_can_sleep() as exported API to users
pwm-backlight: handle BL_CORE_FBBLANK state
pwm: pwm-tiecap: Low power sleep support
pwm: pwm-tiehrpwm: Low power sleep support
pwm: pwm-tiehrpwm: Update the clock handling of pwm-tiehrpwm driver
pwm: vt8500: Add polarity support
pwm: vt8500: Register write busy test performed incorrectly
pwm: atmel: add Timer Counter Block PWM driver
|
|
When booted with DT users can use devm version of of_pwm_get() to benefit
from automatic resource release.
Signed-off-by: Peter Ujfalusi <[email protected]>
Acked-by: Thierry Reding <[email protected]>
Signed-off-by: Bryan Wu <[email protected]>
|
|
Allow client driver to use of_pwm_get() to get the PWM they need. This
is needed for drivers which handle more than one PWM separately, like
leds-pwm driver, which have:
pwmleds {
compatible = "pwm-leds";
kpad {
label = "omap4::keypad";
pwms = <&twl_pwm 0 7812500>;
max-brightness = <127>;
};
charging {
label = "omap4:green:chrg";
pwms = <&twl_pwmled 0 7812500>;
max-brightness = <255>;
};
};
in the dts files.
Signed-off-by: Peter Ujfalusi <[email protected]>
Acked-by: Thierry Reding <[email protected]>
Signed-off-by: Bryan Wu <[email protected]>
|
|
To synchronize the header file definition and the actual code. In the code
the consumer parameter is named as con_id, change the header file and replace
consumer -> con_id in the parameter list.
Signed-off-by: Peter Ujfalusi <[email protected]>
Ackedy-by: Thierry Reding <[email protected]>
Signed-off-by: Bryan Wu <[email protected]>
|
|
Calls to some external PWM chips can sleep. To help users,
add pwm_can_sleep() API.
Cc: Thierry Reding <[email protected]>
Cc: Peter Ujfalusi <[email protected]>
Signed-off-by: Florian Vaussard <[email protected]>
Reviewed-by: Peter Ujfalusi <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
|
|
Add support for encoding PWM properties in bit encoded form with
of_pwm_xlate_with_flags() function support. Platforms require platform
specific PWM properties has to populate in 3rd cell of the pwm-specifier
and PWM driver should also set .of_xlate support with this function.
Currently PWM property polarity encoded in bit position 0 of the third
cell in pwm-specifier.
Signed-off-by: Philip, Avinash <[email protected]>
Acked-by: Grant Likely <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
|
|
Add dummy implemention of public symbols for compilation-safe inclusion
of include/linux/pwm.h file when CONFIG_PWM is not defined.
Reported-by: Sachin Kamat <[email protected]>
Signed-off-by: Tushar Behera <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
|
|
Add resource managed variants of pwm_get() and pwm_put() for
convenience. Code is largely inspired by the equivalent devm functions
of the regulator framework.
Signed-off-by: Alexandre Courbot <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
|
|
Some hardware supports inverting the polarity of the PWM signal. This
commit adds support to the PWM framework to allow users of the PWM API
to configure the polarity. Note that in order to reduce complexity,
changing the polarity of a PWM signal is only allowed while the PWM is
disabled.
A practical example where this can prove useful is to simulate inversion
of the duty cycle. While inversion of polarity and duty cycle are not
exactly the same, the differences for most use-cases are negligible.
Signed-off-by: Philip, Avinash <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
|
|
This patch adds helpers to support device tree bindings for the generic
PWM API. Device tree binding documentation for PWM controllers is also
provided.
Acked-by: Arnd Bergmann <[email protected]>
Reviewed-by: Shawn Guo <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
|
|
In order to get rid of the global namespace for PWM devices, this commit
provides an alternative method, similar to that of the regulator or
clock frameworks, for registering a static mapping for PWM devices. This
works by providing a table with a provider/consumer map in the board
setup code.
With the new pwm_get() and pwm_put() functions available, usage of
pwm_request() and pwm_free() becomes deprecated.
Reviewed-by: Shawn Guo <[email protected]>
Reviewed-by: Mark Brown <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
|
|
This commit adds a debugfs interface that can be used to list the
current internal state of the PWM devices registered with the PWM
framework.
Reviewed-by: Mark Brown <[email protected]>
Reviewed-by: Shawn Guo <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
|
|
Many PWM controllers provide access to more than a single PWM output and
may even share some resource among them. Allowing a PWM chip to provide
multiple PWM devices enables better sharing of those resources. As a
side-effect this change allows easy integration with the device tree
where a given PWM can be looked up based on the PWM chip's phandle and a
corresponding index.
This commit modifies the PWM core to support multiple PWMs per struct
pwm_chip. It achieves this in a similar way to how gpiolib works, by
allowing PWM ranges to be requested dynamically (pwm_chip.base == -1) or
starting at a given offset (pwm_chip.base >= 0). A chip specifies how
many PWMs it controls using the npwm member. Each of the functions in
the pwm_ops structure gets an additional argument that specified the PWM
number (it can be converted to a per-chip index by subtracting the
chip's base).
The total maximum number of PWM devices is currently fixed to 1024 while
the data is actually stored in a radix tree, thus saving resources if
not all of them are used.
Reviewed-by: Mark Brown <[email protected]>
Reviewed-by: Shawn Guo <[email protected]>
[[email protected]: fix error handling in pwmchip_add]
Signed-off-by: Eric Bénard <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
|
|
This patch adds framework support for PWM (pulse width modulation) devices.
The is a barebone PWM API already in the kernel under include/linux/pwm.h,
but it does not allow for multiple drivers as each of them implements the
pwm_*() functions.
There are other PWM framework patches around from Bill Gatliff. Unlike
his framework this one does not change the existing API for PWMs so that
this framework can act as a drop in replacement for the existing API.
Why another framework?
Several people argue that there should not be another framework for PWMs
but they should be integrated into one of the existing frameworks like led
or hwmon. Unlike these frameworks the PWM framework is agnostic to the
purpose of the PWM. In fact, a PWM can drive a LED, but this makes the
LED framework a user of a PWM, like already done in leds-pwm.c. The gpio
framework also is not suitable for PWMs. Every gpio could be turned into
a PWM using timer based toggling, but on the other hand not every PWM hardware
device can be turned into a gpio due to the lack of hardware capabilities.
This patch does not try to improve the PWM API yet, this could be done in
subsequent patches.
Signed-off-by: Sascha Hauer <[email protected]>
Acked-by: Kurt Van Dijck <[email protected]>
Reviewed-by: Arnd Bergmann <[email protected]>
Reviewed-by: Matthias Kaehlcke <[email protected]>
Reviewed-by: Mark Brown <[email protected]>
Reviewed-by: Shawn Guo <[email protected]>
[[email protected]: fixup typos, kerneldoc comments]
Signed-off-by: Thierry Reding <[email protected]>
|
|
Signed-off-by: Mark Vels <[email protected]>
Signed-off-by: Jiri Kosina <[email protected]>
|
|
Signed-off-by: Russell King <[email protected]>
|