aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/acpi.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/acpi.h')
-rw-r--r--include/linux/acpi.h175
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
70static inline bool has_acpi_companion(struct device *dev) 70static 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
75static inline void acpi_preset_companion(struct device *dev, 75static 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
134struct acpi_subtable_proc {
135 int id;
136 acpi_tbl_entry_handler handler;
137 int count;
138};
139
134char * __acpi_map_table (unsigned long phys_addr, unsigned long size); 140char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
135void __acpi_unmap_table(char *map, unsigned long size); 141void __acpi_unmap_table(char *map, unsigned long size);
136int early_acpi_boot_init(void); 142int 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);
148int __init acpi_table_parse_entries(char *id, unsigned long table_size, 154int __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);
158int __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);
162int __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);
152int acpi_table_parse_madt(enum acpi_madt_type id, 165int 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);
193void acpi_irq_stats_init(void); 206void acpi_irq_stats_init(void);
194extern u32 acpi_irq_handled; 207extern u32 acpi_irq_handled;
195extern u32 acpi_irq_not_handled; 208extern u32 acpi_irq_not_handled;
209extern unsigned int acpi_sci_irq;
210#define INVALID_ACPI_IRQ ((unsigned)-1)
211static inline bool acpi_sci_irq_valid(void)
212{
213 return acpi_sci_irq != INVALID_ACPI_IRQ;
214}
196 215
197extern int sbf_port; 216extern int sbf_port;
198extern unsigned long acpi_realmode_flags; 217extern unsigned long acpi_realmode_flags;
@@ -201,6 +220,9 @@ int acpi_register_gsi (struct device *dev, u32 gsi, int triggering, int polarity
201int acpi_gsi_to_irq (u32 gsi, unsigned int *irq); 220int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
202int acpi_isa_irq_to_gsi (unsigned isa_irq, u32 *gsi); 221int acpi_isa_irq_to_gsi (unsigned isa_irq, u32 *gsi);
203 222
223void 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
205extern int acpi_get_override_irq(u32 gsi, int *trigger, int *polarity); 227extern int acpi_get_override_irq(u32 gsi, int *trigger, int *polarity);
206#else 228#else
@@ -217,6 +239,7 @@ struct pci_dev;
217 239
218int acpi_pci_irq_enable (struct pci_dev *dev); 240int acpi_pci_irq_enable (struct pci_dev *dev);
219void acpi_penalize_isa_irq(int irq, int active); 241void acpi_penalize_isa_irq(int irq, int active);
242bool acpi_isa_irq_available(int irq);
220void acpi_penalize_sci_irq(int irq, int trigger, int polarity); 243void acpi_penalize_sci_irq(int irq, int trigger, int polarity);
221void acpi_pci_irq_disable (struct pci_dev *dev); 244void 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
464static inline struct acpi_device *to_acpi_node(struct fwnode_handle *fwnode) 487static inline bool is_acpi_device_node(struct fwnode_handle *fwnode)
488{
489 return false;
490}
491
492static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwnode)
493{
494 return NULL;
495}
496
497static inline bool is_acpi_data_node(struct fwnode_handle *fwnode)
498{
499 return false;
500}
501
502static 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
517static inline void acpi_preset_companion(struct device *dev,
518 struct acpi_device *parent, u64 addr)
519{
520}
521
479static inline const char *acpi_dev_name(struct acpi_device *adev) 522static 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
561static inline bool acpi_check_dma(struct acpi_device *adev, bool *coherent) 604static inline bool acpi_dma_supported(struct acpi_device *adev)
562{ 605{
563 return false; 606 return false;
564} 607}
565 608
609static 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
744int acpi_dev_get_property(struct acpi_device *adev, const char *name, 792int 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);
746int acpi_dev_get_property_array(struct acpi_device *adev, const char *name, 794int 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);
749int acpi_dev_get_property_reference(struct acpi_device *adev, 797
750 const char *name, size_t index, 798int acpi_node_prop_get(struct fwnode_handle *fwnode, const char *propname,
751 struct acpi_reference_args *args); 799 void **valptr);
752
753int acpi_dev_prop_get(struct acpi_device *adev, const char *propname,
754 void **valptr);
755int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname, 800int 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);
802int acpi_node_prop_read(struct fwnode_handle *fwnode, const char *propname,
803 enum dev_prop_type proptype, void *val, size_t nval);
757int acpi_dev_prop_read(struct acpi_device *adev, const char *propname, 804int 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
760struct acpi_device *acpi_get_next_child(struct device *dev, 807struct fwnode_handle *acpi_get_next_subnode(struct device *dev,
761 struct acpi_device *child); 808 struct fwnode_handle *subnode);
809
810struct acpi_probe_entry;
811typedef 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 */
829struct 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
854int __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
763static inline int acpi_dev_get_property(struct acpi_device *adev, 865static 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}
769static inline int acpi_dev_get_property_array(struct acpi_device *adev, 871
770 const char *name, 872static 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}
776static inline int acpi_dev_get_property_reference(struct acpi_device *adev, 878
777 const char *name, const char *cells_name, 879static 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
901static 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
798static inline int acpi_dev_prop_read(struct acpi_device *adev, 909static 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
806static inline struct acpi_device *acpi_get_next_child(struct device *dev, 917static 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*/