hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/acpi.h
....@@ -1,21 +1,8 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * acpi.h - ACPI Interface
34 *
45 * Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
5
- *
6
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
17
- *
18
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
196 */
207
218 #ifndef _LINUX_ACPI_H
....@@ -23,6 +10,7 @@
2310
2411 #include <linux/errno.h>
2512 #include <linux/ioport.h> /* for struct resource */
13
+#include <linux/irqdomain.h>
2614 #include <linux/resource_ext.h>
2715 #include <linux/device.h>
2816 #include <linux/property.h>
....@@ -67,7 +55,7 @@
6755 if (!fwnode)
6856 return NULL;
6957
70
- fwnode->ops = &acpi_static_fwnode_ops;
58
+ fwnode_init(fwnode, &acpi_static_fwnode_ops);
7159
7260 return fwnode;
7361 }
....@@ -141,10 +129,14 @@
141129
142130
143131 /* Table Handlers */
132
+union acpi_subtable_headers {
133
+ struct acpi_subtable_header common;
134
+ struct acpi_hmat_structure hmat;
135
+};
144136
145137 typedef int (*acpi_tbl_table_handler)(struct acpi_table_header *table);
146138
147
-typedef int (*acpi_tbl_entry_handler)(struct acpi_subtable_header *header,
139
+typedef int (*acpi_tbl_entry_handler)(union acpi_subtable_headers *header,
148140 const unsigned long end);
149141
150142 /* Debugger support */
....@@ -291,6 +283,21 @@
291283
292284 /* Validate the processor object's proc_id */
293285 bool acpi_duplicate_processor_id(int proc_id);
286
+/* Processor _CTS control */
287
+struct acpi_processor_power;
288
+
289
+#ifdef CONFIG_ACPI_PROCESSOR_CSTATE
290
+bool acpi_processor_claim_cst_control(void);
291
+int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
292
+ struct acpi_processor_power *info);
293
+#else
294
+static inline bool acpi_processor_claim_cst_control(void) { return false; }
295
+static inline int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
296
+ struct acpi_processor_power *info)
297
+{
298
+ return -ENODEV;
299
+}
300
+#endif
294301
295302 #ifdef CONFIG_ACPI_HOTPLUG_CPU
296303 /* Arch dependent functions for cpu hotplug support */
....@@ -327,6 +334,12 @@
327334 void acpi_set_irq_model(enum acpi_irq_model_id model,
328335 struct fwnode_handle *fwnode);
329336
337
+struct irq_domain *acpi_irq_create_hierarchy(unsigned int flags,
338
+ unsigned int size,
339
+ struct fwnode_handle *fwnode,
340
+ const struct irq_domain_ops *ops,
341
+ void *host_data);
342
+
330343 #ifdef CONFIG_X86_IO_APIC
331344 extern int acpi_get_override_irq(u32 gsi, int *trigger, int *polarity);
332345 #else
....@@ -347,7 +360,14 @@
347360 int acpi_pci_irq_enable (struct pci_dev *dev);
348361 void acpi_penalize_isa_irq(int irq, int active);
349362 bool acpi_isa_irq_available(int irq);
363
+#ifdef CONFIG_PCI
350364 void acpi_penalize_sci_irq(int irq, int trigger, int polarity);
365
+#else
366
+static inline void acpi_penalize_sci_irq(int irq, int trigger,
367
+ int polarity)
368
+{
369
+}
370
+#endif
351371 void acpi_pci_irq_disable (struct pci_dev *dev);
352372
353373 extern int ec_read(u8 addr, u8 *val);
....@@ -376,6 +396,7 @@
376396 extern acpi_status wmi_remove_notify_handler(const char *guid);
377397 extern acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out);
378398 extern bool wmi_has_guid(const char *guid);
399
+extern char *wmi_get_acpi_device_uid(const char *guid);
379400
380401 #endif /* CONFIG_ACPI_WMI */
381402
....@@ -399,10 +420,35 @@
399420 extern bool acpi_osi_is_win8(void);
400421
401422 #ifdef CONFIG_ACPI_NUMA
402
-int acpi_map_pxm_to_online_node(int pxm);
423
+int acpi_map_pxm_to_node(int pxm);
403424 int acpi_get_node(acpi_handle handle);
425
+
426
+/**
427
+ * pxm_to_online_node - Map proximity ID to online node
428
+ * @pxm: ACPI proximity ID
429
+ *
430
+ * This is similar to pxm_to_node(), but always returns an online
431
+ * node. When the mapped node from a given proximity ID is offline, it
432
+ * looks up the node distance table and returns the nearest online node.
433
+ *
434
+ * ACPI device drivers, which are called after the NUMA initialization has
435
+ * completed in the kernel, can call this interface to obtain their device
436
+ * NUMA topology from ACPI tables. Such drivers do not have to deal with
437
+ * offline nodes. A node may be offline when SRAT memory entry does not exist,
438
+ * or NUMA is disabled, ex. "numa=off" on x86.
439
+ */
440
+static inline int pxm_to_online_node(int pxm)
441
+{
442
+ int node = pxm_to_node(pxm);
443
+
444
+ return numa_map_to_online_node(node);
445
+}
404446 #else
405
-static inline int acpi_map_pxm_to_online_node(int pxm)
447
+static inline int pxm_to_online_node(int pxm)
448
+{
449
+ return 0;
450
+}
451
+static inline int acpi_map_pxm_to_node(int pxm)
406452 {
407453 return 0;
408454 }
....@@ -466,6 +512,11 @@
466512 void __init acpi_sleep_no_blacklist(void);
467513 #endif /* CONFIG_PM_SLEEP */
468514
515
+int acpi_register_wakeup_handler(
516
+ int wake_irq, bool (*wakeup)(void *context), void *context);
517
+void acpi_unregister_wakeup_handler(
518
+ bool (*wakeup)(void *context), void *context);
519
+
469520 struct acpi_osc_context {
470521 char *uuid_str; /* UUID string */
471522 int rev;
....@@ -498,6 +549,7 @@
498549 #define OSC_SB_PCLPI_SUPPORT 0x00000080
499550 #define OSC_SB_OSLPI_SUPPORT 0x00000100
500551 #define OSC_SB_CPC_DIVERSE_HIGH_SUPPORT 0x00001000
552
+#define OSC_SB_GENERIC_INITIATOR_SUPPORT 0x00002000
501553
502554 extern bool osc_sb_apei_support_acked;
503555 extern bool osc_pc_lpi_support_confirmed;
....@@ -508,7 +560,9 @@
508560 #define OSC_PCI_CLOCK_PM_SUPPORT 0x00000004
509561 #define OSC_PCI_SEGMENT_GROUPS_SUPPORT 0x00000008
510562 #define OSC_PCI_MSI_SUPPORT 0x00000010
511
-#define OSC_PCI_SUPPORT_MASKS 0x0000001f
563
+#define OSC_PCI_EDR_SUPPORT 0x00000080
564
+#define OSC_PCI_HPX_TYPE_3_SUPPORT 0x00000100
565
+#define OSC_PCI_SUPPORT_MASKS 0x0000019f
512566
513567 /* PCI Host Bridge _OSC: Capabilities DWORD 3: Control Field */
514568 #define OSC_PCI_EXPRESS_NATIVE_HP_CONTROL 0x00000001
....@@ -517,7 +571,8 @@
517571 #define OSC_PCI_EXPRESS_AER_CONTROL 0x00000008
518572 #define OSC_PCI_EXPRESS_CAPABILITY_CONTROL 0x00000010
519573 #define OSC_PCI_EXPRESS_LTR_CONTROL 0x00000020
520
-#define OSC_PCI_CONTROL_MASKS 0x0000003f
574
+#define OSC_PCI_EXPRESS_DPC_CONTROL 0x00000080
575
+#define OSC_PCI_CONTROL_MASKS 0x000000bf
521576
522577 #define ACPI_GSB_ACCESS_ATTRIB_QUICK 0x00000002
523578 #define ACPI_GSB_ACCESS_ATTRIB_SEND_RCV 0x00000004
....@@ -635,6 +690,12 @@
635690 int acpi_arch_timer_mem_init(struct arch_timer_mem *timer_mem, int *timer_count);
636691 #endif
637692
693
+#ifndef ACPI_HAVE_ARCH_SET_ROOT_POINTER
694
+static inline void acpi_arch_set_root_pointer(u64 addr)
695
+{
696
+}
697
+#endif
698
+
638699 #ifndef ACPI_HAVE_ARCH_GET_ROOT_POINTER
639700 static inline u64 acpi_arch_get_root_pointer(void)
640701 {
....@@ -652,6 +713,8 @@
652713 #define ACPI_HANDLE_FWNODE(fwnode) (NULL)
653714 #define ACPI_DEVICE_CLASS(_cls, _msk) .cls = (0), .cls_msk = (0),
654715
716
+#include <acpi/acpi_numa.h>
717
+
655718 struct fwnode_handle;
656719
657720 static inline bool acpi_dev_found(const char *hid)
....@@ -664,11 +727,21 @@
664727 return false;
665728 }
666729
667
-static inline const char *
668
-acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv)
730
+struct acpi_device;
731
+
732
+static inline bool
733
+acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2)
734
+{
735
+ return false;
736
+}
737
+
738
+static inline struct acpi_device *
739
+acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
669740 {
670741 return NULL;
671742 }
743
+
744
+static inline void acpi_dev_put(struct acpi_device *adev) {}
672745
673746 static inline bool is_acpi_node(struct fwnode_handle *fwnode)
674747 {
....@@ -801,7 +874,7 @@
801874
802875 static inline union acpi_object *acpi_evaluate_dsm(acpi_handle handle,
803876 const guid_t *guid,
804
- int rev, int func,
877
+ u64 rev, u64 func,
805878 union acpi_object *argv4)
806879 {
807880 return NULL;
....@@ -848,7 +921,12 @@
848921 return 0;
849922 }
850923
851
-static inline void acpi_dma_deconfigure(struct device *dev) { }
924
+static inline int acpi_dma_configure_id(struct device *dev,
925
+ enum dev_dma_attr attr,
926
+ const u32 *input_id)
927
+{
928
+ return 0;
929
+}
852930
853931 #define ACPI_PTR(_ptr) (NULL)
854932
....@@ -875,6 +953,15 @@
875953 return NULL;
876954 }
877955
956
+static inline int acpi_register_wakeup_handler(int wake_irq,
957
+ bool (*wakeup)(void *context), void *context)
958
+{
959
+ return -ENXIO;
960
+}
961
+
962
+static inline void acpi_unregister_wakeup_handler(
963
+ bool (*wakeup)(void *context), void *context) { }
964
+
878965 #endif /* !CONFIG_ACPI */
879966
880967 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
....@@ -896,7 +983,7 @@
896983 acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state,
897984 u32 val_a, u32 val_b);
898985
899
-#ifdef CONFIG_X86
986
+#ifndef CONFIG_IA64
900987 void arch_reserve_mem_area(acpi_physical_address addr, size_t size);
901988 #else
902989 static inline void arch_reserve_mem_area(acpi_physical_address addr,
....@@ -915,8 +1002,6 @@
9151002 int acpi_subsys_runtime_resume(struct device *dev);
9161003 int acpi_dev_pm_attach(struct device *dev, bool power_on);
9171004 #else
918
-static inline int acpi_dev_runtime_suspend(struct device *dev) { return 0; }
919
-static inline int acpi_dev_runtime_resume(struct device *dev) { return 0; }
9201005 static inline int acpi_subsys_runtime_suspend(struct device *dev) { return 0; }
9211006 static inline int acpi_subsys_runtime_resume(struct device *dev) { return 0; }
9221007 static inline int acpi_dev_pm_attach(struct device *dev, bool power_on)
....@@ -926,7 +1011,6 @@
9261011 #endif
9271012
9281013 #if defined(CONFIG_ACPI) && defined(CONFIG_PM_SLEEP)
929
-int acpi_dev_suspend_late(struct device *dev);
9301014 int acpi_subsys_prepare(struct device *dev);
9311015 void acpi_subsys_complete(struct device *dev);
9321016 int acpi_subsys_suspend_late(struct device *dev);
....@@ -934,8 +1018,9 @@
9341018 int acpi_subsys_suspend(struct device *dev);
9351019 int acpi_subsys_freeze(struct device *dev);
9361020 int acpi_subsys_poweroff(struct device *dev);
1021
+void acpi_ec_mark_gpe_for_wake(void);
1022
+void acpi_ec_set_gpe_wake_mask(u8 action);
9371023 #else
938
-static inline int acpi_dev_resume_early(struct device *dev) { return 0; }
9391024 static inline int acpi_subsys_prepare(struct device *dev) { return 0; }
9401025 static inline void acpi_subsys_complete(struct device *dev) {}
9411026 static inline int acpi_subsys_suspend_late(struct device *dev) { return 0; }
....@@ -943,6 +1028,8 @@
9431028 static inline int acpi_subsys_suspend(struct device *dev) { return 0; }
9441029 static inline int acpi_subsys_freeze(struct device *dev) { return 0; }
9451030 static inline int acpi_subsys_poweroff(struct device *dev) { return 0; }
1031
+static inline void acpi_ec_mark_gpe_for_wake(void) {}
1032
+static inline void acpi_ec_set_gpe_wake_mask(u8 action) {}
9461033 #endif
9471034
9481035 #ifdef CONFIG_ACPI
....@@ -957,9 +1044,6 @@
9571044 #if defined(CONFIG_ACPI) && defined(CONFIG_DYNAMIC_DEBUG)
9581045 __printf(3, 4)
9591046 void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const char *fmt, ...);
960
-#else
961
-#define __acpi_handle_debug(descriptor, handle, fmt, ...) \
962
- acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__);
9631047 #endif
9641048
9651049 /*
....@@ -989,12 +1073,8 @@
9891073 #else
9901074 #if defined(CONFIG_DYNAMIC_DEBUG)
9911075 #define acpi_handle_debug(handle, fmt, ...) \
992
-do { \
993
- DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
994
- if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT)) \
995
- __acpi_handle_debug(&descriptor, handle, pr_fmt(fmt), \
996
- ##__VA_ARGS__); \
997
-} while (0)
1076
+ _dynamic_func_call(fmt, __acpi_handle_debug, \
1077
+ handle, pr_fmt(fmt), ##__VA_ARGS__)
9981078 #else
9991079 #define acpi_handle_debug(handle, fmt, ...) \
10001080 ({ \
....@@ -1005,65 +1085,27 @@
10051085 #endif
10061086 #endif
10071087
1008
-struct acpi_gpio_params {
1009
- unsigned int crs_entry_index;
1010
- unsigned int line_index;
1011
- bool active_low;
1012
-};
1013
-
1014
-struct acpi_gpio_mapping {
1015
- const char *name;
1016
- const struct acpi_gpio_params *data;
1017
- unsigned int size;
1018
-
1019
-/* Ignore IoRestriction field */
1020
-#define ACPI_GPIO_QUIRK_NO_IO_RESTRICTION BIT(0)
1021
-
1022
- unsigned int quirks;
1023
-};
1024
-
10251088 #if defined(CONFIG_ACPI) && defined(CONFIG_GPIOLIB)
1026
-int acpi_dev_add_driver_gpios(struct acpi_device *adev,
1027
- const struct acpi_gpio_mapping *gpios);
1028
-
1029
-static inline void acpi_dev_remove_driver_gpios(struct acpi_device *adev)
1030
-{
1031
- if (adev)
1032
- adev->driver_gpios = NULL;
1033
-}
1034
-
1035
-int devm_acpi_dev_add_driver_gpios(struct device *dev,
1036
- const struct acpi_gpio_mapping *gpios);
1037
-void devm_acpi_dev_remove_driver_gpios(struct device *dev);
1038
-
10391089 bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
10401090 struct acpi_resource_gpio **agpio);
1041
-int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index);
1091
+int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int index);
10421092 #else
1043
-static inline int acpi_dev_add_driver_gpios(struct acpi_device *adev,
1044
- const struct acpi_gpio_mapping *gpios)
1045
-{
1046
- return -ENXIO;
1047
-}
1048
-static inline void acpi_dev_remove_driver_gpios(struct acpi_device *adev) {}
1049
-
1050
-static inline int devm_acpi_dev_add_driver_gpios(struct device *dev,
1051
- const struct acpi_gpio_mapping *gpios)
1052
-{
1053
- return -ENXIO;
1054
-}
1055
-static inline void devm_acpi_dev_remove_driver_gpios(struct device *dev) {}
1056
-
10571093 static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
10581094 struct acpi_resource_gpio **agpio)
10591095 {
10601096 return false;
10611097 }
1062
-static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
1098
+static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev,
1099
+ const char *name, int index)
10631100 {
10641101 return -ENXIO;
10651102 }
10661103 #endif
1104
+
1105
+static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
1106
+{
1107
+ return acpi_dev_gpio_irq_get_by(adev, NULL, index);
1108
+}
10671109
10681110 /* Device properties */
10691111
....@@ -1082,6 +1124,15 @@
10821124 return __acpi_node_get_property_reference(fwnode, name, index,
10831125 NR_FWNODE_REFERENCE_ARGS, args);
10841126 }
1127
+
1128
+static inline bool acpi_dev_has_props(const struct acpi_device *adev)
1129
+{
1130
+ return !list_empty(&adev->data.properties);
1131
+}
1132
+
1133
+struct acpi_device_properties *
1134
+acpi_data_add_props(struct acpi_device_data *data, const guid_t *guid,
1135
+ const union acpi_object *properties);
10851136
10861137 int acpi_node_prop_get(const struct fwnode_handle *fwnode, const char *propname,
10871138 void **valptr);
....@@ -1128,16 +1179,27 @@
11281179 kernel_ulong_t driver_data;
11291180 };
11301181
1131
-#define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, valid, data, fn) \
1182
+#define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, \
1183
+ valid, data, fn) \
11321184 static const struct acpi_probe_entry __acpi_probe_##name \
1133
- __used __section(__##table##_acpi_probe_table) \
1134
- = { \
1185
+ __used __section("__" #table "_acpi_probe_table") = { \
11351186 .id = table_id, \
11361187 .type = subtable, \
11371188 .subtable_valid = valid, \
1138
- .probe_table = (acpi_tbl_table_handler)fn, \
1139
- .driver_data = data, \
1140
- }
1189
+ .probe_table = fn, \
1190
+ .driver_data = data, \
1191
+ }
1192
+
1193
+#define ACPI_DECLARE_SUBTABLE_PROBE_ENTRY(table, name, table_id, \
1194
+ subtable, valid, data, fn) \
1195
+ static const struct acpi_probe_entry __acpi_probe_##name \
1196
+ __used __section("__" #table "_acpi_probe_table") = { \
1197
+ .id = table_id, \
1198
+ .type = subtable, \
1199
+ .subtable_valid = valid, \
1200
+ .probe_subtbl = fn, \
1201
+ .driver_data = data, \
1202
+ }
11411203
11421204 #define ACPI_PROBE_TABLE(name) __##name##_acpi_probe_table
11431205 #define ACPI_PROBE_TABLE_END(name) __##name##_acpi_probe_table_end
....@@ -1179,13 +1241,6 @@
11791241 static inline int acpi_node_prop_get(const struct fwnode_handle *fwnode,
11801242 const char *propname,
11811243 void **valptr)
1182
-{
1183
- return -ENXIO;
1184
-}
1185
-
1186
-static inline int acpi_dev_prop_get(const struct acpi_device *adev,
1187
- const char *propname,
1188
- void **valptr)
11891244 {
11901245 return -ENXIO;
11911246 }
....@@ -1300,6 +1355,7 @@
13001355 int acpi_pptt_cpu_is_thread(unsigned int cpu);
13011356 int find_acpi_cpu_topology(unsigned int cpu, int level);
13021357 int find_acpi_cpu_topology_package(unsigned int cpu);
1358
+int find_acpi_cpu_topology_hetero_id(unsigned int cpu);
13031359 int find_acpi_cpu_cache_topology(unsigned int cpu, int level);
13041360 #else
13051361 static inline int acpi_pptt_cpu_is_thread(unsigned int cpu)
....@@ -1314,10 +1370,24 @@
13141370 {
13151371 return -EINVAL;
13161372 }
1373
+static inline int find_acpi_cpu_topology_hetero_id(unsigned int cpu)
1374
+{
1375
+ return -EINVAL;
1376
+}
13171377 static inline int find_acpi_cpu_cache_topology(unsigned int cpu, int level)
13181378 {
13191379 return -EINVAL;
13201380 }
13211381 #endif
13221382
1383
+#ifdef CONFIG_ACPI
1384
+extern int acpi_platform_notify(struct device *dev, enum kobject_action action);
1385
+#else
1386
+static inline int
1387
+acpi_platform_notify(struct device *dev, enum kobject_action action)
1388
+{
1389
+ return 0;
1390
+}
1391
+#endif
1392
+
13231393 #endif /*_LINUX_ACPI_H*/