diff options
author | Vic Yang <victoryang@chromium.org> | 2013-08-05 11:17:35 +0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-08-27 23:20:33 +0000 |
commit | 5d014fd2dd5e92ad35a4f2dd1b58e0b1baebb65e (patch) | |
tree | 2078f9831177392f22ba202cbea4b09d69a9a710 /board/pit | |
parent | 99f06c39aabd262653c96c589c5cd26fc1fb8389 (diff) | |
download | chrome-ec-5d014fd2dd5e92ad35a4f2dd1b58e0b1baebb65e.tar.gz |
Refactor PWM module
This unifies the PWM module interface for LM4 and STM32. Now PWM
channels are defined in board.h/board.c. Instead of calling functions
named pwm_set_fan_duty(x), one can now use pwm_set_duty(PWM_CH_FAN, x),
which prevents additional functions added when we have a new PWM
channel.
BUG=chrome-os-partner:18343
TEST=Limit input current on Spring.
TEST=Check power LED in S0/S3/S5 on Snow.
TEST=Check keyboard backlight functionality on Link.
TEST=Check fan speed control/detecting on Link.
BRANCH=None
Change-Id: Ibac4d79f72e65c94776d503558a7592f7db859dc
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/64450
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'board/pit')
-rw-r--r-- | board/pit/board.c | 9 | ||||
-rw-r--r-- | board/pit/board.h | 7 |
2 files changed, 16 insertions, 0 deletions
diff --git a/board/pit/board.c b/board/pit/board.c index 6a5dc07c15..da85dafcb8 100644 --- a/board/pit/board.c +++ b/board/pit/board.c @@ -13,6 +13,8 @@ #include "keyboard_raw.h" #include "lid_switch.h" #include "pmu_tpschrome.h" +#include "pwm.h" +#include "pwm_data.h" #include "registers.h" #include "spi.h" #include "task.h" @@ -107,6 +109,13 @@ const struct i2c_port_t i2c_ports[] = { }; BUILD_ASSERT(ARRAY_SIZE(i2c_ports) == I2C_PORTS_USED); +/* PWM channels */ +const struct pwm_t pwm_channels[] = { + [PWM_CH_POWER_LED] = {STM32_TIM(2), STM32_TIM_CH(3), + PWM_CONFIG_ACTIVE_LOW, GPIO_LED_POWER_L}, +}; +BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); + int pmu_board_init(void) { int ver, failure = 0; diff --git a/board/pit/board.h b/board/pit/board.h index c9f4e5d51e..89c54951b9 100644 --- a/board/pit/board.h +++ b/board/pit/board.h @@ -21,6 +21,7 @@ #define CONFIG_PMU_POWERINFO #define CONFIG_PMU_TPS65090 #define CONFIG_SPI +#define CONFIG_PWM #ifndef __ASSEMBLER__ @@ -120,6 +121,12 @@ enum gpio_signal { GPIO_COUNT }; +enum pwm_channel { + PWM_CH_POWER_LED = 0, + /* Number of PWM channels */ + PWM_CH_COUNT +}; + #endif /* !__ASSEMBLER__ */ #endif /* __BOARD_H */ |