mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-10 17:41:54 +00:00
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>
This commit is contained in:
committed by
ChromeBot
parent
a26b0dbd74
commit
6696843708
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#define CONFIG_TASK_PROFILING
|
||||
|
||||
/* Optional features */
|
||||
#define CONFIG_BACKLIGHT_X86
|
||||
#ifdef HAS_TASK_CHIPSET
|
||||
#define CONFIG_CHIPSET_HASWELL
|
||||
#endif
|
||||
|
||||
@@ -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;
|
||||
|
||||
55
common/backlight_x86.c
Normal file
55
common/backlight_x86.c
Normal file
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
20
include/backlight.h
Normal file
20
include/backlight.h
Normal file
@@ -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 */
|
||||
Reference in New Issue
Block a user