From 1bedd55970387fd019c5a6fd368b1576606e8563 Mon Sep 17 00:00:00 2001 From: David Hendricks Date: Mon, 25 Jun 2012 13:51:46 -0700 Subject: Daisy/Snow: Drive power LED with PWM This drives the power LED for Snow (PB3) using TIM2 in PWM mode. Since timer setup and manipulation is STM32-specific, the power LED logic moved to to chip/stm32/power_led.c. This also adds a "powerled" console command for testing. Signed-off-by: David Hendricks BUG=chrome-os-partner:10647 TEST=Tested on Snow with powerled command, compiled for Daisy Change-Id: I5a7dc20d201ea058767e3e76d54e7c8567a3b83c Reviewed-on: https://gerrit.chromium.org/gerrit/26267 Commit-Ready: David Hendricks Reviewed-by: David Hendricks Tested-by: David Hendricks --- board/snow/board.c | 10 +++++++++- board/snow/board.h | 1 - 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'board/snow') diff --git a/board/snow/board.c b/board/snow/board.c index b536ff3eda..4c9e30bd4b 100644 --- a/board/snow/board.c +++ b/board/snow/board.c @@ -56,7 +56,6 @@ const struct gpio_info gpio_list[GPIO_COUNT] = { {"PMIC_PWRON_L",GPIO_A, (1<<12), GPIO_OUT_HIGH, NULL}, {"ENTERING_RW", GPIO_D, (1<<0), GPIO_OUT_LOW, NULL}, {"CHARGER_EN", GPIO_B, (1<<2), GPIO_OUT_LOW, NULL}, - {"POWER_LED_L", GPIO_B, (1<<3), GPIO_OUT_HIGH, NULL}, {"EC_INT", GPIO_B, (1<<9), GPIO_HI_Z, NULL}, {"CODEC_INT", GPIO_D, (1<<1), GPIO_HI_Z, NULL}, {"KB_OUT00", GPIO_B, (1<<0), GPIO_KB_OUTPUT, NULL}, @@ -130,6 +129,15 @@ void configure_board(void) STM32_GPIO_AFIO_MAPR = (STM32_GPIO_AFIO_MAPR & ~(0x7 << 24)) | (2 << 24); + /* remap TIM2_CH2 to PB3 */ + STM32_GPIO_AFIO_MAPR = (STM32_GPIO_AFIO_MAPR & ~(0x3 << 8)) + | (1 << 8); + + /* set power LED to alternate function to be driven by TIM2/PWM */ + val = STM32_GPIO_CRL_OFF(GPIO_B) & ~0x0000f000; + val |= 0x00009000; + STM32_GPIO_CRL_OFF(GPIO_B) = val; + /* * I2C SCL/SDA on PB10-11 and PB6-7, bi-directional, no pull-up/down, * initialized as hi-Z until alt. function is set diff --git a/board/snow/board.h b/board/snow/board.h index 15db5a64d7..c78a30f574 100644 --- a/board/snow/board.h +++ b/board/snow/board.h @@ -79,7 +79,6 @@ enum gpio_signal { GPIO_PMIC_PWRON_L, /* 5v rail ready */ GPIO_EC_ENTERING_RW, /* EC is R/W mode for the kbc mux */ GPIO_CHARGER_EN, - GPIO_POWER_LED_L, /* Power state keyboard LED */ GPIO_EC_INT, GPIO_CODEC_INT, /* To audio codec (KB noise cancellation) */ GPIO_KB_OUT00, -- cgit v1.2.1