diff options
author | Tom Rini <trini@konsulko.com> | 2020-04-16 08:56:37 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-04-16 08:56:37 -0400 |
commit | dba0a6ae1907bbff3ebda06e4874d006f10db1bb (patch) | |
tree | 61d65db08c42dcf0d64d8c084c026d52c9beb3af /include/dm/acpi.h | |
parent | 66b8669d7709cecedf2e0403bb17b48bab86f644 (diff) | |
parent | 1f4431e46120ef913fc9f83c78a734d910d00b3f (diff) |
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-x86
- Provide serial base clock speed via getinfo() for ACPI SPCR
- Initial ACPI support from DM core by leveraging existing ACPI support
in x86
Diffstat (limited to 'include/dm/acpi.h')
-rw-r--r-- | include/dm/acpi.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/include/dm/acpi.h b/include/dm/acpi.h new file mode 100644 index 0000000000..49257914ff --- /dev/null +++ b/include/dm/acpi.h @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Core ACPI (Advanced Configuration and Power Interface) support + * + * Copyright 2019 Google LLC + * Written by Simon Glass <sjg@chromium.org> + */ + +#ifndef __DM_ACPI_H__ +#define __DM_ACPI_H__ + +/* Allow operations to be optional for ACPI */ +#if CONFIG_IS_ENABLED(ACPIGEN) +#define ACPI_OPS_PTR(_ptr) .acpi_ops = _ptr, +#else +#define ACPI_OPS_PTR(_ptr) +#endif + +/* Length of an ACPI name string, excluding nul terminator */ +#define ACPI_NAME_LEN 4 + +/* Length of an ACPI name string including nul terminator */ +#define ACPI_NAME_MAX (ACPI_NAME_LEN + 1) + +#if !defined(__ACPI__) + +/** + * struct acpi_ops - ACPI operations supported by driver model + */ +struct acpi_ops { + /** + * get_name() - Obtain the ACPI name of a device + * + * @dev: Device to check + * @out_name: Place to put the name, must hold at least ACPI_NAME_MAX + * bytes + * @return 0 if OK, -ENOENT if no name is available, other -ve value on + * other error + */ + int (*get_name)(const struct udevice *dev, char *out_name); +}; + +#define device_get_acpi_ops(dev) ((dev)->driver->acpi_ops) + +/** + * acpi_get_name() - Obtain the ACPI name of a device + * + * @dev: Device to check + * @out_name: Place to put the name, must hold at least ACPI_NAME_MAX + * bytes + * @return 0 if OK, -ENOENT if no name is available, other -ve value on + * other error + */ +int acpi_get_name(const struct udevice *dev, char *out_name); + +/** + * acpi_copy_name() - Copy an ACPI name to an output buffer + * + * This convenience function can be used to return a literal string as a name + * in functions that implement the get_name() method. + * + * For example: + * + * static int mydev_get_name(const struct udevice *dev, char *out_name) + * { + * return acpi_copy_name(out_name, "WIBB"); + * } + * + * @out_name: Place to put the name + * @name: Name to copy + * @return 0 (always) + */ +int acpi_copy_name(char *out_name, const char *name); + +#endif /* __ACPI__ */ + +#endif |