zfs: fix missing include for disk_partition definition
[oweals/u-boot.git] / include / dm / acpi.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Core ACPI (Advanced Configuration and Power Interface) support
4  *
5  * Copyright 2019 Google LLC
6  * Written by Simon Glass <sjg@chromium.org>
7  */
8
9 #ifndef __DM_ACPI_H__
10 #define __DM_ACPI_H__
11
12 /* Allow operations to be optional for ACPI */
13 #if CONFIG_IS_ENABLED(ACPIGEN)
14 #define ACPI_OPS_PTR(_ptr)      .acpi_ops       = _ptr,
15 #else
16 #define ACPI_OPS_PTR(_ptr)
17 #endif
18
19 /* Length of an ACPI name string, excluding nul terminator */
20 #define ACPI_NAME_LEN   4
21
22 /* Length of an ACPI name string including nul terminator */
23 #define ACPI_NAME_MAX   (ACPI_NAME_LEN + 1)
24
25 #if !defined(__ACPI__)
26
27 /**
28  * struct acpi_ctx - Context used for writing ACPI tables
29  *
30  * This contains a few useful pieces of information used when writing
31  *
32  * @current: Current address for writing
33  * @rsdp: Pointer to the Root System Description Pointer, typically used when
34  *      adding a new table. The RSDP holds pointers to the RSDT and XSDT.
35  * @rsdt: Pointer to the Root System Description Table
36  * @xsdt: Pointer to the Extended System Description Table
37  */
38 struct acpi_ctx {
39         void *current;
40         struct acpi_rsdp *rsdp;
41         struct acpi_rsdt *rsdt;
42         struct acpi_xsdt *xsdt;
43 };
44
45 /**
46  * struct acpi_ops - ACPI operations supported by driver model
47  */
48 struct acpi_ops {
49         /**
50          * get_name() - Obtain the ACPI name of a device
51          *
52          * @dev: Device to check
53          * @out_name: Place to put the name, must hold at least ACPI_NAME_MAX
54          *      bytes
55          * @return 0 if OK, -ENOENT if no name is available, other -ve value on
56          *      other error
57          */
58         int (*get_name)(const struct udevice *dev, char *out_name);
59
60         /**
61          * write_tables() - Write out any tables required by this device
62          *
63          * @dev: Device to write
64          * @ctx: ACPI context to use
65          * @return 0 if OK, -ve on error
66          */
67         int (*write_tables)(const struct udevice *dev, struct acpi_ctx *ctx);
68 };
69
70 #define device_get_acpi_ops(dev)        ((dev)->driver->acpi_ops)
71
72 /**
73  * acpi_get_name() - Obtain the ACPI name of a device
74  *
75  * @dev: Device to check
76  * @out_name: Place to put the name, must hold at least ACPI_NAME_MAX
77  *      bytes
78  * @return 0 if OK, -ENOENT if no name is available, other -ve value on
79  *      other error
80  */
81 int acpi_get_name(const struct udevice *dev, char *out_name);
82
83 /**
84  * acpi_copy_name() - Copy an ACPI name to an output buffer
85  *
86  * This convenience function can be used to return a literal string as a name
87  * in functions that implement the get_name() method.
88  *
89  * For example:
90  *
91  *      static int mydev_get_name(const struct udevice *dev, char *out_name)
92  *      {
93  *              return acpi_copy_name(out_name, "WIBB");
94  *      }
95  *
96  * @out_name: Place to put the name
97  * @name: Name to copy
98  * @return 0 (always)
99  */
100 int acpi_copy_name(char *out_name, const char *name);
101
102 /**
103  * acpi_write_dev_tables() - Write ACPI tables required by devices
104  *
105  * This scans through all devices and tells them to write any tables they want
106  * to write.
107  *
108  * @return 0 if OK, -ve if any device returned an error
109  */
110 int acpi_write_dev_tables(struct acpi_ctx *ctx);
111
112 #endif /* __ACPI__ */
113
114 #endif