hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
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,
....@@ -914,19 +1001,21 @@
9141001 int acpi_subsys_runtime_suspend(struct device *dev);
9151002 int acpi_subsys_runtime_resume(struct device *dev);
9161003 int acpi_dev_pm_attach(struct device *dev, bool power_on);
1004
+bool acpi_storage_d3(struct device *dev);
9171005 #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; }
9201006 static inline int acpi_subsys_runtime_suspend(struct device *dev) { return 0; }
9211007 static inline int acpi_subsys_runtime_resume(struct device *dev) { return 0; }
9221008 static inline int acpi_dev_pm_attach(struct device *dev, bool power_on)
9231009 {
9241010 return 0;
9251011 }
1012
+static inline bool acpi_storage_d3(struct device *dev)
1013
+{
1014
+ return false;
1015
+}
9261016 #endif
9271017
9281018 #if defined(CONFIG_ACPI) && defined(CONFIG_PM_SLEEP)
929
-int acpi_dev_suspend_late(struct device *dev);
9301019 int acpi_subsys_prepare(struct device *dev);
9311020 void acpi_subsys_complete(struct device *dev);
9321021 int acpi_subsys_suspend_late(struct device *dev);
....@@ -934,8 +1023,9 @@
9341023 int acpi_subsys_suspend(struct device *dev);
9351024 int acpi_subsys_freeze(struct device *dev);
9361025 int acpi_subsys_poweroff(struct device *dev);
1026
+void acpi_ec_mark_gpe_for_wake(void);
1027
+void acpi_ec_set_gpe_wake_mask(u8 action);
9371028 #else
938
-static inline int acpi_dev_resume_early(struct device *dev) { return 0; }
9391029 static inline int acpi_subsys_prepare(struct device *dev) { return 0; }
9401030 static inline void acpi_subsys_complete(struct device *dev) {}
9411031 static inline int acpi_subsys_suspend_late(struct device *dev) { return 0; }
....@@ -943,6 +1033,8 @@
9431033 static inline int acpi_subsys_suspend(struct device *dev) { return 0; }
9441034 static inline int acpi_subsys_freeze(struct device *dev) { return 0; }
9451035 static inline int acpi_subsys_poweroff(struct device *dev) { return 0; }
1036
+static inline void acpi_ec_mark_gpe_for_wake(void) {}
1037
+static inline void acpi_ec_set_gpe_wake_mask(u8 action) {}
9461038 #endif
9471039
9481040 #ifdef CONFIG_ACPI
....@@ -957,9 +1049,6 @@
9571049 #if defined(CONFIG_ACPI) && defined(CONFIG_DYNAMIC_DEBUG)
9581050 __printf(3, 4)
9591051 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__);
9631052 #endif
9641053
9651054 /*
....@@ -989,12 +1078,8 @@
9891078 #else
9901079 #if defined(CONFIG_DYNAMIC_DEBUG)
9911080 #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)
1081
+ _dynamic_func_call(fmt, __acpi_handle_debug, \
1082
+ handle, pr_fmt(fmt), ##__VA_ARGS__)
9981083 #else
9991084 #define acpi_handle_debug(handle, fmt, ...) \
10001085 ({ \
....@@ -1005,65 +1090,27 @@
10051090 #endif
10061091 #endif
10071092
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
-
10251093 #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
-
10391094 bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
10401095 struct acpi_resource_gpio **agpio);
1041
-int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index);
1096
+int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int index);
10421097 #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
-
10571098 static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
10581099 struct acpi_resource_gpio **agpio)
10591100 {
10601101 return false;
10611102 }
1062
-static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
1103
+static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev,
1104
+ const char *name, int index)
10631105 {
10641106 return -ENXIO;
10651107 }
10661108 #endif
1109
+
1110
+static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
1111
+{
1112
+ return acpi_dev_gpio_irq_get_by(adev, NULL, index);
1113
+}
10671114
10681115 /* Device properties */
10691116
....@@ -1082,6 +1129,15 @@
10821129 return __acpi_node_get_property_reference(fwnode, name, index,
10831130 NR_FWNODE_REFERENCE_ARGS, args);
10841131 }
1132
+
1133
+static inline bool acpi_dev_has_props(const struct acpi_device *adev)
1134
+{
1135
+ return !list_empty(&adev->data.properties);
1136
+}
1137
+
1138
+struct acpi_device_properties *
1139
+acpi_data_add_props(struct acpi_device_data *data, const guid_t *guid,
1140
+ const union acpi_object *properties);
10851141
10861142 int acpi_node_prop_get(const struct fwnode_handle *fwnode, const char *propname,
10871143 void **valptr);
....@@ -1128,16 +1184,27 @@
11281184 kernel_ulong_t driver_data;
11291185 };
11301186
1131
-#define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, valid, data, fn) \
1187
+#define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, \
1188
+ valid, data, fn) \
11321189 static const struct acpi_probe_entry __acpi_probe_##name \
1133
- __used __section(__##table##_acpi_probe_table) \
1134
- = { \
1190
+ __used __section("__" #table "_acpi_probe_table") = { \
11351191 .id = table_id, \
11361192 .type = subtable, \
11371193 .subtable_valid = valid, \
1138
- .probe_table = (acpi_tbl_table_handler)fn, \
1139
- .driver_data = data, \
1140
- }
1194
+ .probe_table = fn, \
1195
+ .driver_data = data, \
1196
+ }
1197
+
1198
+#define ACPI_DECLARE_SUBTABLE_PROBE_ENTRY(table, name, table_id, \
1199
+ subtable, valid, data, fn) \
1200
+ static const struct acpi_probe_entry __acpi_probe_##name \
1201
+ __used __section("__" #table "_acpi_probe_table") = { \
1202
+ .id = table_id, \
1203
+ .type = subtable, \
1204
+ .subtable_valid = valid, \
1205
+ .probe_subtbl = fn, \
1206
+ .driver_data = data, \
1207
+ }
11411208
11421209 #define ACPI_PROBE_TABLE(name) __##name##_acpi_probe_table
11431210 #define ACPI_PROBE_TABLE_END(name) __##name##_acpi_probe_table_end
....@@ -1179,13 +1246,6 @@
11791246 static inline int acpi_node_prop_get(const struct fwnode_handle *fwnode,
11801247 const char *propname,
11811248 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)
11891249 {
11901250 return -ENXIO;
11911251 }
....@@ -1300,6 +1360,7 @@
13001360 int acpi_pptt_cpu_is_thread(unsigned int cpu);
13011361 int find_acpi_cpu_topology(unsigned int cpu, int level);
13021362 int find_acpi_cpu_topology_package(unsigned int cpu);
1363
+int find_acpi_cpu_topology_hetero_id(unsigned int cpu);
13031364 int find_acpi_cpu_cache_topology(unsigned int cpu, int level);
13041365 #else
13051366 static inline int acpi_pptt_cpu_is_thread(unsigned int cpu)
....@@ -1314,10 +1375,24 @@
13141375 {
13151376 return -EINVAL;
13161377 }
1378
+static inline int find_acpi_cpu_topology_hetero_id(unsigned int cpu)
1379
+{
1380
+ return -EINVAL;
1381
+}
13171382 static inline int find_acpi_cpu_cache_topology(unsigned int cpu, int level)
13181383 {
13191384 return -EINVAL;
13201385 }
13211386 #endif
13221387
1388
+#ifdef CONFIG_ACPI
1389
+extern int acpi_platform_notify(struct device *dev, enum kobject_action action);
1390
+#else
1391
+static inline int
1392
+acpi_platform_notify(struct device *dev, enum kobject_action action)
1393
+{
1394
+ return 0;
1395
+}
1396
+#endif
1397
+
13231398 #endif /*_LINUX_ACPI_H*/