diff options
-rw-r--r-- | board/falco/board.c | 24 | ||||
-rw-r--r-- | board/falco/board.h | 6 | ||||
-rw-r--r-- | board/link/board.c | 36 | ||||
-rw-r--r-- | board/link/board.h | 2 | ||||
-rw-r--r-- | board/nyan/board.c | 7 | ||||
-rw-r--r-- | board/peppy/board.c | 24 | ||||
-rw-r--r-- | board/peppy/board.h | 6 | ||||
-rw-r--r-- | board/pit/board.c | 13 | ||||
-rw-r--r-- | board/rambi/board.c | 22 | ||||
-rw-r--r-- | board/rambi/board.h | 6 | ||||
-rw-r--r-- | board/samus/board.c | 26 | ||||
-rw-r--r-- | board/samus/board.h | 2 | ||||
-rw-r--r-- | board/samus/power_sequence.c | 98 | ||||
-rw-r--r-- | board/snow/board.c | 13 | ||||
-rw-r--r-- | board/spring/board.c | 13 | ||||
-rw-r--r-- | board/squawks/board.c | 22 | ||||
-rw-r--r-- | board/squawks/board.h | 6 | ||||
-rw-r--r-- | include/chipset.h | 2 | ||||
-rw-r--r-- | include/power.h | 73 | ||||
-rw-r--r-- | power/baytrail.c | 96 | ||||
-rw-r--r-- | power/common.c | 142 | ||||
-rw-r--r-- | power/gaia.c | 2 | ||||
-rw-r--r-- | power/haswell.c | 108 | ||||
-rw-r--r-- | power/ivybridge.c | 108 | ||||
-rw-r--r-- | power/tegra.c | 2 | ||||
-rw-r--r-- | test/adapter.c | 2 |
26 files changed, 440 insertions, 421 deletions
diff --git a/board/falco/board.c b/board/falco/board.c index b343261ebc..54143cc6ce 100644 --- a/board/falco/board.c +++ b/board/falco/board.c @@ -8,7 +8,6 @@ #include "adc_chip.h" #include "backlight.h" #include "board.h" -#include "power.h" #include "common.h" #include "driver/charger/bq24738.h" #include "driver/temp_sensor/g781.h" @@ -21,6 +20,7 @@ #include "keyboard_scan.h" #include "lid_switch.h" #include "peci.h" +#include "power.h" #include "power_button.h" #include "registers.h" #include "switch.h" @@ -43,21 +43,21 @@ const struct gpio_info gpio_list[] = { {"PCH_BKLTEN", LM4_GPIO_M, (1<<3), GPIO_INT_BOTH, backlight_interrupt}, {"PCH_SLP_S0_L", LM4_GPIO_G, (1<<6), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PCH_SLP_S3_L", LM4_GPIO_G, (1<<7), GPIO_INT_BOTH_DSLEEP, - x86_interrupt}, + power_signal_interrupt}, {"PCH_SLP_S5_L", LM4_GPIO_H, (1<<1), GPIO_INT_BOTH_DSLEEP, - x86_interrupt}, + power_signal_interrupt}, {"PCH_SLP_SUS_L", LM4_GPIO_G, (1<<3), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PP1050_PGOOD", LM4_GPIO_H, (1<<4), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PP1350_PGOOD", LM4_GPIO_H, (1<<6), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PP5000_PGOOD", LM4_GPIO_N, (1<<0), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"VCORE_PGOOD", LM4_GPIO_C, (1<<6), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PCH_EDP_VDD_EN", LM4_GPIO_J, (1<<1), GPIO_INT_BOTH, lcdvcc_interrupt}, {"RECOVERY_L", LM4_GPIO_A, (1<<5), GPIO_PULL_UP|GPIO_INT_BOTH, @@ -151,8 +151,8 @@ const struct gpio_alt_func gpio_alt_funcs[] = { }; const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); -/* x86 signal list. Must match order of enum x86_signal. */ -const struct x86_signal_info x86_signal_list[] = { +/* power signal list. Must match order of enum power_signal. */ +const struct power_signal_info power_signal_list[] = { {GPIO_PP5000_PGOOD, 1, "PGOOD_PP5000"}, {GPIO_PP1350_PGOOD, 1, "PGOOD_PP1350"}, {GPIO_PP1050_PGOOD, 1, "PGOOD_PP1050"}, @@ -162,7 +162,7 @@ const struct x86_signal_info x86_signal_list[] = { {GPIO_PCH_SLP_S5_L, 1, "SLP_S5#_DEASSERTED"}, {GPIO_PCH_SLP_SUS_L, 1, "SLP_SUS#_DEASSERTED"}, }; -BUILD_ASSERT(ARRAY_SIZE(x86_signal_list) == X86_SIGNAL_COUNT); +BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT); /* ADC channels. Must be in the exactly same order as in enum adc_channel. */ const struct adc_t adc_channels[] = { diff --git a/board/falco/board.h b/board/falco/board.h index bf25f8263b..347da3b0e2 100644 --- a/board/falco/board.h +++ b/board/falco/board.h @@ -133,8 +133,8 @@ enum gpio_signal { GPIO_COUNT }; -/* x86 signal definitions */ -enum x86_signal { +/* power signal definitions */ +enum power_signal { X86_PGOOD_PP5000 = 0, X86_PGOOD_PP1350, X86_PGOOD_PP1050, @@ -145,7 +145,7 @@ enum x86_signal { X86_SLP_SUS_DEASSERTED, /* Number of X86 signals */ - X86_SIGNAL_COUNT + POWER_SIGNAL_COUNT }; /* Charger module */ diff --git a/board/link/board.c b/board/link/board.c index 95694b25ea..9faadcbfce 100644 --- a/board/link/board.c +++ b/board/link/board.c @@ -8,7 +8,6 @@ #include "adc_chip.h" #include "backlight.h" #include "chipset.h" -#include "power.h" #include "common.h" #include "driver/temp_sensor/tmp006.h" #include "extpower.h" @@ -18,6 +17,7 @@ #include "keyboard_scan.h" #include "lid_switch.h" #include "peci.h" +#include "power.h" #include "power_button.h" #include "pwm.h" #include "pwm_chip.h" @@ -47,35 +47,35 @@ const struct gpio_info gpio_list[] = { {"PCH_BKLTEN", LM4_GPIO_J, (1<<3), GPIO_INT_BOTH, backlight_interrupt}, {"PCH_SLP_A_L", LM4_GPIO_G, (1<<5), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PCH_SLP_ME_CSW_DEV_L", LM4_GPIO_G, (1<<4), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PCH_SLP_S3_L", LM4_GPIO_J, (1<<0), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PCH_SLP_S4_L", LM4_GPIO_J, (1<<1), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PCH_SLP_S5_L", LM4_GPIO_J, (1<<2), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PCH_SLP_SUS_L", LM4_GPIO_G, (1<<3), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PCH_SUSWARN_L", LM4_GPIO_G, (1<<2), GPIO_INT_BOTH, power_interrupt}, {"PGOOD_1_5V_DDR", LM4_GPIO_K, (1<<0), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PGOOD_1_5V_PCH", LM4_GPIO_K, (1<<1), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PGOOD_1_8VS", LM4_GPIO_K, (1<<3), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PGOOD_5VALW", LM4_GPIO_H, (1<<0), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PGOOD_CPU_CORE", LM4_GPIO_M, (1<<3), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PGOOD_VCCP", LM4_GPIO_K, (1<<2), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PGOOD_VCCSA", LM4_GPIO_H, (1<<1), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PGOOD_VGFX_CORE", LM4_GPIO_D, (1<<2), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"RECOVERY_L", LM4_GPIO_H, (1<<7), GPIO_INT_BOTH, switch_interrupt}, {"USB1_STATUS_L", LM4_GPIO_E, (1<<7), GPIO_INPUT, NULL}, @@ -146,8 +146,8 @@ const struct gpio_alt_func gpio_alt_funcs[] = { }; const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); -/* x86 signal list. Must match order of enum x86_signal. */ -const struct x86_signal_info x86_signal_list[] = { +/* power signal list. Must match order of enum power_signal. */ +const struct power_signal_info power_signal_list[] = { {GPIO_PGOOD_5VALW, 1, "PGOOD_5VALW"}, {GPIO_PGOOD_1_5V_DDR, 1, "PGOOD_1_5V_DDR"}, {GPIO_PGOOD_1_5V_PCH, 1, "PGOOD_1_5V_PCH"}, @@ -163,7 +163,7 @@ const struct x86_signal_info x86_signal_list[] = { {GPIO_PCH_SLP_SUS_L, 1, "SLP_SUS#_DEASSERTED"}, {GPIO_PCH_SLP_ME_CSW_DEV_L, 1, "SLP_ME#_DEASSERTED"}, }; -BUILD_ASSERT(ARRAY_SIZE(x86_signal_list) == X86_SIGNAL_COUNT); +BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT); /* ADC channels. Must be in the exactly same order as in enum adc_channel. */ const struct adc_t adc_channels[] = { diff --git a/board/link/board.h b/board/link/board.h index 64aee14198..743f77a72c 100644 --- a/board/link/board.h +++ b/board/link/board.h @@ -174,7 +174,7 @@ enum x86_signal { X86_SLP_ME_DEASSERTED, /* Number of X86 signals */ - X86_SIGNAL_COUNT + POWER_SIGNAL_COUNT }; enum temp_sensor_id { diff --git a/board/nyan/board.c b/board/nyan/board.c index 060b9a40e1..0daa122fe9 100644 --- a/board/nyan/board.c +++ b/board/nyan/board.c @@ -14,6 +14,7 @@ #include "lid_switch.h" #include "pmu_tpschrome.h" #include "power_button.h" +#include "power.h" #include "pwm.h" #include "pwm_chip.h" #include "registers.h" @@ -30,9 +31,11 @@ const struct gpio_info gpio_list[] = { /* Inputs with interrupt handlers are first for efficiency */ {"POWER_BUTTON_L", GPIO_B, (1<<5), GPIO_INT_BOTH, power_button_interrupt}, - {"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_BOTH, power_interrupt}, + {"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_BOTH, + power_signal_interrupt}, {"LID_OPEN", GPIO_C, (1<<13), GPIO_INT_BOTH, lid_interrupt}, - {"SUSPEND_L", GPIO_C, (1<<7), GPIO_KB_INPUT, power_interrupt}, + {"SUSPEND_L", GPIO_C, (1<<7), GPIO_KB_INPUT, + power_signal_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}, diff --git a/board/peppy/board.c b/board/peppy/board.c index 5c85ead4d4..72e98278bd 100644 --- a/board/peppy/board.c +++ b/board/peppy/board.c @@ -8,7 +8,6 @@ #include "adc_chip.h" #include "backlight.h" #include "chipset.h" -#include "power.h" #include "common.h" #include "driver/temp_sensor/g781.h" #include "extpower.h" @@ -20,6 +19,7 @@ #include "keyboard_scan.h" #include "lid_switch.h" #include "peci.h" +#include "power.h" #include "power_button.h" #include "registers.h" #include "switch.h" @@ -42,21 +42,21 @@ const struct gpio_info gpio_list[] = { {"PCH_BKLTEN", LM4_GPIO_M, (1<<3), GPIO_INT_BOTH, backlight_interrupt}, {"PCH_SLP_S0_L", LM4_GPIO_G, (1<<6), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PCH_SLP_S3_L", LM4_GPIO_G, (1<<7), GPIO_INT_BOTH_DSLEEP, - x86_interrupt}, + power_signal_interrupt}, {"PCH_SLP_S5_L", LM4_GPIO_H, (1<<1), GPIO_INT_BOTH_DSLEEP, - x86_interrupt}, + power_signal_interrupt}, {"PCH_SLP_SUS_L", LM4_GPIO_G, (1<<3), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PP1050_PGOOD", LM4_GPIO_H, (1<<4), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PP1350_PGOOD", LM4_GPIO_H, (1<<6), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PP5000_PGOOD", LM4_GPIO_N, (1<<0), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"VCORE_PGOOD", LM4_GPIO_C, (1<<6), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PCH_EDP_VDD_EN", LM4_GPIO_J, (1<<1), GPIO_INT_BOTH, power_interrupt}, {"RECOVERY_L", LM4_GPIO_A, (1<<5), GPIO_PULL_UP|GPIO_INT_BOTH, @@ -149,8 +149,8 @@ const struct gpio_alt_func gpio_alt_funcs[] = { }; const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); -/* x86 signal list. Must match order of enum x86_signal. */ -const struct x86_signal_info x86_signal_list[] = { +/* power signal list. Must match order of enum power_signal. */ +const struct power_signal_info power_signal_list[] = { {GPIO_PP5000_PGOOD, 1, "PGOOD_PP5000"}, {GPIO_PP1350_PGOOD, 1, "PGOOD_PP1350"}, {GPIO_PP1050_PGOOD, 1, "PGOOD_PP1050"}, @@ -160,7 +160,7 @@ const struct x86_signal_info x86_signal_list[] = { {GPIO_PCH_SLP_S5_L, 1, "SLP_S5#_DEASSERTED"}, {GPIO_PCH_SLP_SUS_L, 1, "SLP_SUS#_DEASSERTED"}, }; -BUILD_ASSERT(ARRAY_SIZE(x86_signal_list) == X86_SIGNAL_COUNT); +BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT); /* ADC channels. Must be in the exactly same order as in enum adc_channel. */ const struct adc_t adc_channels[] = { diff --git a/board/peppy/board.h b/board/peppy/board.h index c01d218313..c4ceaf93ee 100644 --- a/board/peppy/board.h +++ b/board/peppy/board.h @@ -135,8 +135,8 @@ enum gpio_signal { GPIO_COUNT }; -/* x86 signal definitions */ -enum x86_signal { +/* power signal definitions */ +enum power_signal { X86_PGOOD_PP5000 = 0, X86_PGOOD_PP1350, X86_PGOOD_PP1050, @@ -147,7 +147,7 @@ enum x86_signal { X86_SLP_SUS_DEASSERTED, /* Number of X86 signals */ - X86_SIGNAL_COUNT + POWER_SIGNAL_COUNT }; /* Charger module */ diff --git a/board/pit/board.c b/board/pit/board.c index 414986a94b..afd8112f94 100644 --- a/board/pit/board.c +++ b/board/pit/board.c @@ -14,6 +14,7 @@ #include "keyboard_raw.h" #include "lid_switch.h" #include "pmu_tpschrome.h" +#include "power.h" #include "pwm.h" #include "pwm_chip.h" #include "registers.h" @@ -28,12 +29,16 @@ /* 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, power_interrupt}, - {"PP1800_LDO2", GPIO_A, (1<<1), GPIO_INT_BOTH, power_interrupt}, - {"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_RISING, power_interrupt}, + {"KB_PWR_ON_L", GPIO_B, (1<<5), GPIO_INT_BOTH, + power_signal_interrupt}, + {"PP1800_LDO2", GPIO_A, (1<<1), GPIO_INT_BOTH, + power_signal_interrupt}, + {"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_RISING, + power_signal_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, power_interrupt}, + {"SUSPEND_L", GPIO_C, (1<<7), GPIO_INT_BOTH, + power_signal_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}, diff --git a/board/rambi/board.c b/board/rambi/board.c index bbd9f46120..2ad37debdf 100644 --- a/board/rambi/board.c +++ b/board/rambi/board.c @@ -7,7 +7,6 @@ #include "adc.h" #include "adc_chip.h" #include "backlight.h" -#include "power.h" #include "common.h" #include "driver/temp_sensor/tmp432.h" #include "extpower.h" @@ -18,6 +17,7 @@ #include "keyboard_scan.h" #include "lid_switch.h" #include "peci.h" +#include "power.h" #include "power_button.h" #include "pwm.h" #include "pwm_chip.h" @@ -41,20 +41,20 @@ const struct gpio_info gpio_list[] = { extpower_interrupt}, {"PCH_SLP_S3_L", LM4_GPIO_G, (1<<7), GPIO_INT_BOTH_DSLEEP | GPIO_PULL_UP, - x86_interrupt}, + power_signal_interrupt}, {"PCH_SLP_S4_L", LM4_GPIO_H, (1<<1), GPIO_INT_BOTH_DSLEEP | GPIO_PULL_UP, - x86_interrupt}, + power_signal_interrupt}, {"PP1050_PGOOD", LM4_GPIO_H, (1<<4), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PP3300_PCH_PGOOD", LM4_GPIO_C, (1<<4), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PP5000_PGOOD", LM4_GPIO_N, (1<<0), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"S5_PGOOD", LM4_GPIO_G, (1<<0), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"VCORE_PGOOD", LM4_GPIO_C, (1<<6), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"WP_L", LM4_GPIO_A, (1<<4), GPIO_INT_BOTH, switch_interrupt}, {"JTAG_TCK", LM4_GPIO_C, (1<<0), GPIO_DEFAULT, @@ -124,8 +124,8 @@ const struct gpio_alt_func gpio_alt_funcs[] = { }; const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); -/* x86 signal list. Must match order of enum x86_signal. */ -const struct x86_signal_info x86_signal_list[] = { +/* power signal list. Must match order of enum power_signal. */ +const struct power_signal_info power_signal_list[] = { {GPIO_PP1050_PGOOD, 1, "PGOOD_PP1050"}, {GPIO_PP3300_PCH_PGOOD, 1, "PGOOD_PP3300_PCH"}, {GPIO_PP5000_PGOOD, 1, "PGOOD_PP5000"}, @@ -138,7 +138,7 @@ const struct x86_signal_info x86_signal_list[] = { {GPIO_PCH_SUS_STAT_L, 0, "SUS_STAT#_ASSERTED"}, {GPIO_PCH_SUSPWRDNACK, 1, "SUSPWRDNACK_ASSERTED"}, }; -BUILD_ASSERT(ARRAY_SIZE(x86_signal_list) == X86_SIGNAL_COUNT); +BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT); /* ADC channels. Must be in the exactly same order as in enum adc_channel. */ const struct adc_t adc_channels[] = { diff --git a/board/rambi/board.h b/board/rambi/board.h index 71feaa2c6b..1cde39f89b 100644 --- a/board/rambi/board.h +++ b/board/rambi/board.h @@ -128,8 +128,8 @@ enum gpio_signal { GPIO_COUNT }; -/* x86 signal definitions */ -enum x86_signal { +/* power signal definitions */ +enum power_signal { X86_PGOOD_PP1050 = 0, X86_PGOOD_PP3300_PCH, X86_PGOOD_PP5000, @@ -143,7 +143,7 @@ enum x86_signal { X86_SUSPWRDNACK_ASSERTED, /* Number of X86 signals */ - X86_SIGNAL_COUNT + POWER_SIGNAL_COUNT }; enum adc_channel { diff --git a/board/samus/board.c b/board/samus/board.c index 96139a5b0c..3ae8e9d590 100644 --- a/board/samus/board.c +++ b/board/samus/board.c @@ -8,7 +8,6 @@ #include "adc.h" #include "adc_chip.h" #include "backlight.h" -#include "power.h" #include "common.h" #include "driver/temp_sensor/tmp006.h" #include "driver/als_isl29035.h" @@ -20,6 +19,7 @@ #include "keyboard_scan.h" #include "lid_switch.h" #include "peci.h" +#include "power.h" #include "power_button.h" #include "pwm.h" #include "pwm_chip.h" @@ -41,23 +41,23 @@ const struct gpio_info gpio_list[] = { {"AC_PRESENT", LM4_GPIO_H, (1<<3), GPIO_INT_BOTH, extpower_interrupt}, {"PCH_SLP_S0_L", LM4_GPIO_G, (1<<6), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PCH_SLP_S3_L", LM4_GPIO_G, (1<<7), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PCH_SLP_S5_L", LM4_GPIO_H, (1<<1), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PCH_SLP_SUS_L", LM4_GPIO_G, (1<<3), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PCH_SUSWARN_L", LM4_GPIO_G, (1<<2), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PP1050_PGOOD", LM4_GPIO_H, (1<<4), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PP1200_PGOOD", LM4_GPIO_H, (1<<6), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PP1800_PGOOD", LM4_GPIO_L, (1<<7), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"VCORE_PGOOD", LM4_GPIO_C, (1<<6), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_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, @@ -150,8 +150,8 @@ const struct gpio_alt_func gpio_alt_funcs[] = { }; const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); -/* x86 signal list. Must match order of enum x86_signal. */ -const struct x86_signal_info x86_signal_list[] = { +/* power signal list. Must match order of enum power_signal. */ +const struct power_signal_info power_signal_list[] = { {GPIO_PP1050_PGOOD, 1, "PGOOD_PP1050"}, {GPIO_PP1200_PGOOD, 1, "PGOOD_PP1200"}, {GPIO_PP1800_PGOOD, 1, "PGOOD_PP1800"}, @@ -162,7 +162,7 @@ const struct x86_signal_info x86_signal_list[] = { {GPIO_PCH_SLP_SUS_L, 1, "SLP_SUS_DEASSERTED"}, {GPIO_PCH_SUSWARN_L, 1, "SUSWARN_DEASSERTED"}, }; -BUILD_ASSERT(ARRAY_SIZE(x86_signal_list) == X86_SIGNAL_COUNT); +BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT); /* ADC channels. Must be in the exactly same order as in enum adc_channel. */ const struct adc_t adc_channels[] = { diff --git a/board/samus/board.h b/board/samus/board.h index e295282d7c..fac709c313 100644 --- a/board/samus/board.h +++ b/board/samus/board.h @@ -168,7 +168,7 @@ enum x86_signal { X86_SUSWARN_DEASSERTED, /* Number of X86 signals */ - X86_SIGNAL_COUNT + POWER_SIGNAL_COUNT }; enum adc_channel { diff --git a/board/samus/power_sequence.c b/board/samus/power_sequence.c index efd367ccb4..74efef873e 100644 --- a/board/samus/power_sequence.c +++ b/board/samus/power_sequence.c @@ -6,13 +6,13 @@ /* X86 chipset power control module for Chrome EC */ #include "chipset.h" -#include "power.h" #include "common.h" #include "console.h" #include "gpio.h" #include "hooks.h" #include "host_command.h" #include "lid_switch.h" +#include "power.h" #include "registers.h" #include "system.h" #include "task.h" @@ -25,15 +25,15 @@ #define CPRINTF(format, args...) cprintf(CC_CHIPSET, format, ## args) /* Input state flags */ -#define IN_PGOOD_PP1050 X86_SIGNAL_MASK(X86_PGOOD_PP1050) -#define IN_PGOOD_PP1200 X86_SIGNAL_MASK(X86_PGOOD_PP1200) -#define IN_PGOOD_PP1800 X86_SIGNAL_MASK(X86_PGOOD_PP1800) -#define IN_PGOOD_VCORE X86_SIGNAL_MASK(X86_PGOOD_VCORE) +#define IN_PGOOD_PP1050 POWER_SIGNAL_MASK(X86_PGOOD_PP1050) +#define IN_PGOOD_PP1200 POWER_SIGNAL_MASK(X86_PGOOD_PP1200) +#define IN_PGOOD_PP1800 POWER_SIGNAL_MASK(X86_PGOOD_PP1800) +#define IN_PGOOD_VCORE POWER_SIGNAL_MASK(X86_PGOOD_VCORE) -#define IN_PCH_SLP_S0_DEASSERTED X86_SIGNAL_MASK(X86_SLP_S0_DEASSERTED) -#define IN_PCH_SLP_S3_DEASSERTED X86_SIGNAL_MASK(X86_SLP_S3_DEASSERTED) -#define IN_PCH_SLP_S5_DEASSERTED X86_SIGNAL_MASK(X86_SLP_S5_DEASSERTED) -#define IN_PCH_SLP_SUS_DEASSERTED X86_SIGNAL_MASK(X86_SLP_SUS_DEASSERTED) +#define IN_PCH_SLP_S0_DEASSERTED POWER_SIGNAL_MASK(X86_SLP_S0_DEASSERTED) +#define IN_PCH_SLP_S3_DEASSERTED POWER_SIGNAL_MASK(X86_SLP_S3_DEASSERTED) +#define IN_PCH_SLP_S5_DEASSERTED POWER_SIGNAL_MASK(X86_SLP_S5_DEASSERTED) +#define IN_PCH_SLP_SUS_DEASSERTED POWER_SIGNAL_MASK(X86_SLP_SUS_DEASSERTED) /* All non-core power rails */ @@ -66,7 +66,7 @@ void chipset_force_shutdown(void) CPRINTF("[%T %s()]\n", __func__); /* - * Force x86 off. This condition will reset once the state machine + * Force off. This condition will reset once the state machine * transitions to G3. */ gpio_set_level(GPIO_PCH_DPWROK, 0); @@ -115,7 +115,7 @@ void chipset_throttle_cpu(int throttle) gpio_set_level(GPIO_CPU_PROCHOT, throttle); } -enum x86_state x86_chipset_init(void) +enum power_state power_chipset_init(void) { /* * If we're switching between images without rebooting, see if the x86 @@ -123,12 +123,12 @@ enum x86_state x86_chipset_init(void) * through G3. */ if (system_jumped_to_this_image()) { - if ((x86_get_signals() & IN_ALL_S0) == IN_ALL_S0) { - CPRINTF("[%T x86 already in S0]\n"); - return X86_S0; + if ((power_get_signals() & IN_ALL_S0) == IN_ALL_S0) { + CPRINTF("[%T already in S0]\n"); + return POWER_S0; } else { /* Force all signals to their G3 states */ - CPRINTF("[%T x86 forcing G3]\n"); + CPRINTF("[%T forcing G3]\n"); gpio_set_level(GPIO_PCH_PWROK, 0); gpio_set_level(GPIO_SYS_PWROK, 0); gpio_set_level(GPIO_PP1050_EN, 0); @@ -143,22 +143,22 @@ enum x86_state x86_chipset_init(void) } } - return X86_G3; + return POWER_G3; } -enum x86_state x86_handle_state(enum x86_state state) +enum power_state power_handle_state(enum power_state state) { switch (state) { - case X86_G3: + case POWER_G3: break; - case X86_S5: + case POWER_S5: if (gpio_get_level(GPIO_PCH_SLP_S5_L) == 1) - return X86_S5S3; /* Power up to next state */ + return POWER_S5S3; /* Power up to next state */ break; - case X86_S3: + case POWER_S3: /* * If lid is closed; hold touchscreen in reset to cut * power usage. If lid is open, take touchscreen out @@ -167,31 +167,31 @@ enum x86_state x86_handle_state(enum x86_state state) gpio_set_level(GPIO_TOUCHSCREEN_RESET_L, lid_is_open()); /* Check for state transitions */ - if (!x86_has_signals(IN_PGOOD_S3)) { + if (!power_has_signals(IN_PGOOD_S3)) { /* Required rail went away */ chipset_force_shutdown(); - return X86_S3S5; + return POWER_S3S5; } else if (gpio_get_level(GPIO_PCH_SLP_S3_L) == 1) { /* Power up to next state */ - return X86_S3S0; + return POWER_S3S0; } else if (gpio_get_level(GPIO_PCH_SLP_S5_L) == 0) { /* Power down to next state */ - return X86_S3S5; + return POWER_S3S5; } break; - case X86_S0: - if (!x86_has_signals(IN_PGOOD_S0)) { + case POWER_S0: + if (!power_has_signals(IN_PGOOD_S0)) { /* Required rail went away */ chipset_force_shutdown(); - return X86_S0S3; + return POWER_S0S3; } else if (gpio_get_level(GPIO_PCH_SLP_S3_L) == 0) { /* Power down to next state */ - return X86_S0S3; + return POWER_S0S3; } break; - case X86_G3S5: + case POWER_G3S5: /* Enable 3.3V DSW */ gpio_set_level(GPIO_PP3300_DSW_EN, 1); @@ -207,11 +207,11 @@ enum x86_state x86_handle_state(enum x86_state state) /* Wait for PP1050/PP1200 PGOOD to go LOW to * indicate that PP5000 is stable */ - while ((x86_get_signals() & IN_PGOOD_PP5000) != 0) { + while ((power_get_signals() & IN_PGOOD_PP5000) != 0) { if (task_wait_event(SECOND) == TASK_EVENT_TIMER) { CPRINTF("[%T timeout waiting for PP5000\n"); chipset_force_shutdown(); - return X86_G3; + return POWER_G3; } } @@ -225,10 +225,10 @@ enum x86_state x86_handle_state(enum x86_state state) gpio_set_level(GPIO_PP1050_EN, 1); /* Wait for 1.05V to come up and CPU to notice */ - if (x86_wait_signals(IN_PGOOD_PP1050 | + if (power_wait_signals(IN_PGOOD_PP1050 | IN_PCH_SLP_SUS_DEASSERTED)) { chipset_force_shutdown(); - return X86_G3; + return POWER_G3; } /* Wait 5ms for SUSCLK to stabilize */ @@ -236,15 +236,15 @@ enum x86_state x86_handle_state(enum x86_state state) /* Call hook to indicate out of G3 state */ hook_notify(HOOK_CHIPSET_PRE_INIT); - return X86_S5; + return POWER_S5; - case X86_S5S3: + case POWER_S5S3: /* Turn on power to RAM */ gpio_set_level(GPIO_PP1800_EN, 1); gpio_set_level(GPIO_PP1200_EN, 1); - if (x86_wait_signals(IN_PGOOD_S3)) { + if (power_wait_signals(IN_PGOOD_S3)) { chipset_force_shutdown(); - return X86_S5; + return POWER_S5; } /* @@ -265,9 +265,9 @@ enum x86_state x86_handle_state(enum x86_state state) /* Call hooks now that rails are up */ hook_notify(HOOK_CHIPSET_STARTUP); - return X86_S3; + return POWER_S3; - case X86_S3S0: + case POWER_S3S0: /* Wait 20ms before allowing VCCST_PGOOD to rise. */ msleep(20); @@ -282,10 +282,10 @@ enum x86_state x86_handle_state(enum x86_state state) gpio_set_level(GPIO_TOUCHSCREEN_RESET_L, 1); /* Wait for non-core power rails good */ - if (x86_wait_signals(IN_PGOOD_S0)) { + if (power_wait_signals(IN_PGOOD_S0)) { chipset_force_shutdown(); wireless_enable(0); - return X86_S3; + return POWER_S3; } /* Call hooks now that rails are up */ @@ -303,9 +303,9 @@ enum x86_state x86_handle_state(enum x86_state state) /* Set PCH_PWROK */ gpio_set_level(GPIO_PCH_PWROK, 1); gpio_set_level(GPIO_SYS_PWROK, 1); - return X86_S0; + return POWER_S0; - case X86_S0S3: + case POWER_S0S3: /* Call hooks before we remove power rails */ hook_notify(HOOK_CHIPSET_SUSPEND); @@ -326,9 +326,9 @@ enum x86_state x86_handle_state(enum x86_state state) */ gpio_set_level(GPIO_CPU_PROCHOT, 0); - return X86_S3; + return POWER_S3; - case X86_S3S5: + case POWER_S3S5: /* Call hooks before we remove power rails */ hook_notify(HOOK_CHIPSET_SHUTDOWN); @@ -356,9 +356,9 @@ enum x86_state x86_handle_state(enum x86_state state) gpio_set_level(GPIO_TOUCHSCREEN_RESET_L, 0); gpio_set_level(GPIO_LIGHTBAR_RESET_L, 0); - return pause_in_s5 ? X86_S5 : X86_S5G3; + return pause_in_s5 ? POWER_S5 : POWER_S5G3; - case X86_S5G3: + case POWER_S5G3: /* Deassert DPWROK */ gpio_set_level(GPIO_PCH_DPWROK, 0); @@ -368,7 +368,7 @@ enum x86_state x86_handle_state(enum x86_state state) gpio_set_level(GPIO_PP5000_EN, 0); /* Disable 3.3V DSW */ gpio_set_level(GPIO_PP3300_DSW_EN, 0); - return X86_G3; + return POWER_G3; } return state; diff --git a/board/snow/board.c b/board/snow/board.c index 7f2b6a44a1..bf89ebc467 100644 --- a/board/snow/board.c +++ b/board/snow/board.c @@ -15,6 +15,7 @@ #include "keyboard_raw.h" #include "lid_switch.h" #include "pmu_tpschrome.h" +#include "power.h" #include "power_led.h" #include "pwm.h" #include "pwm_chip.h" @@ -33,12 +34,16 @@ /* 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, power_interrupt}, - {"PP1800_LDO2", GPIO_A, (1<<1), GPIO_INT_BOTH, power_interrupt}, - {"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_BOTH, power_interrupt}, + {"KB_PWR_ON_L", GPIO_B, (1<<5), GPIO_INT_BOTH, + power_signal_interrupt}, + {"PP1800_LDO2", GPIO_A, (1<<1), GPIO_INT_BOTH, + power_signal_interrupt}, + {"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_BOTH, + power_signal_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, power_interrupt}, + {"SUSPEND_L", GPIO_A, (1<<7), INT_BOTH_FLOATING, + power_signal_interrupt}, {"WP_L", GPIO_B, (1<<4), GPIO_INPUT, NULL}, {"KB_IN00", GPIO_C, (1<<8), GPIO_KB_INPUT, keyboard_raw_gpio_interrupt}, diff --git a/board/spring/board.c b/board/spring/board.c index faa0c179c0..965da81283 100644 --- a/board/spring/board.c +++ b/board/spring/board.c @@ -18,6 +18,7 @@ #include "keyboard_raw.h" #include "lid_switch.h" #include "pmu_tpschrome.h" +#include "power.h" #include "pwm.h" #include "pwm_chip.h" #include "registers.h" @@ -33,12 +34,16 @@ /* 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, power_interrupt}, - {"PP1800_LDO2", GPIO_A, (1<<1), GPIO_INT_BOTH, power_interrupt}, - {"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_BOTH, power_interrupt}, + {"KB_PWR_ON_L", GPIO_B, (1<<5), GPIO_INT_BOTH, + power_signal_interrupt}, + {"PP1800_LDO2", GPIO_A, (1<<1), GPIO_INT_BOTH, + power_signal_interrupt}, + {"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_BOTH, + power_signal_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, power_interrupt}, + {"SUSPEND_L", GPIO_A, (1<<7), INT_BOTH_FLOATING, + power_signal_interrupt}, {"WP_L", GPIO_A, (1<<13), GPIO_INPUT, NULL}, {"KB_IN00", GPIO_C, (1<<8), GPIO_KB_INPUT, keyboard_raw_gpio_interrupt}, diff --git a/board/squawks/board.c b/board/squawks/board.c index b15bd65f1b..825d551c78 100644 --- a/board/squawks/board.c +++ b/board/squawks/board.c @@ -7,7 +7,6 @@ #include "adc.h" #include "adc_chip.h" #include "backlight.h" -#include "power.h" #include "common.h" #include "driver/temp_sensor/tmp432.h" #include "extpower.h" @@ -18,6 +17,7 @@ #include "keyboard_scan.h" #include "lid_switch.h" #include "peci.h" +#include "power.h" #include "power_button.h" #include "pwm.h" #include "pwm_chip.h" @@ -41,20 +41,20 @@ const struct gpio_info gpio_list[] = { extpower_interrupt}, {"PCH_SLP_S3_L", LM4_GPIO_G, (1<<7), GPIO_INT_BOTH_DSLEEP | GPIO_PULL_UP, - x86_interrupt}, + power_signal_interrupt}, {"PCH_SLP_S4_L", LM4_GPIO_H, (1<<1), GPIO_INT_BOTH_DSLEEP | GPIO_PULL_UP, - x86_interrupt}, + power_signal_interrupt}, {"PP1050_PGOOD", LM4_GPIO_H, (1<<4), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PP3300_PCH_PGOOD", LM4_GPIO_C, (1<<4), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"PP5000_PGOOD", LM4_GPIO_N, (1<<0), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"S5_PGOOD", LM4_GPIO_G, (1<<0), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"VCORE_PGOOD", LM4_GPIO_C, (1<<6), GPIO_INT_BOTH, - x86_interrupt}, + power_signal_interrupt}, {"WP_L", LM4_GPIO_A, (1<<4), GPIO_INT_BOTH, switch_interrupt}, {"JTAG_TCK", LM4_GPIO_C, (1<<0), GPIO_DEFAULT, @@ -125,8 +125,8 @@ const struct gpio_alt_func gpio_alt_funcs[] = { }; const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); -/* x86 signal list. Must match order of enum x86_signal. */ -const struct x86_signal_info x86_signal_list[] = { +/* power signal list. Must match order of enum power_signal. */ +const struct power_signal_info power_signal_list[] = { {GPIO_PP1050_PGOOD, 1, "PGOOD_PP1050"}, {GPIO_PP3300_PCH_PGOOD, 1, "PGOOD_PP3300_PCH"}, {GPIO_PP5000_PGOOD, 1, "PGOOD_PP5000"}, @@ -139,7 +139,7 @@ const struct x86_signal_info x86_signal_list[] = { {GPIO_PCH_SUS_STAT_L, 0, "SUS_STAT#_ASSERTED"}, {GPIO_PCH_SUSPWRDNACK, 1, "SUSPWRDNACK_ASSERTED"}, }; -BUILD_ASSERT(ARRAY_SIZE(x86_signal_list) == X86_SIGNAL_COUNT); +BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT); /* ADC channels. Must be in the exactly same order as in enum adc_channel. */ const struct adc_t adc_channels[] = { diff --git a/board/squawks/board.h b/board/squawks/board.h index af9f4a7208..1b93ecab22 100644 --- a/board/squawks/board.h +++ b/board/squawks/board.h @@ -128,8 +128,8 @@ enum gpio_signal { GPIO_COUNT }; -/* x86 signal definitions */ -enum x86_signal { +/* power signal definitions */ +enum power_signal { X86_PGOOD_PP1050 = 0, X86_PGOOD_PP3300_PCH, X86_PGOOD_PP5000, @@ -143,7 +143,7 @@ enum x86_signal { X86_SUSPWRDNACK_ASSERTED, /* Number of X86 signals */ - X86_SIGNAL_COUNT + POWER_SIGNAL_COUNT }; enum adc_channel { diff --git a/include/chipset.h b/include/chipset.h index 728a6be4a4..952c243663 100644 --- a/include/chipset.h +++ b/include/chipset.h @@ -76,7 +76,7 @@ void chipset_force_shutdown(void); void chipset_reset(int cold_reset); /** - * Interrupt handler for power GPIO inputs. + * Interrupt handler to power GPIO inputs. */ void power_interrupt(enum gpio_signal signal); diff --git a/include/power.h b/include/power.h index 21576f1899..e79c949653 100644 --- a/include/power.h +++ b/include/power.h @@ -3,96 +3,97 @@ * found in the LICENSE file. */ -/* Common interface for x86 chipsets */ +/* Common power interface for all chipsets */ -#ifndef __CROS_EC_CHIPSET_X86_COMMON_H -#define __CROS_EC_CHIPSET_X86_COMMON_H +#ifndef __CROS_EC_POWER_COMMON_H +#define __CROS_EC_POWER_COMMON_H #include "common.h" #include "gpio.h" -enum x86_state { +enum power_state { /* Steady states */ - X86_G3 = 0, /* + POWER_G3 = 0, /* * System is off (not technically all the way into G3, * which means totally unpowered...) */ - X86_S5, /* System is soft-off */ - X86_S3, /* Suspend; RAM on, processor is asleep */ - X86_S0, /* System is on */ + POWER_S5, /* System is soft-off */ + POWER_S3, /* Suspend; RAM on, processor is asleep */ + POWER_S0, /* System is on */ /* Transitions */ - X86_G3S5, /* G3 -> S5 (at system init time) */ - X86_S5S3, /* S5 -> S3 */ - X86_S3S0, /* S3 -> S0 */ - X86_S0S3, /* S0 -> S3 */ - X86_S3S5, /* S3 -> S5 */ - X86_S5G3, /* S5 -> G3 */ + POWER_G3S5, /* G3 -> S5 (at system init time) */ + POWER_S5S3, /* S5 -> S3 */ + POWER_S3S0, /* S3 -> S0 */ + POWER_S0S3, /* S0 -> S3 */ + POWER_S3S5, /* S3 -> S5 */ + POWER_S5G3, /* S5 -> G3 */ }; -/* Information on an x86 signal */ -struct x86_signal_info { +/* Information on an power signal */ +struct power_signal_info { enum gpio_signal gpio; /* GPIO for signal */ int level; /* GPIO level which sets signal bit */ const char *name; /* Name of signal */ }; /* - * Each board must provide its signal list and a corresponding enum x86_signal. + * Each board must provide its signal list and a corresponding enum + * power_signal. */ -extern const struct x86_signal_info x86_signal_list[]; +extern const struct power_signal_info power_signal_list[]; -/* Convert enum x86_signal to a mask for signal functions */ -#define X86_SIGNAL_MASK(signal) (1 << (signal)) +/* Convert enum power_signal to a mask for signal functions */ +#define POWER_SIGNAL_MASK(signal) (1 << (signal)) /** - * Return current input signal state (one or more X86_SIGNAL_MASK()s). + * Return current input signal state (one or more POWER_SIGNAL_MASK()s). */ -uint32_t x86_get_signals(void); +uint32_t power_get_signals(void); /** * Check for required inputs * * @param want Mask of signals which must be present (one or more - * X86_SIGNAL_MASK()s). + * POWER_SIGNAL_MASK()s). * * @return Non-zero if all present; zero if a required signal is missing. */ -int x86_has_signals(uint32_t want); +int power_has_signals(uint32_t want); /** - * Wait for x86 input signals to be present + * Wait for power input signals to be present * * @param want Mask of signals which must be present (one or more - * X86_SIGNAL_MASK()s). If want=0, stops waiting for + * POWER_SIGNAL_MASK()s). If want=0, stops waiting for * signals. * @return EC_SUCCESS when all inputs are present, or ERROR_TIMEOUT if timeout * before reaching the desired state. */ -int x86_wait_signals(uint32_t want); +int power_wait_signals(uint32_t want); /** * Chipset-specific initialization * - * @return The state the chipset should start in. Usually X86_G3, but may - * be X86_G0 if the chipset was already on and we've jumped to this image. + * @return The state the chipset should start in. Usually POWER_G3, but may + * be POWER_G0 if the chipset was already on and we've jumped to this image. */ -enum x86_state x86_chipset_init(void); +enum power_state power_chipset_init(void); /** * Chipset-specific state handler * - * @return The updated state for the x86 chipset. + * @return The updated state for the chipset. */ -enum x86_state x86_handle_state(enum x86_state state); +enum power_state power_handle_state(enum power_state state); /** - * Interrupt handler for x86 chipset GPIOs. + * Interrupt handler for chipset GPIOs. */ #ifdef CONFIG_CHIPSET_X86 -void x86_interrupt(enum gpio_signal signal); +void power_signal_interrupt(enum gpio_signal signal); #else -#define x86_interrupt NULL +#define power_signal_interrupt NULL #endif -#endif /* __CROS_EC_CHIPSET_X86_COMMON_H */ +#endif /* __CROS_EC_POWER_COMMON_H */ diff --git a/power/baytrail.c b/power/baytrail.c index b8144b717d..3cb6d5df7e 100644 --- a/power/baytrail.c +++ b/power/baytrail.c @@ -3,10 +3,9 @@ * found in the LICENSE file. */ -/* X86 chipset power control module for Chrome EC */ +/* X86 baytrail chipset power control module for Chrome EC */ #include "chipset.h" -#include "power.h" #include "common.h" #include "console.h" #include "ec_commands.h" @@ -14,6 +13,7 @@ #include "hooks.h" #include "host_command.h" #include "lid_switch.h" +#include "power.h" #include "system.h" #include "timer.h" #include "util.h" @@ -24,12 +24,12 @@ #define CPRINTF(format, args...) cprintf(CC_CHIPSET, format, ## args) /* Input state flags */ -#define IN_PGOOD_PP5000 X86_SIGNAL_MASK(X86_PGOOD_PP5000) -#define IN_PGOOD_PP1050 X86_SIGNAL_MASK(X86_PGOOD_PP1050) -#define IN_PGOOD_S5 X86_SIGNAL_MASK(X86_PGOOD_S5) -#define IN_PGOOD_VCORE X86_SIGNAL_MASK(X86_PGOOD_VCORE) -#define IN_SLP_S3_DEASSERTED X86_SIGNAL_MASK(X86_SLP_S3_DEASSERTED) -#define IN_SLP_S4_DEASSERTED X86_SIGNAL_MASK(X86_SLP_S4_DEASSERTED) +#define IN_PGOOD_PP5000 POWER_SIGNAL_MASK(X86_PGOOD_PP5000) +#define IN_PGOOD_PP1050 POWER_SIGNAL_MASK(X86_PGOOD_PP1050) +#define IN_PGOOD_S5 POWER_SIGNAL_MASK(X86_PGOOD_S5) +#define IN_PGOOD_VCORE POWER_SIGNAL_MASK(X86_PGOOD_VCORE) +#define IN_SLP_S3_DEASSERTED POWER_SIGNAL_MASK(X86_SLP_S3_DEASSERTED) +#define IN_SLP_S4_DEASSERTED POWER_SIGNAL_MASK(X86_SLP_S4_DEASSERTED) /* All always-on supplies */ #define IN_PGOOD_ALWAYS_ON (IN_PGOOD_S5) @@ -56,7 +56,7 @@ void chipset_force_shutdown(void) CPRINTF("[%T %s()]\n", __func__); /* - * Force x86 off. This condition will reset once the state machine + * Force power off. This condition will reset once the state machine * transitions to G3. */ gpio_set_level(GPIO_PCH_SYS_PWROK, 0); @@ -103,7 +103,7 @@ void chipset_throttle_cpu(int throttle) gpio_set_level(GPIO_CPU_PROCHOT, throttle); } -enum x86_state x86_chipset_init(void) +enum power_state power_chipset_init(void) { /* * If we're switching between images without rebooting, see if the x86 @@ -111,15 +111,15 @@ enum x86_state x86_chipset_init(void) * through G3. */ if (system_jumped_to_this_image()) { - if ((x86_get_signals() & IN_ALL_S0) == IN_ALL_S0) { + if ((power_get_signals() & IN_ALL_S0) == IN_ALL_S0) { /* Disable idle task deep sleep when in S0. */ disable_sleep(SLEEP_MASK_AP_RUN); - CPRINTF("[%T x86 already in S0]\n"); - return X86_S0; + CPRINTF("[%T already in S0]\n"); + return POWER_S0; } else { /* Force all signals to their G3 states */ - CPRINTF("[%T x86 forcing G3]\n"); + CPRINTF("[%T forcing G3]\n"); gpio_set_level(GPIO_PCH_CORE_PWROK, 0); gpio_set_level(GPIO_VCORE_EN, 0); gpio_set_level(GPIO_SUSP_VR_EN, 0); @@ -132,21 +132,21 @@ enum x86_state x86_chipset_init(void) } } - return X86_G3; + return POWER_G3; } -enum x86_state x86_handle_state(enum x86_state state) +enum power_state power_handle_state(enum power_state state) { switch (state) { - case X86_G3: + case POWER_G3: break; - case X86_S5: + case POWER_S5: if (gpio_get_level(GPIO_PCH_SLP_S4_L) == 1) - return X86_S5S3; /* Power up to next state */ + return POWER_S5S3; /* Power up to next state */ break; - case X86_S3: + case POWER_S3: /* * If lid is closed; hold touchscreen in reset to cut power * usage. If lid is open, take touchscreen out of reset so it @@ -156,31 +156,31 @@ enum x86_state x86_handle_state(enum x86_state state) gpio_set_level(GPIO_TOUCHSCREEN_RESET_L, lid_is_open()); /* Check for state transitions */ - if (!x86_has_signals(IN_PGOOD_S3)) { + if (!power_has_signals(IN_PGOOD_S3)) { /* Required rail went away */ chipset_force_shutdown(); - return X86_S3S5; + return POWER_S3S5; } else if (gpio_get_level(GPIO_PCH_SLP_S3_L) == 1) { /* Power up to next state */ - return X86_S3S0; + return POWER_S3S0; } else if (gpio_get_level(GPIO_PCH_SLP_S4_L) == 0) { /* Power down to next state */ - return X86_S3S5; + return POWER_S3S5; } break; - case X86_S0: - if (!x86_has_signals(IN_PGOOD_S0)) { + case POWER_S0: + if (!power_has_signals(IN_PGOOD_S0)) { /* Required rail went away */ chipset_force_shutdown(); - return X86_S0S3; + return POWER_S0S3; } else if (gpio_get_level(GPIO_PCH_SLP_S3_L) == 0) { /* Power down to next state */ - return X86_S0S3; + return POWER_S0S3; } break; - case X86_G3S5: + case POWER_G3S5: /* * Wait 10ms after +3VALW good, since that powers VccDSW and * VccSUS. @@ -188,9 +188,9 @@ enum x86_state x86_handle_state(enum x86_state state) msleep(10); gpio_set_level(GPIO_SUSP_VR_EN, 1); - if (x86_wait_signals(IN_PGOOD_S5)) { + if (power_wait_signals(IN_PGOOD_S5)) { chipset_force_shutdown(); - return X86_G3; + return POWER_G3; } /* Deassert RSMRST# */ @@ -198,20 +198,20 @@ enum x86_state x86_handle_state(enum x86_state state) /* Wait 10ms for SUSCLK to stabilize */ msleep(10); - return X86_S5; + return POWER_S5; - case X86_S5S3: + case POWER_S5S3: /* Wait for the always-on rails to be good */ - if (x86_wait_signals(IN_PGOOD_ALWAYS_ON)) { + if (power_wait_signals(IN_PGOOD_ALWAYS_ON)) { chipset_force_shutdown(); - return X86_S5G3; + return POWER_S5G3; } /* Turn on power to RAM */ gpio_set_level(GPIO_PP1350_EN, 1); - if (x86_wait_signals(IN_PGOOD_S3)) { + if (power_wait_signals(IN_PGOOD_S3)) { chipset_force_shutdown(); - return X86_S5G3; + return POWER_S5G3; } /* @@ -222,9 +222,9 @@ enum x86_state x86_handle_state(enum x86_state state) /* Call hooks now that rails are up */ hook_notify(HOOK_CHIPSET_STARTUP); - return X86_S3; + return POWER_S3; - case X86_S3S0: + case POWER_S3S0: /* Turn on power rails */ gpio_set_level(GPIO_PP5000_EN, 1); gpio_set_level(GPIO_PP3300_DX_EN, 1); @@ -240,13 +240,13 @@ enum x86_state x86_handle_state(enum x86_state state) gpio_set_level(GPIO_TOUCHSCREEN_RESET_L, 1); /* Wait for non-core power rails good */ - if (x86_wait_signals(IN_PGOOD_S0)) { + if (power_wait_signals(IN_PGOOD_S0)) { chipset_force_shutdown(); wireless_enable(0); gpio_set_level(GPIO_PP3300_DX_EN, 0); gpio_set_level(GPIO_PP5000_EN, 0); gpio_set_level(GPIO_TOUCHSCREEN_RESET_L, 0); - return X86_S3; + return POWER_S3; } /* @@ -276,9 +276,9 @@ enum x86_state x86_handle_state(enum x86_state state) /* Set SYS and CORE PWROK */ gpio_set_level(GPIO_PCH_SYS_PWROK, 1); gpio_set_level(GPIO_PCH_CORE_PWROK, 1); - return X86_S0; + return POWER_S0; - case X86_S0S3: + case POWER_S0S3: /* Call hooks before we remove power rails */ hook_notify(HOOK_CHIPSET_SUSPEND); @@ -310,9 +310,9 @@ enum x86_state x86_handle_state(enum x86_state state) /* Turn off power rails */ gpio_set_level(GPIO_PP3300_DX_EN, 0); gpio_set_level(GPIO_PP5000_EN, 0); - return X86_S3; + return POWER_S3; - case X86_S3S5: + case POWER_S3S5: /* Call hooks before we remove power rails */ hook_notify(HOOK_CHIPSET_SHUTDOWN); @@ -323,14 +323,14 @@ enum x86_state x86_handle_state(enum x86_state state) gpio_set_level(GPIO_PP1350_EN, 0); /* Start shutting down */ - return pause_in_s5 ? X86_S5 : X86_S5G3; + return pause_in_s5 ? POWER_S5 : POWER_S5G3; - case X86_S5G3: + case POWER_S5G3: /* Assert RSMRST# */ gpio_set_level(GPIO_PCH_RSMRST_L, 0); gpio_set_level(GPIO_SUSP_VR_EN, 0); - return X86_G3; + return POWER_G3; } return state; diff --git a/power/common.c b/power/common.c index 8ddabcf962..3a92780bf4 100644 --- a/power/common.c +++ b/power/common.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -/* Common functionality across x86 chipsets */ +/* Common functionality across all chipsets */ #include "chipset.h" -#include "power.h" #include "common.h" #include "console.h" #include "extpower.h" #include "gpio.h" #include "hooks.h" +#include "power.h" #include "system.h" #include "task.h" #include "timer.h" @@ -47,7 +47,7 @@ static uint32_t in_signals; /* Current input signal states (IN_PGOOD_*) */ static uint32_t in_want; /* Input signal state we're waiting for */ static uint32_t in_debug; /* Signal values which print debug output */ -static enum x86_state state = X86_G3; /* Current state */ +static enum power_state state = POWER_G3; /* Current state */ static int want_g3_exit; /* Should we exit the G3 state? */ static uint64_t last_shutdown_time; /* When did we enter G3? */ @@ -57,40 +57,40 @@ static uint32_t hibernate_delay = 3600; /** * Update input signals mask */ -static void x86_update_signals(void) +static void power_update_signals(void) { uint32_t inew = 0; - const struct x86_signal_info *s = x86_signal_list; + const struct power_signal_info *s = power_signal_list; int i; - for (i = 0; i < X86_SIGNAL_COUNT; i++, s++) { + for (i = 0; i < POWER_SIGNAL_COUNT; i++, s++) { if (gpio_get_level(s->gpio) == s->level) inew |= 1 << i; } if ((in_signals & in_debug) != (inew & in_debug)) - CPRINTF("[%T x86 in 0x%04x]\n", inew); + CPRINTF("[%T power in 0x%04x]\n", inew); in_signals = inew; } -uint32_t x86_get_signals(void) +uint32_t power_get_signals(void) { return in_signals; } -int x86_has_signals(uint32_t want) +int power_has_signals(uint32_t want) { if ((in_signals & want) == want) return 1; - CPRINTF("[%T x86 power lost input; wanted 0x%04x, got 0x%04x]\n", + CPRINTF("[%T power lost input; wanted 0x%04x, got 0x%04x]\n", want, in_signals & want); return 0; } -int x86_wait_signals(uint32_t want) +int power_wait_signals(uint32_t want) { in_want = want; if (!want) @@ -98,8 +98,8 @@ int x86_wait_signals(uint32_t want) while ((in_signals & in_want) != in_want) { if (task_wait_event(DEFAULT_TIMEOUT) == TASK_EVENT_TIMER) { - x86_update_signals(); - CPRINTF("[%T x86 power timeout on input; " + power_update_signals(); + CPRINTF("[%T power timeout on input; " "wanted 0x%04x, got 0x%04x]\n", in_want, in_signals & in_want); return EC_ERROR_TIMEOUT; @@ -115,32 +115,32 @@ int x86_wait_signals(uint32_t want) } /** - * Set the low-level x86 chipset state. + * Set the low-level power chipset state. * * @param new_state New chipset state. */ -void x86_set_state(enum x86_state new_state) +void power_set_state(enum power_state new_state) { /* Record the time we go into G3 */ - if (new_state == X86_G3) + if (new_state == POWER_G3) last_shutdown_time = get_time().val; state = new_state; } /** - * Common handler for x86 steady states + * Common handler for steady states * - * @param state Current x86 state - * @return Updated x86 state + * @param state Current power state + * @return Updated power state */ -static enum x86_state x86_common_state(enum x86_state state) +static enum power_state power_common_state(enum power_state state) { switch (state) { - case X86_G3: + case POWER_G3: if (want_g3_exit) { want_g3_exit = 0; - return X86_G3S5; + return POWER_G3S5; } in_want = 0; @@ -155,7 +155,7 @@ static enum x86_state x86_common_state(enum x86_state state) * Time's up. Hibernate until wake pin * asserted. */ - CPRINTF("[%T x86 hibernating]\n"); + CPRINTF("[%T hibernating]\n"); system_hibernate(0, 0); } else { uint64_t wait = target_time - time_now; @@ -168,26 +168,26 @@ static enum x86_state x86_common_state(enum x86_state state) } break; - case X86_S5: + case POWER_S5: /* Wait for inactivity timeout */ - x86_wait_signals(0); + power_wait_signals(0); if (task_wait_event(S5_INACTIVITY_TIMEOUT) == TASK_EVENT_TIMER) { /* Drop to G3; wake not requested yet */ want_g3_exit = 0; - return X86_S5G3; + return POWER_S5G3; } break; - case X86_S3: + case POWER_S3: /* Wait for a message */ - x86_wait_signals(0); + power_wait_signals(0); task_wait_event(-1); break; - case X86_S0: + case POWER_S0: /* Wait for a message */ - x86_wait_signals(0); + power_wait_signals(0); task_wait_event(-1); break; @@ -212,32 +212,32 @@ int chipset_in_state(int state_mask) * return non-zero. */ switch (state) { - case X86_G3: + case POWER_G3: need_mask = CHIPSET_STATE_HARD_OFF; break; - case X86_G3S5: - case X86_S5G3: + case POWER_G3S5: + case POWER_S5G3: /* * In between hard and soft off states. Match only if caller * will accept both. */ need_mask = CHIPSET_STATE_HARD_OFF | CHIPSET_STATE_SOFT_OFF; break; - case X86_S5: + case POWER_S5: need_mask = CHIPSET_STATE_SOFT_OFF; break; - case X86_S5S3: - case X86_S3S5: + case POWER_S5S3: + case POWER_S3S5: need_mask = CHIPSET_STATE_SOFT_OFF | CHIPSET_STATE_SUSPEND; break; - case X86_S3: + case POWER_S3: need_mask = CHIPSET_STATE_SUSPEND; break; - case X86_S3S0: - case X86_S0S3: + case POWER_S3S0: + case POWER_S0S3: need_mask = CHIPSET_STATE_SUSPEND | CHIPSET_STATE_ON; break; - case X86_S0: + case POWER_S0: need_mask = CHIPSET_STATE_ON; break; } @@ -249,7 +249,7 @@ int chipset_in_state(int state_mask) void chipset_exit_hard_off(void) { /* If not in the hard-off state nor headed there, nothing to do */ - if (state != X86_G3 && state != X86_S5G3) + if (state != POWER_G3 && state != POWER_S5G3) return; /* Set a flag to leave G3, then wake the task */ @@ -264,77 +264,77 @@ void chipset_exit_hard_off(void) void chipset_task(void) { - enum x86_state new_state; + enum power_state new_state; while (1) { - CPRINTF("[%T x86 power state %d = %s, in 0x%04x]\n", + CPRINTF("[%T power state %d = %s, in 0x%04x]\n", state, state_names[state], in_signals); /* Always let the specific chipset handle the state first */ - new_state = x86_handle_state(state); + new_state = power_handle_state(state); /* * If the state hasn't changed, run common steady-state * handler. */ if (new_state == state) - new_state = x86_common_state(state); + new_state = power_common_state(state); /* Handle state changes */ if (new_state != state) - x86_set_state(new_state); + power_set_state(new_state); } } /*****************************************************************************/ /* Hooks */ -static void x86_common_init(void) +static void power_common_init(void) { - const struct x86_signal_info *s = x86_signal_list; + const struct power_signal_info *s = power_signal_list; int i; /* Update input state */ - x86_update_signals(); + power_update_signals(); /* Call chipset-specific init to set initial state */ - x86_set_state(x86_chipset_init()); + power_set_state(power_chipset_init()); /* Enable interrupts for input signals */ - for (i = 0; i < X86_SIGNAL_COUNT; i++, s++) + for (i = 0; i < POWER_SIGNAL_COUNT; i++, s++) gpio_enable_interrupt(s->gpio); } -DECLARE_HOOK(HOOK_INIT, x86_common_init, HOOK_PRIO_INIT_CHIPSET); +DECLARE_HOOK(HOOK_INIT, power_common_init, HOOK_PRIO_INIT_CHIPSET); -static void x86_lid_change(void) +static void power_lid_change(void) { /* Wake up the task to update power state */ task_wake(TASK_ID_CHIPSET); } -DECLARE_HOOK(HOOK_LID_CHANGE, x86_lid_change, HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_LID_CHANGE, power_lid_change, HOOK_PRIO_DEFAULT); -static void x86_ac_change(void) +static void power_ac_change(void) { if (extpower_is_present()) { - CPRINTF("[%T x86 AC on]\n"); + CPRINTF("[%T AC on]\n"); } else { - CPRINTF("[%T x86 AC off]\n"); + CPRINTF("[%T AC off]\n"); - if (state == X86_G3) { + if (state == POWER_G3) { last_shutdown_time = get_time().val; task_wake(TASK_ID_CHIPSET); } } } -DECLARE_HOOK(HOOK_AC_CHANGE, x86_ac_change, HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_AC_CHANGE, power_ac_change, HOOK_PRIO_DEFAULT); /*****************************************************************************/ /* Interrupts */ -void x86_interrupt(enum gpio_signal signal) +void power_signal_interrupt(enum gpio_signal signal) { /* Shadow signals and compare with our desired signal state. */ - x86_update_signals(); + power_update_signals(); /* Wake up the task */ task_wake(TASK_ID_CHIPSET); @@ -346,22 +346,22 @@ void x86_interrupt(enum gpio_signal signal) static int command_powerinfo(int argc, char **argv) { /* - * Print x86 power state in same format as state machine. This is + * Print power state in same format as state machine. This is * used by FAFT tests, so must match exactly. */ - ccprintf("[%T x86 power state %d = %s, in 0x%04x]\n", + ccprintf("[%T power state %d = %s, in 0x%04x]\n", state, state_names[state], in_signals); return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(powerinfo, command_powerinfo, NULL, - "Show current x86 power state", + "Show current power state", NULL); -static int command_x86indebug(int argc, char **argv) +static int command_powerindebug(int argc, char **argv) { - const struct x86_signal_info *s = x86_signal_list; + const struct power_signal_info *s = power_signal_list; int i; char *e; @@ -375,13 +375,13 @@ static int command_x86indebug(int argc, char **argv) } /* Print the mask */ - ccprintf("x86 in: 0x%04x\n", in_signals); + ccprintf("power in: 0x%04x\n", in_signals); ccprintf("debug mask: 0x%04x\n", in_debug); /* Print the decode */ ccprintf("bit meanings:\n"); - for (i = 0; i < X86_SIGNAL_COUNT; i++, s++) { + for (i = 0; i < POWER_SIGNAL_COUNT; i++, s++) { int mask = 1 << i; ccprintf(" 0x%04x %d %s\n", mask, in_signals & mask ? 1 : 0, s->name); @@ -389,9 +389,9 @@ static int command_x86indebug(int argc, char **argv) return EC_SUCCESS; }; -DECLARE_CONSOLE_COMMAND(x86indebug, command_x86indebug, +DECLARE_CONSOLE_COMMAND(powerindebug, command_powerindebug, "[mask]", - "Get/set x86 input debug mask", + "Get/set power input debug mask", NULL); static int command_hibernation_delay(int argc, char **argv) @@ -410,7 +410,7 @@ static int command_hibernation_delay(int argc, char **argv) /* Print the current setting */ ccprintf("Hibernation delay: %d s\n", hibernate_delay); - if (state == X86_G3 && !extpower_is_present()) { + if (state == POWER_G3 && !extpower_is_present()) { ccprintf("Time G3: %d s\n", time_g3); ccprintf("Time left: %d s\n", hibernate_delay - time_g3); } diff --git a/power/gaia.c b/power/gaia.c index 0726198a2b..523c20ed70 100644 --- a/power/gaia.c +++ b/power/gaia.c @@ -283,7 +283,7 @@ static void gaia_suspend_deferred(void) } DECLARE_DEFERRED(gaia_suspend_deferred); -void power_interrupt(enum gpio_signal signal) +void power_signal_interrupt(enum gpio_signal signal) { if (signal == GPIO_SUSPEND_L) { /* Handle suspend events in the hook task */ diff --git a/power/haswell.c b/power/haswell.c index f9ee85d0c9..df727d2983 100644 --- a/power/haswell.c +++ b/power/haswell.c @@ -3,10 +3,9 @@ * found in the LICENSE file. */ -/* X86 chipset power control module for Chrome EC */ +/* X86 haswell chipset power control module for Chrome EC */ #include "chipset.h" -#include "power.h" #include "common.h" #include "console.h" #include "ec_commands.h" @@ -14,6 +13,7 @@ #include "hooks.h" #include "host_command.h" #include "lid_switch.h" +#include "power.h" #include "system.h" #include "timer.h" #include "util.h" @@ -24,14 +24,14 @@ #define CPRINTF(format, args...) cprintf(CC_CHIPSET, format, ## args) /* Input state flags */ -#define IN_PGOOD_PP5000 X86_SIGNAL_MASK(X86_PGOOD_PP5000) -#define IN_PGOOD_PP1350 X86_SIGNAL_MASK(X86_PGOOD_PP1350) -#define IN_PGOOD_PP1050 X86_SIGNAL_MASK(X86_PGOOD_PP1050) -#define IN_PGOOD_VCORE X86_SIGNAL_MASK(X86_PGOOD_VCORE) -#define IN_SLP_S0_DEASSERTED X86_SIGNAL_MASK(X86_SLP_S0_DEASSERTED) -#define IN_SLP_S3_DEASSERTED X86_SIGNAL_MASK(X86_SLP_S3_DEASSERTED) -#define IN_SLP_S5_DEASSERTED X86_SIGNAL_MASK(X86_SLP_S5_DEASSERTED) -#define IN_SLP_SUS_DEASSERTED X86_SIGNAL_MASK(X86_SLP_SUS_DEASSERTED) +#define IN_PGOOD_PP5000 POWER_SIGNAL_MASK(X86_PGOOD_PP5000) +#define IN_PGOOD_PP1350 POWER_SIGNAL_MASK(X86_PGOOD_PP1350) +#define IN_PGOOD_PP1050 POWER_SIGNAL_MASK(X86_PGOOD_PP1050) +#define IN_PGOOD_VCORE POWER_SIGNAL_MASK(X86_PGOOD_VCORE) +#define IN_SLP_S0_DEASSERTED POWER_SIGNAL_MASK(X86_SLP_S0_DEASSERTED) +#define IN_SLP_S3_DEASSERTED POWER_SIGNAL_MASK(X86_SLP_S3_DEASSERTED) +#define IN_SLP_S5_DEASSERTED POWER_SIGNAL_MASK(X86_SLP_S5_DEASSERTED) +#define IN_SLP_SUS_DEASSERTED POWER_SIGNAL_MASK(X86_SLP_SUS_DEASSERTED) /* All always-on supplies */ #define IN_PGOOD_ALWAYS_ON (IN_PGOOD_PP5000) @@ -59,7 +59,7 @@ void chipset_force_shutdown(void) CPRINTF("[%T %s()]\n", __func__); /* - * Force x86 off. This condition will reset once the state machine + * Force power off. This condition will reset once the state machine * transitions to G3. */ gpio_set_level(GPIO_PCH_DPWROK, 0); @@ -117,7 +117,7 @@ void chipset_throttle_cpu(int throttle) gpio_set_level(GPIO_CPU_PROCHOT, throttle); } -enum x86_state x86_chipset_init(void) +enum power_state power_chipset_init(void) { /* Enable interrupts for our GPIOs */ gpio_enable_interrupt(GPIO_PCH_EDP_VDD_EN); @@ -128,14 +128,14 @@ enum x86_state x86_chipset_init(void) * through G3. */ if (system_jumped_to_this_image()) { - if ((x86_get_signals() & IN_ALL_S0) == IN_ALL_S0) { + if ((power_get_signals() & IN_ALL_S0) == IN_ALL_S0) { /* Disable idle task deep sleep when in S0. */ disable_sleep(SLEEP_MASK_AP_RUN); - CPRINTF("[%T x86 already in S0]\n"); - return X86_S0; + CPRINTF("[%T already in S0]\n"); + return POWER_S0; } else { /* Force all signals to their G3 states */ - CPRINTF("[%T x86 forcing G3]\n"); + CPRINTF("[%T forcing G3]\n"); gpio_set_level(GPIO_PCH_PWROK, 0); gpio_set_level(GPIO_VCORE_EN, 0); gpio_set_level(GPIO_SUSP_VR_EN, 0); @@ -149,21 +149,21 @@ enum x86_state x86_chipset_init(void) } } - return X86_G3; + return POWER_G3; } -enum x86_state x86_handle_state(enum x86_state state) +enum power_state power_handle_state(enum power_state state) { switch (state) { - case X86_G3: + case POWER_G3: break; - case X86_S5: + case POWER_S5: if (gpio_get_level(GPIO_PCH_SLP_S5_L) == 1) - return X86_S5S3; /* Power up to next state */ + return POWER_S5S3; /* Power up to next state */ break; - case X86_S3: + case POWER_S3: /* * If lid is closed; hold touchscreen in reset to cut power * usage. If lid is open, take touchscreen out of reset so it @@ -173,31 +173,31 @@ enum x86_state x86_handle_state(enum x86_state state) gpio_set_level(GPIO_TOUCHSCREEN_RESET_L, lid_is_open()); /* Check for state transitions */ - if (!x86_has_signals(IN_PGOOD_S3)) { + if (!power_has_signals(IN_PGOOD_S3)) { /* Required rail went away */ chipset_force_shutdown(); - return X86_S3S5; + return POWER_S3S5; } else if (gpio_get_level(GPIO_PCH_SLP_S3_L) == 1) { /* Power up to next state */ - return X86_S3S0; + return POWER_S3S0; } else if (gpio_get_level(GPIO_PCH_SLP_S5_L) == 0) { /* Power down to next state */ - return X86_S3S5; + return POWER_S3S5; } break; - case X86_S0: - if (!x86_has_signals(IN_PGOOD_S0)) { + case POWER_S0: + if (!power_has_signals(IN_PGOOD_S0)) { /* Required rail went away */ chipset_force_shutdown(); - return X86_S0S3; + return POWER_S0S3; } else if (gpio_get_level(GPIO_PCH_SLP_S3_L) == 0) { /* Power down to next state */ - return X86_S0S3; + return POWER_S0S3; } break; - case X86_G3S5: + case POWER_G3S5: /* * Wait 10ms after +3VALW good, since that powers VccDSW and * VccSUS. @@ -206,15 +206,15 @@ enum x86_state x86_handle_state(enum x86_state state) /* Assert DPWROK */ gpio_set_level(GPIO_PCH_DPWROK, 1); - if (x86_wait_signals(IN_SLP_SUS_DEASSERTED)) { + if (power_wait_signals(IN_SLP_SUS_DEASSERTED)) { chipset_force_shutdown(); - return X86_G3; + return POWER_G3; } gpio_set_level(GPIO_SUSP_VR_EN, 1); - if (x86_wait_signals(IN_PGOOD_PP1050)) { + if (power_wait_signals(IN_PGOOD_PP1050)) { chipset_force_shutdown(); - return X86_G3; + return POWER_G3; } /* Deassert RSMRST# */ @@ -222,27 +222,27 @@ enum x86_state x86_handle_state(enum x86_state state) /* Wait 5ms for SUSCLK to stabilize */ msleep(5); - return X86_S5; + return POWER_S5; - case X86_S5S3: + case POWER_S5S3: /* Enable PP5000 (5V) rail. */ gpio_set_level(GPIO_PP5000_EN, 1); - if (x86_wait_signals(IN_PGOOD_PP5000)) { + if (power_wait_signals(IN_PGOOD_PP5000)) { chipset_force_shutdown(); - return X86_G3; + return POWER_G3; } /* Wait for the always-on rails to be good */ - if (x86_wait_signals(IN_PGOOD_ALWAYS_ON)) { + if (power_wait_signals(IN_PGOOD_ALWAYS_ON)) { chipset_force_shutdown(); - return X86_S5G3; + return POWER_S5G3; } /* Turn on power to RAM */ gpio_set_level(GPIO_PP1350_EN, 1); - if (x86_wait_signals(IN_PGOOD_S3)) { + if (power_wait_signals(IN_PGOOD_S3)) { chipset_force_shutdown(); - return X86_S5G3; + return POWER_S5G3; } /* @@ -253,9 +253,9 @@ enum x86_state x86_handle_state(enum x86_state state) /* Call hooks now that rails are up */ hook_notify(HOOK_CHIPSET_STARTUP); - return X86_S3; + return POWER_S3; - case X86_S3S0: + case POWER_S3S0: /* Turn on power rails */ gpio_set_level(GPIO_PP3300_DX_EN, 1); @@ -270,13 +270,13 @@ enum x86_state x86_handle_state(enum x86_state state) gpio_set_level(GPIO_TOUCHSCREEN_RESET_L, 1); /* Wait for non-core power rails good */ - if (x86_wait_signals(IN_PGOOD_S0)) { + if (power_wait_signals(IN_PGOOD_S0)) { chipset_force_shutdown(); wireless_enable(0); gpio_set_level(GPIO_EC_EDP_VDD_EN, 0); gpio_set_level(GPIO_PP3300_DX_EN, 0); gpio_set_level(GPIO_TOUCHSCREEN_RESET_L, 0); - return X86_S3; + return POWER_S3; } /* @@ -306,9 +306,9 @@ enum x86_state x86_handle_state(enum x86_state state) /* Set PCH_PWROK */ gpio_set_level(GPIO_PCH_PWROK, 1); gpio_set_level(GPIO_SYS_PWROK, 1); - return X86_S0; + return POWER_S0; - case X86_S0S3: + case POWER_S0S3: /* Call hooks before we remove power rails */ hook_notify(HOOK_CHIPSET_SUSPEND); @@ -340,9 +340,9 @@ enum x86_state x86_handle_state(enum x86_state state) /* Turn off power rails */ gpio_set_level(GPIO_EC_EDP_VDD_EN, 0); gpio_set_level(GPIO_PP3300_DX_EN, 0); - return X86_S3; + return POWER_S3; - case X86_S3S5: + case POWER_S3S5: /* Call hooks before we remove power rails */ hook_notify(HOOK_CHIPSET_SHUTDOWN); @@ -356,14 +356,14 @@ enum x86_state x86_handle_state(enum x86_state state) gpio_set_level(GPIO_PP5000_EN, 0); /* Start shutting down */ - return pause_in_s5 ? X86_S5 : X86_S5G3; + return pause_in_s5 ? POWER_S5 : POWER_S5G3; - case X86_S5G3: + case POWER_S5G3: /* Deassert DPWROK, assert RSMRST# */ gpio_set_level(GPIO_PCH_DPWROK, 0); gpio_set_level(GPIO_PCH_RSMRST_L, 0); gpio_set_level(GPIO_SUSP_VR_EN, 0); - return X86_G3; + return POWER_G3; } return state; diff --git a/power/ivybridge.c b/power/ivybridge.c index 5b61c04eef..587960bea8 100644 --- a/power/ivybridge.c +++ b/power/ivybridge.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -/* X86 chipset power control module for Chrome EC */ +/* X86 ivybridge chipset power control module for Chrome EC */ #include "chipset.h" -#include "power.h" #include "common.h" #include "console.h" #include "gpio.h" #include "hooks.h" #include "lid_switch.h" +#include "power.h" #include "system.h" #include "timer.h" #include "util.h" @@ -22,20 +22,20 @@ #define CPRINTF(format, args...) cprintf(CC_CHIPSET, format, ## args) /* Input state flags */ -#define IN_PGOOD_5VALW X86_SIGNAL_MASK(X86_PGOOD_5VALW) -#define IN_PGOOD_1_5V_DDR X86_SIGNAL_MASK(X86_PGOOD_1_5V_DDR) -#define IN_PGOOD_1_5V_PCH X86_SIGNAL_MASK(X86_PGOOD_1_5V_PCH) -#define IN_PGOOD_1_8VS X86_SIGNAL_MASK(X86_PGOOD_1_8VS) -#define IN_PGOOD_VCCP X86_SIGNAL_MASK(X86_PGOOD_VCCP) -#define IN_PGOOD_VCCSA X86_SIGNAL_MASK(X86_PGOOD_VCCSA) -#define IN_PGOOD_CPU_CORE X86_SIGNAL_MASK(X86_PGOOD_CPU_CORE) -#define IN_PGOOD_VGFX_CORE X86_SIGNAL_MASK(X86_PGOOD_VGFX_CORE) -#define IN_SLP_S3_DEASSERTED X86_SIGNAL_MASK(X86_SLP_S3_DEASSERTED) -#define IN_SLP_S4_DEASSERTED X86_SIGNAL_MASK(X86_SLP_S4_DEASSERTED) -#define IN_SLP_S5_DEASSERTED X86_SIGNAL_MASK(X86_SLP_S5_DEASSERTED) -#define IN_SLP_A_DEASSERTED X86_SIGNAL_MASK(X86_SLP_A_DEASSERTED) -#define IN_SLP_SUS_DEASSERTED X86_SIGNAL_MASK(X86_SLP_SUS_DEASSERTED) -#define IN_SLP_ME_DEASSERTED X86_SIGNAL_MASK(X86_SLP_ME_DEASSERTED) +#define IN_PGOOD_5VALW POWER_SIGNAL_MASK(X86_PGOOD_5VALW) +#define IN_PGOOD_1_5V_DDR POWER_SIGNAL_MASK(X86_PGOOD_1_5V_DDR) +#define IN_PGOOD_1_5V_PCH POWER_SIGNAL_MASK(X86_PGOOD_1_5V_PCH) +#define IN_PGOOD_1_8VS POWER_SIGNAL_MASK(X86_PGOOD_1_8VS) +#define IN_PGOOD_VCCP POWER_SIGNAL_MASK(X86_PGOOD_VCCP) +#define IN_PGOOD_VCCSA POWER_SIGNAL_MASK(X86_PGOOD_VCCSA) +#define IN_PGOOD_CPU_CORE POWER_SIGNAL_MASK(X86_PGOOD_CPU_CORE) +#define IN_PGOOD_VGFX_CORE POWER_SIGNAL_MASK(X86_PGOOD_VGFX_CORE) +#define IN_SLP_S3_DEASSERTED POWER_SIGNAL_MASK(X86_SLP_S3_DEASSERTED) +#define IN_SLP_S4_DEASSERTED POWER_SIGNAL_MASK(X86_SLP_S4_DEASSERTED) +#define IN_SLP_S5_DEASSERTED POWER_SIGNAL_MASK(X86_SLP_S5_DEASSERTED) +#define IN_SLP_A_DEASSERTED POWER_SIGNAL_MASK(X86_SLP_A_DEASSERTED) +#define IN_SLP_SUS_DEASSERTED POWER_SIGNAL_MASK(X86_SLP_SUS_DEASSERTED) +#define IN_SLP_ME_DEASSERTED POWER_SIGNAL_MASK(X86_SLP_ME_DEASSERTED) /* All always-on supplies */ #define IN_PGOOD_ALWAYS_ON (IN_PGOOD_5VALW) @@ -65,7 +65,7 @@ void chipset_force_shutdown(void) CPRINTF("[%T chipset force shutdown]\n"); /* - * Force x86 off. This condition will reset once the state machine + * Force power off. This condition will reset once the state machine * transitions to G3. */ gpio_set_level(GPIO_PCH_DPWROK, 0); @@ -115,7 +115,7 @@ void chipset_throttle_cpu(int throttle) gpio_set_level(GPIO_CPU_PROCHOT, throttle); } -enum x86_state x86_chipset_init(void) +enum power_state power_chipset_init(void) { /* * If we're switching between images without rebooting, see if the x86 @@ -123,12 +123,12 @@ enum x86_state x86_chipset_init(void) * through G3. */ if (system_jumped_to_this_image()) { - if ((x86_get_signals() & IN_ALL_S0) == IN_ALL_S0) { - CPRINTF("[%T x86 already in S0]\n"); - return X86_S0; + if ((power_get_signals() & IN_ALL_S0) == IN_ALL_S0) { + CPRINTF("[%T already in S0]\n"); + return POWER_S0; } else { /* Force all signals to their G3 states */ - CPRINTF("[%T x86 forcing G3]\n"); + CPRINTF("[%T forcing G3]\n"); gpio_set_level(GPIO_PCH_PWROK, 0); gpio_set_level(GPIO_ENABLE_VCORE, 0); gpio_set_level(GPIO_ENABLE_VS, 0); @@ -140,23 +140,23 @@ enum x86_state x86_chipset_init(void) } } - return X86_G3; + return POWER_G3; } -enum x86_state x86_handle_state(enum x86_state state) +enum power_state power_handle_state(enum power_state state) { switch (state) { - case X86_G3: + case POWER_G3: break; - case X86_S5: + case POWER_S5: if (gpio_get_level(GPIO_PCH_SLP_S5_L) == 1) { /* Power up to next state */ - return X86_S5S3; + return POWER_S5S3; } break; - case X86_S3: + case POWER_S3: /* * If lid is closed; hold touchscreen in reset to cut power * usage. If lid is open, take touchscreen out of reset so it @@ -165,31 +165,31 @@ enum x86_state x86_handle_state(enum x86_state state) gpio_set_level(GPIO_TOUCHSCREEN_RESET_L, lid_is_open()); /* Check for state transitions */ - if (!x86_has_signals(IN_PGOOD_S3)) { + if (!power_has_signals(IN_PGOOD_S3)) { /* Required rail went away */ chipset_force_shutdown(); - return X86_S3S5; + return POWER_S3S5; } else if (gpio_get_level(GPIO_PCH_SLP_S3_L) == 1) { /* Power up to next state */ - return X86_S3S0; + return POWER_S3S0; } else if (gpio_get_level(GPIO_PCH_SLP_S5_L) == 0) { /* Power down to next state */ - return X86_S3S5; + return POWER_S3S5; } break; - case X86_S0: - if (!x86_has_signals(IN_PGOOD_S0)) { + case POWER_S0: + if (!power_has_signals(IN_PGOOD_S0)) { /* Required rail went away */ chipset_force_shutdown(); - return X86_S0S3; + return POWER_S0S3; } else if (gpio_get_level(GPIO_PCH_SLP_S3_L) == 0) { /* Power down to next state */ - return X86_S0S3; + return POWER_S0S3; } break; - case X86_G3S5: + case POWER_G3S5: /* * Wait 10ms after +3VALW good, since that powers VccDSW and * VccSUS. @@ -202,13 +202,13 @@ enum x86_state x86_handle_state(enum x86_state state) /* Wait 5ms for SUSCLK to stabilize */ msleep(5); - return X86_S5; + return POWER_S5; - case X86_S5S3: + case POWER_S5S3: /* Wait for the always-on rails to be good */ - if (x86_wait_signals(IN_PGOOD_ALWAYS_ON)) { + if (power_wait_signals(IN_PGOOD_ALWAYS_ON)) { chipset_force_shutdown(); - return X86_S5; + return POWER_S5; } /* @@ -219,9 +219,9 @@ enum x86_state x86_handle_state(enum x86_state state) /* Turn on power to RAM */ gpio_set_level(GPIO_ENABLE_1_5V_DDR, 1); - if (x86_wait_signals(IN_PGOOD_S3)) { + if (power_wait_signals(IN_PGOOD_S3)) { chipset_force_shutdown(); - return X86_S5; + return POWER_S5; } /* @@ -232,9 +232,9 @@ enum x86_state x86_handle_state(enum x86_state state) /* Call hooks now that rails are up */ hook_notify(HOOK_CHIPSET_STARTUP); - return X86_S3; + return POWER_S3; - case X86_S3S0: + case POWER_S3S0: /* Turn on power rails */ gpio_set_level(GPIO_ENABLE_VS, 1); @@ -249,12 +249,12 @@ enum x86_state x86_handle_state(enum x86_state state) gpio_set_level(GPIO_TOUCHSCREEN_RESET_L, 1); /* Wait for non-core power rails good */ - if (x86_wait_signals(IN_PGOOD_S0)) { + if (power_wait_signals(IN_PGOOD_S0)) { chipset_force_shutdown(); gpio_set_level(GPIO_TOUCHSCREEN_RESET_L, 0); wireless_enable(0); gpio_set_level(GPIO_ENABLE_VS, 0); - return X86_S3; + return POWER_S3; } /* @@ -277,9 +277,9 @@ enum x86_state x86_handle_state(enum x86_state state) /* Set PCH_PWROK */ gpio_set_level(GPIO_PCH_PWROK, 1); - return X86_S0; + return POWER_S0; - case X86_S0S3: + case POWER_S0S3: /* Call hooks before we remove power rails */ hook_notify(HOOK_CHIPSET_SUSPEND); @@ -303,9 +303,9 @@ enum x86_state x86_handle_state(enum x86_state state) /* Turn off power rails */ gpio_set_level(GPIO_ENABLE_VS, 0); - return X86_S3; + return POWER_S3; - case X86_S3S5: + case POWER_S3S5: /* Call hooks before we remove power rails */ hook_notify(HOOK_CHIPSET_SHUTDOWN); @@ -325,13 +325,13 @@ enum x86_state x86_handle_state(enum x86_state state) */ gpio_set_level(GPIO_TOUCHSCREEN_RESET_L, 0); gpio_set_level(GPIO_LIGHTBAR_RESET_L, 0); - return X86_S5; + return POWER_S5; - case X86_S5G3: + case POWER_S5G3: /* Deassert DPWROK, assert RSMRST# */ gpio_set_level(GPIO_PCH_DPWROK, 0); gpio_set_level(GPIO_PCH_RSMRST_L, 0); - return X86_G3; + return POWER_G3; } return state; diff --git a/power/tegra.c b/power/tegra.c index c2a096db6c..42f57b5023 100644 --- a/power/tegra.c +++ b/power/tegra.c @@ -292,7 +292,7 @@ static void tegra_suspend_deferred(void) } DECLARE_DEFERRED(tegra_suspend_deferred); -void power_interrupt(enum gpio_signal signal) +void power_signal_interrupt(enum gpio_signal signal) { if (signal == GPIO_SUSPEND_L) { /* Handle suspend events in the hook task */ diff --git a/test/adapter.c b/test/adapter.c index 2bfd570bd0..c1b9190d93 100644 --- a/test/adapter.c +++ b/test/adapter.c @@ -6,6 +6,7 @@ */ #include "adc.h" +#include "chipset.h" #include "common.h" #include "console.h" #include "extpower.h" @@ -15,7 +16,6 @@ #include "test_util.h" #include "timer.h" #include "util.h" -#include "chipset.h" #include "power.h" /* Normally private stuff from the modules we're going to test */ |