Commit 75e7ed52 authored by Gokul Praveen's avatar Gokul Praveen Committed by Uwe Kleine-König
Browse files

pwm: tiehrpwm: Enable pwmchip's parent device before setting configuration



The period and duty cycle configurations on J7200 and J784S4 SoCs
does not get reflected after setting them using sysfs nodes.
This is because at the end of ehrpwm_pwm_config function,
the put_sync function is called which resets the hardware.

Hold the PWM controller out of low-power mode during .apply() to
make sure it accepts the writes to its registers.

This renders the calls to pm_runtime_get_sync() and
pm_runtime_put_sync() in ehrpwm_pwm_config() into no-ops, so
these can be dropped.

Fixes: 5f027d9b ("pwm: tiehrpwm: Implement .apply() callback")
Signed-off-by: default avatarGokul Praveen <g-praveen@ti.com>
Suggested-by: default avatarUwe Kleine-König <ukleinek@kernel.org>
Link: https://patch.msgid.link/20260121061134.15466-1-g-praveen@ti.com


Signed-off-by: default avatarUwe Kleine-König <ukleinek@kernel.org>
parent dcce06fb
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -237,8 +237,6 @@ static int ehrpwm_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
	if (period_cycles < 1)
		period_cycles = 1;

	pm_runtime_get_sync(pwmchip_parent(chip));

	/* Update clock prescaler values */
	ehrpwm_modify(pc->mmio_base, TBCTL, TBCTL_CLKDIV_MASK, tb_divval);

@@ -290,8 +288,6 @@ static int ehrpwm_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
	if (!(duty_cycles > period_cycles))
		ehrpwm_write(pc->mmio_base, cmp_reg, duty_cycles);

	pm_runtime_put_sync(pwmchip_parent(chip));

	return 0;
}

@@ -378,6 +374,8 @@ static int ehrpwm_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
	int err;
	bool enabled = pwm->state.enabled;

	guard(pm_runtime_active)(pwmchip_parent(chip));

	if (state->polarity != pwm->state.polarity) {
		if (enabled) {
			ehrpwm_pwm_disable(chip, pwm);