Re: [PATCH v8 1/8] pwm: pca9685: Switch to atomic API

2021-04-17 Thread Clemens Gruber
Hi, On Sat, Apr 17, 2021 at 05:37:28PM +0200, Uwe Kleine-König wrote: > On Mon, Apr 12, 2021 at 03:27:38PM +0200, Clemens Gruber wrote: > > The switch to the atomic API goes hand in hand with a few fixes to > > previously experienced issues: > > - The duty cycle is no long

Re: [PATCH v8 4/8] dt-bindings: pwm: Support new PWM_USAGE_POWER flag

2021-04-16 Thread Clemens Gruber
On Fri, Apr 16, 2021 at 03:55:11PM +0200, Thierry Reding wrote: > On Mon, Apr 12, 2021 at 03:27:41PM +0200, Clemens Gruber wrote: > > Add the flag and corresponding documentation for PWM_USAGE_POWER. > > > > Cc: Rob Herring > > Signed-off-by: Clemens Gruber > >

[PATCH v9 8/8] pwm: pca9685: Add error messages for failed regmap calls

2021-04-15 Thread Clemens Gruber
Regmap operations can fail if the underlying subsystem is not working properly (e.g. hogged I2C bus, etc.) As this is useful information for the user, print an error message if it happens. Let probe fail if the first regmap_read or the first regmap_write fails. Signed-off-by: Clemens Gruber

[PATCH v9 7/8] pwm: pca9685: Restrict period change for enabled PWMs

2021-04-15 Thread Clemens Gruber
the chosen periods must match. GPIOs do not count as enabled PWMs as they are not using the prescaler and can't change it. Signed-off-by: Clemens Gruber --- Changes since v8: - Rebased Changes since v7: - As the HW readout always returns enabled, also set the pwms_enabled bit in request

[PATCH v9 6/8] pwm: pca9685: Support new PWM_USAGE_POWER flag

2021-04-15 Thread Clemens Gruber
-by: Clemens Gruber --- Changes since v8: - Improved readability of failed regmap_read - Rebased drivers/pwm/pwm-pca9685.c | 65 ++- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/drivers/pwm/pwm-pca9685.c b/drivers/pwm/pwm-pca9685.c index 1b013d03f5d8

[PATCH v9 4/8] dt-bindings: pwm: Support new PWM_USAGE_POWER flag

2021-04-15 Thread Clemens Gruber
Add the flag and corresponding documentation for PWM_USAGE_POWER. Cc: Rob Herring Signed-off-by: Clemens Gruber --- Documentation/devicetree/bindings/pwm/pwm.txt | 3 +++ include/dt-bindings/pwm/pwm.h | 1 + 2 files changed, 4 insertions(+) diff --git a/Documentation

[PATCH v9 5/8] pwm: core: Support new PWM_USAGE_POWER flag

2021-04-15 Thread Clemens Gruber
If the flag PWM_USAGE_POWER is set on a channel, the PWM driver may optimize the signal as long as the power output is not changed. Depending on the specific driver, the optimization could for example improve EMI (if supported) by phase-shifting the individual channels. Signed-off-by: Clemens

[PATCH v9 3/8] pwm: pca9685: Improve runtime PM behavior

2021-04-15 Thread Clemens Gruber
The chip does not come out of POR in active state but in sleep state. To be sure (in case the bootloader woke it up) we force it to sleep in probe. If runtime PM is disabled, we instead wake the chip in .probe and put it to sleep in .remove. Signed-off-by: Clemens Gruber --- Changes since v8

[PATCH v9 2/8] pwm: pca9685: Support hardware readout

2021-04-15 Thread Clemens Gruber
frequency when using the internal 25 MHz oscillator, the calculated period from the default prescaler register setting of 30 is 5079040ns. Signed-off-by: Clemens Gruber --- Changes since v8: - As we left the math in apply as-is, use DIV_ROUND_DOWN in get_state Changes since v7: - Always return

[PATCH v9 1/8] pwm: pca9685: Switch to atomic API

2021-04-15 Thread Clemens Gruber
, which is not allowed according to the datasheet - The OFF registers were reset to 0 in probe, which could lead to the forbidden on=0, off=0. Fixed by resetting to POR default (full OFF) Signed-off-by: Clemens Gruber --- Changes since v8: - Revert to DIV_ROUND_UP (keep math as-is) - Readability

Re: [PATCH v8 1/8] pwm: pca9685: Switch to atomic API

2021-04-14 Thread Clemens Gruber
On Wed, Apr 14, 2021 at 09:21:31PM +0200, Uwe Kleine-König wrote: > On Wed, Apr 14, 2021 at 02:09:14PM +0200, Clemens Gruber wrote: > > Hi Uwe, > > > > On Tue, Apr 13, 2021 at 09:38:18PM +0200, Uwe Kleine-König wrote: > > > Hello Clemens, > > > > &g

Re: [PATCH v8 1/8] pwm: pca9685: Switch to atomic API

2021-04-14 Thread Clemens Gruber
Hi Uwe, On Tue, Apr 13, 2021 at 09:38:18PM +0200, Uwe Kleine-König wrote: > Hello Clemens, > > On Tue, Apr 13, 2021 at 02:11:38PM +0200, Clemens Gruber wrote: > > On Mon, Apr 12, 2021 at 10:10:19PM +0200, Uwe Kleine-König wrote: > > > On Mon, Apr 12, 2021 at 06:39:28

Re: [PATCH v8 1/8] pwm: pca9685: Switch to atomic API

2021-04-13 Thread Clemens Gruber
On Tue, Apr 13, 2021 at 02:37:50PM +0200, Thierry Reding wrote: > On Tue, Apr 13, 2021 at 02:11:38PM +0200, Clemens Gruber wrote: > > Hi Uwe, > > > > On Mon, Apr 12, 2021 at 10:10:19PM +0200, Uwe Kleine-König wrote: > > > Hello Clemens, > > > > &g

Re: [PATCH v8 1/8] pwm: pca9685: Switch to atomic API

2021-04-13 Thread Clemens Gruber
On Tue, Apr 13, 2021 at 02:11:38PM +0200, Clemens Gruber wrote: > Hi Uwe, > > On Mon, Apr 12, 2021 at 10:10:19PM +0200, Uwe Kleine-König wrote: > > Hello Clemens, > > > > On Mon, Apr 12, 2021 at 06:39:28PM +0200, Clemens Gruber wrote: > > > On Mon, Apr 12,

Re: [PATCH v8 1/8] pwm: pca9685: Switch to atomic API

2021-04-13 Thread Clemens Gruber
Hi Uwe, On Mon, Apr 12, 2021 at 10:10:19PM +0200, Uwe Kleine-König wrote: > Hello Clemens, > > On Mon, Apr 12, 2021 at 06:39:28PM +0200, Clemens Gruber wrote: > > On Mon, Apr 12, 2021 at 06:18:08PM +0200, Uwe Kleine-König wrote: > > > On Mon, Apr 12, 2021 at 03:27:38

Re: [PATCH v8 6/8] pwm: pca9685: Support new PWM_USAGE_POWER flag

2021-04-12 Thread Clemens Gruber
Hi, On Mon, Apr 12, 2021 at 06:30:45PM +0200, Uwe Kleine-König wrote: > On Mon, Apr 12, 2021 at 03:27:43PM +0200, Clemens Gruber wrote: > > If PWM_USAGE_POWER is set on a PWM, the pca9685 driver will phase shift > > the individual channels relative to their channel number. This i

Re: [PATCH v8 4/8] dt-bindings: pwm: Support new PWM_USAGE_POWER flag

2021-04-12 Thread Clemens Gruber
On Mon, Apr 12, 2021 at 06:27:23PM +0200, Uwe Kleine-König wrote: > On Mon, Apr 12, 2021 at 03:27:41PM +0200, Clemens Gruber wrote: > > Add the flag and corresponding documentation for PWM_USAGE_POWER. > > My concern here in the previous round was that PWM_USAGE_POWER

Re: [PATCH v8 1/8] pwm: pca9685: Switch to atomic API

2021-04-12 Thread Clemens Gruber
Hi Uwe, On Mon, Apr 12, 2021 at 06:18:08PM +0200, Uwe Kleine-König wrote: > Hello Clemens, > > On Mon, Apr 12, 2021 at 03:27:38PM +0200, Clemens Gruber wrote: > > The switch to the atomic API goes hand in hand with a few fixes to > > previously experienced issues:

[PATCH v8 5/8] pwm: core: Support new PWM_USAGE_POWER flag

2021-04-12 Thread Clemens Gruber
If the flag PWM_USAGE_POWER is set on a channel, the PWM driver may optimize the signal as long as the power output is not changed. Depending on the specific driver, the optimization could for example improve EMI (if supported) by phase-shifting the individual channels. Signed-off-by: Clemens

[PATCH v8 6/8] pwm: pca9685: Support new PWM_USAGE_POWER flag

2021-04-12 Thread Clemens Gruber
-by: Clemens Gruber --- drivers/pwm/pwm-pca9685.c | 63 ++- 1 file changed, 49 insertions(+), 14 deletions(-) diff --git a/drivers/pwm/pwm-pca9685.c b/drivers/pwm/pwm-pca9685.c index 7f97965033e7..410b93b115dc 100644 --- a/drivers/pwm/pwm-pca9685.c +++ b/drivers/pwm

[PATCH v8 4/8] dt-bindings: pwm: Support new PWM_USAGE_POWER flag

2021-04-12 Thread Clemens Gruber
Add the flag and corresponding documentation for PWM_USAGE_POWER. Cc: Rob Herring Signed-off-by: Clemens Gruber --- Documentation/devicetree/bindings/pwm/pwm.txt | 3 +++ include/dt-bindings/pwm/pwm.h | 1 + 2 files changed, 4 insertions(+) diff --git a/Documentation

[PATCH v8 2/8] pwm: pca9685: Support hardware readout

2021-04-12 Thread Clemens Gruber
frequency when using the internal 25 MHz oscillator, the calculated period from the default prescaler register setting of 30 is 5079040ns. Signed-off-by: Clemens Gruber --- Changes since v7: - Always return enabled=true for channels except "all LEDs" channel - Use DIV_ROUND_UP in .get_stat

[PATCH v8 1/8] pwm: pca9685: Switch to atomic API

2021-04-12 Thread Clemens Gruber
, which is not allowed according to the datasheet - The OFF registers were reset to 0 in probe, which could lead to the forbidden on=0, off=0. Fixed by resetting to POR default (full OFF) Signed-off-by: Clemens Gruber --- Changes since v7: - Moved check for !state->enabled before presca

[PATCH v8 7/8] pwm: pca9685: Restrict period change for enabled PWMs

2021-04-12 Thread Clemens Gruber
the chosen periods must match. GPIOs do not count as enabled PWMs as they are not using the prescaler and can't change it. Signed-off-by: Clemens Gruber --- Changes since v7: - As the HW readout always returns enabled, also set the pwms_enabled bit in request (except for the "all LEDs&quo

[PATCH v8 8/8] pwm: pca9685: Add error messages for failed regmap calls

2021-04-12 Thread Clemens Gruber
Regmap operations can fail if the underlying subsystem is not working properly (e.g. hogged I2C bus, etc.) As this is useful information for the user, print an error message if it happens. Let probe fail if the first regmap_read or the first regmap_write fails. Signed-off-by: Clemens Gruber

[PATCH v8 3/8] pwm: pca9685: Improve runtime PM behavior

2021-04-12 Thread Clemens Gruber
The chip does not come out of POR in active state but in sleep state. To be sure (in case the bootloader woke it up) we force it to sleep in probe. If runtime PM is disabled, we instead wake the chip in .probe and put it to sleep in .remove. Signed-off-by: Clemens Gruber --- Changes since v7

Re: [PATCH v7 3/8] pwm: pca9685: Improve runtime PM behavior

2021-04-09 Thread Clemens Gruber
On Fri, Apr 09, 2021 at 03:03:20PM +0200, Thierry Reding wrote: > On Tue, Apr 06, 2021 at 06:41:35PM +0200, Clemens Gruber wrote: > > The chip does not come out of POR in active state but in sleep state. > > To be sure (in case the bootloader woke it up) we force it to sle

Re: [PATCH v7 5/8] pwm: core: Support new PWM_STAGGERING_ALLOWED flag

2021-04-09 Thread Clemens Gruber
On Fri, Apr 09, 2021 at 01:25:36PM +0200, Thierry Reding wrote: > On Thu, Apr 08, 2021 at 07:36:37PM +0200, Uwe Kleine-König wrote: > > On Thu, Apr 08, 2021 at 05:51:36PM +0200, Clemens Gruber wrote: > > > On Thu, Apr 08, 2021 at 02:50:40PM +0200, Thierry Reding wrote: > >

Re: [PATCH v7 5/8] pwm: core: Support new PWM_STAGGERING_ALLOWED flag

2021-04-08 Thread Clemens Gruber
On Thu, Apr 08, 2021 at 07:36:37PM +0200, Uwe Kleine-König wrote: > On Thu, Apr 08, 2021 at 05:51:36PM +0200, Clemens Gruber wrote: > > On Thu, Apr 08, 2021 at 02:50:40PM +0200, Thierry Reding wrote: > > > Yes, I think that's basically what this is saying. I think we're perhaps

Re: [PATCH v7 5/8] pwm: core: Support new PWM_STAGGERING_ALLOWED flag

2021-04-08 Thread Clemens Gruber
On Thu, Apr 08, 2021 at 02:50:40PM +0200, Thierry Reding wrote: > On Wed, Apr 07, 2021 at 11:34:03PM +0200, Uwe Kleine-König wrote: > > On Wed, Apr 07, 2021 at 10:21:10PM +0200, Clemens Gruber wrote: > > > On Wed, Apr 07, 2021 at 07:46:58AM +0200, Uwe Kleine-König wrote: >

Re: [PATCH v7 8/8] pwm: pca9685: Add error messages for failed regmap calls

2021-04-07 Thread Clemens Gruber
On Wed, Apr 07, 2021 at 08:16:19AM +0200, Uwe Kleine-König wrote: > On Tue, Apr 06, 2021 at 06:41:40PM +0200, Clemens Gruber wrote: > > Regmap operations can fail if the underlying subsystem is not working > > properly (e.g. hogged I2C bus, etc.) > > As this is useful inf

Re: [PATCH v7 7/8] pwm: pca9685: Restrict period change for enabled PWMs

2021-04-07 Thread Clemens Gruber
On Wed, Apr 07, 2021 at 08:12:29AM +0200, Uwe Kleine-König wrote: > On Tue, Apr 06, 2021 at 06:41:39PM +0200, Clemens Gruber wrote: > > Previously, the last used PWM channel could change the global prescale > > setting, even if other channels are already in use. > > > &

Re: [PATCH v7 5/8] pwm: core: Support new PWM_STAGGERING_ALLOWED flag

2021-04-07 Thread Clemens Gruber
On Wed, Apr 07, 2021 at 07:46:58AM +0200, Uwe Kleine-König wrote: > On Tue, Apr 06, 2021 at 06:41:37PM +0200, Clemens Gruber wrote: > > If the flag PWM_STAGGERING_ALLOWED is set on a channel, the PWM driver > > may (if supported by the HW) delay the ON time of the c

Re: [PATCH v7 2/8] pwm: pca9685: Support hardware readout

2021-04-07 Thread Clemens Gruber
On Wed, Apr 07, 2021 at 11:09:43AM +0200, Uwe Kleine-König wrote: > On Wed, Apr 07, 2021 at 09:33:20AM +0200, Clemens Gruber wrote: > > On Wed, Apr 07, 2021 at 07:31:35AM +0200, Uwe Kleine-König wrote: > > > On Tue, Apr 06, 2021 at 06:41:34PM +0200, Clemens Gruber wrote:

Re: [PATCH v7 2/8] pwm: pca9685: Support hardware readout

2021-04-07 Thread Clemens Gruber
On Wed, Apr 07, 2021 at 07:31:35AM +0200, Uwe Kleine-König wrote: > On Tue, Apr 06, 2021 at 06:41:34PM +0200, Clemens Gruber wrote: > > Implements .get_state to read-out the current hardware state. > > > > The hardware readout may return slightly different values than th

Re: [PATCH v7 1/8] pwm: pca9685: Switch to atomic API

2021-04-07 Thread Clemens Gruber
Hi, On Wed, Apr 07, 2021 at 07:24:28AM +0200, Uwe Kleine-König wrote: > Hello, > > On Tue, Apr 06, 2021 at 06:41:33PM +0200, Clemens Gruber wrote: > > The switch to the atomic API goes hand in hand with a few fixes to > > previously experienced issues: > > - The d

[PATCH v7 8/8] pwm: pca9685: Add error messages for failed regmap calls

2021-04-06 Thread Clemens Gruber
Regmap operations can fail if the underlying subsystem is not working properly (e.g. hogged I2C bus, etc.) As this is useful information for the user, print an error message if it happens. Let probe fail if the first regmap_read or the first regmap_write fails. Signed-off-by: Clemens Gruber

[PATCH v7 7/8] pwm: pca9685: Restrict period change for enabled PWMs

2021-04-06 Thread Clemens Gruber
the chosen periods must match. GPIOs do not count as enabled PWMs as they are not using the prescaler and can't change it. Signed-off-by: Clemens Gruber --- Changes since v6: - Only allow the first PWM that is enabled to change the prescaler, not the first one that uses the prescaler drivers

[PATCH v7 6/8] pwm: pca9685: Support new PWM_STAGGERING_ALLOWED flag

2021-04-06 Thread Clemens Gruber
still maintaining the configured duty cycle of each output. Signed-off-by: Clemens Gruber --- Changes since v6: - Use a per-PWM flag instead of one global DT parameter drivers/pwm/pwm-pca9685.c | 60 ++- 1 file changed, 46 insertions(+), 14 deletions(-) diff

[PATCH v7 5/8] pwm: core: Support new PWM_STAGGERING_ALLOWED flag

2021-04-06 Thread Clemens Gruber
assert multiple or even all enabled channels at the same time. If this feature is supported by the driver and the flag is set on multiple channels, their ON times are spread out to improve EMI and reduce current spikes. Signed-off-by: Clemens Gruber --- drivers/pwm/core.c | 9

[PATCH v7 4/8] dt-bindings: pwm: Support new PWM_STAGGERING_ALLOWED flag

2021-04-06 Thread Clemens Gruber
Add the flag and corresponding documentation for the new PWM staggering mode feature. Cc: Rob Herring Signed-off-by: Clemens Gruber --- Documentation/devicetree/bindings/pwm/pwm.txt | 1 + include/dt-bindings/pwm/pwm.h | 1 + 2 files changed, 2 insertions(+) diff --git

[PATCH v7 3/8] pwm: pca9685: Improve runtime PM behavior

2021-04-06 Thread Clemens Gruber
The chip does not come out of POR in active state but in sleep state. To be sure (in case the bootloader woke it up) we force it to sleep in probe. On kernels without CONFIG_PM, we wake the chip in .probe and put it to sleep in .remove. Signed-off-by: Clemens Gruber --- Changes since v6

[PATCH v7 2/8] pwm: pca9685: Support hardware readout

2021-04-06 Thread Clemens Gruber
frequency when using the internal 25 MHz oscillator, the calculated period from the default prescaler register setting of 30 is 5079040ns. Signed-off-by: Clemens Gruber --- Changes since v6: - Added a comment regarding the division (Suggested by Uwe) - Rebased drivers/pwm/pwm-pca9685.c | 46

[PATCH v7 1/8] pwm: pca9685: Switch to atomic API

2021-04-06 Thread Clemens Gruber
sets a period resulting in the same prescale register value, the sleep and write to the register is now skipped Signed-off-by: Clemens Gruber --- Changes since v6: - Order of a comparison switched for improved readability Changes since v5: - Function documentation for set_duty - Variable

Re: [PATCH v6 4/7] pwm: pca9685: Support staggered output ON times

2021-04-01 Thread Clemens Gruber
On Thu, Apr 01, 2021 at 10:59:36PM +0200, Uwe Kleine-König wrote: > On Wed, Mar 31, 2021 at 03:55:49PM +0200, Clemens Gruber wrote: > > On Wed, Mar 31, 2021 at 02:26:14PM +0200, Clemens Gruber wrote: > > > On Mon, Mar 29, 2021 at 08:02:06PM +0200, Uwe Kleine-König wrote: >

Re: [PATCH v6 4/7] pwm: pca9685: Support staggered output ON times

2021-04-01 Thread Clemens Gruber
Hello Uwe, On Thu, Apr 01, 2021 at 10:58:19PM +0200, Uwe Kleine-König wrote: > Hello Clemens, > > On Wed, Mar 31, 2021 at 02:26:14PM +0200, Clemens Gruber wrote: > > On Mon, Mar 29, 2021 at 08:02:06PM +0200, Uwe Kleine-König wrote: > > > On Mon, Mar 29, 2021 at 07:16:38

Re: [PATCH v6 4/7] pwm: pca9685: Support staggered output ON times

2021-04-01 Thread Clemens Gruber
On Thu, Apr 01, 2021 at 03:47:26PM +0200, Thierry Reding wrote: > On Thu, Apr 01, 2021 at 09:50:44AM +0200, Clemens Gruber wrote: > > Hi Thierry, > > > > On Wed, Mar 31, 2021 at 06:21:32PM +0200, Thierry Reding wrote: > > > On Wed, Mar 31, 2021 at 02:26:14

Re: [PATCH v6 4/7] pwm: pca9685: Support staggered output ON times

2021-04-01 Thread Clemens Gruber
Hi Thierry, On Wed, Mar 31, 2021 at 06:21:32PM +0200, Thierry Reding wrote: > On Wed, Mar 31, 2021 at 02:26:14PM +0200, Clemens Gruber wrote: > > On Mon, Mar 29, 2021 at 08:02:06PM +0200, Uwe Kleine-König wrote: > > > On Mon, Mar 29, 2021 at 07:16:38PM +0200, Clemens Gruber wro

Re: [PATCH v6 4/7] pwm: pca9685: Support staggered output ON times

2021-03-31 Thread Clemens Gruber
On Wed, Mar 31, 2021 at 02:26:14PM +0200, Clemens Gruber wrote: > On Mon, Mar 29, 2021 at 08:02:06PM +0200, Uwe Kleine-König wrote: > > On Mon, Mar 29, 2021 at 07:16:38PM +0200, Clemens Gruber wrote: > > > On Mon, Mar 29, 2021 at 07:03:57PM +0200, Uwe Kleine-König wrote: >

Re: [PATCH v6 4/7] pwm: pca9685: Support staggered output ON times

2021-03-31 Thread Clemens Gruber
On Mon, Mar 29, 2021 at 08:02:06PM +0200, Uwe Kleine-König wrote: > On Mon, Mar 29, 2021 at 07:16:38PM +0200, Clemens Gruber wrote: > > On Mon, Mar 29, 2021 at 07:03:57PM +0200, Uwe Kleine-König wrote: > > > On Mon, Mar 29, 2021 at 02:57:04PM +0200, Clemens Gruber wrote: &

Re: [PATCH v6 6/7] pwm: pca9685: Restrict period change for prescaler users

2021-03-29 Thread Clemens Gruber
On Mon, Mar 29, 2021 at 07:15:59PM +0200, Uwe Kleine-König wrote: > On Mon, Mar 29, 2021 at 02:57:06PM +0200, Clemens Gruber wrote: > > @@ -330,14 +345,22 @@ static int pca9685_pwm_apply(struct pwm_chip *chip, > > struct pwm_device *pwm, > > > > if (

Re: [PATCH v6 4/7] pwm: pca9685: Support staggered output ON times

2021-03-29 Thread Clemens Gruber
On Mon, Mar 29, 2021 at 07:03:57PM +0200, Uwe Kleine-König wrote: > On Mon, Mar 29, 2021 at 02:57:04PM +0200, Clemens Gruber wrote: > > The PCA9685 supports staggered LED output ON times to minimize current > > surges and reduce EMI. > > When this new option is enabled,

Re: [PATCH v6 2/7] pwm: pca9685: Support hardware readout

2021-03-29 Thread Clemens Gruber
On Mon, Mar 29, 2021 at 06:54:29PM +0200, Uwe Kleine-König wrote: > On Mon, Mar 29, 2021 at 02:57:02PM +0200, Clemens Gruber wrote: > > Implements .get_state to read-out the current hardware state. > > > > The hardware readout may return slightly different values than th

Re: [PATCH v6 2/7] pwm: pca9685: Support hardware readout

2021-03-29 Thread Clemens Gruber
Hi Uwe, On Mon, Mar 29, 2021 at 05:51:40PM +0200, Uwe Kleine-König wrote: > Hello Clemens, > > On Mon, Mar 29, 2021 at 02:57:02PM +0200, Clemens Gruber wrote: > > The hardware readout may return slightly different values than those > > that were set in apply due to the limi

Re: [PATCH v6 3/7] pwm: pca9685: Improve runtime PM behavior

2021-03-29 Thread Clemens Gruber
Hi Uwe, On Mon, Mar 29, 2021 at 05:55:27PM +0200, Uwe Kleine-König wrote: > On Mon, Mar 29, 2021 at 02:57:03PM +0200, Clemens Gruber wrote: > > The chip does not come out of POR in active state but in sleep state. > > To be sure (in case the bootloader woke it up) we fo

[PATCH v6 6/7] pwm: pca9685: Restrict period change for prescaler users

2021-03-29 Thread Clemens Gruber
resulting from the chosen periods must match. PWMs that are disabled or have a duty cycle of 0% or 100% are not considered to be using the prescaler as they have the full OFF or full ON bits set. This also applies to channels used as GPIOs. Signed-off-by: Clemens Gruber --- Changes since v5: - Reused

[PATCH v6 5/7] dt-bindings: pwm: pca9685: Add nxp,staggered-outputs property

2021-03-29 Thread Clemens Gruber
The pca9685 driver supports a new nxp,staggered-outputs property for reduced current surges and EMI. This adds documentation for the new DT property. Signed-off-by: Clemens Gruber --- Documentation/devicetree/bindings/pwm/nxp,pca9685-pwm.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git

[PATCH v6 4/7] pwm: pca9685: Support staggered output ON times

2021-03-29 Thread Clemens Gruber
maintaining the configured duty cycle of each output. Signed-off-by: Clemens Gruber --- Changes since v5: - Simplified staggered outputs special case in set/get_duty drivers/pwm/pwm-pca9685.c | 58 +-- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git

[PATCH v6 7/7] pwm: pca9685: Add error messages for failed regmap calls

2021-03-29 Thread Clemens Gruber
Regmap operations can fail if the underlying subsystem is not working properly (e.g. hogged I2C bus, etc.) As this is useful information for the user, print an error message if it happens. Let probe fail if the first regmap_read or the first regmap_write fails. Signed-off-by: Clemens Gruber

[PATCH v6 3/7] pwm: pca9685: Improve runtime PM behavior

2021-03-29 Thread Clemens Gruber
The chip does not come out of POR in active state but in sleep state. To be sure (in case the bootloader woke it up) we force it to sleep in probe. On kernels without CONFIG_PM, we wake the chip in .probe and put it to sleep in .remove. Signed-off-by: Clemens Gruber --- drivers/pwm/pwm-pca9685

[PATCH v6 2/7] pwm: pca9685: Support hardware readout

2021-03-29 Thread Clemens Gruber
frequency when using the internal 25 MHz oscillator, the calculated period from the default prescaler register setting of 30 is 5079040ns. Signed-off-by: Clemens Gruber --- drivers/pwm/pwm-pca9685.c | 41 +++ 1 file changed, 41 insertions(+) diff --git a/drivers

[PATCH v6 1/7] pwm: pca9685: Switch to atomic API

2021-03-29 Thread Clemens Gruber
sets a period resulting in the same prescale register value, the sleep and write to the register is now skipped Signed-off-by: Clemens Gruber --- Changes since v5: - Function documentation for set_duty - Variable initializations - Print warning if all LEDs channel - Changed EOPNOTSUPP to EINVAL

Re: [PATCH v5 2/7] pwm: pca9685: Support hardware readout

2021-03-27 Thread Clemens Gruber
Hi Thierry, On Mon, Mar 22, 2021 at 10:19:22AM +0100, Thierry Reding wrote: > On Fri, Jan 29, 2021 at 09:37:47PM +0100, Clemens Gruber wrote: > > Hi Sven, > > > > On Fri, Jan 29, 2021 at 01:05:14PM -0500, Sven Van Asbroeck wrote: > > > Hi Clemens, > > >

Re: [PATCH v5 1/7] pwm: pca9685: Switch to atomic API

2021-03-27 Thread Clemens Gruber
Hi Thierry, On Mon, Mar 22, 2021 at 08:58:35AM +0100, Thierry Reding wrote: > On Thu, Dec 17, 2020 at 12:10:10PM -0500, Sven Van Asbroeck wrote: > > On Thu, Dec 17, 2020 at 11:48 AM Clemens Gruber > > wrote: > > > > > > I can initialize the values to 0 of co

Re: [PATCH v5 2/7] pwm: pca9685: Support hardware readout

2021-03-04 Thread Clemens Gruber
Hi Uwe, On Mon, Mar 01, 2021 at 10:52:48PM +0100, Uwe Kleine-König wrote: > Hello, > > On Mon, Feb 01, 2021 at 06:24:02PM +0100, Clemens Gruber wrote: > > Hi Sven, Thierry, Uwe, > > > > On Fri, Jan 29, 2021 at 05:16:51PM -0500, Sven Van Asbroeck wrote: > > >

Re: [PATCH v5 4/7] pwm: pca9685: Reset registers to POR state in probe

2021-03-04 Thread Clemens Gruber
On Mon, Mar 01, 2021 at 10:46:33PM +0100, Uwe Kleine-König wrote: > Hello Clemens, > > On Tue, Dec 15, 2020 at 10:22:25PM +0100, Clemens Gruber wrote: > > Reset the prescale and ON/OFF registers to their POR default state in > > the probe function. Otherwise, the PWMs could

Re: [PATCH v5 1/7] pwm: pca9685: Switch to atomic API

2021-03-04 Thread Clemens Gruber
Hi Uwe, On Mon, Mar 01, 2021 at 10:44:07PM +0100, Uwe Kleine-König wrote: > Hello Clemens, > > On Tue, Dec 15, 2020 at 10:22:22PM +0100, Clemens Gruber wrote: > > + if (state->polarity != PWM_POLARITY_NORMAL) > > + return -EOPNOTSUPP; > > We agreed

Re: [PATCH v5 1/7] pwm: pca9685: Switch to atomic API

2021-03-04 Thread Clemens Gruber
Hi Uwe, On Mon, Mar 01, 2021 at 10:41:15PM +0100, Uwe Kleine-König wrote: > On Thu, Dec 17, 2020 at 12:10:10PM -0500, Sven Van Asbroeck wrote: > > On Thu, Dec 17, 2020 at 11:48 AM Clemens Gruber > > wrote: > > > > > > I can initialize the values to 0 of co

Re: [PATCH v5 2/7] pwm: pca9685: Support hardware readout

2021-02-14 Thread Clemens Gruber
Hi all, On Fri, Jan 29, 2021 at 09:37:47PM +0100, Clemens Gruber wrote: > Hi Sven, > > On Fri, Jan 29, 2021 at 01:05:14PM -0500, Sven Van Asbroeck wrote: > > Hi Clemens, > > > > On Fri, Jan 29, 2021 at 11:31 AM Clemens Gruber > > wrote: > > > > &

Re: [PATCH v5 2/7] pwm: pca9685: Support hardware readout

2021-02-01 Thread Clemens Gruber
Hi Sven, Thierry, Uwe, On Fri, Jan 29, 2021 at 05:16:51PM -0500, Sven Van Asbroeck wrote: > Hi Clemens, > > On Fri, Jan 29, 2021 at 4:24 PM Sven Van Asbroeck wrote: > > > > LEN_ON = 409, LED_OFF = 1228 and > > LED_ON = 419, LED_OFF = 1238 > > produ

Re: [PATCH v5 2/7] pwm: pca9685: Support hardware readout

2021-01-29 Thread Clemens Gruber
Hi Sven, On Fri, Jan 29, 2021 at 01:05:14PM -0500, Sven Van Asbroeck wrote: > Hi Clemens, > > On Fri, Jan 29, 2021 at 11:31 AM Clemens Gruber > wrote: > > > > Ok, so you suggest we extend our get_state logic to deal with cases > > like the following: > >

Re: [PATCH v5 2/7] pwm: pca9685: Support hardware readout

2021-01-29 Thread Clemens Gruber
r all we've learnt that the pca9685 > looks simple on the surface, but is actually quite challenging to get right. > > Clemens, Uwe, what do you think? Ok, so you suggest we extend our get_state logic to deal with cases like the following: If neither full OFF nor full ON is set &

Re: [PATCH v5 2/7] pwm: pca9685: Support hardware readout

2021-01-14 Thread Clemens Gruber
Hi, On Mon, Jan 11, 2021 at 09:35:32PM +0100, Uwe Kleine-König wrote: > Hello, > > On Thu, Dec 17, 2020 at 06:43:04PM +0100, Clemens Gruber wrote: > > On Wed, Dec 16, 2020 at 11:00:59PM -0500, Sven Van Asbroeck wrote: > > > On Wed, Dec 16, 2020 at 7:53 AM Cle

Re: [PATCH v5 2/7] pwm: pca9685: Support hardware readout

2021-01-03 Thread Clemens Gruber
Hi everyone, happy new year, hope you are all well! On Thu, Dec 17, 2020 at 12:52:42PM -0500, Sven Van Asbroeck wrote: > On Thu, Dec 17, 2020 at 12:43 PM Clemens Gruber > wrote: > > > > > > Conclusion: .get_state() will always return "pwm disabled", so why do w

Re: [PATCH v5 7/7] pwm: pca9685: Restrict period change for prescaler users

2020-12-17 Thread Clemens Gruber
Hi Sven, On Wed, Dec 16, 2020 at 11:03:39PM -0500, Sven Van Asbroeck wrote: > Hi Clemens, see below. > > On Wed, Dec 16, 2020 at 7:53 AM Clemens Gruber > wrote: > > > > Previously, the last used PWM channel could change the global prescale > > setting, even if othe

Re: [PATCH v5 5/7] pwm: pca9685: Support staggered output ON times

2020-12-17 Thread Clemens Gruber
On Wed, Dec 16, 2020 at 11:02:57PM -0500, Sven Van Asbroeck wrote: > Hi Clemens, see below. > > On Wed, Dec 16, 2020 at 7:53 AM Clemens Gruber > wrote: > > > > The PCA9685 supports staggered LED output ON times to minimize current > > surges and reduce EMI. >

Re: [PATCH v5 4/7] pwm: pca9685: Reset registers to POR state in probe

2020-12-17 Thread Clemens Gruber
On Wed, Dec 16, 2020 at 11:02:03PM -0500, Sven Van Asbroeck wrote: > Hi Clemens, minor nit below. > > On Wed, Dec 16, 2020 at 7:53 AM Clemens Gruber > wrote: > > > > Reset the prescale and ON/OFF registers to their POR default state in > > the probe function. O

Re: [PATCH v5 2/7] pwm: pca9685: Support hardware readout

2020-12-17 Thread Clemens Gruber
On Wed, Dec 16, 2020 at 11:00:59PM -0500, Sven Van Asbroeck wrote: > On Wed, Dec 16, 2020 at 7:53 AM Clemens Gruber > wrote: > > > > Implements .get_state to read-out the current hardware state. > > > > I am not convinced that we actually need this. > >

Re: [PATCH v5 1/7] pwm: pca9685: Switch to atomic API

2020-12-17 Thread Clemens Gruber
Hi Sven, On Wed, Dec 16, 2020 at 10:58:07PM -0500, Sven Van Asbroeck wrote: > Hi Clemens, this looks compact, simple and neat. I like it a lot !! Thanks! > > Few very minor nits below. > > On Wed, Dec 16, 2020 at 7:53 AM Clemens Gruber > wrote: > > > > The swit

[PATCH v5 7/7] pwm: pca9685: Restrict period change for prescaler users

2020-12-15 Thread Clemens Gruber
resulting from the chosen periods must match. PWMs that are disabled or have a duty cycle of 0% or 100% are not considered to be using the prescaler as they have the full OFF or full ON bits set. This also applies to channels used as GPIOs. Signed-off-by: Clemens Gruber --- drivers/pwm/pwm-pca9685.c

[PATCH v5 6/7] dt-bindings: pwm: pca9685: Add nxp,staggered-outputs property

2020-12-15 Thread Clemens Gruber
The pca9685 driver supports a new nxp,staggered-outputs property for reduced current surges and EMI. This adds documentation for the new DT property. Signed-off-by: Clemens Gruber --- Documentation/devicetree/bindings/pwm/nxp,pca9685-pwm.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git

[PATCH v5 5/7] pwm: pca9685: Support staggered output ON times

2020-12-15 Thread Clemens Gruber
maintaining the configured duty cycle of each output. Signed-off-by: Clemens Gruber --- drivers/pwm/pwm-pca9685.c | 62 +++ 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/drivers/pwm/pwm-pca9685.c b/drivers/pwm/pwm-pca9685.c index 38aadaf50996

[PATCH v5 3/7] pwm: pca9685: Improve runtime PM behavior

2020-12-15 Thread Clemens Gruber
The chip does not come out of POR in active state but in sleep state. To be sure (in case the bootloader woke it up) we force it to sleep in probe. On kernels without CONFIG_PM, we wake the chip in .probe and put it to sleep in .remove. Signed-off-by: Clemens Gruber --- drivers/pwm/pwm-pca9685

[PATCH v5 4/7] pwm: pca9685: Reset registers to POR state in probe

2020-12-15 Thread Clemens Gruber
Reset the prescale and ON/OFF registers to their POR default state in the probe function. Otherwise, the PWMs could still be active after a watchdog reset and reboot, etc. Signed-off-by: Clemens Gruber --- drivers/pwm/pwm-pca9685.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions

[PATCH v5 2/7] pwm: pca9685: Support hardware readout

2020-12-15 Thread Clemens Gruber
frequency when using the internal 25 MHz oscillator, the calculated period from the default prescaler register setting of 30 is 5079040ns. Signed-off-by: Clemens Gruber --- drivers/pwm/pwm-pca9685.c | 41 +++ 1 file changed, 41 insertions(+) diff --git a/drivers

[PATCH v5 1/7] pwm: pca9685: Switch to atomic API

2020-12-15 Thread Clemens Gruber
sets a period resulting in the same prescale register value, the sleep and write to the register is now skipped Signed-off-by: Clemens Gruber --- Changes since v4: - Patches split up - Use a single set_duty function - Improve readability / new macros - Added a patch to restrict prescale changes

Re: [PATCH v4 1/4] pwm: pca9685: Switch to atomic API

2020-12-14 Thread Clemens Gruber
pstream and for some reason just > haven't gotten around to it. > > On the other hand, almost 18-24 months without activity is quite long. A > compromise that works well for me is to keep drivers, even unused ones, > as long as they're not getting in the way. > > &

Re: [PATCH v4 1/4] pwm: pca9685: Switch to atomic API

2020-12-10 Thread Clemens Gruber
full-on or full-off > PWM. It would still be a PWM, but just with additional restrictions > on the duty cycle. > > 2) Use one channel as full PWM and the other channel as GPIO. > > 2) is a subset of 1) because we can implement 2) using 1) by treating >

Re: [PATCH v4 1/4] pwm: pca9685: Switch to atomic API

2020-12-08 Thread Clemens Gruber
e duty cycle is 0% or 100%. > > > > We can of course make this much simpler by assumung that gpio or on/off > > > pwms > > > are actually using the prescaler. But then we'd be limiting this chip's > > > functionality. > > > > Yeah, this is obviously much simpler, but the cost is a bit high, in my > > opinion. I'm fine with this alternative if there aren't any use-cases > > where multiple outputs are actually used. > > This metric is wishy-washy; of course you can construct a use-case. I'd > still go for this simpler option and assume the prescaler used if the > PWM runs at 0% or 100%, but not when it is a GPIO. I'd also prefer this solution. Thanks, Clemens

Re: [PATCH v4 1/4] pwm: pca9685: Switch to atomic API

2020-12-08 Thread Clemens Gruber
Hello Uwe, On Tue, Dec 08, 2020 at 10:10:33AM +0100, Uwe Kleine-König wrote: > Hello Clemens, > > On Tue, Dec 08, 2020 at 12:13:44AM +0100, Clemens Gruber wrote: > > On Mon, Dec 07, 2020 at 11:00:25PM +0100, Uwe Kleine-König wrote: > > > On Mon, Dec 07, 2020 at 08:36:27

Re: [PATCH v4 1/4] pwm: pca9685: Switch to atomic API

2020-12-07 Thread Clemens Gruber
Hi Sven, On Mon, Dec 07, 2020 at 06:22:08PM -0500, Sven Van Asbroeck wrote: > Hi Clemens, see below. > > On Mon, Dec 7, 2020 at 2:37 PM Clemens Gruber > wrote: > > > > The switch to the atomic API goes hand in hand with a few fixes to > > previously experience

Re: [PATCH v4 1/4] pwm: pca9685: Switch to atomic API

2020-12-07 Thread Clemens Gruber
in step 5 as well. So, only the first consumer is allowed to change the period and only as long as it is the only one that is in use / was requested. But that's definitely a breaking change. Thanks, Clemens

Re: [PATCH v4 1/4] pwm: pca9685: Switch to atomic API

2020-12-07 Thread Clemens Gruber
On Mon, Dec 07, 2020 at 11:00:25PM +0100, Uwe Kleine-König wrote: > On Mon, Dec 07, 2020 at 08:36:27PM +0100, Clemens Gruber wrote: > > The switch to the atomic API goes hand in hand with a few fixes to > > previously experienced issues: > > - The duty cycle is no longer lost

[PATCH v4 2/4] pwm: pca9685: Set full OFF bits in probe

2020-12-07 Thread Clemens Gruber
still clear the rest of the OFF regs but now we set the full OFF bit to avoid having both OFF and ON registers set to 0 and start up in a safe default state. Signed-off-by: Clemens Gruber --- Changes since v1: - Rebased drivers/pwm/pwm-pca9685.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions

[PATCH v4 4/4] dt-bindings: pwm: pca9685: Add nxp,staggered-outputs property

2020-12-07 Thread Clemens Gruber
The pca9685 driver supports a new nxp,staggered-outputs property for reduced current surges and EMI. This adds documentation for the new DT property. Signed-off-by: Clemens Gruber --- Changes since v1: - Added vendor prefix Documentation/devicetree/bindings/pwm/nxp,pca9685-pwm.txt | 2 ++ 1

[PATCH v4 1/4] pwm: pca9685: Switch to atomic API

2020-12-07 Thread Clemens Gruber
frequency changed. (The PCA9685 has only one prescaler!) Note that although the datasheet mentions 200 Hz as default frequency when using the internal 25 MHz oscillator, the calculated period from the default prescaler register setting of 30 is 5079040ns. Signed-off-by: Clemens Gruber --- Changes

[PATCH v4 3/4] pwm: pca9685: Support staggered output ON times

2020-12-07 Thread Clemens Gruber
maintaining the configured duty cycle of each output. Signed-off-by: Clemens Gruber --- Changes since v3: - Refactoring: Extracted common functions - Fixed error in .get_state - Added vendor prefix to DT property Changes since v1: - Rebased drivers/pwm/pwm-pca9685.c | 72

Re: [PATCH v3 1/4] pwm: pca9685: Switch to atomic API

2020-11-25 Thread Clemens Gruber
Hi Sven, On Wed, Nov 25, 2020 at 10:04:32AM -0500, Sven Van Asbroeck wrote: > On Wed, Nov 25, 2020 at 3:35 AM Clemens Gruber > wrote: > > > > > > > > The datasheet I found for this chip indicates that every ALL_LED_XXX > > > register > > > is writ

Re: [PATCH v3 1/4] pwm: pca9685: Switch to atomic API

2020-11-25 Thread Clemens Gruber
On Wed, Nov 25, 2020 at 09:35:08AM +0100, Clemens Gruber wrote: > On Tue, Nov 24, 2020 at 10:49:27PM -0500, Sven Van Asbroeck wrote: > > Hi Clemens, I checked the patch against the datasheet register definitions. > > More constructive feedback below. > > > > On T

Re: [PATCH v3 3/4] pwm: pca9685: Support staggered output ON times

2020-11-25 Thread Clemens Gruber
On Tue, Nov 24, 2020 at 10:51:23PM -0500, Sven Van Asbroeck wrote: > On Tue, Nov 24, 2020 at 1:10 PM Clemens Gruber > wrote: > > > > The PCA9685 supports staggered LED output ON times to minimize current > > surges and reduce EMI. > > When this new option is enabled

  1   2   3   4   5   6   7   8   9   10   >