summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-07-11 13:43:13 -0700
committerChromeBot <chrome-bot@google.com>2013-07-11 16:51:39 -0700
commit6696843708b7e5cb83a6c061a76cf70cbfd2523f (patch)
treefd1f1b8948054b74a1da01be9210131c3e03451c
parenta26b0dbd747386c841a31144c7fdf07b68ccb811 (diff)
downloadchrome-ec-6696843708b7e5cb83a6c061a76cf70cbfd2523f.tar.gz
Move x86 backlight-enable passthru code to its own module
This code is not LM4-specific, it's x86-specific. So it doesn't belong in chip/lm4. Put it in its own module rather than leaving it in switch.c, since some x86 systems may need the power button state machine but not the backlight-enable passthru. BUG=chrome-os-partner:18343 BRANCH=none TEST=Quickly run a magnet over the lid switch; the backlight goes off and then back on. Change-Id: I72f7139b73f91539dcfbe6b5cb6d56587ab66fde Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/61595 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
-rw-r--r--board/falco/board.c4
-rw-r--r--board/falco/board.h1
-rw-r--r--board/link/board.c4
-rw-r--r--board/link/board.h1
-rw-r--r--board/peppy/board.c4
-rw-r--r--board/peppy/board.h1
-rw-r--r--board/slippy/board.c4
-rw-r--r--board/slippy/board.h1
-rw-r--r--board/wolf/board.c4
-rw-r--r--board/wolf/board.h1
-rw-r--r--chip/lm4/switch.c43
-rw-r--r--common/backlight_x86.c55
-rw-r--r--common/build.mk1
-rw-r--r--include/backlight.h20
14 files changed, 92 insertions, 52 deletions
diff --git a/board/falco/board.c b/board/falco/board.c
index f394244d63..b98d03f7b2 100644
--- a/board/falco/board.c
+++ b/board/falco/board.c
@@ -5,7 +5,7 @@
/* EC for Falco board configuration */
#include "adc.h"
-#include "board.h"
+#include "backlight.h"
#include "chip_temp_sensor.h"
#include "chipset_haswell.h"
#include "chipset_x86_common.h"
@@ -37,7 +37,7 @@ const struct gpio_info gpio_list[GPIO_COUNT] = {
{"AC_PRESENT", LM4_GPIO_H, (1<<3), GPIO_INT_BOTH,
extpower_interrupt},
{"PCH_BKLTEN", LM4_GPIO_M, (1<<3), GPIO_INT_BOTH,
- switch_interrupt},
+ backlight_interrupt},
{"PCH_SLP_S0_L", LM4_GPIO_G, (1<<6), GPIO_INT_BOTH,
x86_interrupt},
{"PCH_SLP_S3_L", LM4_GPIO_G, (1<<7), GPIO_INT_BOTH,
diff --git a/board/falco/board.h b/board/falco/board.h
index a2fbc8a47d..5a20099288 100644
--- a/board/falco/board.h
+++ b/board/falco/board.h
@@ -16,6 +16,7 @@
/* Optional features */
#define CONFIG_SMART_BATTERY
+#define CONFIG_BACKLIGHT_X86
#define CONFIG_BATTERY_FALCO
#define CONFIG_EXTPOWER_FALCO
#define CONFIG_BOARD_VERSION
diff --git a/board/link/board.c b/board/link/board.c
index 301140d9b9..62c7332d78 100644
--- a/board/link/board.c
+++ b/board/link/board.c
@@ -5,7 +5,7 @@
/* EC for Link board configuration */
#include "adc.h"
-#include "board.h"
+#include "backlight.h"
#include "chip_temp_sensor.h"
#include "chipset_ivybridge.h"
#include "chipset_x86_common.h"
@@ -41,7 +41,7 @@ const struct gpio_info gpio_list[GPIO_COUNT] = {
{"BOARD_VERSION2", LM4_GPIO_L, (1<<6), 0, NULL},
{"BOARD_VERSION3", LM4_GPIO_L, (1<<7), 0, NULL},
{"PCH_BKLTEN", LM4_GPIO_J, (1<<3), GPIO_INT_BOTH,
- switch_interrupt},
+ backlight_interrupt},
{"PCH_SLP_A_L", LM4_GPIO_G, (1<<5), GPIO_INT_BOTH,
x86_interrupt},
{"PCH_SLP_ME_CSW_DEV_L", LM4_GPIO_G, (1<<4), GPIO_INT_BOTH,
diff --git a/board/link/board.h b/board/link/board.h
index 711c36c2c3..38e7130ba7 100644
--- a/board/link/board.h
+++ b/board/link/board.h
@@ -16,6 +16,7 @@
/* Optional features */
#define CONFIG_SMART_BATTERY
+#define CONFIG_BACKLIGHT_X86
#define CONFIG_BATTERY_LINK
#define CONFIG_BOARD_VERSION
#define CONFIG_CHARGER
diff --git a/board/peppy/board.c b/board/peppy/board.c
index 5f1422e98c..293747c43b 100644
--- a/board/peppy/board.c
+++ b/board/peppy/board.c
@@ -5,7 +5,7 @@
/* EC for Peppy board configuration */
#include "adc.h"
-#include "board.h"
+#include "backlight.h"
#include "chip_temp_sensor.h"
#include "chipset_haswell.h"
#include "chipset_x86_common.h"
@@ -37,7 +37,7 @@ const struct gpio_info gpio_list[GPIO_COUNT] = {
{"AC_PRESENT", LM4_GPIO_H, (1<<3), GPIO_INT_BOTH,
extpower_interrupt},
{"PCH_BKLTEN", LM4_GPIO_M, (1<<3), GPIO_INT_BOTH,
- switch_interrupt},
+ backlight_interrupt},
{"PCH_SLP_S0_L", LM4_GPIO_G, (1<<6), GPIO_INT_BOTH,
x86_interrupt},
{"PCH_SLP_S3_L", LM4_GPIO_G, (1<<7), GPIO_INT_BOTH,
diff --git a/board/peppy/board.h b/board/peppy/board.h
index 102c2fffa9..70ad78c48d 100644
--- a/board/peppy/board.h
+++ b/board/peppy/board.h
@@ -16,6 +16,7 @@
/* Optional features */
#define CONFIG_SMART_BATTERY
+#define CONFIG_BACKLIGHT_X86
#define CONFIG_BATTERY_PEPPY
#define CONFIG_BOARD_VERSION
#define CONFIG_CHARGER
diff --git a/board/slippy/board.c b/board/slippy/board.c
index bf06a80b54..da361174c2 100644
--- a/board/slippy/board.c
+++ b/board/slippy/board.c
@@ -5,7 +5,7 @@
/* EC for Slippy board configuration */
#include "adc.h"
-#include "board.h"
+#include "backlight.h"
#include "chip_temp_sensor.h"
#include "chipset_haswell.h"
#include "chipset_x86_common.h"
@@ -37,7 +37,7 @@ const struct gpio_info gpio_list[GPIO_COUNT] = {
{"AC_PRESENT", LM4_GPIO_H, (1<<3), GPIO_INT_BOTH,
extpower_interrupt},
{"PCH_BKLTEN", LM4_GPIO_M, (1<<3), GPIO_INT_BOTH,
- switch_interrupt},
+ backlight_interrupt},
{"PCH_SLP_S0_L", LM4_GPIO_G, (1<<6), GPIO_INT_BOTH,
x86_interrupt},
{"PCH_SLP_S3_L", LM4_GPIO_G, (1<<7), GPIO_INT_BOTH,
diff --git a/board/slippy/board.h b/board/slippy/board.h
index e322d1abd5..d41db4781b 100644
--- a/board/slippy/board.h
+++ b/board/slippy/board.h
@@ -16,6 +16,7 @@
/* Optional features */
#define CONFIG_SMART_BATTERY
+#define CONFIG_BACKLIGHT_X86
#define CONFIG_BATTERY_SLIPPY
#define CONFIG_BOARD_VERSION
#define CONFIG_CHARGER
diff --git a/board/wolf/board.c b/board/wolf/board.c
index 8c05c72ae8..c1afbb1cbd 100644
--- a/board/wolf/board.c
+++ b/board/wolf/board.c
@@ -5,7 +5,7 @@
/* EC for Wolf board configuration */
#include "adc.h"
-#include "board.h"
+#include "backlight.h"
#include "chip_temp_sensor.h"
#include "chipset_haswell.h"
#include "chipset_x86_common.h"
@@ -36,7 +36,7 @@ const struct gpio_info gpio_list[GPIO_COUNT] = {
{"AC_PRESENT", LM4_GPIO_H, (1<<3), GPIO_INT_BOTH,
extpower_interrupt},
{"PCH_BKLTEN", LM4_GPIO_M, (1<<3), GPIO_INT_BOTH,
- switch_interrupt},
+ backlight_interrupt},
{"PCH_SLP_S0_L", LM4_GPIO_G, (1<<6), GPIO_INT_BOTH,
x86_interrupt},
{"PCH_SLP_S3_L", LM4_GPIO_G, (1<<7), GPIO_INT_BOTH,
diff --git a/board/wolf/board.h b/board/wolf/board.h
index 06598cfe66..2e8a41b884 100644
--- a/board/wolf/board.h
+++ b/board/wolf/board.h
@@ -15,6 +15,7 @@
#define CONFIG_TASK_PROFILING
/* Optional features */
+#define CONFIG_BACKLIGHT_X86
#ifdef HAS_TASK_CHIPSET
#define CONFIG_CHIPSET_HASWELL
#endif
diff --git a/chip/lm4/switch.c b/chip/lm4/switch.c
index a70a163dbb..9d11aa2d9e 100644
--- a/chip/lm4/switch.c
+++ b/chip/lm4/switch.c
@@ -146,15 +146,6 @@ static void set_pwrbtn_to_pch(int high)
gpio_set_level(GPIO_PCH_PWRBTN_L, high);
}
-static void update_backlight(void)
-{
- /* Only enable the backlight if the lid is open */
- if (gpio_get_level(GPIO_PCH_BKLTEN) && lid_is_open())
- gpio_set_level(GPIO_ENABLE_BACKLIGHT, 1);
- else
- gpio_set_level(GPIO_ENABLE_BACKLIGHT, 0);
-}
-
/**
* Handle debounced power button down.
*/
@@ -402,14 +393,12 @@ static void switch_init(void)
*memmap_switches |= EC_SWITCH_LID_OPEN;
update_other_switches();
- update_backlight();
set_initial_pwrbtn_state();
/* Switch data is now present */
*host_get_memmap(EC_MEMMAP_SWITCHES_VERSION) = 1;
/* Enable interrupts, now that we've initialized */
- gpio_enable_interrupt(GPIO_PCH_BKLTEN);
gpio_enable_interrupt(GPIO_POWER_BUTTON_L);
gpio_enable_interrupt(GPIO_RECOVERY_L);
#ifdef CONFIG_WP_ACTIVE_HIGH
@@ -425,8 +414,6 @@ DECLARE_HOOK(HOOK_INIT, switch_init, HOOK_PRIO_DEFAULT);
*/
static void switch_lid_change(void)
{
- update_backlight();
-
if (lid_is_open()) {
*memmap_switches |= EC_SWITCH_LID_OPEN;
@@ -484,26 +471,7 @@ DECLARE_HOOK(HOOK_POWER_BUTTON_CHANGE, power_button_changed, HOOK_PRIO_DEFAULT);
void switch_interrupt(enum gpio_signal signal)
{
- /* Reset debounce time for the changed signal */
- switch (signal) {
- case GPIO_PCH_BKLTEN:
- update_backlight();
- break;
- default:
- /*
- * Change in non-debounced switches; we'll update their state
- * automatically the next time through the task loop.
- */
- break;
- }
-
- /*
- * We don't have a way to tell the task to wake up at the end of the
- * debounce interval; wake it up now so it can go back to sleep for the
- * remainder of the interval. The alternative would be to have the
- * task wake up _every_ debounce_us on its own; that's less desirable
- * when the EC should be sleeping.
- */
+ /* Wake task to handle change in non-debounced switches */
task_wake(TASK_ID_SWITCH);
}
@@ -535,15 +503,6 @@ DECLARE_CONSOLE_COMMAND(mmapinfo, command_mmapinfo,
/*****************************************************************************/
/* Host commands */
-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);
-
static int switch_command_enable_wireless(struct host_cmd_handler_args *args)
{
const struct ec_params_switch_enable_wireless *p = args->params;
diff --git a/common/backlight_x86.c b/common/backlight_x86.c
new file mode 100644
index 0000000000..83e9aeab04
--- /dev/null
+++ b/common/backlight_x86.c
@@ -0,0 +1,55 @@
+/* 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.
+ */
+
+/* Backlight passthru for x86 platforms */
+
+#include "common.h"
+#include "gpio.h"
+#include "hooks.h"
+#include "host_command.h"
+#include "lid_switch.h"
+
+/**
+ * Update backlight state.
+ */
+static void update_backlight(void)
+{
+ /* Only enable the backlight if the lid is open */
+ if (gpio_get_level(GPIO_PCH_BKLTEN) && lid_is_open())
+ gpio_set_level(GPIO_ENABLE_BACKLIGHT, 1);
+ else
+ gpio_set_level(GPIO_ENABLE_BACKLIGHT, 0);
+}
+DECLARE_HOOK(HOOK_LID_CHANGE, update_backlight, HOOK_PRIO_DEFAULT);
+
+/**
+ * Initialize backlight module.
+ */
+static void backlight_init(void)
+{
+ 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/common/build.mk b/common/build.mk
index 9968afa041..a9391d3f68 100644
--- a/common/build.mk
+++ b/common/build.mk
@@ -9,6 +9,7 @@
common-y=main.o util.o console_output.o uart_buffering.o
common-y+=memory_commands.o shared_mem.o system_common.o hooks.o
common-y+=gpio_common.o version.o printf.o queue.o
+common-$(CONFIG_BACKLIGHT_X86)+=backlight_x86.o
common-$(CONFIG_BATTERY_BQ20Z453)+=battery_bq20z453.o
common-$(CONFIG_BATTERY_LINK)+=battery_link.o
common-$(CONFIG_BATTERY_SLIPPY)+=battery_slippy.o
diff --git a/include/backlight.h b/include/backlight.h
new file mode 100644
index 0000000000..dd4e06e991
--- /dev/null
+++ b/include/backlight.h
@@ -0,0 +1,20 @@
+/* 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.
+ */
+
+/* Backlight API for Chrome EC */
+
+#ifndef __CROS_EC_BACKLIGHT_H
+#define __CROS_EC_BACKLIGHT_H
+
+#include "common.h"
+
+/**
+ * Interrupt handler for backlight.
+ *
+ * @param signal Signal which triggered the interrupt.
+ */
+void backlight_interrupt(enum gpio_signal signal);
+
+#endif /* __CROS_EC_BACKLIGHT_H */