Split out power button code from switch.c

The power button code is platform-independent.  This change splits the
code out of the LM4 switch.c module so that a subseqent change to
STM32 platforms can start using it.

BUG=chrome-os-partner:18945
BRANCH=none
TEST=manual

1. Power+refresh+esc goes to recovery mode,
2. Press power button at recovery screen turns off.
3. With system off, power button turns system on.
4. Press power button for a second; screen locks.
5. Press power button while typing; blocks keystrokes while it's pressed.
6. Hold power button down for 8 sec; system forced to shutdown.
7. From EC console, with system on:
   hostevent clear
   hostevent -> event 0x04 is clear
   press power button
   hostevent -> event 0x04 is set
8. From EC console, with system off:
   powerbtn -> system turns on
   powerbtn 5000 -> system turns off, just like power button was held for 5 sec

Change-Id: If2a9b02514a201e1d03c857d128e2ccab51a16ef
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49217
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
This commit is contained in:
Randall Spangler
2013-04-23 17:02:07 -07:00
committed by ChromeBot
parent b4b2c6ae70
commit 45bc5c1a21
13 changed files with 261 additions and 175 deletions

View File

@@ -25,6 +25,8 @@ enum hook_priority {
HOOK_PRIO_INIT_CHIPSET = HOOK_PRIO_FIRST + 2,
/* Lid switch inits before power button */
HOOK_PRIO_INIT_LID = HOOK_PRIO_FIRST + 3,
/* Power button inits before chipset and switch */
HOOK_PRIO_INIT_POWER_BUTTON = HOOK_PRIO_FIRST + 4,
};
enum hook_type {
@@ -105,6 +107,14 @@ enum hook_type {
*/
HOOK_LID_CHANGE,
/*
* Power button pressed or released. Based on debounced power button
* state, not raw GPIO input.
*
* Hook routines are called from the chipset task.
*/
HOOK_POWER_BUTTON_CHANGE,
/*
* Periodic tick, every HOOK_TICK_INTERVAL.
*

View File

@@ -27,9 +27,4 @@ void keyboard_host_write(int data, int is_cmd);
*/
void keyboard_state_changed(int row, int col, int is_pressed);
/**
* Send make/break code of power button to host.
*/
void keyboard_set_power_button(int pressed);
#endif /* __CROS_EC_KEYBOARD_8042_H */

27
include/power_button.h Normal file
View File

@@ -0,0 +1,27 @@
/* 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.
*/
/* Power button API for Chrome EC */
#ifndef __CROS_EC_POWER_BUTTON_H
#define __CROS_EC_POWER_BUTTON_H
#include "common.h"
/**
* Return non-zero if power button is pressed.
*
* Uses the debounced button state, not the raw signal from the GPIO.
*/
int power_button_is_pressed(void);
/**
* Interrupt handler for power button.
*
* @param signal Signal which triggered the interrupt.
*/
void power_button_interrupt(enum gpio_signal signal);
#endif /* __CROS_EC_POWER_BUTTON_H */