Russell King | 1a189b9 | 2008-04-13 21:41:55 +0100 | [diff] [blame] | 1 | #ifndef __LINUX_PWM_H |
| 2 | #define __LINUX_PWM_H |
| 3 | |
Tushar Behera | 0bcf168 | 2012-09-12 15:31:46 +0530 | [diff] [blame] | 4 | #include <linux/err.h> |
Jonathan Richardson | d1cd214 | 2015-10-16 17:40:58 -0700 | [diff] [blame] | 5 | #include <linux/mutex.h> |
Thierry Reding | 7299ab7 | 2011-12-14 11:10:32 +0100 | [diff] [blame] | 6 | #include <linux/of.h> |
| 7 | |
Lee Jones | 3a3d1a4 | 2016-06-08 10:21:23 +0100 | [diff] [blame] | 8 | struct pwm_capture; |
Thierry Reding | 62099ab | 2012-03-26 09:31:48 +0200 | [diff] [blame] | 9 | struct seq_file; |
Lee Jones | 3a3d1a4 | 2016-06-08 10:21:23 +0100 | [diff] [blame] | 10 | |
Sascha Hauer | 0c2498f | 2011-01-28 09:40:40 +0100 | [diff] [blame] | 11 | struct pwm_chip; |
| 12 | |
Philip, Avinash | 0aa0869 | 2012-07-24 19:35:32 +0530 | [diff] [blame] | 13 | /** |
| 14 | * enum pwm_polarity - polarity of a PWM signal |
| 15 | * @PWM_POLARITY_NORMAL: a high signal for the duration of the duty- |
| 16 | * cycle, followed by a low signal for the remainder of the pulse |
| 17 | * period |
| 18 | * @PWM_POLARITY_INVERSED: a low signal for the duration of the duty- |
| 19 | * cycle, followed by a high signal for the remainder of the pulse |
| 20 | * period |
| 21 | */ |
| 22 | enum pwm_polarity { |
| 23 | PWM_POLARITY_NORMAL, |
| 24 | PWM_POLARITY_INVERSED, |
| 25 | }; |
| 26 | |
Boris Brezillon | e39c0df | 2016-04-14 21:17:21 +0200 | [diff] [blame] | 27 | /** |
| 28 | * struct pwm_args - board-dependent PWM arguments |
| 29 | * @period: reference period |
| 30 | * @polarity: reference polarity |
| 31 | * |
| 32 | * This structure describes board-dependent arguments attached to a PWM |
| 33 | * device. These arguments are usually retrieved from the PWM lookup table or |
| 34 | * device tree. |
| 35 | * |
| 36 | * Do not confuse this with the PWM state: PWM arguments represent the initial |
| 37 | * configuration that users want to use on this PWM device rather than the |
| 38 | * current PWM hardware state. |
| 39 | */ |
| 40 | struct pwm_args { |
Fenglin Wu | 9faf274 | 2018-09-10 10:05:52 +0800 | [diff] [blame] | 41 | u64 period; |
Boris Brezillon | e39c0df | 2016-04-14 21:17:21 +0200 | [diff] [blame] | 42 | enum pwm_polarity polarity; |
| 43 | }; |
| 44 | |
Thierry Reding | f051c46 | 2011-12-14 11:12:23 +0100 | [diff] [blame] | 45 | enum { |
| 46 | PWMF_REQUESTED = 1 << 0, |
Boris Brezillon | 09a7e4a | 2016-04-14 21:17:39 +0200 | [diff] [blame] | 47 | PWMF_EXPORTED = 1 << 1, |
Thierry Reding | f051c46 | 2011-12-14 11:12:23 +0100 | [diff] [blame] | 48 | }; |
| 49 | |
Fenglin Wu | ccee0bb | 2017-12-04 09:56:51 +0800 | [diff] [blame] | 50 | /** |
| 51 | * enum pwm_output_type - output type of the PWM signal |
| 52 | * @PWM_OUTPUT_FIXED: PWM output is fixed until a change request |
| 53 | * @PWM_OUTPUT_MODULATED: PWM output is modulated in hardware |
| 54 | * autonomously with a predefined pattern |
| 55 | */ |
| 56 | enum pwm_output_type { |
| 57 | PWM_OUTPUT_FIXED = 1 << 0, |
| 58 | PWM_OUTPUT_MODULATED = 1 << 1, |
| 59 | }; |
| 60 | |
| 61 | /** |
| 62 | * struct pwm_output_pattern - PWM duty pattern for MODULATED duty type |
| 63 | * @duty_pattern: PWM duty cycles in the pattern for duty modulation |
| 64 | * @num_entries: number of entries in the pattern |
| 65 | * @cycles_per_duty: number of PWM period cycles an entry stays at |
| 66 | */ |
| 67 | struct pwm_output_pattern { |
Fenglin Wu | 9faf274 | 2018-09-10 10:05:52 +0800 | [diff] [blame] | 68 | u64 *duty_pattern; |
Fenglin Wu | ccee0bb | 2017-12-04 09:56:51 +0800 | [diff] [blame] | 69 | unsigned int num_entries; |
Fenglin Wu | 9faf274 | 2018-09-10 10:05:52 +0800 | [diff] [blame] | 70 | u64 cycles_per_duty; |
Fenglin Wu | ccee0bb | 2017-12-04 09:56:51 +0800 | [diff] [blame] | 71 | }; |
| 72 | |
Boris Brezillon | 43a276b | 2016-04-14 21:17:38 +0200 | [diff] [blame] | 73 | /* |
| 74 | * struct pwm_state - state of a PWM channel |
| 75 | * @period: PWM period (in nanoseconds) |
| 76 | * @duty_cycle: PWM duty cycle (in nanoseconds) |
| 77 | * @polarity: PWM polarity |
Boris Brezillon | 09a7e4a | 2016-04-14 21:17:39 +0200 | [diff] [blame] | 78 | * @enabled: PWM enabled status |
Boris Brezillon | 43a276b | 2016-04-14 21:17:38 +0200 | [diff] [blame] | 79 | */ |
| 80 | struct pwm_state { |
Fenglin Wu | 9faf274 | 2018-09-10 10:05:52 +0800 | [diff] [blame] | 81 | u64 period; |
| 82 | u64 duty_cycle; |
Boris Brezillon | 43a276b | 2016-04-14 21:17:38 +0200 | [diff] [blame] | 83 | enum pwm_polarity polarity; |
Fenglin Wu | ccee0bb | 2017-12-04 09:56:51 +0800 | [diff] [blame] | 84 | enum pwm_output_type output_type; |
| 85 | struct pwm_output_pattern *output_pattern; |
Boris Brezillon | 09a7e4a | 2016-04-14 21:17:39 +0200 | [diff] [blame] | 86 | bool enabled; |
Boris Brezillon | 43a276b | 2016-04-14 21:17:38 +0200 | [diff] [blame] | 87 | }; |
| 88 | |
Thierry Reding | 0488380 | 2015-07-27 11:58:32 +0200 | [diff] [blame] | 89 | /** |
| 90 | * struct pwm_device - PWM channel object |
| 91 | * @label: name of the PWM device |
| 92 | * @flags: flags associated with the PWM device |
| 93 | * @hwpwm: per-chip relative index of the PWM device |
| 94 | * @pwm: global index of the PWM device |
| 95 | * @chip: PWM chip providing this PWM device |
| 96 | * @chip_data: chip-private data associated with the PWM device |
Boris Brezillon | e39c0df | 2016-04-14 21:17:21 +0200 | [diff] [blame] | 97 | * @args: PWM arguments |
Boris Brezillon | 43a276b | 2016-04-14 21:17:38 +0200 | [diff] [blame] | 98 | * @state: curent PWM channel state |
Thierry Reding | 0488380 | 2015-07-27 11:58:32 +0200 | [diff] [blame] | 99 | */ |
Thierry Reding | f051c46 | 2011-12-14 11:12:23 +0100 | [diff] [blame] | 100 | struct pwm_device { |
Thierry Reding | 6bc7064 | 2015-07-27 11:57:28 +0200 | [diff] [blame] | 101 | const char *label; |
| 102 | unsigned long flags; |
| 103 | unsigned int hwpwm; |
| 104 | unsigned int pwm; |
| 105 | struct pwm_chip *chip; |
| 106 | void *chip_data; |
Thierry Reding | f051c46 | 2011-12-14 11:12:23 +0100 | [diff] [blame] | 107 | |
Boris Brezillon | e39c0df | 2016-04-14 21:17:21 +0200 | [diff] [blame] | 108 | struct pwm_args args; |
Boris Brezillon | 43a276b | 2016-04-14 21:17:38 +0200 | [diff] [blame] | 109 | struct pwm_state state; |
Thierry Reding | f051c46 | 2011-12-14 11:12:23 +0100 | [diff] [blame] | 110 | }; |
| 111 | |
Boris Brezillon | 43a276b | 2016-04-14 21:17:38 +0200 | [diff] [blame] | 112 | /** |
| 113 | * pwm_get_state() - retrieve the current PWM state |
| 114 | * @pwm: PWM device |
| 115 | * @state: state to fill with the current PWM state |
| 116 | */ |
| 117 | static inline void pwm_get_state(const struct pwm_device *pwm, |
| 118 | struct pwm_state *state) |
| 119 | { |
| 120 | *state = pwm->state; |
| 121 | } |
| 122 | |
Boris Brezillon | 5c31252 | 2015-07-01 10:21:47 +0200 | [diff] [blame] | 123 | static inline bool pwm_is_enabled(const struct pwm_device *pwm) |
| 124 | { |
Boris Brezillon | 09a7e4a | 2016-04-14 21:17:39 +0200 | [diff] [blame] | 125 | struct pwm_state state; |
| 126 | |
| 127 | pwm_get_state(pwm, &state); |
| 128 | |
| 129 | return state.enabled; |
Boris Brezillon | 5c31252 | 2015-07-01 10:21:47 +0200 | [diff] [blame] | 130 | } |
| 131 | |
Thierry Reding | f051c46 | 2011-12-14 11:12:23 +0100 | [diff] [blame] | 132 | static inline void pwm_set_period(struct pwm_device *pwm, unsigned int period) |
| 133 | { |
| 134 | if (pwm) |
Boris Brezillon | 43a276b | 2016-04-14 21:17:38 +0200 | [diff] [blame] | 135 | pwm->state.period = period; |
Thierry Reding | f051c46 | 2011-12-14 11:12:23 +0100 | [diff] [blame] | 136 | } |
| 137 | |
Fenglin Wu | 9faf274 | 2018-09-10 10:05:52 +0800 | [diff] [blame] | 138 | static inline void pwm_set_period_extend(struct pwm_device *pwm, u64 period) |
| 139 | { |
| 140 | if (pwm) |
| 141 | pwm->state.period = period; |
| 142 | } |
| 143 | |
Boris Brezillon | a1cf421 | 2015-07-01 10:21:48 +0200 | [diff] [blame] | 144 | static inline unsigned int pwm_get_period(const struct pwm_device *pwm) |
Thierry Reding | f051c46 | 2011-12-14 11:12:23 +0100 | [diff] [blame] | 145 | { |
Boris Brezillon | 43a276b | 2016-04-14 21:17:38 +0200 | [diff] [blame] | 146 | struct pwm_state state; |
| 147 | |
| 148 | pwm_get_state(pwm, &state); |
| 149 | |
Fenglin Wu | 9faf274 | 2018-09-10 10:05:52 +0800 | [diff] [blame] | 150 | if (state.period > UINT_MAX) |
| 151 | pr_warn("PWM period %llu is truncated\n", state.period); |
| 152 | |
| 153 | return (unsigned int)state.period; |
| 154 | } |
| 155 | |
| 156 | static inline u64 pwm_get_period_extend(const struct pwm_device *pwm) |
| 157 | { |
| 158 | struct pwm_state state; |
| 159 | |
| 160 | pwm_get_state(pwm, &state); |
| 161 | |
Boris Brezillon | 43a276b | 2016-04-14 21:17:38 +0200 | [diff] [blame] | 162 | return state.period; |
Thierry Reding | f051c46 | 2011-12-14 11:12:23 +0100 | [diff] [blame] | 163 | } |
| 164 | |
H Hartley Sweeten | 76abbdde | 2013-06-11 10:38:59 -0700 | [diff] [blame] | 165 | static inline void pwm_set_duty_cycle(struct pwm_device *pwm, unsigned int duty) |
| 166 | { |
| 167 | if (pwm) |
Boris Brezillon | 43a276b | 2016-04-14 21:17:38 +0200 | [diff] [blame] | 168 | pwm->state.duty_cycle = duty; |
H Hartley Sweeten | 76abbdde | 2013-06-11 10:38:59 -0700 | [diff] [blame] | 169 | } |
| 170 | |
Fenglin Wu | 9faf274 | 2018-09-10 10:05:52 +0800 | [diff] [blame] | 171 | static inline void pwm_set_duty_cycle_extend(struct pwm_device *pwm, u64 duty) |
| 172 | { |
| 173 | if (pwm) |
| 174 | pwm->state.duty_cycle = duty; |
| 175 | } |
| 176 | |
Boris Brezillon | a1cf421 | 2015-07-01 10:21:48 +0200 | [diff] [blame] | 177 | static inline unsigned int pwm_get_duty_cycle(const struct pwm_device *pwm) |
H Hartley Sweeten | 76abbdde | 2013-06-11 10:38:59 -0700 | [diff] [blame] | 178 | { |
Boris Brezillon | 43a276b | 2016-04-14 21:17:38 +0200 | [diff] [blame] | 179 | struct pwm_state state; |
| 180 | |
| 181 | pwm_get_state(pwm, &state); |
| 182 | |
Fenglin Wu | 9faf274 | 2018-09-10 10:05:52 +0800 | [diff] [blame] | 183 | if (state.duty_cycle > UINT_MAX) |
| 184 | pr_warn("PWM duty cycle %llu is truncated\n", state.duty_cycle); |
| 185 | |
| 186 | return (unsigned int)state.duty_cycle; |
| 187 | } |
| 188 | |
| 189 | static inline u64 pwm_get_duty_cycle_extend(const struct pwm_device *pwm) |
| 190 | { |
| 191 | struct pwm_state state; |
| 192 | |
| 193 | pwm_get_state(pwm, &state); |
| 194 | |
Boris Brezillon | 43a276b | 2016-04-14 21:17:38 +0200 | [diff] [blame] | 195 | return state.duty_cycle; |
H Hartley Sweeten | 76abbdde | 2013-06-11 10:38:59 -0700 | [diff] [blame] | 196 | } |
| 197 | |
Boris Brezillon | 011e763 | 2015-07-01 10:21:49 +0200 | [diff] [blame] | 198 | static inline enum pwm_polarity pwm_get_polarity(const struct pwm_device *pwm) |
| 199 | { |
Boris Brezillon | 43a276b | 2016-04-14 21:17:38 +0200 | [diff] [blame] | 200 | struct pwm_state state; |
| 201 | |
| 202 | pwm_get_state(pwm, &state); |
| 203 | |
| 204 | return state.polarity; |
Boris Brezillon | 011e763 | 2015-07-01 10:21:49 +0200 | [diff] [blame] | 205 | } |
| 206 | |
Fenglin Wu | ccee0bb | 2017-12-04 09:56:51 +0800 | [diff] [blame] | 207 | static inline enum pwm_output_type pwm_get_output_type( |
| 208 | const struct pwm_device *pwm) |
| 209 | { |
| 210 | struct pwm_state state; |
| 211 | |
| 212 | pwm_get_state(pwm, &state); |
| 213 | |
| 214 | return state.output_type; |
| 215 | } |
| 216 | |
| 217 | static inline struct pwm_output_pattern *pwm_get_output_pattern( |
| 218 | struct pwm_device *pwm) |
| 219 | { |
| 220 | struct pwm_state state; |
| 221 | |
| 222 | pwm_get_state(pwm, &state); |
| 223 | |
| 224 | return pwm->state.output_pattern ?: NULL; |
| 225 | } |
| 226 | |
Boris Brezillon | e39c0df | 2016-04-14 21:17:21 +0200 | [diff] [blame] | 227 | static inline void pwm_get_args(const struct pwm_device *pwm, |
| 228 | struct pwm_args *args) |
| 229 | { |
| 230 | *args = pwm->args; |
| 231 | } |
| 232 | |
Sascha Hauer | 0c2498f | 2011-01-28 09:40:40 +0100 | [diff] [blame] | 233 | /** |
Boris Brezillon | a6a0dbb | 2016-06-14 11:13:09 +0200 | [diff] [blame] | 234 | * pwm_init_state() - prepare a new state to be applied with pwm_apply_state() |
| 235 | * @pwm: PWM device |
| 236 | * @state: state to fill with the prepared PWM state |
| 237 | * |
| 238 | * This functions prepares a state that can later be tweaked and applied |
| 239 | * to the PWM device with pwm_apply_state(). This is a convenient function |
| 240 | * that first retrieves the current PWM state and the replaces the period |
| 241 | * and polarity fields with the reference values defined in pwm->args. |
| 242 | * Once the function returns, you can adjust the ->enabled and ->duty_cycle |
| 243 | * fields according to your needs before calling pwm_apply_state(). |
| 244 | * |
| 245 | * ->duty_cycle is initially set to zero to avoid cases where the current |
| 246 | * ->duty_cycle value exceed the pwm_args->period one, which would trigger |
| 247 | * an error if the user calls pwm_apply_state() without adjusting ->duty_cycle |
| 248 | * first. |
| 249 | */ |
| 250 | static inline void pwm_init_state(const struct pwm_device *pwm, |
| 251 | struct pwm_state *state) |
| 252 | { |
| 253 | struct pwm_args args; |
| 254 | |
| 255 | /* First get the current state. */ |
| 256 | pwm_get_state(pwm, state); |
| 257 | |
| 258 | /* Then fill it with the reference config */ |
| 259 | pwm_get_args(pwm, &args); |
| 260 | |
| 261 | state->period = args.period; |
| 262 | state->polarity = args.polarity; |
| 263 | state->duty_cycle = 0; |
| 264 | } |
| 265 | |
| 266 | /** |
Boris Brezillon | f6f3bdd | 2016-06-14 11:13:10 +0200 | [diff] [blame] | 267 | * pwm_get_relative_duty_cycle() - Get a relative duty cycle value |
| 268 | * @state: PWM state to extract the duty cycle from |
| 269 | * @scale: target scale of the relative duty cycle |
| 270 | * |
| 271 | * This functions converts the absolute duty cycle stored in @state (expressed |
| 272 | * in nanosecond) into a value relative to the period. |
| 273 | * |
| 274 | * For example if you want to get the duty_cycle expressed in percent, call: |
| 275 | * |
| 276 | * pwm_get_state(pwm, &state); |
| 277 | * duty = pwm_get_relative_duty_cycle(&state, 100); |
| 278 | */ |
| 279 | static inline unsigned int |
| 280 | pwm_get_relative_duty_cycle(const struct pwm_state *state, unsigned int scale) |
| 281 | { |
| 282 | if (!state->period) |
| 283 | return 0; |
| 284 | |
| 285 | return DIV_ROUND_CLOSEST_ULL((u64)state->duty_cycle * scale, |
| 286 | state->period); |
| 287 | } |
| 288 | |
| 289 | /** |
| 290 | * pwm_set_relative_duty_cycle() - Set a relative duty cycle value |
| 291 | * @state: PWM state to fill |
| 292 | * @duty_cycle: relative duty cycle value |
| 293 | * @scale: scale in which @duty_cycle is expressed |
| 294 | * |
| 295 | * This functions converts a relative into an absolute duty cycle (expressed |
| 296 | * in nanoseconds), and puts the result in state->duty_cycle. |
| 297 | * |
| 298 | * For example if you want to configure a 50% duty cycle, call: |
| 299 | * |
| 300 | * pwm_init_state(pwm, &state); |
| 301 | * pwm_set_relative_duty_cycle(&state, 50, 100); |
| 302 | * pwm_apply_state(pwm, &state); |
| 303 | * |
| 304 | * This functions returns -EINVAL if @duty_cycle and/or @scale are |
| 305 | * inconsistent (@scale == 0 or @duty_cycle > @scale). |
| 306 | */ |
| 307 | static inline int |
| 308 | pwm_set_relative_duty_cycle(struct pwm_state *state, unsigned int duty_cycle, |
| 309 | unsigned int scale) |
| 310 | { |
| 311 | if (!scale || duty_cycle > scale) |
| 312 | return -EINVAL; |
| 313 | |
| 314 | state->duty_cycle = DIV_ROUND_CLOSEST_ULL((u64)duty_cycle * |
| 315 | state->period, |
| 316 | scale); |
| 317 | |
| 318 | return 0; |
| 319 | } |
| 320 | |
| 321 | /** |
Sascha Hauer | 0c2498f | 2011-01-28 09:40:40 +0100 | [diff] [blame] | 322 | * struct pwm_ops - PWM controller operations |
| 323 | * @request: optional hook for requesting a PWM |
| 324 | * @free: optional hook for freeing a PWM |
| 325 | * @config: configure duty cycles and period length for this PWM |
Fenglin Wu | 9faf274 | 2018-09-10 10:05:52 +0800 | [diff] [blame] | 326 | * @config_extend: configure duty cycles and period length for this |
| 327 | * PWM with u64 data type |
Philip, Avinash | 0aa0869 | 2012-07-24 19:35:32 +0530 | [diff] [blame] | 328 | * @set_polarity: configure the polarity of this PWM |
Lee Jones | 3a3d1a4 | 2016-06-08 10:21:23 +0100 | [diff] [blame] | 329 | * @capture: capture and report PWM signal |
Sascha Hauer | 0c2498f | 2011-01-28 09:40:40 +0100 | [diff] [blame] | 330 | * @enable: enable PWM output toggling |
| 331 | * @disable: disable PWM output toggling |
Fenglin Wu | ccee0bb | 2017-12-04 09:56:51 +0800 | [diff] [blame] | 332 | * @get_output_type_supported: get the supported output type |
| 333 | * @set_output_type: set PWM output type |
| 334 | * @set_output_pattern: set the pattern for the modulated output |
Boris Brezillon | 5ec803e | 2016-04-14 21:17:41 +0200 | [diff] [blame] | 335 | * @apply: atomically apply a new PWM config. The state argument |
| 336 | * should be adjusted with the real hardware config (if the |
| 337 | * approximate the period or duty_cycle value, state should |
| 338 | * reflect it) |
Boris Brezillon | 15fa8a43 | 2016-04-14 21:17:40 +0200 | [diff] [blame] | 339 | * @get_state: get the current PWM state. This function is only |
| 340 | * called once per PWM device when the PWM chip is |
| 341 | * registered. |
Thierry Reding | 62099ab | 2012-03-26 09:31:48 +0200 | [diff] [blame] | 342 | * @dbg_show: optional routine to show contents in debugfs |
Sascha Hauer | 0c2498f | 2011-01-28 09:40:40 +0100 | [diff] [blame] | 343 | * @owner: helps prevent removal of modules exporting active PWMs |
| 344 | */ |
| 345 | struct pwm_ops { |
Thierry Reding | 6bc7064 | 2015-07-27 11:57:28 +0200 | [diff] [blame] | 346 | int (*request)(struct pwm_chip *chip, struct pwm_device *pwm); |
| 347 | void (*free)(struct pwm_chip *chip, struct pwm_device *pwm); |
| 348 | int (*config)(struct pwm_chip *chip, struct pwm_device *pwm, |
| 349 | int duty_ns, int period_ns); |
Fenglin Wu | 9faf274 | 2018-09-10 10:05:52 +0800 | [diff] [blame] | 350 | int (*config_extend)(struct pwm_chip *chip, struct pwm_device *pwm, |
| 351 | u64 duty_ns, u64 period_ns); |
Thierry Reding | 6bc7064 | 2015-07-27 11:57:28 +0200 | [diff] [blame] | 352 | int (*set_polarity)(struct pwm_chip *chip, struct pwm_device *pwm, |
| 353 | enum pwm_polarity polarity); |
Lee Jones | 3a3d1a4 | 2016-06-08 10:21:23 +0100 | [diff] [blame] | 354 | int (*capture)(struct pwm_chip *chip, struct pwm_device *pwm, |
| 355 | struct pwm_capture *result, unsigned long timeout); |
Thierry Reding | 6bc7064 | 2015-07-27 11:57:28 +0200 | [diff] [blame] | 356 | int (*enable)(struct pwm_chip *chip, struct pwm_device *pwm); |
| 357 | void (*disable)(struct pwm_chip *chip, struct pwm_device *pwm); |
Fenglin Wu | ccee0bb | 2017-12-04 09:56:51 +0800 | [diff] [blame] | 358 | int (*get_output_type_supported)(struct pwm_chip *chip, |
| 359 | struct pwm_device *pwm); |
| 360 | int (*set_output_type)(struct pwm_chip *chip, struct pwm_device *pwm, |
| 361 | enum pwm_output_type output_type); |
| 362 | int (*set_output_pattern)(struct pwm_chip *chip, |
| 363 | struct pwm_device *pwm, |
| 364 | struct pwm_output_pattern *output_pattern); |
Boris Brezillon | 5ec803e | 2016-04-14 21:17:41 +0200 | [diff] [blame] | 365 | int (*apply)(struct pwm_chip *chip, struct pwm_device *pwm, |
| 366 | struct pwm_state *state); |
Boris Brezillon | 15fa8a43 | 2016-04-14 21:17:40 +0200 | [diff] [blame] | 367 | void (*get_state)(struct pwm_chip *chip, struct pwm_device *pwm, |
| 368 | struct pwm_state *state); |
Thierry Reding | 62099ab | 2012-03-26 09:31:48 +0200 | [diff] [blame] | 369 | #ifdef CONFIG_DEBUG_FS |
Thierry Reding | 6bc7064 | 2015-07-27 11:57:28 +0200 | [diff] [blame] | 370 | void (*dbg_show)(struct pwm_chip *chip, struct seq_file *s); |
Thierry Reding | 62099ab | 2012-03-26 09:31:48 +0200 | [diff] [blame] | 371 | #endif |
Thierry Reding | 6bc7064 | 2015-07-27 11:57:28 +0200 | [diff] [blame] | 372 | struct module *owner; |
Sascha Hauer | 0c2498f | 2011-01-28 09:40:40 +0100 | [diff] [blame] | 373 | }; |
| 374 | |
| 375 | /** |
Thierry Reding | f051c46 | 2011-12-14 11:12:23 +0100 | [diff] [blame] | 376 | * struct pwm_chip - abstract a PWM controller |
| 377 | * @dev: device providing the PWMs |
| 378 | * @list: list node for internal use |
| 379 | * @ops: callbacks for this PWM controller |
| 380 | * @base: number of first PWM controlled by this chip |
| 381 | * @npwm: number of PWMs controlled by this chip |
| 382 | * @pwms: array of PWM devices allocated by the framework |
Thierry Reding | 0488380 | 2015-07-27 11:58:32 +0200 | [diff] [blame] | 383 | * @of_xlate: request a PWM device given a device tree PWM specifier |
| 384 | * @of_pwm_n_cells: number of cells expected in the device tree PWM specifier |
Florian Vaussard | 6e69ab1 | 2013-01-28 15:00:57 +0100 | [diff] [blame] | 385 | * @can_sleep: must be true if the .config(), .enable() or .disable() |
| 386 | * operations may sleep |
Sascha Hauer | 0c2498f | 2011-01-28 09:40:40 +0100 | [diff] [blame] | 387 | */ |
| 388 | struct pwm_chip { |
Thierry Reding | 6bc7064 | 2015-07-27 11:57:28 +0200 | [diff] [blame] | 389 | struct device *dev; |
| 390 | struct list_head list; |
| 391 | const struct pwm_ops *ops; |
| 392 | int base; |
| 393 | unsigned int npwm; |
Thierry Reding | f051c46 | 2011-12-14 11:12:23 +0100 | [diff] [blame] | 394 | |
Thierry Reding | 6bc7064 | 2015-07-27 11:57:28 +0200 | [diff] [blame] | 395 | struct pwm_device *pwms; |
Thierry Reding | 7299ab7 | 2011-12-14 11:10:32 +0100 | [diff] [blame] | 396 | |
Thierry Reding | 6bc7064 | 2015-07-27 11:57:28 +0200 | [diff] [blame] | 397 | struct pwm_device * (*of_xlate)(struct pwm_chip *pc, |
| 398 | const struct of_phandle_args *args); |
| 399 | unsigned int of_pwm_n_cells; |
| 400 | bool can_sleep; |
Sascha Hauer | 0c2498f | 2011-01-28 09:40:40 +0100 | [diff] [blame] | 401 | }; |
| 402 | |
Lee Jones | 3a3d1a4 | 2016-06-08 10:21:23 +0100 | [diff] [blame] | 403 | /** |
| 404 | * struct pwm_capture - PWM capture data |
| 405 | * @period: period of the PWM signal (in nanoseconds) |
| 406 | * @duty_cycle: duty cycle of the PWM signal (in nanoseconds) |
| 407 | */ |
| 408 | struct pwm_capture { |
Fenglin Wu | 9faf274 | 2018-09-10 10:05:52 +0800 | [diff] [blame] | 409 | u64 period; |
| 410 | u64 duty_cycle; |
Lee Jones | 3a3d1a4 | 2016-06-08 10:21:23 +0100 | [diff] [blame] | 411 | }; |
| 412 | |
Tushar Behera | 0bcf168 | 2012-09-12 15:31:46 +0530 | [diff] [blame] | 413 | #if IS_ENABLED(CONFIG_PWM) |
Boris Brezillon | 5ec803e | 2016-04-14 21:17:41 +0200 | [diff] [blame] | 414 | /* PWM user APIs */ |
| 415 | struct pwm_device *pwm_request(int pwm_id, const char *label); |
| 416 | void pwm_free(struct pwm_device *pwm); |
| 417 | int pwm_apply_state(struct pwm_device *pwm, struct pwm_state *state); |
| 418 | int pwm_adjust_config(struct pwm_device *pwm); |
| 419 | |
| 420 | /** |
Fenglin Wu | ccee0bb | 2017-12-04 09:56:51 +0800 | [diff] [blame] | 421 | * pwm_output_type_support() |
| 422 | * @pwm: PWM device |
| 423 | * |
| 424 | * Returns: output types supported by the PWM device |
| 425 | */ |
| 426 | static inline int pwm_get_output_type_supported(struct pwm_device *pwm) |
| 427 | { |
| 428 | if (pwm->chip->ops->get_output_type_supported != NULL) |
| 429 | return pwm->chip->ops-> |
| 430 | get_output_type_supported(pwm->chip, pwm); |
| 431 | else |
| 432 | return PWM_OUTPUT_FIXED; |
| 433 | } |
| 434 | |
| 435 | /** |
Boris Brezillon | 5ec803e | 2016-04-14 21:17:41 +0200 | [diff] [blame] | 436 | * pwm_config() - change a PWM device configuration |
| 437 | * @pwm: PWM device |
| 438 | * @duty_ns: "on" time (in nanoseconds) |
| 439 | * @period_ns: duration (in nanoseconds) of one cycle |
| 440 | * |
| 441 | * Returns: 0 on success or a negative error code on failure. |
| 442 | */ |
| 443 | static inline int pwm_config(struct pwm_device *pwm, int duty_ns, |
| 444 | int period_ns) |
| 445 | { |
| 446 | struct pwm_state state; |
| 447 | |
| 448 | if (!pwm) |
| 449 | return -EINVAL; |
| 450 | |
Brian Norris | ef2bf49 | 2016-05-27 09:45:49 -0700 | [diff] [blame] | 451 | if (duty_ns < 0 || period_ns < 0) |
| 452 | return -EINVAL; |
| 453 | |
Boris Brezillon | 5ec803e | 2016-04-14 21:17:41 +0200 | [diff] [blame] | 454 | pwm_get_state(pwm, &state); |
| 455 | if (state.duty_cycle == duty_ns && state.period == period_ns) |
| 456 | return 0; |
| 457 | |
| 458 | state.duty_cycle = duty_ns; |
| 459 | state.period = period_ns; |
| 460 | return pwm_apply_state(pwm, &state); |
| 461 | } |
| 462 | |
| 463 | /** |
Fenglin Wu | 9faf274 | 2018-09-10 10:05:52 +0800 | [diff] [blame] | 464 | * pwm_config_extend() - change PWM period and duty length with u64 data type |
| 465 | * @pwm: PWM device |
| 466 | * @duty_ns: "on" time (in nanoseconds) |
| 467 | * @period_ns: duration (in nanoseconds) of one cycle |
| 468 | * |
| 469 | * Returns: 0 on success or a negative error code on failure. |
| 470 | */ |
| 471 | static inline int pwm_config_extend(struct pwm_device *pwm, u64 duty_ns, |
| 472 | u64 period_ns) |
| 473 | { |
| 474 | struct pwm_state state; |
| 475 | |
| 476 | if (!pwm) |
| 477 | return -EINVAL; |
| 478 | |
| 479 | pwm_get_state(pwm, &state); |
| 480 | if (state.duty_cycle == duty_ns && state.period == period_ns) |
| 481 | return 0; |
| 482 | |
| 483 | state.duty_cycle = duty_ns; |
| 484 | state.period = period_ns; |
| 485 | return pwm_apply_state(pwm, &state); |
| 486 | } |
| 487 | |
| 488 | /** |
Boris Brezillon | 5ec803e | 2016-04-14 21:17:41 +0200 | [diff] [blame] | 489 | * pwm_set_polarity() - configure the polarity of a PWM signal |
| 490 | * @pwm: PWM device |
| 491 | * @polarity: new polarity of the PWM signal |
| 492 | * |
| 493 | * Note that the polarity cannot be configured while the PWM device is |
| 494 | * enabled. |
| 495 | * |
| 496 | * Returns: 0 on success or a negative error code on failure. |
| 497 | */ |
| 498 | static inline int pwm_set_polarity(struct pwm_device *pwm, |
| 499 | enum pwm_polarity polarity) |
| 500 | { |
| 501 | struct pwm_state state; |
| 502 | |
| 503 | if (!pwm) |
| 504 | return -EINVAL; |
| 505 | |
| 506 | pwm_get_state(pwm, &state); |
| 507 | if (state.polarity == polarity) |
| 508 | return 0; |
| 509 | |
| 510 | /* |
| 511 | * Changing the polarity of a running PWM without adjusting the |
| 512 | * dutycycle/period value is a bit risky (can introduce glitches). |
| 513 | * Return -EBUSY in this case. |
| 514 | * Note that this is allowed when using pwm_apply_state() because |
| 515 | * the user specifies all the parameters. |
| 516 | */ |
| 517 | if (state.enabled) |
| 518 | return -EBUSY; |
| 519 | |
| 520 | state.polarity = polarity; |
| 521 | return pwm_apply_state(pwm, &state); |
| 522 | } |
| 523 | |
| 524 | /** |
| 525 | * pwm_enable() - start a PWM output toggling |
| 526 | * @pwm: PWM device |
| 527 | * |
| 528 | * Returns: 0 on success or a negative error code on failure. |
| 529 | */ |
| 530 | static inline int pwm_enable(struct pwm_device *pwm) |
| 531 | { |
| 532 | struct pwm_state state; |
| 533 | |
| 534 | if (!pwm) |
| 535 | return -EINVAL; |
| 536 | |
| 537 | pwm_get_state(pwm, &state); |
| 538 | if (state.enabled) |
| 539 | return 0; |
| 540 | |
| 541 | state.enabled = true; |
| 542 | return pwm_apply_state(pwm, &state); |
| 543 | } |
| 544 | |
| 545 | /** |
| 546 | * pwm_disable() - stop a PWM output toggling |
| 547 | * @pwm: PWM device |
| 548 | */ |
| 549 | static inline void pwm_disable(struct pwm_device *pwm) |
| 550 | { |
| 551 | struct pwm_state state; |
| 552 | |
| 553 | if (!pwm) |
| 554 | return; |
| 555 | |
| 556 | pwm_get_state(pwm, &state); |
| 557 | if (!state.enabled) |
| 558 | return; |
| 559 | |
| 560 | state.enabled = false; |
| 561 | pwm_apply_state(pwm, &state); |
| 562 | } |
| 563 | |
Boris Brezillon | 5ec803e | 2016-04-14 21:17:41 +0200 | [diff] [blame] | 564 | /* PWM provider APIs */ |
Lee Jones | 3a3d1a4 | 2016-06-08 10:21:23 +0100 | [diff] [blame] | 565 | int pwm_capture(struct pwm_device *pwm, struct pwm_capture *result, |
| 566 | unsigned long timeout); |
Thierry Reding | f051c46 | 2011-12-14 11:12:23 +0100 | [diff] [blame] | 567 | int pwm_set_chip_data(struct pwm_device *pwm, void *data); |
| 568 | void *pwm_get_chip_data(struct pwm_device *pwm); |
| 569 | |
Tim Kryger | b6a00fa | 2015-05-26 13:08:16 -0700 | [diff] [blame] | 570 | int pwmchip_add_with_polarity(struct pwm_chip *chip, |
| 571 | enum pwm_polarity polarity); |
Sascha Hauer | 0c2498f | 2011-01-28 09:40:40 +0100 | [diff] [blame] | 572 | int pwmchip_add(struct pwm_chip *chip); |
| 573 | int pwmchip_remove(struct pwm_chip *chip); |
Thierry Reding | f051c46 | 2011-12-14 11:12:23 +0100 | [diff] [blame] | 574 | struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip, |
| 575 | unsigned int index, |
| 576 | const char *label); |
Thierry Reding | 8138d2d | 2012-03-26 08:42:48 +0200 | [diff] [blame] | 577 | |
Philip, Avinash | 83af240 | 2012-11-21 13:10:44 +0530 | [diff] [blame] | 578 | struct pwm_device *of_pwm_xlate_with_flags(struct pwm_chip *pc, |
| 579 | const struct of_phandle_args *args); |
| 580 | |
Peter Ujfalusi | d4c0c47 | 2012-12-21 01:43:57 -0800 | [diff] [blame] | 581 | struct pwm_device *pwm_get(struct device *dev, const char *con_id); |
Peter Ujfalusi | 8eb9612 | 2012-12-21 01:43:58 -0800 | [diff] [blame] | 582 | struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id); |
Thierry Reding | 8138d2d | 2012-03-26 08:42:48 +0200 | [diff] [blame] | 583 | void pwm_put(struct pwm_device *pwm); |
| 584 | |
Peter Ujfalusi | d4c0c47 | 2012-12-21 01:43:57 -0800 | [diff] [blame] | 585 | struct pwm_device *devm_pwm_get(struct device *dev, const char *con_id); |
Peter Ujfalusi | 261a5ed | 2012-12-21 01:43:59 -0800 | [diff] [blame] | 586 | struct pwm_device *devm_of_pwm_get(struct device *dev, struct device_node *np, |
| 587 | const char *con_id); |
Alexandre Courbot | 6354316 | 2012-08-01 19:20:58 +0900 | [diff] [blame] | 588 | void devm_pwm_put(struct device *dev, struct pwm_device *pwm); |
Florian Vaussard | 6e69ab1 | 2013-01-28 15:00:57 +0100 | [diff] [blame] | 589 | |
| 590 | bool pwm_can_sleep(struct pwm_device *pwm); |
Tushar Behera | 0bcf168 | 2012-09-12 15:31:46 +0530 | [diff] [blame] | 591 | #else |
Boris Brezillon | 5ec803e | 2016-04-14 21:17:41 +0200 | [diff] [blame] | 592 | static inline struct pwm_device *pwm_request(int pwm_id, const char *label) |
| 593 | { |
| 594 | return ERR_PTR(-ENODEV); |
| 595 | } |
| 596 | |
| 597 | static inline void pwm_free(struct pwm_device *pwm) |
| 598 | { |
| 599 | } |
| 600 | |
| 601 | static inline int pwm_apply_state(struct pwm_device *pwm, |
| 602 | const struct pwm_state *state) |
| 603 | { |
| 604 | return -ENOTSUPP; |
| 605 | } |
| 606 | |
| 607 | static inline int pwm_adjust_config(struct pwm_device *pwm) |
| 608 | { |
| 609 | return -ENOTSUPP; |
| 610 | } |
| 611 | |
| 612 | static inline int pwm_config(struct pwm_device *pwm, int duty_ns, |
| 613 | int period_ns) |
| 614 | { |
| 615 | return -EINVAL; |
| 616 | } |
| 617 | |
Lee Jones | 3a3d1a4 | 2016-06-08 10:21:23 +0100 | [diff] [blame] | 618 | static inline int pwm_capture(struct pwm_device *pwm, |
| 619 | struct pwm_capture *result, |
| 620 | unsigned long timeout) |
| 621 | { |
| 622 | return -EINVAL; |
| 623 | } |
| 624 | |
Boris Brezillon | 5ec803e | 2016-04-14 21:17:41 +0200 | [diff] [blame] | 625 | static inline int pwm_set_polarity(struct pwm_device *pwm, |
| 626 | enum pwm_polarity polarity) |
| 627 | { |
| 628 | return -ENOTSUPP; |
| 629 | } |
| 630 | |
| 631 | static inline int pwm_enable(struct pwm_device *pwm) |
| 632 | { |
| 633 | return -EINVAL; |
| 634 | } |
| 635 | |
| 636 | static inline void pwm_disable(struct pwm_device *pwm) |
| 637 | { |
| 638 | } |
| 639 | |
Tushar Behera | 0bcf168 | 2012-09-12 15:31:46 +0530 | [diff] [blame] | 640 | static inline int pwm_set_chip_data(struct pwm_device *pwm, void *data) |
| 641 | { |
| 642 | return -EINVAL; |
| 643 | } |
| 644 | |
| 645 | static inline void *pwm_get_chip_data(struct pwm_device *pwm) |
| 646 | { |
| 647 | return NULL; |
| 648 | } |
| 649 | |
| 650 | static inline int pwmchip_add(struct pwm_chip *chip) |
| 651 | { |
| 652 | return -EINVAL; |
| 653 | } |
| 654 | |
Tim Kryger | b6a00fa | 2015-05-26 13:08:16 -0700 | [diff] [blame] | 655 | static inline int pwmchip_add_inversed(struct pwm_chip *chip) |
| 656 | { |
| 657 | return -EINVAL; |
| 658 | } |
| 659 | |
Tushar Behera | 0bcf168 | 2012-09-12 15:31:46 +0530 | [diff] [blame] | 660 | static inline int pwmchip_remove(struct pwm_chip *chip) |
| 661 | { |
| 662 | return -EINVAL; |
| 663 | } |
| 664 | |
| 665 | static inline struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip, |
| 666 | unsigned int index, |
| 667 | const char *label) |
| 668 | { |
| 669 | return ERR_PTR(-ENODEV); |
| 670 | } |
| 671 | |
| 672 | static inline struct pwm_device *pwm_get(struct device *dev, |
| 673 | const char *consumer) |
| 674 | { |
| 675 | return ERR_PTR(-ENODEV); |
| 676 | } |
| 677 | |
Peter Ujfalusi | 8eb9612 | 2012-12-21 01:43:58 -0800 | [diff] [blame] | 678 | static inline struct pwm_device *of_pwm_get(struct device_node *np, |
| 679 | const char *con_id) |
| 680 | { |
| 681 | return ERR_PTR(-ENODEV); |
| 682 | } |
| 683 | |
Tushar Behera | 0bcf168 | 2012-09-12 15:31:46 +0530 | [diff] [blame] | 684 | static inline void pwm_put(struct pwm_device *pwm) |
| 685 | { |
| 686 | } |
| 687 | |
| 688 | static inline struct pwm_device *devm_pwm_get(struct device *dev, |
| 689 | const char *consumer) |
| 690 | { |
| 691 | return ERR_PTR(-ENODEV); |
| 692 | } |
| 693 | |
Peter Ujfalusi | 261a5ed | 2012-12-21 01:43:59 -0800 | [diff] [blame] | 694 | static inline struct pwm_device *devm_of_pwm_get(struct device *dev, |
| 695 | struct device_node *np, |
| 696 | const char *con_id) |
| 697 | { |
| 698 | return ERR_PTR(-ENODEV); |
| 699 | } |
| 700 | |
Tushar Behera | 0bcf168 | 2012-09-12 15:31:46 +0530 | [diff] [blame] | 701 | static inline void devm_pwm_put(struct device *dev, struct pwm_device *pwm) |
| 702 | { |
| 703 | } |
Florian Vaussard | 6e69ab1 | 2013-01-28 15:00:57 +0100 | [diff] [blame] | 704 | |
| 705 | static inline bool pwm_can_sleep(struct pwm_device *pwm) |
| 706 | { |
| 707 | return false; |
| 708 | } |
Tushar Behera | 0bcf168 | 2012-09-12 15:31:46 +0530 | [diff] [blame] | 709 | #endif |
Alexandre Courbot | 6354316 | 2012-08-01 19:20:58 +0900 | [diff] [blame] | 710 | |
Boris Brezillon | 5ec803e | 2016-04-14 21:17:41 +0200 | [diff] [blame] | 711 | static inline void pwm_apply_args(struct pwm_device *pwm) |
| 712 | { |
Boris Brezillon | 33cdcee | 2016-06-22 09:25:14 +0200 | [diff] [blame] | 713 | struct pwm_state state = { }; |
| 714 | |
Boris Brezillon | 5ec803e | 2016-04-14 21:17:41 +0200 | [diff] [blame] | 715 | /* |
| 716 | * PWM users calling pwm_apply_args() expect to have a fresh config |
| 717 | * where the polarity and period are set according to pwm_args info. |
| 718 | * The problem is, polarity can only be changed when the PWM is |
| 719 | * disabled. |
| 720 | * |
| 721 | * PWM drivers supporting hardware readout may declare the PWM device |
| 722 | * as enabled, and prevent polarity setting, which changes from the |
| 723 | * existing behavior, where all PWM devices are declared as disabled |
| 724 | * at startup (even if they are actually enabled), thus authorizing |
| 725 | * polarity setting. |
| 726 | * |
Boris Brezillon | 33cdcee | 2016-06-22 09:25:14 +0200 | [diff] [blame] | 727 | * To fulfill this requirement, we apply a new state which disables |
| 728 | * the PWM device and set the reference period and polarity config. |
Boris Brezillon | 5ec803e | 2016-04-14 21:17:41 +0200 | [diff] [blame] | 729 | * |
| 730 | * Note that PWM users requiring a smooth handover between the |
| 731 | * bootloader and the kernel (like critical regulators controlled by |
| 732 | * PWM devices) will have to switch to the atomic API and avoid calling |
| 733 | * pwm_apply_args(). |
| 734 | */ |
Boris Brezillon | 33cdcee | 2016-06-22 09:25:14 +0200 | [diff] [blame] | 735 | |
| 736 | state.enabled = false; |
| 737 | state.polarity = pwm->args.polarity; |
| 738 | state.period = pwm->args.period; |
| 739 | |
| 740 | pwm_apply_state(pwm, &state); |
Boris Brezillon | 5ec803e | 2016-04-14 21:17:41 +0200 | [diff] [blame] | 741 | } |
| 742 | |
Thierry Reding | 8138d2d | 2012-03-26 08:42:48 +0200 | [diff] [blame] | 743 | struct pwm_lookup { |
| 744 | struct list_head list; |
| 745 | const char *provider; |
| 746 | unsigned int index; |
| 747 | const char *dev_id; |
| 748 | const char *con_id; |
Alexandre Belloni | 3796ce1 | 2014-05-19 22:42:32 +0200 | [diff] [blame] | 749 | unsigned int period; |
| 750 | enum pwm_polarity polarity; |
Thierry Reding | 8138d2d | 2012-03-26 08:42:48 +0200 | [diff] [blame] | 751 | }; |
| 752 | |
Alexandre Belloni | 4284402 | 2014-05-19 22:42:37 +0200 | [diff] [blame] | 753 | #define PWM_LOOKUP(_provider, _index, _dev_id, _con_id, _period, _polarity) \ |
Thierry Reding | 8138d2d | 2012-03-26 08:42:48 +0200 | [diff] [blame] | 754 | { \ |
| 755 | .provider = _provider, \ |
| 756 | .index = _index, \ |
| 757 | .dev_id = _dev_id, \ |
| 758 | .con_id = _con_id, \ |
Alexandre Belloni | 4284402 | 2014-05-19 22:42:37 +0200 | [diff] [blame] | 759 | .period = _period, \ |
| 760 | .polarity = _polarity \ |
Thierry Reding | 8138d2d | 2012-03-26 08:42:48 +0200 | [diff] [blame] | 761 | } |
| 762 | |
Tushar Behera | 0bcf168 | 2012-09-12 15:31:46 +0530 | [diff] [blame] | 763 | #if IS_ENABLED(CONFIG_PWM) |
Thierry Reding | 8138d2d | 2012-03-26 08:42:48 +0200 | [diff] [blame] | 764 | void pwm_add_table(struct pwm_lookup *table, size_t num); |
Shobhit Kumar | efb0de5 | 2015-05-05 15:04:18 +0530 | [diff] [blame] | 765 | void pwm_remove_table(struct pwm_lookup *table, size_t num); |
Tushar Behera | 0bcf168 | 2012-09-12 15:31:46 +0530 | [diff] [blame] | 766 | #else |
| 767 | static inline void pwm_add_table(struct pwm_lookup *table, size_t num) |
| 768 | { |
| 769 | } |
Shobhit Kumar | efb0de5 | 2015-05-05 15:04:18 +0530 | [diff] [blame] | 770 | |
| 771 | static inline void pwm_remove_table(struct pwm_lookup *table, size_t num) |
| 772 | { |
| 773 | } |
Sascha Hauer | 0c2498f | 2011-01-28 09:40:40 +0100 | [diff] [blame] | 774 | #endif |
| 775 | |
H Hartley Sweeten | 76abbdde | 2013-06-11 10:38:59 -0700 | [diff] [blame] | 776 | #ifdef CONFIG_PWM_SYSFS |
| 777 | void pwmchip_sysfs_export(struct pwm_chip *chip); |
| 778 | void pwmchip_sysfs_unexport(struct pwm_chip *chip); |
| 779 | #else |
| 780 | static inline void pwmchip_sysfs_export(struct pwm_chip *chip) |
| 781 | { |
| 782 | } |
| 783 | |
| 784 | static inline void pwmchip_sysfs_unexport(struct pwm_chip *chip) |
| 785 | { |
| 786 | } |
| 787 | #endif /* CONFIG_PWM_SYSFS */ |
| 788 | |
Mark Vels | 5243ef8 | 2009-01-18 18:42:45 +0100 | [diff] [blame] | 789 | #endif /* __LINUX_PWM_H */ |