summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorDavid Hendricks <dhendrix@chromium.org>2012-08-08 17:28:13 -0700
committerChe-Liang Chiou <clchiou@chromium.org>2012-08-24 15:43:53 -0700
commitc65c81c3ddc5f4de3a0e214b989322bf561ab7f7 (patch)
treee506bea10b14cdec3a4d9596e3d94ff9e26a2341 /board
parent68aa938cde5730eed65780e550efb9eaabb9ec58 (diff)
downloadchrome-ec-c65c81c3ddc5f4de3a0e214b989322bf561ab7f7.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 Original-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> (cherry picked from commit 1f091487b210125e351c8397186e2012d8a19cb7) Change-Id: I1f9ca7179bd7bbc20a456a62c0c052b90e671055 Reviewed-on: https://gerrit.chromium.org/gerrit/30971 Reviewed-by: David Hendricks <dhendrix@chromium.org> Reviewed-by: Che-Liang Chiou <clchiou@chromium.org> Tested-by: Che-Liang Chiou <clchiou@chromium.org>
Diffstat (limited to 'board')
-rw-r--r--board/snow/board.c36
-rw-r--r--board/snow/board.h1
2 files changed, 32 insertions, 5 deletions
diff --git a/board/snow/board.c b/board/snow/board.c
index 8fe26dd15d..8bdca0cde9 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,