aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/platform_data/pwm-renesas-tpu.h16
-rw-r--r--include/linux/pwm.h29
2 files changed, 44 insertions, 1 deletions
diff --git a/include/linux/platform_data/pwm-renesas-tpu.h b/include/linux/platform_data/pwm-renesas-tpu.h
new file mode 100644
index 000000000000..a7220b10ddab
--- /dev/null
+++ b/include/linux/platform_data/pwm-renesas-tpu.h
@@ -0,0 +1,16 @@
1#ifndef __PWM_RENESAS_TPU_H__
2#define __PWM_RENESAS_TPU_H__
3
4#include <linux/pwm.h>
5
6#define TPU_CHANNEL_MAX 4
7
8struct tpu_pwm_channel_data {
9 enum pwm_polarity polarity;
10};
11
12struct tpu_pwm_platform_data {
13 struct tpu_pwm_channel_data channels[TPU_CHANNEL_MAX];
14};
15
16#endif /* __PWM_RENESAS_TPU_H__ */
diff --git a/include/linux/pwm.h b/include/linux/pwm.h
index a4df2042b79c..f0feafd184a0 100644
--- a/include/linux/pwm.h
+++ b/include/linux/pwm.h
@@ -76,6 +76,7 @@ enum pwm_polarity {
76enum { 76enum {
77 PWMF_REQUESTED = 1 << 0, 77 PWMF_REQUESTED = 1 << 0,
78 PWMF_ENABLED = 1 << 1, 78 PWMF_ENABLED = 1 << 1,
79 PWMF_EXPORTED = 1 << 2,
79}; 80};
80 81
81struct pwm_device { 82struct pwm_device {
@@ -86,7 +87,9 @@ struct pwm_device {
86 struct pwm_chip *chip; 87 struct pwm_chip *chip;
87 void *chip_data; 88 void *chip_data;
88 89
89 unsigned int period; /* in nanoseconds */ 90 unsigned int period; /* in nanoseconds */
91 unsigned int duty_cycle; /* in nanoseconds */
92 enum pwm_polarity polarity;
90}; 93};
91 94
92static inline void pwm_set_period(struct pwm_device *pwm, unsigned int period) 95static inline void pwm_set_period(struct pwm_device *pwm, unsigned int period)
@@ -100,6 +103,17 @@ static inline unsigned int pwm_get_period(struct pwm_device *pwm)
100 return pwm ? pwm->period : 0; 103 return pwm ? pwm->period : 0;
101} 104}
102 105
106static inline void pwm_set_duty_cycle(struct pwm_device *pwm, unsigned int duty)
107{
108 if (pwm)
109 pwm->duty_cycle = duty;
110}
111
112static inline unsigned int pwm_get_duty_cycle(struct pwm_device *pwm)
113{
114 return pwm ? pwm->duty_cycle : 0;
115}
116
103/* 117/*
104 * pwm_set_polarity - configure the polarity of a PWM signal 118 * pwm_set_polarity - configure the polarity of a PWM signal
105 */ 119 */
@@ -278,4 +292,17 @@ static inline void pwm_add_table(struct pwm_lookup *table, size_t num)
278} 292}
279#endif 293#endif
280 294
295#ifdef CONFIG_PWM_SYSFS
296void pwmchip_sysfs_export(struct pwm_chip *chip);
297void pwmchip_sysfs_unexport(struct pwm_chip *chip);
298#else
299static inline void pwmchip_sysfs_export(struct pwm_chip *chip)
300{
301}
302
303static inline void pwmchip_sysfs_unexport(struct pwm_chip *chip)
304{
305}
306#endif /* CONFIG_PWM_SYSFS */
307
281#endif /* __LINUX_PWM_H */ 308#endif /* __LINUX_PWM_H */