diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2012-01-31 10:19:50 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-02-17 10:18:27 +0100 |
commit | f917e6f866e6b0304a9f4e64980c27fb85271a40 (patch) | |
tree | af91238075be4467346b9e6db8032beb23d095ba /include/pwm.h | |
parent | c20952a62135d791a1a070aeedeee712a3bf017e (diff) | |
download | barebox-f917e6f866e6b0304a9f4e64980c27fb85271a40.tar.gz barebox-f917e6f866e6b0304a9f4e64980c27fb85271a40.tar.xz |
Add pwm core support
This patch adds framework support for PWM (pulse width modulation)
devices.
A new pwm can be registered from a hardware driver using
pwmchip_add(). It can then be requested from a client driver using
pwm_request(). A string is used as a unique identifier for the
pwms. It should usually be initialized by the hardware drivers
using dev_name(dev). The client API is the same as currently
in the Linux Kernel.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/pwm.h')
-rw-r--r-- | include/pwm.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/include/pwm.h b/include/pwm.h new file mode 100644 index 0000000000..80f88b194d --- /dev/null +++ b/include/pwm.h @@ -0,0 +1,63 @@ +#ifndef __PWM_H +#define __PWM_H + +struct pwm_device; + +/* + * pwm_request - request a PWM device + */ +struct pwm_device *pwm_request(const char *pwmname); + +/* + * pwm_free - free a PWM device + */ +void pwm_free(struct pwm_device *pwm); + +/* + * pwm_config - change a PWM device configuration + */ +int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns); + +/* + * pwm_enable - start a PWM output toggling + */ +int pwm_enable(struct pwm_device *pwm); + +/* + * pwm_disable - stop a PWM output toggling + */ +void pwm_disable(struct pwm_device *pwm); + +struct pwm_chip; + +/** + * struct pwm_ops - PWM operations + * @request: optional hook for requesting a PWM + * @free: optional hook for freeing a PWM + * @config: configure duty cycles and period length for this PWM + * @enable: enable PWM output toggling + * @disable: disable PWM output toggling + */ +struct pwm_ops { + int (*request)(struct pwm_chip *chip); + void (*free)(struct pwm_chip *chip); + int (*config)(struct pwm_chip *chip, int duty_ns, + int period_ns); + int (*enable)(struct pwm_chip *chip); + void (*disable)(struct pwm_chip *chip); +}; + +/** + * struct pwm_chip - abstract a PWM + * @devname: unique identifier for this pwm + * @ops: The callbacks for this PWM + */ +struct pwm_chip { + const char *devname; + struct pwm_ops *ops; +}; + +int pwmchip_add(struct pwm_chip *chip); +int pwmchip_remove(struct pwm_chip *chip); + +#endif /* __PWM_H */ |