Commit 9e40ee18 authored by Clemens Gruber's avatar Clemens Gruber Committed by Thierry Reding

pwm: core: Support new usage_power setting in PWM state

If usage_power is set, the PWM driver is only required to maintain
the power output but has more freedom regarding signal form.

If supported, the signal can be optimized, for example to
improve EMI by phase shifting individual channels.
Signed-off-by: default avatarClemens Gruber <clemens.gruber@pqgruber.com>
Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
parent 98761ce4
...@@ -48,6 +48,10 @@ After being requested, a PWM has to be configured using:: ...@@ -48,6 +48,10 @@ After being requested, a PWM has to be configured using::
This API controls both the PWM period/duty_cycle config and the This API controls both the PWM period/duty_cycle config and the
enable/disable state. enable/disable state.
There is also a usage_power setting: If set, the PWM driver is only required to
maintain the power output but has more freedom regarding signal form.
If supported by the driver, the signal can be optimized, for example to improve
EMI by phase shifting the individual channels of a chip.
The pwm_config(), pwm_enable() and pwm_disable() functions are just wrappers The pwm_config(), pwm_enable() and pwm_disable() functions are just wrappers
around pwm_apply_state() and should not be used if the user wants to change around pwm_apply_state() and should not be used if the user wants to change
......
...@@ -536,7 +536,8 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state) ...@@ -536,7 +536,8 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state)
if (state->period == pwm->state.period && if (state->period == pwm->state.period &&
state->duty_cycle == pwm->state.duty_cycle && state->duty_cycle == pwm->state.duty_cycle &&
state->polarity == pwm->state.polarity && state->polarity == pwm->state.polarity &&
state->enabled == pwm->state.enabled) state->enabled == pwm->state.enabled &&
state->usage_power == pwm->state.usage_power)
return 0; return 0;
if (chip->ops->apply) { if (chip->ops->apply) {
...@@ -1241,6 +1242,9 @@ static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s) ...@@ -1241,6 +1242,9 @@ static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s)
seq_printf(s, " polarity: %s", seq_printf(s, " polarity: %s",
state.polarity ? "inverse" : "normal"); state.polarity ? "inverse" : "normal");
if (state.usage_power)
seq_puts(s, " usage_power");
seq_puts(s, "\n"); seq_puts(s, "\n");
} }
} }
......
...@@ -54,12 +54,17 @@ enum { ...@@ -54,12 +54,17 @@ enum {
* @duty_cycle: PWM duty cycle (in nanoseconds) * @duty_cycle: PWM duty cycle (in nanoseconds)
* @polarity: PWM polarity * @polarity: PWM polarity
* @enabled: PWM enabled status * @enabled: PWM enabled status
* @usage_power: If set, the PWM driver is only required to maintain the power
* output but has more freedom regarding signal form.
* If supported, the signal can be optimized, for example to
* improve EMI by phase shifting individual channels.
*/ */
struct pwm_state { struct pwm_state {
u64 period; u64 period;
u64 duty_cycle; u64 duty_cycle;
enum pwm_polarity polarity; enum pwm_polarity polarity;
bool enabled; bool enabled;
bool usage_power;
}; };
/** /**
...@@ -188,6 +193,7 @@ static inline void pwm_init_state(const struct pwm_device *pwm, ...@@ -188,6 +193,7 @@ static inline void pwm_init_state(const struct pwm_device *pwm,
state->period = args.period; state->period = args.period;
state->polarity = args.polarity; state->polarity = args.polarity;
state->duty_cycle = 0; state->duty_cycle = 0;
state->usage_power = false;
} }
/** /**
...@@ -558,6 +564,7 @@ static inline void pwm_apply_args(struct pwm_device *pwm) ...@@ -558,6 +564,7 @@ static inline void pwm_apply_args(struct pwm_device *pwm)
state.enabled = false; state.enabled = false;
state.polarity = pwm->args.polarity; state.polarity = pwm->args.polarity;
state.period = pwm->args.period; state.period = pwm->args.period;
state.usage_power = false;
pwm_apply_state(pwm, &state); pwm_apply_state(pwm, &state);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment