Skip to content

Commit

Permalink
pwm: Reload counters when they reach 0
Browse files Browse the repository at this point in the history
Add IT5570E register that controls when DCRi is updated. Set it to
update when the counter reaches 0, instead of immediately when the
register is written.

Fixes keyboard color when changing brightness levels if not using 0xFF
for an RGB value.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
  • Loading branch information
crawfxrd committed Oct 11, 2022
1 parent 76019bd commit 00a617b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/board/system76/common/pwm.c
Expand Up @@ -26,6 +26,11 @@ void pwm_init(void) {
// Turn off CPU fan (temperature control in peci_get_fan_duty)
DCR2 = 0;

#ifdef it5570e
// Reload counters when they reach 0 instead of immediately
PWMLCCR = 0xFF;
#endif

// Enable PWM
ZTIER = BIT(1);
}
5 changes: 5 additions & 0 deletions src/ec/ite/include/ec/pwm.h
Expand Up @@ -62,4 +62,9 @@ volatile uint8_t __xdata __at(0x1823) ZTIER;
// Tachometer switch control register
volatile uint8_t __xdata __at(0x1848) TSWCTLR;

#ifdef it5570e
// PWM Load Counter Control Register
volatile uint8_t __xdata __at(0x185A) PWMLCCR;
#endif

#endif // _EC_PWM_H

0 comments on commit 00a617b

Please sign in to comment.