diff options
Diffstat (limited to 'include/linux/acpi.h')
-rw-r--r-- | include/linux/acpi.h | 175 |
1 files changed, 148 insertions, 27 deletions
diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 7235c4851460..054833939995 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h | |||
@@ -49,7 +49,7 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev) | |||
49 | return adev ? adev->handle : NULL; | 49 | return adev ? adev->handle : NULL; |
50 | } | 50 | } |
51 | 51 | ||
52 | #define ACPI_COMPANION(dev) to_acpi_node((dev)->fwnode) | 52 | #define ACPI_COMPANION(dev) to_acpi_device_node((dev)->fwnode) |
53 | #define ACPI_COMPANION_SET(dev, adev) set_primary_fwnode(dev, (adev) ? \ | 53 | #define ACPI_COMPANION_SET(dev, adev) set_primary_fwnode(dev, (adev) ? \ |
54 | acpi_fwnode_handle(adev) : NULL) | 54 | acpi_fwnode_handle(adev) : NULL) |
55 | #define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev)) | 55 | #define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev)) |
@@ -69,7 +69,7 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev) | |||
69 | 69 | ||
70 | static inline bool has_acpi_companion(struct device *dev) | 70 | static inline bool has_acpi_companion(struct device *dev) |
71 | { | 71 | { |
72 | return is_acpi_node(dev->fwnode); | 72 | return is_acpi_device_node(dev->fwnode); |
73 | } | 73 | } |
74 | 74 | ||
75 | static inline void acpi_preset_companion(struct device *dev, | 75 | static inline void acpi_preset_companion(struct device *dev, |
@@ -131,6 +131,12 @@ static inline void acpi_initrd_override(void *data, size_t size) | |||
131 | (!entry) || (unsigned long)entry + sizeof(*entry) > end || \ | 131 | (!entry) || (unsigned long)entry + sizeof(*entry) > end || \ |
132 | ((struct acpi_subtable_header *)entry)->length < sizeof(*entry)) | 132 | ((struct acpi_subtable_header *)entry)->length < sizeof(*entry)) |
133 | 133 | ||
134 | struct acpi_subtable_proc { | ||
135 | int id; | ||
136 | acpi_tbl_entry_handler handler; | ||
137 | int count; | ||
138 | }; | ||
139 | |||
134 | char * __acpi_map_table (unsigned long phys_addr, unsigned long size); | 140 | char * __acpi_map_table (unsigned long phys_addr, unsigned long size); |
135 | void __acpi_unmap_table(char *map, unsigned long size); | 141 | void __acpi_unmap_table(char *map, unsigned long size); |
136 | int early_acpi_boot_init(void); | 142 | int early_acpi_boot_init(void); |
@@ -146,9 +152,16 @@ int __init acpi_parse_entries(char *id, unsigned long table_size, | |||
146 | struct acpi_table_header *table_header, | 152 | struct acpi_table_header *table_header, |
147 | int entry_id, unsigned int max_entries); | 153 | int entry_id, unsigned int max_entries); |
148 | int __init acpi_table_parse_entries(char *id, unsigned long table_size, | 154 | int __init acpi_table_parse_entries(char *id, unsigned long table_size, |
149 | int entry_id, | 155 | int entry_id, |
150 | acpi_tbl_entry_handler handler, | 156 | acpi_tbl_entry_handler handler, |
151 | unsigned int max_entries); | 157 | unsigned int max_entries); |
158 | int __init acpi_table_parse_entries(char *id, unsigned long table_size, | ||
159 | int entry_id, | ||
160 | acpi_tbl_entry_handler handler, | ||
161 | unsigned int max_entries); | ||
162 | int __init acpi_table_parse_entries_array(char *id, unsigned long table_size, | ||
163 | struct acpi_subtable_proc *proc, int proc_num, | ||
164 | unsigned int max_entries); | ||
152 | int acpi_table_parse_madt(enum acpi_madt_type id, | 165 | int acpi_table_parse_madt(enum acpi_madt_type id, |
153 | acpi_tbl_entry_handler handler, | 166 | acpi_tbl_entry_handler handler, |
154 | unsigned int max_entries); | 167 | unsigned int max_entries); |
@@ -193,6 +206,12 @@ int acpi_ioapic_registered(acpi_handle handle, u32 gsi_base); | |||
193 | void acpi_irq_stats_init(void); | 206 | void acpi_irq_stats_init(void); |
194 | extern u32 acpi_irq_handled; | 207 | extern u32 acpi_irq_handled; |
195 | extern u32 acpi_irq_not_handled; | 208 | extern u32 acpi_irq_not_handled; |
209 | extern unsigned int acpi_sci_irq; | ||
210 | #define INVALID_ACPI_IRQ ((unsigned)-1) | ||
211 | static inline bool acpi_sci_irq_valid(void) | ||
212 | { | ||
213 | return acpi_sci_irq != INVALID_ACPI_IRQ; | ||
214 | } | ||
196 | 215 | ||
197 | extern int sbf_port; | 216 | extern int sbf_port; |
198 | extern unsigned long acpi_realmode_flags; | 217 | extern unsigned long acpi_realmode_flags; |
@@ -201,6 +220,9 @@ int acpi_register_gsi (struct device *dev, u32 gsi, int triggering, int polarity | |||
201 | int acpi_gsi_to_irq (u32 gsi, unsigned int *irq); | 220 | int acpi_gsi_to_irq (u32 gsi, unsigned int *irq); |
202 | int acpi_isa_irq_to_gsi (unsigned isa_irq, u32 *gsi); | 221 | int acpi_isa_irq_to_gsi (unsigned isa_irq, u32 *gsi); |
203 | 222 | ||
223 | void acpi_set_irq_model(enum acpi_irq_model_id model, | ||
224 | struct fwnode_handle *fwnode); | ||
225 | |||
204 | #ifdef CONFIG_X86_IO_APIC | 226 | #ifdef CONFIG_X86_IO_APIC |
205 | extern int acpi_get_override_irq(u32 gsi, int *trigger, int *polarity); | 227 | extern int acpi_get_override_irq(u32 gsi, int *trigger, int *polarity); |
206 | #else | 228 | #else |
@@ -217,6 +239,7 @@ struct pci_dev; | |||
217 | 239 | ||
218 | int acpi_pci_irq_enable (struct pci_dev *dev); | 240 | int acpi_pci_irq_enable (struct pci_dev *dev); |
219 | void acpi_penalize_isa_irq(int irq, int active); | 241 | void acpi_penalize_isa_irq(int irq, int active); |
242 | bool acpi_isa_irq_available(int irq); | ||
220 | void acpi_penalize_sci_irq(int irq, int trigger, int polarity); | 243 | void acpi_penalize_sci_irq(int irq, int trigger, int polarity); |
221 | void acpi_pci_irq_disable (struct pci_dev *dev); | 244 | void acpi_pci_irq_disable (struct pci_dev *dev); |
222 | 245 | ||
@@ -461,7 +484,22 @@ static inline bool is_acpi_node(struct fwnode_handle *fwnode) | |||
461 | return false; | 484 | return false; |
462 | } | 485 | } |
463 | 486 | ||
464 | static inline struct acpi_device *to_acpi_node(struct fwnode_handle *fwnode) | 487 | static inline bool is_acpi_device_node(struct fwnode_handle *fwnode) |
488 | { | ||
489 | return false; | ||
490 | } | ||
491 | |||
492 | static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwnode) | ||
493 | { | ||
494 | return NULL; | ||
495 | } | ||
496 | |||
497 | static inline bool is_acpi_data_node(struct fwnode_handle *fwnode) | ||
498 | { | ||
499 | return false; | ||
500 | } | ||
501 | |||
502 | static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode) | ||
465 | { | 503 | { |
466 | return NULL; | 504 | return NULL; |
467 | } | 505 | } |
@@ -476,6 +514,11 @@ static inline bool has_acpi_companion(struct device *dev) | |||
476 | return false; | 514 | return false; |
477 | } | 515 | } |
478 | 516 | ||
517 | static inline void acpi_preset_companion(struct device *dev, | ||
518 | struct acpi_device *parent, u64 addr) | ||
519 | { | ||
520 | } | ||
521 | |||
479 | static inline const char *acpi_dev_name(struct acpi_device *adev) | 522 | static inline const char *acpi_dev_name(struct acpi_device *adev) |
480 | { | 523 | { |
481 | return NULL; | 524 | return NULL; |
@@ -558,11 +601,16 @@ static inline int acpi_device_modalias(struct device *dev, | |||
558 | return -ENODEV; | 601 | return -ENODEV; |
559 | } | 602 | } |
560 | 603 | ||
561 | static inline bool acpi_check_dma(struct acpi_device *adev, bool *coherent) | 604 | static inline bool acpi_dma_supported(struct acpi_device *adev) |
562 | { | 605 | { |
563 | return false; | 606 | return false; |
564 | } | 607 | } |
565 | 608 | ||
609 | static inline enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev) | ||
610 | { | ||
611 | return DEV_DMA_NOT_SUPPORTED; | ||
612 | } | ||
613 | |||
566 | #define ACPI_PTR(_ptr) (NULL) | 614 | #define ACPI_PTR(_ptr) (NULL) |
567 | 615 | ||
568 | #endif /* !CONFIG_ACPI */ | 616 | #endif /* !CONFIG_ACPI */ |
@@ -743,22 +791,76 @@ struct acpi_reference_args { | |||
743 | #ifdef CONFIG_ACPI | 791 | #ifdef CONFIG_ACPI |
744 | int acpi_dev_get_property(struct acpi_device *adev, const char *name, | 792 | int acpi_dev_get_property(struct acpi_device *adev, const char *name, |
745 | acpi_object_type type, const union acpi_object **obj); | 793 | acpi_object_type type, const union acpi_object **obj); |
746 | int acpi_dev_get_property_array(struct acpi_device *adev, const char *name, | 794 | int acpi_node_get_property_reference(struct fwnode_handle *fwnode, |
747 | acpi_object_type type, | 795 | const char *name, size_t index, |
748 | const union acpi_object **obj); | 796 | struct acpi_reference_args *args); |
749 | int acpi_dev_get_property_reference(struct acpi_device *adev, | 797 | |
750 | const char *name, size_t index, | 798 | int acpi_node_prop_get(struct fwnode_handle *fwnode, const char *propname, |
751 | struct acpi_reference_args *args); | 799 | void **valptr); |
752 | |||
753 | int acpi_dev_prop_get(struct acpi_device *adev, const char *propname, | ||
754 | void **valptr); | ||
755 | int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname, | 800 | int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname, |
756 | enum dev_prop_type proptype, void *val); | 801 | enum dev_prop_type proptype, void *val); |
802 | int acpi_node_prop_read(struct fwnode_handle *fwnode, const char *propname, | ||
803 | enum dev_prop_type proptype, void *val, size_t nval); | ||
757 | int acpi_dev_prop_read(struct acpi_device *adev, const char *propname, | 804 | int acpi_dev_prop_read(struct acpi_device *adev, const char *propname, |
758 | enum dev_prop_type proptype, void *val, size_t nval); | 805 | enum dev_prop_type proptype, void *val, size_t nval); |
759 | 806 | ||
760 | struct acpi_device *acpi_get_next_child(struct device *dev, | 807 | struct fwnode_handle *acpi_get_next_subnode(struct device *dev, |
761 | struct acpi_device *child); | 808 | struct fwnode_handle *subnode); |
809 | |||
810 | struct acpi_probe_entry; | ||
811 | typedef bool (*acpi_probe_entry_validate_subtbl)(struct acpi_subtable_header *, | ||
812 | struct acpi_probe_entry *); | ||
813 | |||
814 | #define ACPI_TABLE_ID_LEN 5 | ||
815 | |||
816 | /** | ||
817 | * struct acpi_probe_entry - boot-time probing entry | ||
818 | * @id: ACPI table name | ||
819 | * @type: Optional subtable type to match | ||
820 | * (if @id contains subtables) | ||
821 | * @subtable_valid: Optional callback to check the validity of | ||
822 | * the subtable | ||
823 | * @probe_table: Callback to the driver being probed when table | ||
824 | * match is successful | ||
825 | * @probe_subtbl: Callback to the driver being probed when table and | ||
826 | * subtable match (and optional callback is successful) | ||
827 | * @driver_data: Sideband data provided back to the driver | ||
828 | */ | ||
829 | struct acpi_probe_entry { | ||
830 | __u8 id[ACPI_TABLE_ID_LEN]; | ||
831 | __u8 type; | ||
832 | acpi_probe_entry_validate_subtbl subtable_valid; | ||
833 | union { | ||
834 | acpi_tbl_table_handler probe_table; | ||
835 | acpi_tbl_entry_handler probe_subtbl; | ||
836 | }; | ||
837 | kernel_ulong_t driver_data; | ||
838 | }; | ||
839 | |||
840 | #define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, valid, data, fn) \ | ||
841 | static const struct acpi_probe_entry __acpi_probe_##name \ | ||
842 | __used __section(__##table##_acpi_probe_table) \ | ||
843 | = { \ | ||
844 | .id = table_id, \ | ||
845 | .type = subtable, \ | ||
846 | .subtable_valid = valid, \ | ||
847 | .probe_table = (acpi_tbl_table_handler)fn, \ | ||
848 | .driver_data = data, \ | ||
849 | } | ||
850 | |||
851 | #define ACPI_PROBE_TABLE(name) __##name##_acpi_probe_table | ||
852 | #define ACPI_PROBE_TABLE_END(name) __##name##_acpi_probe_table_end | ||
853 | |||
854 | int __acpi_probe_device_table(struct acpi_probe_entry *start, int nr); | ||
855 | |||
856 | #define acpi_probe_device_table(t) \ | ||
857 | ({ \ | ||
858 | extern struct acpi_probe_entry ACPI_PROBE_TABLE(t), \ | ||
859 | ACPI_PROBE_TABLE_END(t); \ | ||
860 | __acpi_probe_device_table(&ACPI_PROBE_TABLE(t), \ | ||
861 | (&ACPI_PROBE_TABLE_END(t) - \ | ||
862 | &ACPI_PROBE_TABLE(t))); \ | ||
863 | }) | ||
762 | #else | 864 | #else |
763 | static inline int acpi_dev_get_property(struct acpi_device *adev, | 865 | static inline int acpi_dev_get_property(struct acpi_device *adev, |
764 | const char *name, acpi_object_type type, | 866 | const char *name, acpi_object_type type, |
@@ -766,16 +868,17 @@ static inline int acpi_dev_get_property(struct acpi_device *adev, | |||
766 | { | 868 | { |
767 | return -ENXIO; | 869 | return -ENXIO; |
768 | } | 870 | } |
769 | static inline int acpi_dev_get_property_array(struct acpi_device *adev, | 871 | |
770 | const char *name, | 872 | static inline int acpi_node_get_property_reference(struct fwnode_handle *fwnode, |
771 | acpi_object_type type, | 873 | const char *name, const char *cells_name, |
772 | const union acpi_object **obj) | 874 | size_t index, struct acpi_reference_args *args) |
773 | { | 875 | { |
774 | return -ENXIO; | 876 | return -ENXIO; |
775 | } | 877 | } |
776 | static inline int acpi_dev_get_property_reference(struct acpi_device *adev, | 878 | |
777 | const char *name, const char *cells_name, | 879 | static inline int acpi_node_prop_get(struct fwnode_handle *fwnode, |
778 | size_t index, struct acpi_reference_args *args) | 880 | const char *propname, |
881 | void **valptr) | ||
779 | { | 882 | { |
780 | return -ENXIO; | 883 | return -ENXIO; |
781 | } | 884 | } |
@@ -795,6 +898,14 @@ static inline int acpi_dev_prop_read_single(struct acpi_device *adev, | |||
795 | return -ENXIO; | 898 | return -ENXIO; |
796 | } | 899 | } |
797 | 900 | ||
901 | static inline int acpi_node_prop_read(struct fwnode_handle *fwnode, | ||
902 | const char *propname, | ||
903 | enum dev_prop_type proptype, | ||
904 | void *val, size_t nval) | ||
905 | { | ||
906 | return -ENXIO; | ||
907 | } | ||
908 | |||
798 | static inline int acpi_dev_prop_read(struct acpi_device *adev, | 909 | static inline int acpi_dev_prop_read(struct acpi_device *adev, |
799 | const char *propname, | 910 | const char *propname, |
800 | enum dev_prop_type proptype, | 911 | enum dev_prop_type proptype, |
@@ -803,12 +914,22 @@ static inline int acpi_dev_prop_read(struct acpi_device *adev, | |||
803 | return -ENXIO; | 914 | return -ENXIO; |
804 | } | 915 | } |
805 | 916 | ||
806 | static inline struct acpi_device *acpi_get_next_child(struct device *dev, | 917 | static inline struct fwnode_handle *acpi_get_next_subnode(struct device *dev, |
807 | struct acpi_device *child) | 918 | struct fwnode_handle *subnode) |
808 | { | 919 | { |
809 | return NULL; | 920 | return NULL; |
810 | } | 921 | } |
811 | 922 | ||
923 | #define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, validate, data, fn) \ | ||
924 | static const void * __acpi_table_##name[] \ | ||
925 | __attribute__((unused)) \ | ||
926 | = { (void *) table_id, \ | ||
927 | (void *) subtable, \ | ||
928 | (void *) valid, \ | ||
929 | (void *) fn, \ | ||
930 | (void *) data } | ||
931 | |||
932 | #define acpi_probe_device_table(t) ({ int __r = 0; __r;}) | ||
812 | #endif | 933 | #endif |
813 | 934 | ||
814 | #endif /*_LINUX_ACPI_H*/ | 935 | #endif /*_LINUX_ACPI_H*/ |