diff options
Diffstat (limited to 'board/halvor/board.c')
-rw-r--r-- | board/halvor/board.c | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/board/halvor/board.c b/board/halvor/board.c index a242c2431d..8bf58af26a 100644 --- a/board/halvor/board.c +++ b/board/halvor/board.c @@ -17,6 +17,8 @@ #include "lid_switch.h" #include "power.h" #include "power_button.h" +#include "pwm.h" +#include "pwm_chip.h" #include "switch.h" #include "system.h" #include "task.h" @@ -29,7 +31,9 @@ static void board_init(void) { - /* TODO */ + /* Illuminate motherboard and daughter board LEDs equally to start. */ + pwm_enable(PWM_CH_LED4_SIDESEL, 1); + pwm_set_duty(PWM_CH_LED4_SIDESEL, 50); } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); @@ -114,6 +118,50 @@ const struct i2c_port_t i2c_ports[] = { }; const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); +/* PWM configuration */ +const struct pwm_t pwm_channels[] = { + [PWM_CH_LED1_BLUE] = { + .channel = 2, + .flags = PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, + .freq = 2400, + }, + [PWM_CH_LED2_GREEN] = { + .channel = 0, + .flags = PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, + .freq = 2400, + }, + [PWM_CH_LED3_RED] = { + .channel = 1, + .flags = PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, + .freq = 2400, + }, + [PWM_CH_LED4_SIDESEL] = { + .channel = 7, + .flags = PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, + /* Run at a higher frequency than the color PWM signals to avoid + * timing-based color shifts. + */ + .freq = 4800, + }, + [PWM_CH_FAN] = { + .channel = 5, + .flags = PWM_CONFIG_OPEN_DRAIN, + .freq = 25000 + }, + [PWM_CH_KBLIGHT] = { + .channel = 3, + .flags = 0, + /* + * Set PWM frequency to multiple of 50 Hz and 60 Hz to prevent + * flicker. Higher frequencies consume similar average power to + * lower PWM frequencies, but higher frequencies record a much + * lower maximum power. + */ + .freq = 2400, + }, +}; +BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); + /******************************************************************************/ void halvor_tcpc_alert_event(enum gpio_signal signal) { |