summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncan Laurie <dlaurie@chromium.org>2013-08-22 08:25:17 -0700
committerChromeBot <chrome-bot@google.com>2013-08-22 09:09:19 -0700
commit8b1222a39d80dfa847757789367a64f6ce64580b (patch)
tree4987e6e16224efdd3b6b3be931a2a1780bcada83
parent239681b0e263ed709d02a0b969d34894f6ac9013 (diff)
downloadchrome-ec-8b1222a39d80dfa847757789367a64f6ce64580b.tar.gz
falco: delay backlight enable by 420ms
In order to meet the panel power sequencing requirements the backlight enable needs to be delayed by 420ms. As the EC has direct control over the panel backlight, it's difficult to align with the reset of the panel signals which are controlled by an LVDS bridge. In order to not affect other boards the backlight implementation has been moved within falco's board directory. BUG=chrome-os-partner:21234 BRANCH=falco TEST=Built with a printf to verify rough timing transitions. Original-Change-Id: I5d6cd2989f17cc5c188d307f6ceacb52341a87b4 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/66238 Reviewed-by: Bill Richardson <wfrichar@chromium.org> (cherry picked from commit 02ec04d215059464cf7acc6accdec720fc4c7c8c) Change-Id: Ia0ae5d3413eee461d522e975685fa9efb95d2bc9 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/66649
-rw-r--r--board/falco/backlight.c89
-rw-r--r--board/falco/board.h1
-rw-r--r--board/falco/build.mk2
3 files changed, 90 insertions, 2 deletions
diff --git a/board/falco/backlight.c b/board/falco/backlight.c
new file mode 100644
index 0000000000..a1d0b44b0f
--- /dev/null
+++ b/board/falco/backlight.c
@@ -0,0 +1,89 @@
+/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "common.h"
+#include "gpio.h"
+#include "hooks.h"
+#include "host_command.h"
+#include "lid_switch.h"
+
+/*
+ * Falco needs a 420ms delay for a 0->1 transition of the PCH's backlight
+ * enable signal. The reason is that Falco has a LVDS bridge which controls
+ * all the other signals for the panel except the backlight. In order to
+ * meet the penel power sequencing requirements a delay needs to be added.
+ */
+
+#define BL_ENABLE_DELAY_US 420000 /* 420 ms delay */
+
+static int backlight_deferred_value;
+
+static void set_backlight_value(void)
+{
+ gpio_set_level(GPIO_ENABLE_BACKLIGHT, backlight_deferred_value);
+}
+DECLARE_DEFERRED(set_backlight_value);
+
+/**
+ * Update backlight state.
+ */
+static void update_backlight(void)
+{
+ int pch_value;
+
+ pch_value = gpio_get_level(GPIO_PCH_BKLTEN);
+
+ /* Immediately disable the backlight when the lid is closed or the PCH
+ * is instructing the backlight to be disabled. */
+ if (!lid_is_open() || !pch_value) {
+ /* If there was a scheduled callback pending make sure it picks
+ * up the disabled value. */
+ backlight_deferred_value = 0;
+ gpio_set_level(GPIO_ENABLE_BACKLIGHT, 0);
+ /* Cancel pending hook */
+ hook_call_deferred(&set_backlight_value, -1);
+ return;
+ }
+ /* Handle a 0->1 transition by calling a deferred hook. */
+ if (pch_value && !backlight_deferred_value) {
+ backlight_deferred_value = 1;
+ hook_call_deferred(&set_backlight_value, BL_ENABLE_DELAY_US);
+ }
+}
+DECLARE_HOOK(HOOK_LID_CHANGE, update_backlight, HOOK_PRIO_DEFAULT);
+
+/**
+ * Initialize backlight module.
+ */
+static void backlight_init(void)
+{
+ /* Set initial deferred value and signal to the current PCH signal. */
+ backlight_deferred_value = gpio_get_level(GPIO_PCH_BKLTEN);
+ set_backlight_value();
+
+ update_backlight();
+
+ gpio_enable_interrupt(GPIO_PCH_BKLTEN);
+}
+DECLARE_HOOK(HOOK_INIT, backlight_init, HOOK_PRIO_DEFAULT);
+
+void backlight_interrupt(enum gpio_signal signal)
+{
+ update_backlight();
+}
+
+/**
+ * Host command to toggle backlight.
+ */
+static int switch_command_enable_backlight(struct host_cmd_handler_args *args)
+{
+ const struct ec_params_switch_enable_backlight *p = args->params;
+ gpio_set_level(GPIO_ENABLE_BACKLIGHT, p->enabled);
+ return EC_RES_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_CMD_SWITCH_ENABLE_BKLIGHT,
+ switch_command_enable_backlight, 0);
+
+
diff --git a/board/falco/board.h b/board/falco/board.h
index 2d0d6f2fdb..19136f7d26 100644
--- a/board/falco/board.h
+++ b/board/falco/board.h
@@ -9,7 +9,6 @@
#define __BOARD_H
/* Optional features */
-#define CONFIG_BACKLIGHT_X86
#define CONFIG_BATTERY_SMART
#define CONFIG_BOARD_VERSION
#define CONFIG_CHARGER
diff --git a/board/falco/build.mk b/board/falco/build.mk
index 1843369ed4..b7f987e71f 100644
--- a/board/falco/build.mk
+++ b/board/falco/build.mk
@@ -9,4 +9,4 @@
# the IC is TI Stellaris LM4
CHIP:=lm4
-board-y=board.o
+board-y=board.o backlight.o