Skip to contentSkip to conversation

question about pwm-tiecap driver pwm_disable behavior

DISCUSSION David Lechner 1 participant 1 message Oct 3, 2016 PWM

lore
Share & tools
lore
#0 lore raw

In drivers/pwm/pwm-tiecap.c, there is the following function for disabling the pwm.

static void ecap_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)

{
	struct ecap_pwm_chip *pc = to_ecap_pwm_chip(chip);
	unsigned int reg_val;

	/*
	 * Disable 'Free run Time stamp counter mode' to stop counter
	 * and 'APWM mode' to put APWM output to low
	 */
	reg_val = readw(pc->mmio_base + ECCTL2);
	reg_val &= ~(ECCTL2_TSCTR_FREERUN | ECCTL2_APWM_MODE);
	writew(reg_val, pc->mmio_base + ECCTL2);

	/* Disable clock on PWM disable */
	pm_runtime_put_sync(pc->chip.dev);
}

I am using this with the pwm-backlight driver to control the backlight of a display. When you tell the pwm-backlight driver to use a brightness of 0, it disables the pwm.

What I would like to happen is, as the comment says, for the output to go low. However, what actually happens is that the output becomes and input (and therefore goes high because of an external pullup resisitor). This happens because by turning off the ECCTL2_APWM_MODE bit, the PWM is switched back to ECAP mode, which acts as an input.

So the question is: Is the comment correct and there is a bug in the code, or is the code correct and the comment should be changed?