/**
 * Handle the hang detect timer expiring.
 */
static void hang_detect_deferred(void)
{
	/* If we're no longer active, nothing to do */
	if (!active)
		return;

	/* If we're rebooting the AP, stop hang detection */
	if (timeout_will_reboot) {
		CPRINTS("hang detect triggering warm reboot");
		host_set_single_event(EC_HOST_EVENT_HANG_REBOOT);
		chipset_reset(0);
		active = 0;
		return;
	}

	/* Otherwise, we're starting with the host event */
	CPRINTS("hang detect sending host event");
	host_set_single_event(EC_HOST_EVENT_HANG_DETECT);

	/* If we're also rebooting, defer for the remaining delay */
	if (hdparams.warm_reboot_timeout_msec) {
		CPRINTS("hang detect continuing (for reboot)");
		timeout_will_reboot = 1;
		hook_call_deferred(hang_detect_deferred,
				   (hdparams.warm_reboot_timeout_msec -
				    hdparams.host_event_timeout_msec) * MSEC);
	} else {
		/* Not rebooting, so go back to idle */
		active = 0;
	}
}
static int command_apreset(int argc, char **argv)
{
	int is_cold = 1;

	if (argc > 1 && !strcasecmp(argv[1], "cold"))
		is_cold = 1;
	else if (argc > 1 && !strcasecmp(argv[1], "warm"))
		is_cold = 0;

	/* Force the chipset to reset */
	ccprintf("Issuing AP %s reset...\n", is_cold ? "cold" : "warm");
	chipset_reset(is_cold);
	return EC_SUCCESS;
}
Exemple #3
0
/* Using this hook if system doesn't have enough external line. */
static void check_ap_reset_second(void)
{
	/* Check the warm reset signal from servo board */
	static int warm_reset, last;

	warm_reset = !gpio_get_level(GPIO_AP_RESET_L);

	if (last == warm_reset)
		return;

	if (warm_reset)
		chipset_reset(0); /* Warm reset AP */

	last = warm_reset;
}
Exemple #4
0
enum power_state power_chipset_init(void)
{
	int init_power_state;
	uint32_t reset_flags = system_get_reset_flags();

	/*
	 * Force the AP shutdown unless we are doing SYSJUMP. Otherwise,
	 * the AP could stay in strange state.
	 */
	if (!(reset_flags & RESET_FLAG_SYSJUMP)) {
		CPRINTS("not sysjump; forcing AP shutdown");
		chipset_turn_off_power_rails();

		/*
		 * The warm reset triggers AP into the RK recovery mode (
		 * flash SPI from USB).
		 */
		chipset_reset(0);

		init_power_state = POWER_G3;
	} else {
		/* In the SYSJUMP case, we check if the AP is on */
		if (power_get_signals() & IN_POWER_GOOD)
			init_power_state = POWER_S0;
		else
			init_power_state = POWER_G3;
	}

	/* Leave power off only if requested by reset flags */
	if (!(reset_flags & RESET_FLAG_AP_OFF) &&
	    !(reset_flags & RESET_FLAG_SYSJUMP)) {
		CPRINTS("auto_power_on set due to reset_flag 0x%x",
			system_get_reset_flags());
		auto_power_on = 1;
	}

	/*
	 * Some batteries use clock stretching feature, which requires
	 * more time to be stable. See http://crosbug.com/p/28289
	 */
	battery_wait_for_stable();

	return init_power_state;
}