cleanup: Consolidate power interrupts

Every chipset had its own header file just to declare a GPIO interrupt
handler.  Since this seems to be a common feature of the power
interface, make a standard power_interrupt() API provided by
chipset.h.  This lets us get rid of 4 include files, and makes it
easier to add more chipsets in the future.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all boards; pass unit tests

Change-Id: I1fc5612d42625ea46e0a8e16a83085b66d476664
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/173745
This commit is contained in:
Randall Spangler
2013-10-18 10:38:07 -07:00
committed by chrome-internal-fetch
parent 15e2fa02fd
commit d9530449fd
25 changed files with 64 additions and 163 deletions

View File

@@ -8,7 +8,7 @@
#include "board.h"
#include "backlight.h"
#include "chip_temp_sensor.h"
#include "chipset_haswell.h"
#include "chipset.h"
#include "chipset_x86_common.h"
#include "common.h"
#include "ec_commands.h"
@@ -61,7 +61,7 @@ const struct gpio_info gpio_list[] = {
{"VCORE_PGOOD", LM4_GPIO_C, (1<<6), GPIO_INT_BOTH,
x86_interrupt},
{"PCH_EDP_VDD_EN", LM4_GPIO_J, (1<<1), GPIO_INT_BOTH,
bolt_interrupt},
power_interrupt},
{"RECOVERY_L", LM4_GPIO_A, (1<<5), GPIO_PULL_UP|GPIO_INT_BOTH,
switch_interrupt},
{"WP", LM4_GPIO_A, (1<<4), GPIO_INT_BOTH,

View File

@@ -216,8 +216,6 @@ enum board_version {
#define WIRELESS_GPIO_WWAN GPIO_PP3300_LTE_EN
#define WIRELESS_GPIO_WLAN_POWER GPIO_PP3300_WLAN_EN
void bolt_interrupt(enum gpio_signal signal);
#endif /* !__ASSEMBLER__ */
#endif /* __BOARD_H */

View File

@@ -383,7 +383,7 @@ enum x86_state x86_handle_state(enum x86_state state)
return state;
}
void bolt_interrupt(enum gpio_signal signal)
void power_interrupt(enum gpio_signal signal)
{
/* Pass through eDP VDD enable from PCH */
gpio_set_level(GPIO_EC_EDP_VDD_EN, gpio_get_level(GPIO_PCH_EDP_VDD_EN));

View File

@@ -5,8 +5,8 @@
/* Daisy board-specific configuration */
#include "battery.h"
#include "chipset.h"
#include "common.h"
#include "gaia_power.h"
#include "gpio.h"
#include "i2c.h"
#include "keyboard_raw.h"
@@ -37,12 +37,12 @@
/* GPIO signal list. Must match order from enum gpio_signal. */
const struct gpio_info gpio_list[] = {
/* Inputs with interrupt handlers are first for efficiency */
{"KB_PWR_ON_L", GPIO_B, (1<<5), GPIO_INT_BOTH, gaia_power_event},
{"PP1800_LDO2", GPIO_A, (1<<1), GPIO_INT_BOTH, gaia_power_event},
{"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_RISING, gaia_power_event},
{"KB_PWR_ON_L", GPIO_B, (1<<5), GPIO_INT_BOTH, power_interrupt},
{"PP1800_LDO2", GPIO_A, (1<<1), GPIO_INT_BOTH, power_interrupt},
{"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_RISING, power_interrupt},
{"CHARGER_INT_L", GPIO_C, (1<<4), GPIO_INT_FALLING, NULL},
{"LID_OPEN", GPIO_C, (1<<13), GPIO_INT_BOTH, lid_interrupt},
{"SUSPEND_L", GPIO_A, (1<<7), GPIO_INT_BOTH, gaia_suspend_event},
{"SUSPEND_L", GPIO_A, (1<<7), GPIO_INT_BOTH, power_interrupt},
{"KB_IN00", GPIO_C, (1<<8), GPIO_KB_INPUT,
keyboard_raw_gpio_interrupt},
{"KB_IN01", GPIO_C, (1<<9), GPIO_KB_INPUT,

View File

@@ -9,7 +9,6 @@
#include "board.h"
#include "charger_bq24738.h"
#include "chip_temp_sensor.h"
#include "chipset_haswell.h"
#include "chipset_x86_common.h"
#include "common.h"
#include "ec_commands.h"

View File

@@ -8,7 +8,6 @@
#include "common.h"
#include "chipset.h"
#include "extpower.h"
#include "gaia_power.h"
#include "gpio.h"
#include "hooks.h"
#include "i2c.h"
@@ -28,8 +27,8 @@
/* GPIO signal list. Must match order from enum gpio_signal. */
const struct gpio_info gpio_list[] = {
/* Inputs with interrupt handlers are first for efficiency */
{"KB_PWR_ON_L", GPIO_A, (1<<0), GPIO_INT_BOTH, gaia_power_event},
{"XPSHOLD", GPIO_E, (1<<5), GPIO_INT_RISING, gaia_power_event},
{"KB_PWR_ON_L", GPIO_A, (1<<0), GPIO_INT_BOTH, power_interrupt},
{"XPSHOLD", GPIO_E, (1<<5), GPIO_INT_RISING, power_interrupt},
{"CHARGER_INT_L", GPIO_E, (1<<2), GPIO_INT_FALLING,
NULL /*pmu_irq_handler*/},
{"USB_CHG_INT", GPIO_E, (1<<15), GPIO_INT_FALLING,
@@ -37,7 +36,7 @@ const struct gpio_info gpio_list[] = {
{"USBPD_INT_L", GPIO_E, (1<<1), GPIO_INT_FALLING,
NULL /*extpower_interrupt*/},
{"LID_OPEN", GPIO_E, (1<<6), GPIO_INT_BOTH, lid_interrupt},
{"SUSPEND_L", GPIO_E, (1<<3), GPIO_INT_BOTH, gaia_suspend_event},
{"SUSPEND_L", GPIO_E, (1<<3), GPIO_INT_BOTH, power_interrupt},
{"SPI1_NSS", GPIO_A, (1<<4), GPIO_INT_BOTH | GPIO_PULL_UP,
spi_event},
{"AC_PRESENT_L", GPIO_A, (1<<1), GPIO_INT_BOTH, extpower_interrupt},

View File

@@ -7,7 +7,7 @@
#include "adc.h"
#include "backlight.h"
#include "chip_temp_sensor.h"
#include "chipset_ivybridge.h"
#include "chipset.h"
#include "chipset_x86_common.h"
#include "common.h"
#include "ec_commands.h"
@@ -59,7 +59,7 @@ const struct gpio_info gpio_list[] = {
{"PCH_SLP_SUS_L", LM4_GPIO_G, (1<<3), GPIO_INT_BOTH,
x86_interrupt},
{"PCH_SUSWARN_L", LM4_GPIO_G, (1<<2), GPIO_INT_BOTH,
ivybridge_interrupt},
power_interrupt},
{"PGOOD_1_5V_DDR", LM4_GPIO_K, (1<<0), GPIO_INT_BOTH,
x86_interrupt},
{"PGOOD_1_5V_PCH", LM4_GPIO_K, (1<<1), GPIO_INT_BOTH,

View File

@@ -5,9 +5,9 @@
/* Nyan board-specific configuration */
#include "battery.h"
#include "chipset.h"
#include "common.h"
#include "extpower.h"
#include "tegra_power.h"
#include "gpio.h"
#include "i2c.h"
#include "keyboard_raw.h"
@@ -27,11 +27,11 @@
/* GPIO signal list. Must match order from enum gpio_signal. */
const struct gpio_info gpio_list[] = {
/* Inputs with interrupt handlers are first for efficiency */
{"KB_PWR_ON_L", GPIO_B, (1<<5), GPIO_INT_BOTH, tegra_power_event},
{"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_BOTH, tegra_power_event},
{"KB_PWR_ON_L", GPIO_B, (1<<5), GPIO_INT_BOTH, power_interrupt},
{"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_BOTH, power_interrupt},
{"CHARGER_INT", GPIO_C, (1<<6), GPIO_INT_RISING, NULL},
{"LID_OPEN", GPIO_C, (1<<13), GPIO_INT_BOTH, lid_interrupt},
{"SUSPEND_L", GPIO_C, (1<<7), GPIO_KB_INPUT, tegra_suspend_event},
{"SUSPEND_L", GPIO_C, (1<<7), GPIO_KB_INPUT, power_interrupt},
{"SPI1_NSS", GPIO_A, (1<<4), GPIO_INT_BOTH | GPIO_PULL_UP,
spi_event},
{"AC_PRESENT", GPIO_A, (1<<0), GPIO_INT_BOTH, extpower_interrupt},

View File

@@ -7,7 +7,7 @@
#include "adc.h"
#include "backlight.h"
#include "chip_temp_sensor.h"
#include "chipset_haswell.h"
#include "chipset.h"
#include "chipset_x86_common.h"
#include "common.h"
#include "ec_commands.h"
@@ -58,7 +58,7 @@ const struct gpio_info gpio_list[] = {
{"VCORE_PGOOD", LM4_GPIO_C, (1<<6), GPIO_INT_BOTH,
x86_interrupt},
{"PCH_EDP_VDD_EN", LM4_GPIO_J, (1<<1), GPIO_INT_BOTH,
haswell_interrupt},
power_interrupt},
{"RECOVERY_L", LM4_GPIO_A, (1<<5), GPIO_PULL_UP|GPIO_INT_BOTH,
switch_interrupt},
{"WP_L", LM4_GPIO_A, (1<<4), GPIO_INT_BOTH,

View File

@@ -5,9 +5,9 @@
/* Pit board-specific configuration */
#include "battery.h"
#include "chipset.h"
#include "common.h"
#include "extpower.h"
#include "gaia_power.h"
#include "gpio.h"
#include "i2c.h"
#include "keyboard_scan.h"
@@ -28,12 +28,12 @@
/* GPIO signal list. Must match order from enum gpio_signal. */
const struct gpio_info gpio_list[] = {
/* Inputs with interrupt handlers are first for efficiency */
{"KB_PWR_ON_L", GPIO_B, (1<<5), GPIO_INT_BOTH, gaia_power_event},
{"PP1800_LDO2", GPIO_A, (1<<1), GPIO_INT_BOTH, gaia_power_event},
{"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_RISING, gaia_power_event},
{"KB_PWR_ON_L", GPIO_B, (1<<5), GPIO_INT_BOTH, power_interrupt},
{"PP1800_LDO2", GPIO_A, (1<<1), GPIO_INT_BOTH, power_interrupt},
{"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_RISING, power_interrupt},
{"CHARGER_INT_L", GPIO_C, (1<<6), GPIO_INT_FALLING, pmu_irq_handler},
{"LID_OPEN", GPIO_C, (1<<13), GPIO_INT_BOTH, lid_interrupt},
{"SUSPEND_L", GPIO_C, (1<<7), GPIO_INT_BOTH, gaia_suspend_event},
{"SUSPEND_L", GPIO_C, (1<<7), GPIO_INT_BOTH, power_interrupt},
{"SPI1_NSS", GPIO_A, (1<<4), GPIO_INT_BOTH | GPIO_PULL_UP,
spi_event},
{"AC_PRESENT", GPIO_A, (1<<0), GPIO_INT_BOTH, extpower_interrupt},

View File

@@ -5,9 +5,9 @@
/* Puppy board-specific configuration */
#include "battery.h"
#include "chipset.h"
#include "common.h"
#include "extpower.h"
#include "gaia_power.h"
#include "gpio.h"
#include "i2c.h"
#include "keyboard_raw.h"
@@ -26,12 +26,12 @@
/* GPIO signal list. Must match order from enum gpio_signal. */
const struct gpio_info gpio_list[] = {
/* Inputs with interrupt handlers are first for efficiency */
{"KB_PWR_ON_L", GPIO_B, (1<<5), GPIO_INT_BOTH, gaia_power_event},
{"PP1800_LDO2", GPIO_A, (1<<1), GPIO_INT_BOTH, gaia_power_event},
{"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_BOTH, gaia_power_event},
{"KB_PWR_ON_L", GPIO_B, (1<<5), GPIO_INT_BOTH, power_interrupt},
{"PP1800_LDO2", GPIO_A, (1<<1), GPIO_INT_BOTH, power_interrupt},
{"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_BOTH, power_interrupt},
{"CHARGER_INT_L", GPIO_C, (1<<6), GPIO_INT_FALLING, pmu_irq_handler},
{"LID_OPEN", GPIO_C, (1<<13), GPIO_INT_BOTH, lid_interrupt},
{"SUSPEND_L", GPIO_C, (1<<7), GPIO_KB_INPUT, gaia_suspend_event},
{"SUSPEND_L", GPIO_C, (1<<7), GPIO_KB_INPUT, power_interrupt},
{"SPI1_NSS", GPIO_A, (1<<4), GPIO_INT_BOTH | GPIO_PULL_UP,
spi_event},
{"AC_PRESENT", GPIO_A, (1<<0), GPIO_INT_BOTH, extpower_interrupt},

View File

@@ -7,7 +7,6 @@
#include "adc.h"
#include "backlight.h"
#include "chip_temp_sensor.h"
#include "chipset_haswell.h"
#include "chipset_x86_common.h"
#include "common.h"
#include "ec_commands.h"

View File

@@ -8,7 +8,6 @@
#include "board.h"
#include "backlight.h"
#include "chip_temp_sensor.h"
#include "chipset_haswell.h"
#include "chipset_x86_common.h"
#include "common.h"
#include "ec_commands.h"

View File

@@ -7,7 +7,7 @@
#include "adc.h"
#include "backlight.h"
#include "chip_temp_sensor.h"
#include "chipset_haswell.h"
#include "chipset.h"
#include "chipset_x86_common.h"
#include "common.h"
#include "ec_commands.h"
@@ -58,7 +58,7 @@ const struct gpio_info gpio_list[] = {
{"VCORE_PGOOD", LM4_GPIO_C, (1<<6), GPIO_INT_BOTH,
x86_interrupt},
{"PCH_EDP_VDD_EN", LM4_GPIO_J, (1<<1), GPIO_INT_BOTH,
haswell_interrupt},
power_interrupt},
{"RECOVERY_L", LM4_GPIO_A, (1<<5), GPIO_PULL_UP|GPIO_INT_BOTH,
switch_interrupt},
{"WP_L", LM4_GPIO_A, (1<<4), GPIO_INT_BOTH,

View File

@@ -9,7 +9,6 @@
#include "chipset.h"
#include "common.h"
#include "console.h"
#include "gaia_power.h"
#include "gpio.h"
#include "hooks.h"
#include "i2c.h"
@@ -34,12 +33,12 @@
/* GPIO signal list. Must match order from enum gpio_signal. */
const struct gpio_info gpio_list[] = {
/* Inputs with interrupt handlers are first for efficiency */
{"KB_PWR_ON_L", GPIO_B, (1<<5), GPIO_INT_BOTH, gaia_power_event},
{"PP1800_LDO2", GPIO_A, (1<<1), GPIO_INT_BOTH, gaia_power_event},
{"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_BOTH, gaia_power_event},
{"KB_PWR_ON_L", GPIO_B, (1<<5), GPIO_INT_BOTH, power_interrupt},
{"PP1800_LDO2", GPIO_A, (1<<1), GPIO_INT_BOTH, power_interrupt},
{"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_BOTH, power_interrupt},
{"CHARGER_INT_L", GPIO_C, (1<<4), GPIO_INT_FALLING, pmu_irq_handler},
{"LID_OPEN", GPIO_C, (1<<13), GPIO_INT_BOTH, lid_interrupt},
{"SUSPEND_L", GPIO_A, (1<<7), INT_BOTH_FLOATING, gaia_suspend_event},
{"SUSPEND_L", GPIO_A, (1<<7), INT_BOTH_FLOATING, power_interrupt},
{"WP_L", GPIO_B, (1<<4), GPIO_INPUT, NULL},
{"KB_IN00", GPIO_C, (1<<8), GPIO_KB_INPUT,
keyboard_raw_gpio_interrupt},

View File

@@ -10,7 +10,6 @@
#include "common.h"
#include "console.h"
#include "extpower.h"
#include "gaia_power.h"
#include "gpio.h"
#include "hooks.h"
#include "host_command.h"
@@ -34,12 +33,12 @@
/* GPIO signal list. Must match order from enum gpio_signal. */
const struct gpio_info gpio_list[] = {
/* Inputs with interrupt handlers are first for efficiency */
{"KB_PWR_ON_L", GPIO_B, (1<<5), GPIO_INT_BOTH, gaia_power_event},
{"PP1800_LDO2", GPIO_A, (1<<1), GPIO_INT_BOTH, gaia_power_event},
{"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_BOTH, gaia_power_event},
{"KB_PWR_ON_L", GPIO_B, (1<<5), GPIO_INT_BOTH, power_interrupt},
{"PP1800_LDO2", GPIO_A, (1<<1), GPIO_INT_BOTH, power_interrupt},
{"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_BOTH, power_interrupt},
{"CHARGER_INT_L", GPIO_C, (1<<4), GPIO_INT_FALLING, pmu_irq_handler},
{"LID_OPEN", GPIO_C, (1<<13), GPIO_INT_BOTH, lid_interrupt},
{"SUSPEND_L", GPIO_A, (1<<7), INT_BOTH_FLOATING, gaia_suspend_event},
{"SUSPEND_L", GPIO_A, (1<<7), INT_BOTH_FLOATING, power_interrupt},
{"WP_L", GPIO_A, (1<<13), GPIO_INPUT, NULL},
{"KB_IN00", GPIO_C, (1<<8), GPIO_KB_INPUT,
keyboard_raw_gpio_interrupt},

View File

@@ -27,7 +27,6 @@
#include "chipset.h" /* This module implements chipset functions too */
#include "common.h"
#include "console.h"
#include "gaia_power.h"
#include "gpio.h"
#include "hooks.h"
#include "lid_switch.h"
@@ -289,15 +288,15 @@ static void gaia_suspend_deferred(void)
}
DECLARE_DEFERRED(gaia_suspend_deferred);
void gaia_suspend_event(enum gpio_signal signal)
void power_interrupt(enum gpio_signal signal)
{
hook_call_deferred(gaia_suspend_deferred, 0);
}
void gaia_power_event(enum gpio_signal signal)
{
/* Wake up the task */
task_wake(TASK_ID_CHIPSET);
if (signal == GPIO_SUSPEND_L) {
/* Handle suspend events in the hook task */
hook_call_deferred(gaia_suspend_deferred, 0);
} else {
/* All other events are handled in the chipset task */
task_wake(TASK_ID_CHIPSET);
}
}
static void gaia_lid_event(void)

View File

@@ -367,7 +367,7 @@ enum x86_state x86_handle_state(enum x86_state state)
return state;
}
void haswell_interrupt(enum gpio_signal signal)
void power_interrupt(enum gpio_signal signal)
{
/* Pass through eDP VDD enable from PCH */
gpio_set_level(GPIO_EC_EDP_VDD_EN, gpio_get_level(GPIO_PCH_EDP_VDD_EN));

View File

@@ -337,7 +337,7 @@ enum x86_state x86_handle_state(enum x86_state state)
return state;
}
void ivybridge_interrupt(enum gpio_signal signal)
void power_interrupt(enum gpio_signal signal)
{
/* Route SUSWARN# back to SUSACK# */
gpio_set_level(GPIO_PCH_SUSACK_L, gpio_get_level(GPIO_PCH_SUSWARN_L));

View File

@@ -27,7 +27,6 @@
#include "chipset.h" /* This module implements chipset functions too */
#include "common.h"
#include "console.h"
#include "tegra_power.h"
#include "gpio.h"
#include "hooks.h"
#include "lid_switch.h"
@@ -248,15 +247,15 @@ static void tegra_suspend_deferred(void)
}
DECLARE_DEFERRED(tegra_suspend_deferred);
void tegra_suspend_event(enum gpio_signal signal)
void power_interrupt(enum gpio_signal signal)
{
hook_call_deferred(tegra_suspend_deferred, 0);
}
void tegra_power_event(enum gpio_signal signal)
{
/* Wake up the task */
task_wake(TASK_ID_CHIPSET);
if (signal == GPIO_SUSPEND_L) {
/* Handle suspend events in the hook task */
hook_call_deferred(tegra_suspend_deferred, 0);
} else {
/* All other events are handled in the chipset task */
task_wake(TASK_ID_CHIPSET);
}
}
static void tegra_lid_event(void)

View File

@@ -75,6 +75,11 @@ void chipset_force_shutdown(void);
*/
void chipset_reset(int cold_reset);
/**
* Interrupt handler for power GPIO inputs.
*/
void power_interrupt(enum gpio_signal signal);
#else /* !HAS_TASK_CHIPSET */
/*
* Allow other modules to compile if the chipset module is disabled. This is
@@ -91,6 +96,8 @@ static inline void chipset_throttle_cpu(int throttle) { }
static inline void chipset_force_shutdown(void) { }
static inline void chipset_reset(int cold_reset) { }
#define power_interrupt NULL
#endif /* !HAS_TASK_CHIPSET */
#endif /* __CROS_EC_CHIPSET_H */

View File

@@ -1,20 +0,0 @@
/* 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.
*/
/* Haswell chipset interface */
#ifndef __CROS_EC_CHIPSET_HASWELL_H
#define __CROS_EC_CHIPSET_HASWELL_H
/**
* Interrupt handler for Haswell-specific GPIOs.
*/
#ifdef CONFIG_CHIPSET_HASWELL
void haswell_interrupt(enum gpio_signal signal);
#else
#define haswell_interrupt NULL
#endif
#endif

View File

@@ -1,20 +0,0 @@
/* 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.
*/
/* Ivy bridge chipset interface */
#ifndef __CROS_EC_CHIPSET_IVYBRIDGE_H
#define __CROS_EC_CHIPSET_IVYBRIDGE_H
/**
* Interrupt handler for Ivy Bridge-specific GPIOs.
*/
#ifdef CONFIG_CHIPSET_IVYBRIDGE
void ivybridge_interrupt(enum gpio_signal signal);
#else
#define ivybridge_interrupt NULL
#endif
#endif

View File

@@ -1,28 +0,0 @@
/* 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.
*/
/* Gaia power module for Chrome EC */
#ifndef __CROS_EC_GAIA_POWER_H
#define __CROS_EC_GAIA_POWER_H
#include "gpio.h"
#ifdef CONFIG_CHIPSET_GAIA
/**
* Interrupt handlers for Gaia chipset GPIOs.
*/
void gaia_power_event(enum gpio_signal signal);
void gaia_suspend_event(enum gpio_signal signal);
#else
#define gaia_power_event NULL
#define gaia_suspend_event NULL
#endif
#endif /* __CROS_EC_GAIA_POWER_H */

View File

@@ -1,28 +0,0 @@
/* 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.
*/
/* Tegra power module for Chrome EC */
#ifndef __CROS_EC_TEGRA_POWER_H
#define __CROS_EC_TEGRA_POWER_H
#include "gpio.h"
#ifdef CONFIG_CHIPSET_TEGRA
/**
* Interrupt handlers for Tegra chipset GPIOs.
*/
void tegra_power_event(enum gpio_signal signal);
void tegra_suspend_event(enum gpio_signal signal);
#else
#define tegra_power_event NULL
#define tegra_suspend_event NULL
#endif
#endif /* __CROS_EC_TEGRA_POWER_H */