linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] pwm: core: Support new usage_power setting in PWM state
@ 2021-05-07 13:18 Clemens Gruber
  2021-05-07 13:18 ` [PATCH 2/4] pwm: pca9685: " Clemens Gruber
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Clemens Gruber @ 2021-05-07 13:18 UTC (permalink / raw)
  To: linux-pwm
  Cc: Thierry Reding, Sven Van Asbroeck, Uwe Kleine-König,
	linux-kernel, Clemens Gruber

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: Clemens Gruber <clemens.gruber@pqgruber.com>
---
 Documentation/driver-api/pwm.rst | 4 ++++
 drivers/pwm/core.c               | 6 +++++-
 include/linux/pwm.h              | 7 +++++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/Documentation/driver-api/pwm.rst b/Documentation/driver-api/pwm.rst
index a7ca4f58305a..750734a7f874 100644
--- a/Documentation/driver-api/pwm.rst
+++ b/Documentation/driver-api/pwm.rst
@@ -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
 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
 around pwm_apply_state() and should not be used if the user wants to change
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index c4d5c0667137..4aa5a24cc6c5 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -554,7 +554,8 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state)
 	if (state->period == pwm->state.period &&
 	    state->duty_cycle == pwm->state.duty_cycle &&
 	    state->polarity == pwm->state.polarity &&
-	    state->enabled == pwm->state.enabled)
+	    state->enabled == pwm->state.enabled &&
+	    state->usage_power == pwm->state.usage_power)
 		return 0;
 
 	if (chip->ops->apply) {
@@ -1259,6 +1260,9 @@ static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s)
 		seq_printf(s, " polarity: %s",
 			   state.polarity ? "inverse" : "normal");
 
+		if (state.usage_power)
+			seq_puts(s, " usage_power");
+
 		seq_puts(s, "\n");
 	}
 }
diff --git a/include/linux/pwm.h b/include/linux/pwm.h
index 5bb90af4997e..5a73251d28e3 100644
--- a/include/linux/pwm.h
+++ b/include/linux/pwm.h
@@ -54,12 +54,17 @@ enum {
  * @duty_cycle: PWM duty cycle (in nanoseconds)
  * @polarity: PWM polarity
  * @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 {
 	u64 period;
 	u64 duty_cycle;
 	enum pwm_polarity polarity;
 	bool enabled;
+	bool usage_power;
 };
 
 /**
@@ -188,6 +193,7 @@ static inline void pwm_init_state(const struct pwm_device *pwm,
 	state->period = args.period;
 	state->polarity = args.polarity;
 	state->duty_cycle = 0;
+	state->usage_power = false;
 }
 
 /**
@@ -558,6 +564,7 @@ static inline void pwm_apply_args(struct pwm_device *pwm)
 	state.enabled = false;
 	state.polarity = pwm->args.polarity;
 	state.period = pwm->args.period;
+	state.usage_power = false;
 
 	pwm_apply_state(pwm, &state);
 }
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2021-06-25  9:55 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-07 13:18 [PATCH 1/4] pwm: core: Support new usage_power setting in PWM state Clemens Gruber
2021-05-07 13:18 ` [PATCH 2/4] pwm: pca9685: " Clemens Gruber
2021-05-07 13:18 ` [PATCH 3/4] pwm: pca9685: Restrict period change for enabled PWMs Clemens Gruber
2021-05-07 13:18 ` [PATCH 4/4] pwm: pca9685: Add error messages for failed regmap calls Clemens Gruber
2021-05-07 15:03 ` [PATCH 1/4] pwm: core: Support new usage_power setting in PWM state Uwe Kleine-König
2021-05-07 15:47   ` Clemens Gruber
2021-05-07 23:18     ` Uwe Kleine-König
2021-05-31 16:12       ` Clemens Gruber
2021-06-04  9:49         ` Thierry Reding
2021-06-07  6:08           ` Uwe Kleine-König
2021-06-07 14:40             ` Thierry Reding
2021-06-07 18:51               ` Uwe Kleine-König
2021-06-09 20:41                 ` Uwe Kleine-König
2021-06-10 13:11                   ` Thierry Reding
2021-06-21  6:47                     ` PWM-Patches for next merge window [Was: Re: [PATCH 1/4] pwm: core: Support new usage_power setting in PWM] state Uwe Kleine-König
2021-06-25  9:55                       ` PWM-Patches for next merge window Uwe Kleine-König
2021-06-04  9:44 ` [PATCH 1/4] pwm: core: Support new usage_power setting in PWM state Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).