linux/drivers/acpi/sleep.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * sleep.c - ACPI sleep support.
 *
 * Copyright (c) 2005 Alexey Starikovskiy <[email protected]>
 * Copyright (c) 2004 David Shaohua Li <[email protected]>
 * Copyright (c) 2000-2003 Patrick Mochel
 * Copyright (c) 2003 Open Source Development Lab
 */

#define pr_fmt(fmt)

#include <linux/delay.h>
#include <linux/irq.h>
#include <linux/dmi.h>
#include <linux/device.h>
#include <linux/interrupt.h>
#include <linux/suspend.h>
#include <linux/reboot.h>
#include <linux/acpi.h>
#include <linux/module.h>
#include <linux/syscore_ops.h>
#include <asm/io.h>
#include <trace/events/power.h>

#include "internal.h"
#include "sleep.h"

/*
 * Some HW-full platforms do not have _S5, so they may need
 * to leverage efi power off for a shutdown.
 */
bool acpi_no_s5;
static u8 sleep_states[ACPI_S_STATE_COUNT];

static void acpi_sleep_tts_switch(u32 acpi_state)
{}

static int tts_notify_reboot(struct notifier_block *this,
			unsigned long code, void *x)
{}

static struct notifier_block tts_notifier =;

#ifndef acpi_skip_set_wakeup_address
#define acpi_skip_set_wakeup_address
#endif

static int acpi_sleep_prepare(u32 acpi_state)
{}

bool acpi_sleep_state_supported(u8 sleep_state)
{}

#ifdef CONFIG_ACPI_SLEEP
static u32 acpi_target_sleep_state =;

u32 acpi_target_system_state(void)
{}
EXPORT_SYMBOL_GPL();

static bool pwr_btn_event_pending;

/*
 * The ACPI specification wants us to save NVS memory regions during hibernation
 * and to restore them during the subsequent resume.  Windows does that also for
 * suspend to RAM.  However, it is known that this mechanism does not work on
 * all machines, so we allow the user to disable it with the help of the
 * 'acpi_sleep=nonvs' kernel command line option.
 */
static bool nvs_nosave;

void __init acpi_nvs_nosave(void)
{}

/*
 * The ACPI specification wants us to save NVS memory regions during hibernation
 * but says nothing about saving NVS during S3.  Not all versions of Windows
 * save NVS on S3 suspend either, and it is clear that not all systems need
 * NVS to be saved at S3 time.  To improve suspend/resume time, allow the
 * user to disable saving NVS on S3 if their system does not require it, but
 * continue to save/restore NVS for S4 as specified.
 */
static bool nvs_nosave_s3;

void __init acpi_nvs_nosave_s3(void)
{}

static int __init init_nvs_save_s3(const struct dmi_system_id *d)
{}

/*
 * ACPI 1.0 wants us to execute _PTS before suspending devices, so we allow the
 * user to request that behavior by using the 'acpi_old_suspend_ordering'
 * kernel command line option that causes the following variable to be set.
 */
static bool old_suspend_ordering;

void __init acpi_old_suspend_ordering(void)
{}

static int __init init_old_suspend_ordering(const struct dmi_system_id *d)
{}

static int __init init_nvs_nosave(const struct dmi_system_id *d)
{}

bool acpi_sleep_default_s3;

static int __init init_default_s3(const struct dmi_system_id *d)
{}

static const struct dmi_system_id acpisleep_dmi_table[] __initconst =;

static bool ignore_blacklist;

void __init acpi_sleep_no_blacklist(void)
{}

static void __init acpi_sleep_dmi_check(void)
{}

/**
 * acpi_pm_freeze - Disable the GPEs and suspend EC transactions.
 */
static int acpi_pm_freeze(void)
{}

/**
 * acpi_pm_pre_suspend - Enable wakeup devices, "freeze" EC and save NVS.
 */
static int acpi_pm_pre_suspend(void)
{}

/**
 *	__acpi_pm_prepare - Prepare the platform to enter the target state.
 *
 *	If necessary, set the firmware waking vector and do arch-specific
 *	nastiness to get the wakeup code to the waking vector.
 */
static int __acpi_pm_prepare(void)
{}

/**
 *	acpi_pm_prepare - Prepare the platform to enter the target sleep
 *		state and disable the GPEs.
 */
static int acpi_pm_prepare(void)
{}

/**
 *	acpi_pm_finish - Instruct the platform to leave a sleep state.
 *
 *	This is called after we wake back up (or if entering the sleep state
 *	failed).
 */
static void acpi_pm_finish(void)
{}

/**
 * acpi_pm_start - Start system PM transition.
 * @acpi_state: The target ACPI power state to transition to.
 */
static void acpi_pm_start(u32 acpi_state)
{}

/**
 * acpi_pm_end - Finish up system PM transition.
 */
static void acpi_pm_end(void)
{}
#else /* !CONFIG_ACPI_SLEEP */
#define sleep_no_lps0
#define acpi_target_sleep_state
#define acpi_sleep_default_s3
static inline void acpi_sleep_dmi_check(void) {}
#endif /* CONFIG_ACPI_SLEEP */

#ifdef CONFIG_SUSPEND
static u32 acpi_suspend_states[] =;

/**
 * acpi_suspend_begin - Set the target system sleep state to the state
 *	associated with given @pm_state, if supported.
 * @pm_state: The target system power management state.
 */
static int acpi_suspend_begin(suspend_state_t pm_state)
{}

/**
 *	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)
{}

static int acpi_suspend_state_valid(suspend_state_t pm_state)
{}

static const struct platform_suspend_ops acpi_suspend_ops =;

/**
 * acpi_suspend_begin_old - Set the target system sleep state to the
 *	state associated with given @pm_state, if supported, and
 *	execute the _PTS control method.  This function is used if the
 *	pre-ACPI 2.0 suspend ordering has been requested.
 * @pm_state: The target suspend state for the system.
 */
static int acpi_suspend_begin_old(suspend_state_t pm_state)
{}

/*
 * The following callbacks are used if the pre-ACPI 2.0 suspend ordering has
 * been requested.
 */
static const struct platform_suspend_ops acpi_suspend_ops_old =;

static bool s2idle_wakeup;

int acpi_s2idle_begin(void)
{}

int acpi_s2idle_prepare(void)
{}

bool acpi_s2idle_wake(void)
{}

void acpi_s2idle_restore(void)
{}

void acpi_s2idle_end(void)
{}

static const struct platform_s2idle_ops acpi_s2idle_ops =;

void __weak acpi_s2idle_setup(void)
{}

static void __init acpi_sleep_suspend_setup(void)
{}

#else /* !CONFIG_SUSPEND */
#define s2idle_wakeup
static inline void acpi_sleep_suspend_setup(void) {}
#endif /* !CONFIG_SUSPEND */

bool acpi_s2idle_wakeup(void)
{}

#ifdef CONFIG_PM_SLEEP
static u32 saved_bm_rld;

static int  acpi_save_bm_rld(void)
{}

static void  acpi_restore_bm_rld(void)
{}

static struct syscore_ops acpi_sleep_syscore_ops =;

static void acpi_sleep_syscore_init(void)
{}
#else
static inline void acpi_sleep_syscore_init(void) {}
#endif /* CONFIG_PM_SLEEP */

#ifdef CONFIG_HIBERNATION
static unsigned long s4_hardware_signature;
static struct acpi_table_facs *facs;
int acpi_check_s4_hw_signature =; /* Default behaviour is just to warn */

static int acpi_hibernation_begin(pm_message_t stage)
{}

static int acpi_hibernation_enter(void)
{}

static void acpi_hibernation_leave(void)
{}

static void acpi_pm_thaw(void)
{}

static const struct platform_hibernation_ops acpi_hibernation_ops =;

/**
 * acpi_hibernation_begin_old - Set the target system sleep state to
 *	ACPI_STATE_S4 and execute the _PTS control method.  This
 *	function is used if the pre-ACPI 2.0 suspend ordering has been
 *	requested.
 * @stage: The power management event message.
 */
static int acpi_hibernation_begin_old(pm_message_t stage)
{}

/*
 * The following callbacks are used if the pre-ACPI 2.0 suspend ordering has
 * been requested.
 */
static const struct platform_hibernation_ops acpi_hibernation_ops_old =;

static void acpi_sleep_hibernate_setup(void)
{}
#else /* !CONFIG_HIBERNATION */
static inline void acpi_sleep_hibernate_setup(void) {}
#endif /* !CONFIG_HIBERNATION */

static int acpi_power_off_prepare(struct sys_off_data *data)
{}

static int acpi_power_off(struct sys_off_data *data)
{}

int __init acpi_sleep_init(void)
{}