diff options
author | David Hendricks <dhendrix@chromium.org> | 2012-08-08 17:28:13 -0700 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-08-17 16:55:26 -0700 |
commit | 1f091487b210125e351c8397186e2012d8a19cb7 (patch) | |
tree | afd7aa4e91ffad842b05cc415bab7da9e0e31408 /board | |
parent | c1c3ec56f89bd2bb132e1e360b0aaf43aa77e0d8 (diff) | |
download | chrome-ec-1f091487b210125e351c8397186e2012d8a19cb7.tar.gz |
snow/stm32: re-configure power LED on the fly (input vs. pwm)
Usually the power LED is driven by the PWM mode so that its nominal
brightness can be set to a "soft" on value. However, when
the LED is to remain off the LED should be switched to floating
input mode. This reduces voltage leakage.
This CL updates the power_led_task to configure the LED however is
appropriate and adds board functions to re-configure the GPIO.
Signed-off-by: David Hendricks <dhendrix@chromium.org>
BRANCH=snow
BUG=chrome-os-partner:12381
TEST=LED responds as expected in suspend and on/off states, also
tested that leakage is reduced with multimeter
Change-Id: If90ac78aaffe7358cce80dd02ec1423c2cb4f664
Reviewed-on: https://gerrit.chromium.org/gerrit/29705
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/snow/board.c | 36 | ||||
-rw-r--r-- | board/snow/board.h | 1 |
2 files changed, 32 insertions, 5 deletions
diff --git a/board/snow/board.c b/board/snow/board.c index 50fcdfd04c..b612955af3 100644 --- a/board/snow/board.c +++ b/board/snow/board.c @@ -12,6 +12,7 @@ #include "gpio.h" #include "i2c.h" #include "pmu_tpschrome.h" +#include "power_led.h" #include "registers.h" #include "spi.h" #include "timer.h" @@ -67,6 +68,7 @@ const struct gpio_info gpio_list[GPIO_COUNT] = { {"CHARGER_EN", GPIO_B, (1<<2), GPIO_OUT_LOW, NULL}, {"EC_INT", GPIO_B, (1<<9), GPIO_HI_Z, NULL}, {"CODEC_INT", GPIO_D, (1<<1), GPIO_HI_Z, NULL}, + {"LED_POWER_L", GPIO_B, (1<<3), GPIO_INPUT, NULL}, {"KB_OUT00", GPIO_B, (1<<0), GPIO_KB_OUTPUT, NULL}, {"KB_OUT01", GPIO_B, (1<<8), GPIO_KB_OUTPUT, NULL}, {"KB_OUT02", GPIO_B, (1<<12), GPIO_KB_OUTPUT, NULL}, @@ -107,11 +109,6 @@ void configure_board(void) 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 @@ -152,6 +149,35 @@ void board_keyboard_suppress_noise(void) gpio_set_level(GPIO_CODEC_INT, 1); } +void board_power_led_config(enum powerled_config config) +{ + uint32_t val; + + switch (config) { + case POWERLED_CONFIG_PWM: + val = STM32_GPIO_CRL_OFF(GPIO_B) & ~0x0000f000; + val |= 0x00009000; /* alt. function (TIM2/PWM) */ + STM32_GPIO_CRL_OFF(GPIO_B) = val; + break; + case POWERLED_CONFIG_MANUAL_OFF: + /* + * Re-configure GPIO as a floating input. Alternatively we could + * configure it as an open-drain output and set it to high + * impedence, but reconfiguring as an input had better results + * in testing. + */ + gpio_set_flags(GPIO_LED_POWER_L, GPIO_INPUT); + gpio_set_level(GPIO_LED_POWER_L, 1); + break; + case POWERLED_CONFIG_MANUAL_ON: + gpio_set_flags(GPIO_LED_POWER_L, GPIO_OUTPUT | GPIO_OPEN_DRAIN); + gpio_set_level(GPIO_LED_POWER_L, 0); + break; + default: + break; + } +} + enum { /* Time between requesting bus and deciding that we have it */ BUS_SLEW_DELAY_US = 10, diff --git a/board/snow/board.h b/board/snow/board.h index c7ecae04e7..07b29f0fb7 100644 --- a/board/snow/board.h +++ b/board/snow/board.h @@ -87,6 +87,7 @@ enum gpio_signal { GPIO_CHARGER_EN, GPIO_EC_INT, GPIO_CODEC_INT, /* To audio codec (KB noise cancellation) */ + GPIO_LED_POWER_L, /* Keyboard power LED */ GPIO_KB_OUT00, GPIO_KB_OUT01, GPIO_KB_OUT02, |