pwm: PWM is disabled when duty is set to max value

The CTR was set to 1 less than the max PWM value, so when the DCR
is set to max PWM value, duty goes to zero. The bug is fixed by
setting CTR to PWM max vlaue.

BUG=chrome-os-partner:57052
BRANCH=None
TEST=Manual on terminal.
> pwmduty 1 raw 0
Setting channel 1 to raw 0
  1: disabled
> pwmduty 1 raw 65535
Setting channel 1 to raw 65535
verified that screen didn't blank

Change-Id: I10885d382f1bd252a5e7355da99dc00bd876e29f
Reviewed-on: https://chromium-review.googlesource.com/381632
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
This commit is contained in:
Sam Hurst
2016-09-06 13:56:57 -07:00
committed by chrome-bot
parent 64d6f5781b
commit df80ec22ca
2 changed files with 3 additions and 4 deletions

View File

@@ -84,9 +84,9 @@ static void pwm_set_freq(enum pwm_channel ch, uint32_t freq)
NPCX_PRSC(mdl) = (uint16_t)prescaler_divider;
/* Set PWM cycle time */
NPCX_CTR(mdl) = EC_PWM_MAX_DUTY - 1;
NPCX_CTR(mdl) = EC_PWM_MAX_DUTY;
/* Set the duty cycle to 0% since DCR > CTR */
/* Set the duty cycle to 100% since DCR == CTR */
NPCX_DCR(mdl) = EC_PWM_MAX_DUTY;
}

View File

@@ -144,8 +144,7 @@ static int cc_pwm_duty(int argc, char **argv)
/* Negative = disable */
pwm_enable(ch, 0);
} else {
ccprintf("Setting channel %d to%s%d%%\n",
ch, (max_duty == 100) ? " " : " raw ", value);
ccprintf("Setting channel %d to %d\n", ch, value);
pwm_enable(ch, 1);
(max_duty == 100) ? pwm_set_duty(ch, value) :
pwm_set_raw_duty(ch, value);