diff options
-rw-r--r-- | board/jerry/board.h | 4 | ||||
-rw-r--r-- | board/jerry/gpio.inc | 9 | ||||
-rw-r--r-- | board/jerry/led.c | 29 | ||||
-rw-r--r-- | board/pinky/board.c | 15 | ||||
-rw-r--r-- | power/rockchip.c | 14 |
5 files changed, 44 insertions, 27 deletions
diff --git a/board/jerry/board.h b/board/jerry/board.h index 398a56b62a..5a05393717 100644 --- a/board/jerry/board.h +++ b/board/jerry/board.h @@ -28,6 +28,7 @@ #define CONFIG_LOW_POWER_IDLE #define CONFIG_LOW_POWER_S0 #define CONFIG_POWER_BUTTON +#define CONFIG_POWER_BUTTON_ACTIVE_STATE 1 #define CONFIG_POWER_COMMON #define CONFIG_PWM #define CONFIG_SPI @@ -35,6 +36,8 @@ #define CONFIG_VBOOT_HASH #undef CONFIG_WATCHDOG_HELP +#define CONFIG_HIBERNATE_WAKEUP_PINS (STM32_PWR_CSR_EWUP1 | STM32_PWR_CSR_EWUP6) + #ifndef __ASSEMBLER__ /* 48 MHz SYSCLK clock frequency */ @@ -57,7 +60,6 @@ enum power_signal { RK_POWER_GOOD = 0, RK_SUSPEND_ASSERTED, - /* Number of power signals */ POWER_SIGNAL_COUNT }; diff --git a/board/jerry/gpio.inc b/board/jerry/gpio.inc index a0909168c2..29efb848d1 100644 --- a/board/jerry/gpio.inc +++ b/board/jerry/gpio.inc @@ -6,12 +6,12 @@ */ /* Inputs with interrupt handlers are first for efficiency */ -GPIO(POWER_BUTTON_L, B, 5, GPIO_INT_BOTH, power_button_interrupt) +GPIO(POWER_BUTTON_L, B, 5, GPIO_INT_BOTH, power_button_interrupt) /* wk6 */ /* active high, the name is for compatibility with existing code */ GPIO(SOC_POWER_GOOD, A, 3, GPIO_INT_BOTH, power_signal_interrupt) GPIO(LID_OPEN, C, 13, GPIO_INT_BOTH, lid_interrupt) GPIO(SUSPEND_L, C, 7, GPIO_INT_BOTH, power_signal_interrupt) GPIO(SPI1_NSS, A, 4, GPIO_INT_BOTH, spi_event) -GPIO(AC_PRESENT, A, 0, GPIO_INT_BOTH | GPIO_PULL_UP, extpower_interrupt) +GPIO(AC_PRESENT, A, 8, GPIO_INT_BOTH | GPIO_PULL_UP, extpower_interrupt) /* Keyboard inputs */ GPIO(KB_IN00, C, 8, GPIO_KB_INPUT, keyboard_raw_gpio_interrupt) @@ -24,10 +24,10 @@ GPIO(KB_IN06, C, 15, GPIO_KB_INPUT, keyboard_raw_gpio_interrupt) GPIO(KB_IN07, D, 2, GPIO_KB_INPUT, keyboard_raw_gpio_interrupt) /* Other inputs */ -GPIO(WP_L, B, 4, GPIO_INPUT, NULL) +GPIO(EC_WAKE, A, 0, GPIO_INPUT | GPIO_PULL_DOWN, NULL) /* wk1 */ +GPIO(WP_L, B, 4, GPIO_INPUT, NULL) /* Outputs */ -GPIO(5V_DRV, A, 8, GPIO_OUT_LOW, NULL) GPIO(BAT_LED0, B, 11, GPIO_OUT_LOW, NULL) GPIO(BAT_LED1, A, 11, GPIO_OUT_LOW, NULL) GPIO(EC_BL_OVERRIDE, F, 1, GPIO_OUT_LOW, NULL) @@ -48,6 +48,7 @@ GPIO(KB_OUT09, B, 1, GPIO_KB_OUTPUT, NULL) GPIO(KB_OUT10, C, 5, GPIO_KB_OUTPUT, NULL) GPIO(KB_OUT11, C, 4, GPIO_KB_OUTPUT, NULL) GPIO(KB_OUT12, A, 13, GPIO_KB_OUTPUT, NULL) +GPIO(POWER_LED, A, 2, GPIO_OUT_LOW, NULL) GPIO(PMIC_PWRON, A, 12, GPIO_OUT_LOW, NULL) GPIO(PMIC_RESET, B, 3, GPIO_OUT_LOW, NULL) GPIO(PMIC_SOURCE_PWREN, B, 10, GPIO_OUT_LOW, NULL) diff --git a/board/jerry/led.c b/board/jerry/led.c index 005f314c7e..aead84efd8 100644 --- a/board/jerry/led.c +++ b/board/jerry/led.c @@ -14,7 +14,9 @@ #include "util.h" const enum ec_led_id supported_led_ids[] = { - EC_LED_ID_BATTERY_LED}; + EC_LED_ID_BATTERY_LED, + EC_LED_ID_POWER_LED, +}; const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); @@ -39,6 +41,12 @@ static int bat_led_set(enum led_color color, int on) return EC_SUCCESS; } +static int pwr_led_set(int on) +{ + gpio_set_level(GPIO_POWER_LED, on); + return EC_SUCCESS; +} + void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) { /* Ignoring led_id as both leds support the same colors */ @@ -48,7 +56,8 @@ void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) { - if (EC_LED_ID_BATTERY_LED == led_id) { + switch (led_id) { + case EC_LED_ID_BATTERY_LED: if (brightness[EC_LED_COLOR_GREEN] != 0) { bat_led_set(LED_GREEN, 1); bat_led_set(LED_ORANGE, 0); @@ -59,11 +68,15 @@ int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) bat_led_set(LED_GREEN, 0); bat_led_set(LED_ORANGE, 0); } - return EC_SUCCESS; - } else { + break; + case EC_LED_ID_POWER_LED: + pwr_led_set(brightness[EC_LED_COLOR_BLUE]); + break; + default: return EC_ERROR_UNKNOWN; - } + } + return EC_SUCCESS; } static void jerry_led_set_power(void) @@ -78,11 +91,11 @@ static void jerry_led_set_power(void) * Power off: OFF */ if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) - bat_led_set(LED_GREEN, 0); + pwr_led_set(0); else if (chipset_in_state(CHIPSET_STATE_ON)) - bat_led_set(LED_GREEN, 1); + pwr_led_set(1); else if (chipset_in_state(CHIPSET_STATE_SUSPEND)) - bat_led_set(LED_GREEN, (power_second & 3) ? 0 : 1); + pwr_led_set((power_second & 3) ? 0 : 1); } diff --git a/board/pinky/board.c b/board/pinky/board.c index a91a25c6a4..0de6da5567 100644 --- a/board/pinky/board.c +++ b/board/pinky/board.c @@ -9,6 +9,7 @@ #include "common.h" #include "extpower.h" #include "gpio.h" +#include "hooks.h" #include "i2c.h" #include "keyboard_raw.h" #include "lid_switch.h" @@ -58,6 +59,20 @@ int board_discharge_on_ac(int enable) return charger_discharge_on_ac(enable); } +static void board_startup_hook(void) +{ + /* Power on the VCC_5V */ + gpio_set_level(GPIO_5V_DRV, 1); +} +DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_startup_hook, HOOK_PRIO_DEFAULT); + +static void board_shutdown_hook(void) +{ + /* Power off the VCC_5V */ + gpio_set_level(GPIO_5V_DRV, 0); +} +DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_shutdown_hook, HOOK_PRIO_DEFAULT); + void board_config_pre_init(void) { /* enable SYSCFG clock */ diff --git a/power/rockchip.c b/power/rockchip.c index 1db537cb2a..2d71e2f697 100644 --- a/power/rockchip.c +++ b/power/rockchip.c @@ -159,17 +159,6 @@ static void set_pmic_source(int asserted) } /** - * Power on or off the VCC_5V - * - * @param asserted Assert (=1) or deassert (=0) the signal. - */ -static void set_5v_power(int asserted) -{ - /* Signal is active-high */ - gpio_set_level(GPIO_5V_DRV, asserted ? 1 : 0); -} - -/** * Check for some event triggering the shutdown. * * It can be either a long power button press or a shutdown triggered from the @@ -384,8 +373,6 @@ static void power_on(void) usleep(PMIC_RESET_HOLD_TIME); set_pmic_reset(0); set_pmic_warm_reset(0); - - set_5v_power(1); } /** @@ -424,7 +411,6 @@ static int wait_for_power_button_release(unsigned int timeout_us) */ static void power_off(void) { - set_5v_power(0); /* Call hooks before we drop power rails */ hook_notify(HOOK_CHIPSET_SHUTDOWN); /* switch off all rails */ |