]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/linux/of_platform.h
ACPI: fix acpi_find_child_device() invocation in acpi_preset_companion()
[mirror_ubuntu-bionic-kernel.git] / include / linux / of_platform.h
CommitLineData
b41912ca
SR
1#ifndef _LINUX_OF_PLATFORM_H
2#define _LINUX_OF_PLATFORM_H
3/*
4 * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp.
5 * <benh@kernel.crashing.org>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 *
12 */
13
b41912ca
SR
14#include <linux/device.h>
15#include <linux/mod_devicetable.h>
16#include <linux/pm.h>
17#include <linux/of_device.h>
eca39301 18#include <linux/platform_device.h>
b41912ca 19
15c3597d
GL
20/**
21 * struct of_dev_auxdata - lookup table entry for device names & platform_data
22 * @compatible: compatible value of node to match against node
23 * @phys_addr: Start address of registers to match against node
24 * @name: Name to assign for matching nodes
25 * @platform_data: platform_data to assign for matching nodes
26 *
27 * This lookup table allows the caller of of_platform_populate() to override
28 * the names of devices when creating devices from the device tree. The table
29 * should be terminated with an empty entry. It also allows the platform_data
30 * pointer to be set.
31 *
32 * The reason for this functionality is that some Linux infrastructure uses
33 * the device name to look up a specific device, but the Linux-specific names
34 * are not encoded into the device tree, so the kernel needs to provide specific
35 * values.
36 *
37 * Note: Using an auxdata lookup table should be considered a last resort when
38 * converting a platform to use the DT. Normally the automatically generated
39 * device name will not matter, and drivers should obtain data from the device
8c1eb253 40 * node instead of from an anonymous platform_data pointer.
15c3597d
GL
41 */
42struct of_dev_auxdata {
43 char *compatible;
44 resource_size_t phys_addr;
45 char *name;
46 void *platform_data;
47};
48
49/* Macro to simplify populating a lookup table */
50#define OF_DEV_AUXDATA(_compat,_phys,_name,_pdata) \
51 { .compatible = _compat, .phys_addr = _phys, .name = _name, \
52 .platform_data = _pdata }
53
cbb49c26
GL
54extern const struct of_device_id of_default_bus_match_table[];
55
0763ed23 56/* Platform drivers register/unregister */
94a0cb1f 57extern struct platform_device *of_device_alloc(struct device_node *np,
94c09319
GL
58 const char *bus_id,
59 struct device *parent);
aa767cfb 60#ifdef CONFIG_OF
94a0cb1f 61extern struct platform_device *of_find_device_by_node(struct device_node *np);
aa767cfb
AB
62#else
63static inline struct platform_device *of_find_device_by_node(struct device_node *np)
64{
65 return NULL;
66}
67#endif
b41912ca 68
5fd200f3 69/* Platform devices and busses creation */
94a0cb1f 70extern struct platform_device *of_platform_device_create(struct device_node *np,
5fd200f3
GL
71 const char *bus_id,
72 struct device *parent);
73
c2372c20 74extern int of_platform_device_destroy(struct device *dev, void *data);
5fd200f3
GL
75extern int of_platform_bus_probe(struct device_node *root,
76 const struct of_device_id *matches,
77 struct device *parent);
8a46f4f7 78#ifdef CONFIG_OF_ADDRESS
29d4f8a4
GL
79extern int of_platform_populate(struct device_node *root,
80 const struct of_device_id *matches,
15c3597d 81 const struct of_dev_auxdata *lookup,
29d4f8a4 82 struct device *parent);
43443ad6
HM
83extern int of_platform_default_populate(struct device_node *root,
84 const struct of_dev_auxdata *lookup,
85 struct device *parent);
75f353b6 86extern void of_platform_depopulate(struct device *parent);
38b0b219
BG
87
88extern int devm_of_platform_populate(struct device *dev);
89
90extern void devm_of_platform_depopulate(struct device *dev);
8a46f4f7 91#else
964dba28
GL
92static inline int of_platform_populate(struct device_node *root,
93 const struct of_device_id *matches,
94 const struct of_dev_auxdata *lookup,
95 struct device *parent)
96{
97 return -ENODEV;
98}
43443ad6
HM
99static inline int of_platform_default_populate(struct device_node *root,
100 const struct of_dev_auxdata *lookup,
101 struct device *parent)
102{
103 return -ENODEV;
104}
75f353b6 105static inline void of_platform_depopulate(struct device *parent) { }
38b0b219
BG
106
107static inline int devm_of_platform_populate(struct device *dev)
108{
109 return -ENODEV;
110}
111
112static inline void devm_of_platform_depopulate(struct device *dev) { }
8a46f4f7 113#endif
5fd200f3 114
a697c2ef 115#if defined(CONFIG_OF_DYNAMIC) && defined(CONFIG_OF_ADDRESS)
801d728c
PA
116extern void of_platform_register_reconfig_notifier(void);
117#else
118static inline void of_platform_register_reconfig_notifier(void) { }
119#endif
120
b41912ca 121#endif /* _LINUX_OF_PLATFORM_H */