Beispiel #1
0
static void acpi_hibernation_leave(void)
{
    /*
     * If ACPI is not enabled by the BIOS and the boot kernel, we need to
     * enable it here.
     */
    acpi_enable();
    /* Reprogram control registers and execute _BFS */
    acpi_leave_sleep_state_prep(ACPI_STATE_S4);
}
Beispiel #2
0
/**
 *	acpi_suspend_enter - Actually enter a sleep state.
 *	@pm_state: ignored
 *
 *	Flush caches and go to sleep. For STR we have to call arch-specific
 *	assembly, which in turn call acpi_enter_sleep_state().
 *	It's unfortunate, but it works. Please fix if you're feeling frisky.
 */
static int acpi_suspend_enter(suspend_state_t pm_state)
{
    acpi_status status = AE_OK;
    unsigned long flags = 0;
    u32 acpi_state = acpi_target_sleep_state;

    ACPI_FLUSH_CPU_CACHE();

    /* Do arch specific saving of state. */
    if (acpi_state == ACPI_STATE_S3) {
        int error = acpi_save_state_mem();

        if (error)
            return error;
    }

    local_irq_save(flags);
    acpi_enable_wakeup_device(acpi_state);
    switch (acpi_state) {
    case ACPI_STATE_S1:
        barrier();
        status = acpi_enter_sleep_state(acpi_state);
        break;

    case ACPI_STATE_S3:
        do_suspend_lowlevel();
        break;
    }

    /* Reprogram control registers and execute _BFS */
    acpi_leave_sleep_state_prep(acpi_state);

    /* ACPI 3.0 specs (P62) says that it's the responsibility
     * of the OSPM to clear the status bit [ implying that the
     * POWER_BUTTON event should not reach userspace ]
     */
    if (ACPI_SUCCESS(status) && (acpi_state == ACPI_STATE_S3))
        acpi_clear_event(ACPI_EVENT_POWER_BUTTON);

    /*
     * Disable and clear GPE status before interrupt is enabled. Some GPEs
     * (like wakeup GPE) haven't handler, this can avoid such GPE misfire.
     * acpi_leave_sleep_state will reenable specific GPEs later
     */
    acpi_hw_disable_all_gpes();

    local_irq_restore(flags);
    printk(KERN_DEBUG "Back to C!\n");

    /* restore processor state */
    if (acpi_state == ACPI_STATE_S3)
        acpi_restore_state_mem();

    return ACPI_SUCCESS(status) ? 0 : -EFAULT;
}
Beispiel #3
0
static int acpi_hibernation_enter(void)
{
    acpi_status status = AE_OK;
    unsigned long flags = 0;

    ACPI_FLUSH_CPU_CACHE();

    local_irq_save(flags);
    acpi_enable_wakeup_device(ACPI_STATE_S4);
    /* This shouldn't return.  If it returns, we have a problem */
    status = acpi_enter_sleep_state(ACPI_STATE_S4);
    /* Reprogram control registers and execute _BFS */
    acpi_leave_sleep_state_prep(ACPI_STATE_S4);
    local_irq_restore(flags);

    return ACPI_SUCCESS(status) ? 0 : -EFAULT;
}
Beispiel #4
0
static void acpi_db_do_one_sleep_state(u8 sleep_state)
{
	acpi_status status;
	u8 sleep_type_a;
	u8 sleep_type_b;

	/* Validate parameter */

	if (sleep_state > ACPI_S_STATES_MAX) {
		acpi_os_printf("Sleep state %d out of range (%d max)\n",
			       sleep_state, ACPI_S_STATES_MAX);
		return;
	}

	acpi_os_printf("\n---- Invoking sleep state S%d (%s):\n",
		       sleep_state, acpi_gbl_sleep_state_names[sleep_state]);

	/* Get the values for the sleep type registers (for display only) */

	status =
	    acpi_get_sleep_type_data(sleep_state, &sleep_type_a, &sleep_type_b);
	if (ACPI_FAILURE(status)) {
		acpi_os_printf("Could not evaluate [%s] method, %s\n",
			       acpi_gbl_sleep_state_names[sleep_state],
			       acpi_format_exception(status));
		return;
	}

	acpi_os_printf
	    ("Register values for sleep state S%d: Sleep-A: %.2X, Sleep-B: %.2X\n",
	     sleep_state, sleep_type_a, sleep_type_b);

	/* Invoke the various sleep/wake interfaces */

	acpi_os_printf("**** Sleep: Prepare to sleep (S%d) ****\n",
		       sleep_state);
	status = acpi_enter_sleep_state_prep(sleep_state);
	if (ACPI_FAILURE(status)) {
		goto error_exit;
	}

	acpi_os_printf("**** Sleep: Going to sleep (S%d) ****\n", sleep_state);
	status = acpi_enter_sleep_state(sleep_state);
	if (ACPI_FAILURE(status)) {
		goto error_exit;
	}

	acpi_os_printf("**** Wake: Prepare to return from sleep (S%d) ****\n",
		       sleep_state);
	status = acpi_leave_sleep_state_prep(sleep_state);
	if (ACPI_FAILURE(status)) {
		goto error_exit;
	}

	acpi_os_printf("**** Wake: Return from sleep (S%d) ****\n",
		       sleep_state);
	status = acpi_leave_sleep_state(sleep_state);
	if (ACPI_FAILURE(status)) {
		goto error_exit;
	}

	return;

error_exit:
	ACPI_EXCEPTION((AE_INFO, status, "During invocation of sleep state S%d",
			sleep_state));
}