Russell King | 1a189b9 | 2008-04-13 21:41:55 +0100 | [diff] [blame] | 1 | #ifndef __LINUX_PWM_H |
| 2 | #define __LINUX_PWM_H |
| 3 | |
| 4 | struct pwm_device; |
| 5 | |
| 6 | /* |
| 7 | * pwm_request - request a PWM device |
| 8 | */ |
| 9 | struct pwm_device *pwm_request(int pwm_id, const char *label); |
| 10 | |
| 11 | /* |
| 12 | * pwm_free - free a PWM device |
| 13 | */ |
| 14 | void pwm_free(struct pwm_device *pwm); |
| 15 | |
| 16 | /* |
| 17 | * pwm_config - change a PWM device configuration |
| 18 | */ |
| 19 | int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns); |
| 20 | |
| 21 | /* |
| 22 | * pwm_enable - start a PWM output toggling |
| 23 | */ |
| 24 | int pwm_enable(struct pwm_device *pwm); |
| 25 | |
| 26 | /* |
| 27 | * pwm_disable - stop a PWM output toggling |
| 28 | */ |
| 29 | void pwm_disable(struct pwm_device *pwm); |
| 30 | |
Sascha Hauer | 0c2498f | 2011-01-28 09:40:40 +0100 | [diff] [blame^] | 31 | #ifdef CONFIG_PWM |
| 32 | struct 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 | */ |
| 43 | struct 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 | */ |
| 59 | struct pwm_chip { |
| 60 | int pwm_id; |
| 61 | const char *label; |
| 62 | struct pwm_ops *ops; |
| 63 | }; |
| 64 | |
| 65 | int pwmchip_add(struct pwm_chip *chip); |
| 66 | int pwmchip_remove(struct pwm_chip *chip); |
| 67 | #endif |
| 68 | |
Mark Vels | 5243ef8 | 2009-01-18 18:42:45 +0100 | [diff] [blame] | 69 | #endif /* __LINUX_PWM_H */ |