]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - include/linux/acpi.h
Merge remote-tracking branch 'pm/linux-next'
[karo-tx-linux.git] / include / linux / acpi.h
index 55af199f8aaf73fef834d242442c5cffc6a089c9..ebfac2fe0c813bea9d98d01e8dc4f244e1bd97d4 100644 (file)
@@ -49,7 +49,7 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
        return adev ? adev->handle : NULL;
 }
 
-#define ACPI_COMPANION(dev)            to_acpi_node((dev)->fwnode)
+#define ACPI_COMPANION(dev)            to_acpi_device_node((dev)->fwnode)
 #define ACPI_COMPANION_SET(dev, adev)  set_primary_fwnode(dev, (adev) ? \
        acpi_fwnode_handle(adev) : NULL)
 #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)
 
 static inline bool has_acpi_companion(struct device *dev)
 {
-       return is_acpi_node(dev->fwnode);
+       return is_acpi_device_node(dev->fwnode);
 }
 
 static inline void acpi_preset_companion(struct device *dev,
@@ -131,6 +131,12 @@ static inline void acpi_initrd_override(void *data, size_t size)
                (!entry) || (unsigned long)entry + sizeof(*entry) > end ||  \
                ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
 
+struct acpi_subtable_proc {
+       int id;
+       acpi_tbl_entry_handler handler;
+       int count;
+};
+
 char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
 void __acpi_unmap_table(char *map, unsigned long size);
 int early_acpi_boot_init(void);
@@ -146,9 +152,16 @@ int __init acpi_parse_entries(char *id, unsigned long table_size,
                              struct acpi_table_header *table_header,
                              int entry_id, unsigned int max_entries);
 int __init acpi_table_parse_entries(char *id, unsigned long table_size,
-                                   int entry_id,
-                                   acpi_tbl_entry_handler handler,
-                                   unsigned int max_entries);
+                             int entry_id,
+                             acpi_tbl_entry_handler handler,
+                             unsigned int max_entries);
+int __init acpi_table_parse_entries(char *id, unsigned long table_size,
+                             int entry_id,
+                             acpi_tbl_entry_handler handler,
+                             unsigned int max_entries);
+int __init acpi_table_parse_entries_array(char *id, unsigned long table_size,
+                             struct acpi_subtable_proc *proc, int proc_num,
+                             unsigned int max_entries);
 int acpi_table_parse_madt(enum acpi_madt_type id,
                          acpi_tbl_entry_handler handler,
                          unsigned int max_entries);
@@ -193,6 +206,12 @@ int acpi_ioapic_registered(acpi_handle handle, u32 gsi_base);
 void acpi_irq_stats_init(void);
 extern u32 acpi_irq_handled;
 extern u32 acpi_irq_not_handled;
+extern unsigned int acpi_sci_irq;
+#define INVALID_ACPI_IRQ       ((unsigned)-1)
+static inline bool acpi_sci_irq_valid(void)
+{
+       return acpi_sci_irq != INVALID_ACPI_IRQ;
+}
 
 extern int sbf_port;
 extern unsigned long acpi_realmode_flags;
@@ -465,7 +484,22 @@ static inline bool is_acpi_node(struct fwnode_handle *fwnode)
        return false;
 }
 
-static inline struct acpi_device *to_acpi_node(struct fwnode_handle *fwnode)
+static inline bool is_acpi_device_node(struct fwnode_handle *fwnode)
+{
+       return false;
+}
+
+static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwnode)
+{
+       return NULL;
+}
+
+static inline bool is_acpi_data_node(struct fwnode_handle *fwnode)
+{
+       return false;
+}
+
+static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode)
 {
        return NULL;
 }
@@ -752,22 +786,76 @@ struct acpi_reference_args {
 #ifdef CONFIG_ACPI
 int acpi_dev_get_property(struct acpi_device *adev, const char *name,
                          acpi_object_type type, const union acpi_object **obj);
-int acpi_dev_get_property_array(struct acpi_device *adev, const char *name,
-                               acpi_object_type type,
-                               const union acpi_object **obj);
-int acpi_dev_get_property_reference(struct acpi_device *adev,
-                                   const char *name, size_t index,
-                                   struct acpi_reference_args *args);
-
-int acpi_dev_prop_get(struct acpi_device *adev, const char *propname,
-                     void **valptr);
+int acpi_node_get_property_reference(struct fwnode_handle *fwnode,
+                                    const char *name, size_t index,
+                                    struct acpi_reference_args *args);
+
+int acpi_node_prop_get(struct fwnode_handle *fwnode, const char *propname,
+                      void **valptr);
 int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname,
                              enum dev_prop_type proptype, void *val);
+int acpi_node_prop_read(struct fwnode_handle *fwnode, const char *propname,
+                       enum dev_prop_type proptype, void *val, size_t nval);
 int acpi_dev_prop_read(struct acpi_device *adev, const char *propname,
                       enum dev_prop_type proptype, void *val, size_t nval);
 
-struct acpi_device *acpi_get_next_child(struct device *dev,
-                                       struct acpi_device *child);
+struct fwnode_handle *acpi_get_next_subnode(struct device *dev,
+                                           struct fwnode_handle *subnode);
+
+struct acpi_probe_entry;
+typedef bool (*acpi_probe_entry_validate_subtbl)(struct acpi_subtable_header *,
+                                                struct acpi_probe_entry *);
+
+#define ACPI_TABLE_ID_LEN      5
+
+/**
+ * struct acpi_probe_entry - boot-time probing entry
+ * @id:                        ACPI table name
+ * @type:              Optional subtable type to match
+ *                     (if @id contains subtables)
+ * @subtable_valid:    Optional callback to check the validity of
+ *                     the subtable
+ * @probe_table:       Callback to the driver being probed when table
+ *                     match is successful
+ * @probe_subtbl:      Callback to the driver being probed when table and
+ *                     subtable match (and optional callback is successful)
+ * @driver_data:       Sideband data provided back to the driver
+ */
+struct acpi_probe_entry {
+       __u8 id[ACPI_TABLE_ID_LEN];
+       __u8 type;
+       acpi_probe_entry_validate_subtbl subtable_valid;
+       union {
+               acpi_tbl_table_handler probe_table;
+               acpi_tbl_entry_handler probe_subtbl;
+       };
+       kernel_ulong_t driver_data;
+};
+
+#define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, valid, data, fn)     \
+       static const struct acpi_probe_entry __acpi_probe_##name        \
+               __used __section(__##table##_acpi_probe_table)          \
+                = {                                                    \
+                       .id = table_id,                                 \
+                       .type = subtable,                               \
+                       .subtable_valid = valid,                        \
+                       .probe_table = (acpi_tbl_table_handler)fn,      \
+                       .driver_data = data,                            \
+                  }
+
+#define ACPI_PROBE_TABLE(name)         __##name##_acpi_probe_table
+#define ACPI_PROBE_TABLE_END(name)     __##name##_acpi_probe_table_end
+
+int __acpi_probe_device_table(struct acpi_probe_entry *start, int nr);
+
+#define acpi_probe_device_table(t)                                     \
+       ({                                                              \
+               extern struct acpi_probe_entry ACPI_PROBE_TABLE(t),     \
+                                              ACPI_PROBE_TABLE_END(t); \
+               __acpi_probe_device_table(&ACPI_PROBE_TABLE(t),         \
+                                         (&ACPI_PROBE_TABLE_END(t) -   \
+                                          &ACPI_PROBE_TABLE(t)));      \
+       })
 #else
 static inline int acpi_dev_get_property(struct acpi_device *adev,
                                        const char *name, acpi_object_type type,
@@ -775,16 +863,17 @@ static inline int acpi_dev_get_property(struct acpi_device *adev,
 {
        return -ENXIO;
 }
-static inline int acpi_dev_get_property_array(struct acpi_device *adev,
-                                             const char *name,
-                                             acpi_object_type type,
-                                             const union acpi_object **obj)
+
+static inline int acpi_node_get_property_reference(struct fwnode_handle *fwnode,
+                               const char *name, const char *cells_name,
+                               size_t index, struct acpi_reference_args *args)
 {
        return -ENXIO;
 }
-static inline int acpi_dev_get_property_reference(struct acpi_device *adev,
-                               const char *name, const char *cells_name,
-                               size_t index, struct acpi_reference_args *args)
+
+static inline int acpi_node_prop_get(struct fwnode_handle *fwnode,
+                                    const char *propname,
+                                    void **valptr)
 {
        return -ENXIO;
 }
@@ -804,6 +893,14 @@ static inline int acpi_dev_prop_read_single(struct acpi_device *adev,
        return -ENXIO;
 }
 
+static inline int acpi_node_prop_read(struct fwnode_handle *fwnode,
+                                     const char *propname,
+                                     enum dev_prop_type proptype,
+                                     void *val, size_t nval)
+{
+       return -ENXIO;
+}
+
 static inline int acpi_dev_prop_read(struct acpi_device *adev,
                                     const char *propname,
                                     enum dev_prop_type proptype,
@@ -812,12 +909,22 @@ static inline int acpi_dev_prop_read(struct acpi_device *adev,
        return -ENXIO;
 }
 
-static inline struct acpi_device *acpi_get_next_child(struct device *dev,
-                                                     struct acpi_device *child)
+static inline struct fwnode_handle *acpi_get_next_subnode(struct device *dev,
+                                               struct fwnode_handle *subnode)
 {
        return NULL;
 }
 
+#define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, validate, data, fn) \
+       static const void * __acpi_table_##name[]                       \
+               __attribute__((unused))                                 \
+                = { (void *) table_id,                                 \
+                    (void *) subtable,                                 \
+                    (void *) valid,                                    \
+                    (void *) fn,                                       \
+                    (void *) data }
+
+#define acpi_probe_device_table(t)     ({ int __r = 0; __r;})
 #endif
 
 #endif /*_LINUX_ACPI_H*/