xref: /OK3568_Linux_fs/kernel/include/linux/pwm.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __LINUX_PWM_H
3 #define __LINUX_PWM_H
4 
5 #include <linux/err.h>
6 #include <linux/mutex.h>
7 #include <linux/of.h>
8 #include <linux/android_kabi.h>
9 
10 struct pwm_capture;
11 struct seq_file;
12 
13 struct pwm_chip;
14 
15 /**
16  * enum pwm_polarity - polarity of a PWM signal
17  * @PWM_POLARITY_NORMAL: a high signal for the duration of the duty-
18  * cycle, followed by a low signal for the remainder of the pulse
19  * period
20  * @PWM_POLARITY_INVERSED: a low signal for the duration of the duty-
21  * cycle, followed by a high signal for the remainder of the pulse
22  * period
23  */
24 enum pwm_polarity {
25 	PWM_POLARITY_NORMAL,
26 	PWM_POLARITY_INVERSED,
27 };
28 
29 /**
30  * struct pwm_args - board-dependent PWM arguments
31  * @period: reference period
32  * @polarity: reference polarity
33  *
34  * This structure describes board-dependent arguments attached to a PWM
35  * device. These arguments are usually retrieved from the PWM lookup table or
36  * device tree.
37  *
38  * Do not confuse this with the PWM state: PWM arguments represent the initial
39  * configuration that users want to use on this PWM device rather than the
40  * current PWM hardware state.
41  */
42 struct pwm_args {
43 	u64 period;
44 	enum pwm_polarity polarity;
45 };
46 
47 enum {
48 	PWMF_REQUESTED = 1 << 0,
49 	PWMF_EXPORTED = 1 << 1,
50 };
51 
52 /**
53  * enum pwm_output_type - output type of the PWM signal
54  * @PWM_OUTPUT_FIXED: PWM output is fixed until a change request
55  * @PWM_OUTPUT_MODULATED: PWM output is modulated in hardware
56  * autonomously with a predefined pattern
57  */
58 enum pwm_output_type {
59 	PWM_OUTPUT_FIXED = 1 << 0,
60 	PWM_OUTPUT_MODULATED = 1 << 1,
61 };
62 
63 /*
64  * struct pwm_state - state of a PWM channel
65  * @period: PWM period (in nanoseconds)
66  * @duty_cycle: PWM duty cycle (in nanoseconds)
67  * @polarity: PWM polarity
68  * @enabled: PWM enabled status
69  */
70 struct pwm_state {
71 	u64 period;
72 	u64 duty_cycle;
73 	enum pwm_polarity polarity;
74 	enum pwm_output_type output_type;
75 #ifdef CONFIG_PWM_ROCKCHIP_ONESHOT
76 	u64 oneshot_count;
77 #endif /* CONFIG_PWM_ROCKCHIP_ONESHOT */
78 	bool enabled;
79 };
80 
81 /**
82  * struct pwm_device - PWM channel object
83  * @label: name of the PWM device
84  * @flags: flags associated with the PWM device
85  * @hwpwm: per-chip relative index of the PWM device
86  * @pwm: global index of the PWM device
87  * @chip: PWM chip providing this PWM device
88  * @chip_data: chip-private data associated with the PWM device
89  * @args: PWM arguments
90  * @state: last applied state
91  * @last: last implemented state (for PWM_DEBUG)
92  */
93 struct pwm_device {
94 	const char *label;
95 	unsigned long flags;
96 	unsigned int hwpwm;
97 	unsigned int pwm;
98 	struct pwm_chip *chip;
99 	void *chip_data;
100 
101 	struct pwm_args args;
102 	struct pwm_state state;
103 	struct pwm_state last;
104 
105 	ANDROID_KABI_RESERVE(1);
106 };
107 
108 /**
109  * pwm_get_state() - retrieve the current PWM state
110  * @pwm: PWM device
111  * @state: state to fill with the current PWM state
112  */
pwm_get_state(const struct pwm_device * pwm,struct pwm_state * state)113 static inline void pwm_get_state(const struct pwm_device *pwm,
114 				 struct pwm_state *state)
115 {
116 	*state = pwm->state;
117 }
118 
pwm_is_enabled(const struct pwm_device * pwm)119 static inline bool pwm_is_enabled(const struct pwm_device *pwm)
120 {
121 	struct pwm_state state;
122 
123 	pwm_get_state(pwm, &state);
124 
125 	return state.enabled;
126 }
127 
pwm_set_period(struct pwm_device * pwm,u64 period)128 static inline void pwm_set_period(struct pwm_device *pwm, u64 period)
129 {
130 	if (pwm)
131 		pwm->state.period = period;
132 }
133 
pwm_get_period(const struct pwm_device * pwm)134 static inline u64 pwm_get_period(const struct pwm_device *pwm)
135 {
136 	struct pwm_state state;
137 
138 	pwm_get_state(pwm, &state);
139 
140 	return state.period;
141 }
142 
pwm_set_duty_cycle(struct pwm_device * pwm,unsigned int duty)143 static inline void pwm_set_duty_cycle(struct pwm_device *pwm, unsigned int duty)
144 {
145 	if (pwm)
146 		pwm->state.duty_cycle = duty;
147 }
148 
pwm_get_duty_cycle(const struct pwm_device * pwm)149 static inline u64 pwm_get_duty_cycle(const struct pwm_device *pwm)
150 {
151 	struct pwm_state state;
152 
153 	pwm_get_state(pwm, &state);
154 
155 	return state.duty_cycle;
156 }
157 
pwm_get_polarity(const struct pwm_device * pwm)158 static inline enum pwm_polarity pwm_get_polarity(const struct pwm_device *pwm)
159 {
160 	struct pwm_state state;
161 
162 	pwm_get_state(pwm, &state);
163 
164 	return state.polarity;
165 }
166 
pwm_get_output_type(const struct pwm_device * pwm)167 static inline enum pwm_output_type pwm_get_output_type(
168 		const struct pwm_device *pwm)
169 {
170 	struct pwm_state state;
171 
172 	pwm_get_state(pwm, &state);
173 
174 	return state.output_type;
175 }
176 
pwm_get_args(const struct pwm_device * pwm,struct pwm_args * args)177 static inline void pwm_get_args(const struct pwm_device *pwm,
178 				struct pwm_args *args)
179 {
180 	*args = pwm->args;
181 }
182 
183 /**
184  * pwm_init_state() - prepare a new state to be applied with pwm_apply_state()
185  * @pwm: PWM device
186  * @state: state to fill with the prepared PWM state
187  *
188  * This functions prepares a state that can later be tweaked and applied
189  * to the PWM device with pwm_apply_state(). This is a convenient function
190  * that first retrieves the current PWM state and the replaces the period
191  * and polarity fields with the reference values defined in pwm->args.
192  * Once the function returns, you can adjust the ->enabled and ->duty_cycle
193  * fields according to your needs before calling pwm_apply_state().
194  *
195  * ->duty_cycle is initially set to zero to avoid cases where the current
196  * ->duty_cycle value exceed the pwm_args->period one, which would trigger
197  * an error if the user calls pwm_apply_state() without adjusting ->duty_cycle
198  * first.
199  */
pwm_init_state(const struct pwm_device * pwm,struct pwm_state * state)200 static inline void pwm_init_state(const struct pwm_device *pwm,
201 				  struct pwm_state *state)
202 {
203 	struct pwm_args args;
204 
205 	/* First get the current state. */
206 	pwm_get_state(pwm, state);
207 
208 	/* Then fill it with the reference config */
209 	pwm_get_args(pwm, &args);
210 
211 	state->period = args.period;
212 	state->polarity = args.polarity;
213 	state->duty_cycle = 0;
214 }
215 
216 /**
217  * pwm_get_relative_duty_cycle() - Get a relative duty cycle value
218  * @state: PWM state to extract the duty cycle from
219  * @scale: target scale of the relative duty cycle
220  *
221  * This functions converts the absolute duty cycle stored in @state (expressed
222  * in nanosecond) into a value relative to the period.
223  *
224  * For example if you want to get the duty_cycle expressed in percent, call:
225  *
226  * pwm_get_state(pwm, &state);
227  * duty = pwm_get_relative_duty_cycle(&state, 100);
228  */
229 static inline unsigned int
pwm_get_relative_duty_cycle(const struct pwm_state * state,unsigned int scale)230 pwm_get_relative_duty_cycle(const struct pwm_state *state, unsigned int scale)
231 {
232 	if (!state->period)
233 		return 0;
234 
235 	return DIV_ROUND_CLOSEST_ULL((u64)state->duty_cycle * scale,
236 				     state->period);
237 }
238 
239 /**
240  * pwm_set_relative_duty_cycle() - Set a relative duty cycle value
241  * @state: PWM state to fill
242  * @duty_cycle: relative duty cycle value
243  * @scale: scale in which @duty_cycle is expressed
244  *
245  * This functions converts a relative into an absolute duty cycle (expressed
246  * in nanoseconds), and puts the result in state->duty_cycle.
247  *
248  * For example if you want to configure a 50% duty cycle, call:
249  *
250  * pwm_init_state(pwm, &state);
251  * pwm_set_relative_duty_cycle(&state, 50, 100);
252  * pwm_apply_state(pwm, &state);
253  *
254  * This functions returns -EINVAL if @duty_cycle and/or @scale are
255  * inconsistent (@scale == 0 or @duty_cycle > @scale).
256  */
257 static inline int
pwm_set_relative_duty_cycle(struct pwm_state * state,unsigned int duty_cycle,unsigned int scale)258 pwm_set_relative_duty_cycle(struct pwm_state *state, unsigned int duty_cycle,
259 			    unsigned int scale)
260 {
261 	if (!scale || duty_cycle > scale)
262 		return -EINVAL;
263 
264 	state->duty_cycle = DIV_ROUND_CLOSEST_ULL((u64)duty_cycle *
265 						  state->period,
266 						  scale);
267 
268 	return 0;
269 }
270 
271 /**
272  * struct pwm_ops - PWM controller operations
273  * @request: optional hook for requesting a PWM
274  * @free: optional hook for freeing a PWM
275  * @capture: capture and report PWM signal
276  * @apply: atomically apply a new PWM config
277  * @get_state: get the current PWM state. This function is only
278  *	       called once per PWM device when the PWM chip is
279  *	       registered.
280  * @get_output_type_supported: get the supported output type of this PWM
281  * @owner: helps prevent removal of modules exporting active PWMs
282  * @config: configure duty cycles and period length for this PWM
283  * @set_polarity: configure the polarity of this PWM
284  * @enable: enable PWM output toggling
285  * @disable: disable PWM output toggling
286  */
287 struct pwm_ops {
288 	int (*request)(struct pwm_chip *chip, struct pwm_device *pwm);
289 	void (*free)(struct pwm_chip *chip, struct pwm_device *pwm);
290 	int (*capture)(struct pwm_chip *chip, struct pwm_device *pwm,
291 		       struct pwm_capture *result, unsigned long timeout);
292 	int (*apply)(struct pwm_chip *chip, struct pwm_device *pwm,
293 		     const struct pwm_state *state);
294 	void (*get_state)(struct pwm_chip *chip, struct pwm_device *pwm,
295 			  struct pwm_state *state);
296 	int (*get_output_type_supported)(struct pwm_chip *chip,
297 			struct pwm_device *pwm);
298 	struct module *owner;
299 
300 	/* Only used by legacy drivers */
301 	int (*config)(struct pwm_chip *chip, struct pwm_device *pwm,
302 		      int duty_ns, int period_ns);
303 	int (*set_polarity)(struct pwm_chip *chip, struct pwm_device *pwm,
304 			    enum pwm_polarity polarity);
305 	int (*enable)(struct pwm_chip *chip, struct pwm_device *pwm);
306 	void (*disable)(struct pwm_chip *chip, struct pwm_device *pwm);
307 
308 	ANDROID_KABI_RESERVE(1);
309 };
310 
311 /**
312  * struct pwm_chip - abstract a PWM controller
313  * @dev: device providing the PWMs
314  * @ops: callbacks for this PWM controller
315  * @base: number of first PWM controlled by this chip
316  * @npwm: number of PWMs controlled by this chip
317  * @of_xlate: request a PWM device given a device tree PWM specifier
318  * @of_pwm_n_cells: number of cells expected in the device tree PWM specifier
319  * @list: list node for internal use
320  * @pwms: array of PWM devices allocated by the framework
321  */
322 struct pwm_chip {
323 	struct device *dev;
324 	const struct pwm_ops *ops;
325 	int base;
326 	unsigned int npwm;
327 
328 	struct pwm_device * (*of_xlate)(struct pwm_chip *pc,
329 					const struct of_phandle_args *args);
330 	unsigned int of_pwm_n_cells;
331 
332 	/* only used internally by the PWM framework */
333 	struct list_head list;
334 	struct pwm_device *pwms;
335 
336 	ANDROID_KABI_RESERVE(1);
337 };
338 
339 /**
340  * struct pwm_capture - PWM capture data
341  * @period: period of the PWM signal (in nanoseconds)
342  * @duty_cycle: duty cycle of the PWM signal (in nanoseconds)
343  */
344 struct pwm_capture {
345 	unsigned int period;
346 	unsigned int duty_cycle;
347 };
348 
349 #if IS_ENABLED(CONFIG_PWM)
350 /* PWM user APIs */
351 struct pwm_device *pwm_request(int pwm_id, const char *label);
352 void pwm_free(struct pwm_device *pwm);
353 int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state);
354 int pwm_adjust_config(struct pwm_device *pwm);
355 
356 /**
357  * pwm_get_output_type_supported() - obtain output type of a PWM device.
358  * @pwm: PWM device
359  *
360  * Returns:  output type supported by the PWM device
361  */
pwm_get_output_type_supported(struct pwm_device * pwm)362 static inline int pwm_get_output_type_supported(struct pwm_device *pwm)
363 {
364 	if (!pwm)
365 		return -EINVAL;
366 
367 	if (pwm->chip->ops->get_output_type_supported)
368 		return pwm->chip->ops->get_output_type_supported(pwm->chip,
369 				pwm);
370 
371 	return PWM_OUTPUT_FIXED;
372 }
373 
374 /**
375  * pwm_config() - change a PWM device configuration
376  * @pwm: PWM device
377  * @duty_ns: "on" time (in nanoseconds)
378  * @period_ns: duration (in nanoseconds) of one cycle
379  *
380  * Returns: 0 on success or a negative error code on failure.
381  */
pwm_config(struct pwm_device * pwm,int duty_ns,int period_ns)382 static inline int pwm_config(struct pwm_device *pwm, int duty_ns,
383 			     int period_ns)
384 {
385 	struct pwm_state state;
386 
387 	if (!pwm)
388 		return -EINVAL;
389 
390 	if (duty_ns < 0 || period_ns < 0)
391 		return -EINVAL;
392 
393 	pwm_get_state(pwm, &state);
394 	if (state.duty_cycle == duty_ns && state.period == period_ns)
395 		return 0;
396 
397 	state.duty_cycle = duty_ns;
398 	state.period = period_ns;
399 	return pwm_apply_state(pwm, &state);
400 }
401 
402 /**
403  * pwm_enable() - start a PWM output toggling
404  * @pwm: PWM device
405  *
406  * Returns: 0 on success or a negative error code on failure.
407  */
pwm_enable(struct pwm_device * pwm)408 static inline int pwm_enable(struct pwm_device *pwm)
409 {
410 	struct pwm_state state;
411 
412 	if (!pwm)
413 		return -EINVAL;
414 
415 	pwm_get_state(pwm, &state);
416 	if (state.enabled)
417 		return 0;
418 
419 	state.enabled = true;
420 	return pwm_apply_state(pwm, &state);
421 }
422 
423 /**
424  * pwm_disable() - stop a PWM output toggling
425  * @pwm: PWM device
426  */
pwm_disable(struct pwm_device * pwm)427 static inline void pwm_disable(struct pwm_device *pwm)
428 {
429 	struct pwm_state state;
430 
431 	if (!pwm)
432 		return;
433 
434 	pwm_get_state(pwm, &state);
435 	if (!state.enabled)
436 		return;
437 
438 	state.enabled = false;
439 	pwm_apply_state(pwm, &state);
440 }
441 
442 /* PWM provider APIs */
443 int pwm_capture(struct pwm_device *pwm, struct pwm_capture *result,
444 		unsigned long timeout);
445 int pwm_set_chip_data(struct pwm_device *pwm, void *data);
446 void *pwm_get_chip_data(struct pwm_device *pwm);
447 
448 int pwmchip_add_with_polarity(struct pwm_chip *chip,
449 			      enum pwm_polarity polarity);
450 int pwmchip_add(struct pwm_chip *chip);
451 int pwmchip_remove(struct pwm_chip *chip);
452 struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip,
453 					 unsigned int index,
454 					 const char *label);
455 
456 struct pwm_device *of_pwm_xlate_with_flags(struct pwm_chip *pc,
457 		const struct of_phandle_args *args);
458 
459 struct pwm_device *pwm_get(struct device *dev, const char *con_id);
460 struct pwm_device *of_pwm_get(struct device *dev, struct device_node *np,
461 			      const char *con_id);
462 void pwm_put(struct pwm_device *pwm);
463 
464 struct pwm_device *devm_pwm_get(struct device *dev, const char *con_id);
465 struct pwm_device *devm_of_pwm_get(struct device *dev, struct device_node *np,
466 				   const char *con_id);
467 struct pwm_device *devm_fwnode_pwm_get(struct device *dev,
468 				       struct fwnode_handle *fwnode,
469 				       const char *con_id);
470 void devm_pwm_put(struct device *dev, struct pwm_device *pwm);
471 #else
pwm_request(int pwm_id,const char * label)472 static inline struct pwm_device *pwm_request(int pwm_id, const char *label)
473 {
474 	return ERR_PTR(-ENODEV);
475 }
476 
pwm_free(struct pwm_device * pwm)477 static inline void pwm_free(struct pwm_device *pwm)
478 {
479 }
480 
pwm_apply_state(struct pwm_device * pwm,const struct pwm_state * state)481 static inline int pwm_apply_state(struct pwm_device *pwm,
482 				  const struct pwm_state *state)
483 {
484 	return -ENOTSUPP;
485 }
486 
pwm_adjust_config(struct pwm_device * pwm)487 static inline int pwm_adjust_config(struct pwm_device *pwm)
488 {
489 	return -ENOTSUPP;
490 }
491 
pwm_get_output_type_supported(struct pwm_device * pwm)492 static inline int pwm_get_output_type_supported(struct pwm_device *pwm)
493 {
494 	return -EINVAL;
495 }
496 
pwm_config(struct pwm_device * pwm,int duty_ns,int period_ns)497 static inline int pwm_config(struct pwm_device *pwm, int duty_ns,
498 			     int period_ns)
499 {
500 	return -EINVAL;
501 }
502 
pwm_capture(struct pwm_device * pwm,struct pwm_capture * result,unsigned long timeout)503 static inline int pwm_capture(struct pwm_device *pwm,
504 			      struct pwm_capture *result,
505 			      unsigned long timeout)
506 {
507 	return -EINVAL;
508 }
509 
pwm_enable(struct pwm_device * pwm)510 static inline int pwm_enable(struct pwm_device *pwm)
511 {
512 	return -EINVAL;
513 }
514 
pwm_disable(struct pwm_device * pwm)515 static inline void pwm_disable(struct pwm_device *pwm)
516 {
517 }
518 
pwm_set_chip_data(struct pwm_device * pwm,void * data)519 static inline int pwm_set_chip_data(struct pwm_device *pwm, void *data)
520 {
521 	return -EINVAL;
522 }
523 
pwm_get_chip_data(struct pwm_device * pwm)524 static inline void *pwm_get_chip_data(struct pwm_device *pwm)
525 {
526 	return NULL;
527 }
528 
pwmchip_add(struct pwm_chip * chip)529 static inline int pwmchip_add(struct pwm_chip *chip)
530 {
531 	return -EINVAL;
532 }
533 
pwmchip_add_inversed(struct pwm_chip * chip)534 static inline int pwmchip_add_inversed(struct pwm_chip *chip)
535 {
536 	return -EINVAL;
537 }
538 
pwmchip_remove(struct pwm_chip * chip)539 static inline int pwmchip_remove(struct pwm_chip *chip)
540 {
541 	return -EINVAL;
542 }
543 
pwm_request_from_chip(struct pwm_chip * chip,unsigned int index,const char * label)544 static inline struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip,
545 						       unsigned int index,
546 						       const char *label)
547 {
548 	return ERR_PTR(-ENODEV);
549 }
550 
pwm_get(struct device * dev,const char * consumer)551 static inline struct pwm_device *pwm_get(struct device *dev,
552 					 const char *consumer)
553 {
554 	return ERR_PTR(-ENODEV);
555 }
556 
of_pwm_get(struct device * dev,struct device_node * np,const char * con_id)557 static inline struct pwm_device *of_pwm_get(struct device *dev,
558 					    struct device_node *np,
559 					    const char *con_id)
560 {
561 	return ERR_PTR(-ENODEV);
562 }
563 
pwm_put(struct pwm_device * pwm)564 static inline void pwm_put(struct pwm_device *pwm)
565 {
566 }
567 
devm_pwm_get(struct device * dev,const char * consumer)568 static inline struct pwm_device *devm_pwm_get(struct device *dev,
569 					      const char *consumer)
570 {
571 	return ERR_PTR(-ENODEV);
572 }
573 
devm_of_pwm_get(struct device * dev,struct device_node * np,const char * con_id)574 static inline struct pwm_device *devm_of_pwm_get(struct device *dev,
575 						 struct device_node *np,
576 						 const char *con_id)
577 {
578 	return ERR_PTR(-ENODEV);
579 }
580 
581 static inline struct pwm_device *
devm_fwnode_pwm_get(struct device * dev,struct fwnode_handle * fwnode,const char * con_id)582 devm_fwnode_pwm_get(struct device *dev, struct fwnode_handle *fwnode,
583 		    const char *con_id)
584 {
585 	return ERR_PTR(-ENODEV);
586 }
587 
devm_pwm_put(struct device * dev,struct pwm_device * pwm)588 static inline void devm_pwm_put(struct device *dev, struct pwm_device *pwm)
589 {
590 }
591 #endif
592 
pwm_apply_args(struct pwm_device * pwm)593 static inline void pwm_apply_args(struct pwm_device *pwm)
594 {
595 	struct pwm_state state = { };
596 
597 	/*
598 	 * PWM users calling pwm_apply_args() expect to have a fresh config
599 	 * where the polarity and period are set according to pwm_args info.
600 	 * The problem is, polarity can only be changed when the PWM is
601 	 * disabled.
602 	 *
603 	 * PWM drivers supporting hardware readout may declare the PWM device
604 	 * as enabled, and prevent polarity setting, which changes from the
605 	 * existing behavior, where all PWM devices are declared as disabled
606 	 * at startup (even if they are actually enabled), thus authorizing
607 	 * polarity setting.
608 	 *
609 	 * To fulfill this requirement, we apply a new state which disables
610 	 * the PWM device and set the reference period and polarity config.
611 	 *
612 	 * Note that PWM users requiring a smooth handover between the
613 	 * bootloader and the kernel (like critical regulators controlled by
614 	 * PWM devices) will have to switch to the atomic API and avoid calling
615 	 * pwm_apply_args().
616 	 */
617 
618 	state.enabled = false;
619 	state.polarity = pwm->args.polarity;
620 	state.period = pwm->args.period;
621 
622 	pwm_apply_state(pwm, &state);
623 }
624 
625 struct pwm_lookup {
626 	struct list_head list;
627 	const char *provider;
628 	unsigned int index;
629 	const char *dev_id;
630 	const char *con_id;
631 	unsigned int period;
632 	enum pwm_polarity polarity;
633 	const char *module; /* optional, may be NULL */
634 };
635 
636 #define PWM_LOOKUP_WITH_MODULE(_provider, _index, _dev_id, _con_id,	\
637 			       _period, _polarity, _module)		\
638 	{								\
639 		.provider = _provider,					\
640 		.index = _index,					\
641 		.dev_id = _dev_id,					\
642 		.con_id = _con_id,					\
643 		.period = _period,					\
644 		.polarity = _polarity,					\
645 		.module = _module,					\
646 	}
647 
648 #define PWM_LOOKUP(_provider, _index, _dev_id, _con_id, _period, _polarity) \
649 	PWM_LOOKUP_WITH_MODULE(_provider, _index, _dev_id, _con_id, _period, \
650 			       _polarity, NULL)
651 
652 #if IS_ENABLED(CONFIG_PWM)
653 void pwm_add_table(struct pwm_lookup *table, size_t num);
654 void pwm_remove_table(struct pwm_lookup *table, size_t num);
655 #else
pwm_add_table(struct pwm_lookup * table,size_t num)656 static inline void pwm_add_table(struct pwm_lookup *table, size_t num)
657 {
658 }
659 
pwm_remove_table(struct pwm_lookup * table,size_t num)660 static inline void pwm_remove_table(struct pwm_lookup *table, size_t num)
661 {
662 }
663 #endif
664 
665 #ifdef CONFIG_PWM_SYSFS
666 void pwmchip_sysfs_export(struct pwm_chip *chip);
667 void pwmchip_sysfs_unexport(struct pwm_chip *chip);
668 #else
pwmchip_sysfs_export(struct pwm_chip * chip)669 static inline void pwmchip_sysfs_export(struct pwm_chip *chip)
670 {
671 }
672 
pwmchip_sysfs_unexport(struct pwm_chip * chip)673 static inline void pwmchip_sysfs_unexport(struct pwm_chip *chip)
674 {
675 }
676 #endif /* CONFIG_PWM_SYSFS */
677 
678 #endif /* __LINUX_PWM_H */
679