When duty-cycle is at full level (100%), the TCNTn and TCMPn registers
needs to be flushed in order to disable the signal. The PWM manual does
not say anything about this, but states that only clearing the TCON
auto-reload bit should be needed, and this seems to be true when the PWM
duty-cycle is not at full level. This can be observed on an Axis
ARTPEC-8, by running:
echo <period> > pwm/period
echo <period> > pwm/duty_cycle
echo 1 > pwm/enable
echo 0 > pwm/enable
Since the TCNTn and TCMPn registers are activated when enabling the PWM
(setting TCON auto-reload bit), and are not touched when disabling the
PWM, the double buffered auto-reload function seems to be still active.
Lowering duty-cycle, and restoring it again in between the enabling and
disabling, makes the disable work since it triggers a reload of the
TCNTn and TCMPn registers.
Fix this by securing a reload of the TCNTn and TCMPn registers when
disabling the PWM and having a full duty-cycle.
Signed-off-by: Mårten Lindahl <redacted>
---
v2:
- Move fix above setting of disabled_mask
drivers/pwm/pwm-samsung.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
Hello,
On Wed, Sep 08, 2021 at 05:59:01PM +0200, Mårten Lindahl wrote:
quoted hunk
When duty-cycle is at full level (100%), the TCNTn and TCMPn registers
needs to be flushed in order to disable the signal. The PWM manual does
not say anything about this, but states that only clearing the TCON
auto-reload bit should be needed, and this seems to be true when the PWM
duty-cycle is not at full level. This can be observed on an Axis
ARTPEC-8, by running:
echo <period> > pwm/period
echo <period> > pwm/duty_cycle
echo 1 > pwm/enable
echo 0 > pwm/enable
Since the TCNTn and TCMPn registers are activated when enabling the PWM
(setting TCON auto-reload bit), and are not touched when disabling the
PWM, the double buffered auto-reload function seems to be still active.
Lowering duty-cycle, and restoring it again in between the enabling and
disabling, makes the disable work since it triggers a reload of the
TCNTn and TCMPn registers.
Fix this by securing a reload of the TCNTn and TCMPn registers when
disabling the PWM and having a full duty-cycle.
Signed-off-by: Mårten Lindahl <redacted>
---
v2:
- Move fix above setting of disabled_mask
drivers/pwm/pwm-samsung.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
)
Maybe split the patch to have it nice and reviewable?
Orthogonal to your patch: I wonder what &samsung_pwm_lock actually
protects and why it disables irqs. In general the pwm functions might
sleep, at least some implementations do.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
On Thu, Sep 09, 2021 at 10:05:17AM +0200, Uwe Kleine-König wrote:
Hi Uwe!
Thanks for your feedback!
Hello,
On Wed, Sep 08, 2021 at 05:59:01PM +0200, Mårten Lindahl wrote:
quoted
When duty-cycle is at full level (100%), the TCNTn and TCMPn registers
needs to be flushed in order to disable the signal. The PWM manual does
not say anything about this, but states that only clearing the TCON
auto-reload bit should be needed, and this seems to be true when the PWM
duty-cycle is not at full level. This can be observed on an Axis
ARTPEC-8, by running:
echo <period> > pwm/period
echo <period> > pwm/duty_cycle
echo 1 > pwm/enable
echo 0 > pwm/enable
Since the TCNTn and TCMPn registers are activated when enabling the PWM
(setting TCON auto-reload bit), and are not touched when disabling the
PWM, the double buffered auto-reload function seems to be still active.
Lowering duty-cycle, and restoring it again in between the enabling and
disabling, makes the disable work since it triggers a reload of the
TCNTn and TCMPn registers.
Fix this by securing a reload of the TCNTn and TCMPn registers when
disabling the PWM and having a full duty-cycle.
Signed-off-by: Mårten Lindahl <redacted>
---
v2:
- Move fix above setting of disabled_mask
drivers/pwm/pwm-samsung.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
)
Maybe split the patch to have it nice and reviewable?
If I only move up the definition of __pwm_samsung_manual_update, and
leave pwm_samsung_manual_update at its place, the patch becomes quite
straightforward and overviewable. Or do you prefer to group the definitions
of those two functions together?
Kind regards
Mårten
Orthogonal to your patch: I wonder what &samsung_pwm_lock actually
protects and why it disables irqs. In general the pwm functions might
sleep, at least some implementations do.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
Hello Marten,
On Thu, Sep 09, 2021 at 11:24:10AM +0200, Marten Lindahl wrote:
If I only move up the definition of __pwm_samsung_manual_update, and
leave pwm_samsung_manual_update at its place, the patch becomes quite
straightforward and overviewable. Or do you prefer to group the definitions
of those two functions together?
No strong preference. I found it natural to keep
__pwm_samsung_manual_update and pwm_samsung_manual_update together, but
I wouldn't object your suggestion either.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |