10 #if IS_ENABLED(CONFIG_PWM) || IS_ENABLED(CONFIG_HAVE_PWM)
12 * pwm_request - request a PWM device
14 struct pwm_device
*pwm_request(int pwm_id
, const char *label
);
17 * pwm_free - free a PWM device
19 void pwm_free(struct pwm_device
*pwm
);
22 * pwm_config - change a PWM device configuration
24 int pwm_config(struct pwm_device
*pwm
, int duty_ns
, int period_ns
);
27 * pwm_enable - start a PWM output toggling
29 int pwm_enable(struct pwm_device
*pwm
);
32 * pwm_disable - stop a PWM output toggling
34 void pwm_disable(struct pwm_device
*pwm
);
36 static inline struct pwm_device
*pwm_request(int pwm_id
, const char *label
)
38 return ERR_PTR(-ENODEV
);
41 static inline void pwm_free(struct pwm_device
*pwm
)
45 static inline int pwm_config(struct pwm_device
*pwm
, int duty_ns
, int period_ns
)
50 static inline int pwm_enable(struct pwm_device
*pwm
)
55 static inline void pwm_disable(struct pwm_device
*pwm
)
63 * enum pwm_polarity - polarity of a PWM signal
64 * @PWM_POLARITY_NORMAL: a high signal for the duration of the duty-
65 * cycle, followed by a low signal for the remainder of the pulse
67 * @PWM_POLARITY_INVERSED: a low signal for the duration of the duty-
68 * cycle, followed by a high signal for the remainder of the pulse
73 PWM_POLARITY_INVERSED
,
77 PWMF_REQUESTED
= 1 << 0,
78 PWMF_ENABLED
= 1 << 1,
86 struct pwm_chip
*chip
;
89 unsigned int period
; /* in nanoseconds */
92 static inline void pwm_set_period(struct pwm_device
*pwm
, unsigned int period
)
98 static inline unsigned int pwm_get_period(struct pwm_device
*pwm
)
100 return pwm
? pwm
->period
: 0;
104 * pwm_set_polarity - configure the polarity of a PWM signal
106 int pwm_set_polarity(struct pwm_device
*pwm
, enum pwm_polarity polarity
);
109 * struct pwm_ops - PWM controller operations
110 * @request: optional hook for requesting a PWM
111 * @free: optional hook for freeing a PWM
112 * @config: configure duty cycles and period length for this PWM
113 * @set_polarity: configure the polarity of this PWM
114 * @enable: enable PWM output toggling
115 * @disable: disable PWM output toggling
116 * @dbg_show: optional routine to show contents in debugfs
117 * @owner: helps prevent removal of modules exporting active PWMs
120 int (*request
)(struct pwm_chip
*chip
,
121 struct pwm_device
*pwm
);
122 void (*free
)(struct pwm_chip
*chip
,
123 struct pwm_device
*pwm
);
124 int (*config
)(struct pwm_chip
*chip
,
125 struct pwm_device
*pwm
,
126 int duty_ns
, int period_ns
);
127 int (*set_polarity
)(struct pwm_chip
*chip
,
128 struct pwm_device
*pwm
,
129 enum pwm_polarity polarity
);
130 int (*enable
)(struct pwm_chip
*chip
,
131 struct pwm_device
*pwm
);
132 void (*disable
)(struct pwm_chip
*chip
,
133 struct pwm_device
*pwm
);
134 #ifdef CONFIG_DEBUG_FS
135 void (*dbg_show
)(struct pwm_chip
*chip
,
138 struct module
*owner
;
142 * struct pwm_chip - abstract a PWM controller
143 * @dev: device providing the PWMs
144 * @list: list node for internal use
145 * @ops: callbacks for this PWM controller
146 * @base: number of first PWM controlled by this chip
147 * @npwm: number of PWMs controlled by this chip
148 * @pwms: array of PWM devices allocated by the framework
149 * @can_sleep: must be true if the .config(), .enable() or .disable()
150 * operations may sleep
154 struct list_head list
;
155 const struct pwm_ops
*ops
;
159 struct pwm_device
*pwms
;
161 struct pwm_device
* (*of_xlate
)(struct pwm_chip
*pc
,
162 const struct of_phandle_args
*args
);
163 unsigned int of_pwm_n_cells
;
167 #if IS_ENABLED(CONFIG_PWM)
168 int pwm_set_chip_data(struct pwm_device
*pwm
, void *data
);
169 void *pwm_get_chip_data(struct pwm_device
*pwm
);
171 int pwmchip_add(struct pwm_chip
*chip
);
172 int pwmchip_remove(struct pwm_chip
*chip
);
173 struct pwm_device
*pwm_request_from_chip(struct pwm_chip
*chip
,
177 struct pwm_device
*of_pwm_xlate_with_flags(struct pwm_chip
*pc
,
178 const struct of_phandle_args
*args
);
180 struct pwm_device
*pwm_get(struct device
*dev
, const char *con_id
);
181 struct pwm_device
*of_pwm_get(struct device_node
*np
, const char *con_id
);
182 void pwm_put(struct pwm_device
*pwm
);
184 struct pwm_device
*devm_pwm_get(struct device
*dev
, const char *con_id
);
185 struct pwm_device
*devm_of_pwm_get(struct device
*dev
, struct device_node
*np
,
187 void devm_pwm_put(struct device
*dev
, struct pwm_device
*pwm
);
189 bool pwm_can_sleep(struct pwm_device
*pwm
);
191 static inline int pwm_set_chip_data(struct pwm_device
*pwm
, void *data
)
196 static inline void *pwm_get_chip_data(struct pwm_device
*pwm
)
201 static inline int pwmchip_add(struct pwm_chip
*chip
)
206 static inline int pwmchip_remove(struct pwm_chip
*chip
)
211 static inline struct pwm_device
*pwm_request_from_chip(struct pwm_chip
*chip
,
215 return ERR_PTR(-ENODEV
);
218 static inline struct pwm_device
*pwm_get(struct device
*dev
,
219 const char *consumer
)
221 return ERR_PTR(-ENODEV
);
224 static inline struct pwm_device
*of_pwm_get(struct device_node
*np
,
227 return ERR_PTR(-ENODEV
);
230 static inline void pwm_put(struct pwm_device
*pwm
)
234 static inline struct pwm_device
*devm_pwm_get(struct device
*dev
,
235 const char *consumer
)
237 return ERR_PTR(-ENODEV
);
240 static inline struct pwm_device
*devm_of_pwm_get(struct device
*dev
,
241 struct device_node
*np
,
244 return ERR_PTR(-ENODEV
);
247 static inline void devm_pwm_put(struct device
*dev
, struct pwm_device
*pwm
)
251 static inline bool pwm_can_sleep(struct pwm_device
*pwm
)
258 struct list_head list
;
259 const char *provider
;
265 #define PWM_LOOKUP(_provider, _index, _dev_id, _con_id) \
267 .provider = _provider, \
273 #if IS_ENABLED(CONFIG_PWM)
274 void pwm_add_table(struct pwm_lookup
*table
, size_t num
);
276 static inline void pwm_add_table(struct pwm_lookup
*table
, size_t num
)
281 #endif /* __LINUX_PWM_H */
This page took 0.047769 seconds and 5 git commands to generate.