linux/drivers/acpi/power.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * drivers/acpi/power.c - ACPI Power Resources management.
 *
 * Copyright (C) 2001 - 2015 Intel Corp.
 * Author: Andy Grover <[email protected]>
 * Author: Paul Diefenbaugh <[email protected]>
 * Author: Rafael J. Wysocki <[email protected]>
 */

/*
 * ACPI power-managed devices may be controlled in two ways:
 * 1. via "Device Specific (D-State) Control"
 * 2. via "Power Resource Control".
 * The code below deals with ACPI Power Resources control.
 *
 * An ACPI "power resource object" represents a software controllable power
 * plane, clock plane, or other resource depended on by a device.
 *
 * A device may rely on multiple power resources, and a power resource
 * may be shared by multiple devices.
 */

#define pr_fmt(fmt)

#include <linux/dmi.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/types.h>
#include <linux/slab.h>
#include <linux/pm_runtime.h>
#include <linux/sysfs.h>
#include <linux/acpi.h>
#include "sleep.h"
#include "internal.h"

#define ACPI_POWER_CLASS
#define ACPI_POWER_DEVICE_NAME
#define ACPI_POWER_RESOURCE_STATE_OFF
#define ACPI_POWER_RESOURCE_STATE_ON
#define ACPI_POWER_RESOURCE_STATE_UNKNOWN

struct acpi_power_dependent_device {};

struct acpi_power_resource {};

struct acpi_power_resource_entry {};

static LIST_HEAD(acpi_power_resource_list);
static DEFINE_MUTEX(power_resource_list_lock);

/* --------------------------------------------------------------------------
                             Power Resource Management
   -------------------------------------------------------------------------- */

static inline const char *resource_dev_name(struct acpi_power_resource *pr)
{}

static inline
struct acpi_power_resource *to_power_resource(struct acpi_device *device)
{}

static struct acpi_power_resource *acpi_power_get_context(acpi_handle handle)
{}

static int acpi_power_resources_list_add(acpi_handle handle,
					 struct list_head *list)
{}

void acpi_power_resources_list_free(struct list_head *list)
{}

static bool acpi_power_resource_is_dup(union acpi_object *package,
				       unsigned int start, unsigned int i)
{}

int acpi_extract_power_resources(union acpi_object *package, unsigned int start,
				 struct list_head *list)
{}

static int __get_state(acpi_handle handle, u8 *state)
{}

static int acpi_power_get_state(struct acpi_power_resource *resource, u8 *state)
{}

static int acpi_power_get_list_state(struct list_head *list, u8 *state)
{}

static int
acpi_power_resource_add_dependent(struct acpi_power_resource *resource,
				  struct device *dev)
{}

static void
acpi_power_resource_remove_dependent(struct acpi_power_resource *resource,
				     struct device *dev)
{}

/**
 * acpi_device_power_add_dependent - Add dependent device of this ACPI device
 * @adev: ACPI device pointer
 * @dev: Dependent device
 *
 * If @adev has non-empty _PR0 the @dev is added as dependent device to all
 * power resources returned by it. This means that whenever these power
 * resources are turned _ON the dependent devices get runtime resumed. This
 * is needed for devices such as PCI to allow its driver to re-initialize
 * it after it went to D0uninitialized.
 *
 * If @adev does not have _PR0 this does nothing.
 *
 * Returns %0 in case of success and negative errno otherwise.
 */
int acpi_device_power_add_dependent(struct acpi_device *adev,
				    struct device *dev)
{}

/**
 * acpi_device_power_remove_dependent - Remove dependent device
 * @adev: ACPI device pointer
 * @dev: Dependent device
 *
 * Does the opposite of acpi_device_power_add_dependent() and removes the
 * dependent device if it is found. Can be called to @adev that does not
 * have _PR0 as well.
 */
void acpi_device_power_remove_dependent(struct acpi_device *adev,
					struct device *dev)
{}

static int __acpi_power_on(struct acpi_power_resource *resource)
{}

static int acpi_power_on_unlocked(struct acpi_power_resource *resource)
{}

static int acpi_power_on(struct acpi_power_resource *resource)
{}

static int __acpi_power_off(struct acpi_power_resource *resource)
{}

static int acpi_power_off_unlocked(struct acpi_power_resource *resource)
{}

static int acpi_power_off(struct acpi_power_resource *resource)
{}

static int acpi_power_off_list(struct list_head *list)
{}

static int acpi_power_on_list(struct list_head *list)
{}

static struct attribute *attrs[] =;

static const struct attribute_group attr_groups[] =;

static const struct attribute_group wakeup_attr_group =;

static void acpi_power_hide_list(struct acpi_device *adev,
				 struct list_head *resources,
				 const struct attribute_group *attr_group)
{}

static void acpi_power_expose_list(struct acpi_device *adev,
				   struct list_head *resources,
				   const struct attribute_group *attr_group)
{}

static void acpi_power_expose_hide(struct acpi_device *adev,
				   struct list_head *resources,
				   const struct attribute_group *attr_group,
				   bool expose)
{}

void acpi_power_add_remove_device(struct acpi_device *adev, bool add)
{}

int acpi_power_wakeup_list_init(struct list_head *list, int *system_level_p)
{}

/* --------------------------------------------------------------------------
                             Device Power Management
   -------------------------------------------------------------------------- */

/**
 * acpi_device_sleep_wake - execute _DSW (Device Sleep Wake) or (deprecated in
 *                          ACPI 3.0) _PSW (Power State Wake)
 * @dev: Device to handle.
 * @enable: 0 - disable, 1 - enable the wake capabilities of the device.
 * @sleep_state: Target sleep state of the system.
 * @dev_state: Target power state of the device.
 *
 * Execute _DSW (Device Sleep Wake) or (deprecated in ACPI 3.0) _PSW (Power
 * State Wake) for the device, if present.  On failure reset the device's
 * wakeup.flags.valid flag.
 *
 * RETURN VALUE:
 * 0 if either _DSW or _PSW has been successfully executed
 * 0 if neither _DSW nor _PSW has been found
 * -ENODEV if the execution of either _DSW or _PSW has failed
 */
int acpi_device_sleep_wake(struct acpi_device *dev,
			   int enable, int sleep_state, int dev_state)
{}

/*
 * Prepare a wakeup device, two steps (Ref ACPI 2.0:P229):
 * 1. Power on the power resources required for the wakeup device
 * 2. Execute _DSW (Device Sleep Wake) or (deprecated in ACPI 3.0) _PSW (Power
 *    State Wake) for the device, if present
 */
int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
{}

/*
 * Shutdown a wakeup device, counterpart of above method
 * 1. Execute _DSW (Device Sleep Wake) or (deprecated in ACPI 3.0) _PSW (Power
 *    State Wake) for the device, if present
 * 2. Shutdown down the power resources
 */
int acpi_disable_wakeup_device_power(struct acpi_device *dev)
{}

int acpi_power_get_inferred_state(struct acpi_device *device, int *state)
{}

int acpi_power_on_resources(struct acpi_device *device, int state)
{}

int acpi_power_transition(struct acpi_device *device, int state)
{}

static void acpi_release_power_resource(struct device *dev)
{}

static ssize_t resource_in_use_show(struct device *dev,
				    struct device_attribute *attr,
				    char *buf)
{}
static DEVICE_ATTR_RO(resource_in_use);

static void acpi_power_sysfs_remove(struct acpi_device *device)
{}

static void acpi_power_add_resource_to_list(struct acpi_power_resource *resource)
{}

struct acpi_device *acpi_add_power_resource(acpi_handle handle)
{}

#ifdef CONFIG_ACPI_SLEEP
void acpi_resume_power_resources(void)
{}
#endif

static const struct dmi_system_id dmi_leave_unused_power_resources_on[] =;

/**
 * acpi_turn_off_unused_power_resources - Turn off power resources not in use.
 */
void acpi_turn_off_unused_power_resources(void)
{}