Allow lid-less configuration

power_button_x86.c and switch.c assume there is a lid switch. This
patch separate them so that a board with power button but with no
lid can be configured properly.

This patch also moves backlight control to the board directory
so that only the boards with a backlight turn it on/off when power
state changes.

BUG=none
BRANCH=none
TEST=boot fizz. make buildall.

Change-Id: If4070cdc4b1221fae68b35ec3497335d81f192fd
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/489602
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Daisuke Nojiri
2017-04-27 12:48:08 -07:00
committed by chrome-bot
parent 600df851c5
commit e8982ea3cd
9 changed files with 42 additions and 4 deletions

View File

@@ -402,6 +402,7 @@ DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT);
/* Called on AP S3 -> S0 transition */
static void board_chipset_resume(void)
{
gpio_set_level(GPIO_ENABLE_BACKLIGHT, 1);
gpio_set_level(GPIO_PP1800_DX_AUDIO_EN, 1);
gpio_set_level(GPIO_PP1800_DX_DMIC_EN, 1);
}
@@ -410,6 +411,7 @@ DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume, HOOK_PRIO_DEFAULT);
/* Called on AP S0 -> S3 transition */
static void board_chipset_suspend(void)
{
gpio_set_level(GPIO_ENABLE_BACKLIGHT, 0);
gpio_set_level(GPIO_PP1800_DX_AUDIO_EN, 0);
gpio_set_level(GPIO_PP1800_DX_DMIC_EN, 0);
}

View File

@@ -612,6 +612,7 @@ DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT);
/* Called on AP S0 -> S3 transition */
static void board_chipset_suspend(void)
{
gpio_set_level(GPIO_ENABLE_BACKLIGHT, 0);
if (!tablet_get_mode() && lid_is_open())
trackpad_wake_enable(1);
}
@@ -620,6 +621,7 @@ DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT);
/* Called on AP S3 -> S0 transition */
static void board_chipset_resume(void)
{
gpio_set_level(GPIO_ENABLE_BACKLIGHT, 1);
trackpad_wake_enable(0);
}
DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume, HOOK_PRIO_DEFAULT);

View File

@@ -393,6 +393,7 @@ DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT);
/* Called on AP S3 -> S0 transition */
static void board_chipset_resume(void)
{
gpio_set_level(GPIO_ENABLE_BACKLIGHT, 1);
gpio_set_level(GPIO_PP1800_DX_AUDIO_EN, 1);
gpio_set_level(GPIO_PP1800_DX_SENSOR_EN, 1);
@@ -414,6 +415,7 @@ DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume,
/* Called on AP S0 -> S3 transition */
static void board_chipset_suspend(void)
{
gpio_set_level(GPIO_ENABLE_BACKLIGHT, 0);
gpio_set_level(GPIO_PP1800_DX_AUDIO_EN, 0);
gpio_set_level(GPIO_PP1800_DX_SENSOR_EN, 0);
}

View File

@@ -831,3 +831,17 @@ struct motion_sensor_t motion_sensors[] = {
},
};
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
/* Called on AP S3 -> S0 transition */
static void board_chipset_resume(void)
{
gpio_set_level(GPIO_ENABLE_BACKLIGHT, 1);
}
DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume, HOOK_PRIO_DEFAULT);
/* Called on AP S0 -> S3 transition */
static void board_chipset_suspend(void)
{
gpio_set_level(GPIO_ENABLE_BACKLIGHT, 0);
}
DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT);

View File

@@ -734,6 +734,19 @@ DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT);
/* FIXME(dhendrix): Add CHIPSET_RESUME and CHIPSET_SUSPEND
hooks to enable/disable sensors? */
/* Called on AP S3 -> S0 transition */
static void board_chipset_resume(void)
{
gpio_set_level(GPIO_ENABLE_BACKLIGHT, 1);
}
DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume, HOOK_PRIO_DEFAULT);
/* Called on AP S0 -> S3 transition */
static void board_chipset_suspend(void)
{
gpio_set_level(GPIO_ENABLE_BACKLIGHT, 0);
}
DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT);
/*
* FIXME(dhendrix): Weak symbol hack until we can get a better solution for

View File

@@ -347,6 +347,7 @@ DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT);
/* Called on AP S3 -> S0 transition */
static void board_chipset_resume(void)
{
gpio_set_level(GPIO_ENABLE_BACKLIGHT, 1);
gpio_set_level(GPIO_PP1800_DX_AUDIO_EN, 1);
gpio_set_level(GPIO_PP1800_DX_SENSOR_EN, 1);
@@ -368,6 +369,7 @@ DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume,
/* Called on AP S0 -> S3 transition */
static void board_chipset_suspend(void)
{
gpio_set_level(GPIO_ENABLE_BACKLIGHT, 0);
gpio_set_level(GPIO_PP1800_DX_AUDIO_EN, 0);
gpio_set_level(GPIO_PP1800_DX_SENSOR_EN, 0);
}

View File

@@ -410,6 +410,7 @@ static void powerbtn_x86_init(void)
}
DECLARE_HOOK(HOOK_INIT, powerbtn_x86_init, HOOK_PRIO_DEFAULT);
#ifdef CONFIG_LID_SWITCH
/**
* Handle switch changes based on lid event.
*/
@@ -420,6 +421,7 @@ static void powerbtn_x86_lid_change(void)
power_button_pch_pulse();
}
DECLARE_HOOK(HOOK_LID_CHANGE, powerbtn_x86_lid_change, HOOK_PRIO_DEFAULT);
#endif
/**
* Handle debounced power button changing state.

View File

@@ -43,10 +43,15 @@ static void switch_update(void)
else
*memmap_switches &= ~EC_SWITCH_POWER_BUTTON_PRESSED;
#ifdef CONFIG_LID_SWITCH
if (lid_is_open())
*memmap_switches |= EC_SWITCH_LID_OPEN;
else
*memmap_switches &= ~EC_SWITCH_LID_OPEN;
#else
/* For lid-less systems, lid looks always open */
*memmap_switches |= EC_SWITCH_LID_OPEN;
#endif
if ((flash_get_protect() & EC_FLASH_PROTECT_GPIO_ASSERTED) == 0)
*memmap_switches |= EC_SWITCH_WRITE_PROTECT_DISABLED;

View File

@@ -295,8 +295,6 @@ enum power_state common_intel_x86_power_handle_state(enum power_state state)
return POWER_S3S5;
}
gpio_set_level(GPIO_ENABLE_BACKLIGHT, 1);
/* Enable wireless */
wireless_set_state(WIRELESS_ON);
@@ -321,8 +319,6 @@ enum power_state common_intel_x86_power_handle_state(enum power_state state)
/* Call hooks before we remove power rails */
hook_notify(HOOK_CHIPSET_SUSPEND);
gpio_set_level(GPIO_ENABLE_BACKLIGHT, 0);
/* Suspend wireless */
wireless_set_state(WIRELESS_SUSPEND);