aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/pwm.h
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2011-01-28 03:40:40 -0500
committerThierry Reding <thierry.reding@avionic-design.de>2012-06-15 06:56:50 -0400
commit0c2498f1660878339350bea8d18550b1b87ca055 (patch)
treea1509cfa2de90c8a35be4594af5daa79896f7662 /include/linux/pwm.h
parentcfaf025112d3856637ff34a767ef785ef5cf2ca9 (diff)
pwm: Add PWM framework support
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 <s.hauer@pengutronix.de> Acked-by: Kurt Van Dijck <kurt.van.dijck@eia.be> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Matthias Kaehlcke <matthias@kaehlcke.net> Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Reviewed-by: Shawn Guo <shawn.guo@linaro.org> [thierry.reding@avionic-design.de: fixup typos, kerneldoc comments] Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
Diffstat (limited to 'include/linux/pwm.h')
-rw-r--r--include/linux/pwm.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/include/linux/pwm.h b/include/linux/pwm.h
index 7c775751392c..1f308a13105f 100644
--- a/include/linux/pwm.h
+++ b/include/linux/pwm.h
@@ -28,4 +28,42 @@ int pwm_enable(struct pwm_device *pwm);
28 */ 28 */
29void pwm_disable(struct pwm_device *pwm); 29void pwm_disable(struct pwm_device *pwm);
30 30
31#ifdef CONFIG_PWM
32struct pwm_chip;
33
34/**
35 * struct pwm_ops - PWM controller operations
36 * @request: optional hook for requesting a PWM
37 * @free: optional hook for freeing a PWM
38 * @config: configure duty cycles and period length for this PWM
39 * @enable: enable PWM output toggling
40 * @disable: disable PWM output toggling
41 * @owner: helps prevent removal of modules exporting active PWMs
42 */
43struct pwm_ops {
44 int (*request)(struct pwm_chip *chip);
45 void (*free)(struct pwm_chip *chip);
46 int (*config)(struct pwm_chip *chip, int duty_ns,
47 int period_ns);
48 int (*enable)(struct pwm_chip *chip);
49 void (*disable)(struct pwm_chip *chip);
50 struct module *owner;
51};
52
53/**
54 * struct pwm_chip - abstract a PWM
55 * @pwm_id: global PWM device index
56 * @label: PWM device label
57 * @ops: controller operations
58 */
59struct pwm_chip {
60 int pwm_id;
61 const char *label;
62 struct pwm_ops *ops;
63};
64
65int pwmchip_add(struct pwm_chip *chip);
66int pwmchip_remove(struct pwm_chip *chip);
67#endif
68
31#endif /* __LINUX_PWM_H */ 69#endif /* __LINUX_PWM_H */