Skip to content

Commit 15effed

Browse files
dlechUwe Kleine-König
authored andcommitted
pwm: axi-pwmgen: Enable FORCE_ALIGN by default
Enable the FORCE_ALIGN flag by default in the AXI PWMGEN driver. This flag makes the behavior of the PWM output consistent with the description at the top of the driver file. * Limitations: * - The writes to registers for period and duty are shadowed until * LOAD_CONFIG is written to AXI_PWMGEN_REG_RSTN, at which point * they take effect. * - Writing LOAD_CONFIG also has the effect of re-synchronizing all * enabled channels, which could cause glitching on other channels. It * is therefore expected that channels are assigned harmonic periods * and all have a single user coordinating this. Without this flag, the PWM output does not change until the period of all PWM output channels has run out, which makes the PWM impossible to use in some cases because it takes too long to change the output. Signed-off-by: David Lechner <[email protected]> Reviewed-by: Nuno Sa <[email protected]> Link: https://lore.kernel.org/r/20241009-pwm-axi-pwmgen-enable-force_align-v1-2-5d6ad8cbf5b4@baylibre.com Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent 2e82d58 commit 15effed

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/pwm/pwm-axi-pwmgen.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
#define AXI_PWMGEN_REG_RSTN_LOAD_CONFIG BIT(1)
3838
#define AXI_PWMGEN_REG_RSTN_RESET BIT(0)
3939
#define AXI_PWMGEN_REG_NPWM 0x14
40+
#define AXI_PWMGEN_REG_CONFIG 0x18
41+
#define AXI_PWMGEN_REG_CONFIG_FORCE_ALIGN BIT(1)
4042
#define AXI_PWMGEN_CHX_PERIOD(ch) (0x40 + (4 * (ch)))
4143
#define AXI_PWMGEN_CHX_DUTY(ch) (0x80 + (4 * (ch)))
4244
#define AXI_PWMGEN_CHX_OFFSET(ch) (0xC0 + (4 * (ch)))
@@ -227,6 +229,16 @@ static int axi_pwmgen_setup(struct regmap *regmap, struct device *dev)
227229
if (ret)
228230
return ret;
229231

232+
/*
233+
* Enable force align so that changes to PWM period and duty cycle take
234+
* effect immediately. Otherwise, the effect of the change is delayed
235+
* until the period of all channels run out, which can be long after the
236+
* apply function returns.
237+
*/
238+
ret = regmap_set_bits(regmap, AXI_PWMGEN_REG_CONFIG, AXI_PWMGEN_REG_CONFIG_FORCE_ALIGN);
239+
if (ret)
240+
return ret;
241+
230242
ret = regmap_read(regmap, AXI_PWMGEN_REG_NPWM, &val);
231243
if (ret)
232244
return ret;

0 commit comments

Comments
 (0)