1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2f898f8dbSStephen Rothwell #ifndef _LINUX_OF_DEVICE_H
3f898f8dbSStephen Rothwell #define _LINUX_OF_DEVICE_H
4f898f8dbSStephen Rothwell
5*ef175b29SRob Herring #include <linux/device/driver.h>
6f898f8dbSStephen Rothwell
7313162d0SPaul Gortmaker struct device;
82e8fff66SRob Herring struct of_device_id;
92e8fff66SRob Herring struct kobj_uevent_env;
10313162d0SPaul Gortmaker
11ba166e90SRob Herring #ifdef CONFIG_OF
12f898f8dbSStephen Rothwell extern const struct of_device_id *of_match_device(
1344504b2bSGrant Likely const struct of_device_id *matches, const struct device *dev);
14f898f8dbSStephen Rothwell
158cec0e7bSGrant Likely /**
168cec0e7bSGrant Likely * of_driver_match_device - Tell if a driver's of_match_table matches a device.
178cec0e7bSGrant Likely * @drv: the device_driver structure to test
188cec0e7bSGrant Likely * @dev: the device structure to match against
198cec0e7bSGrant Likely */
of_driver_match_device(struct device * dev,const struct device_driver * drv)20b826291cSGrant Likely static inline int of_driver_match_device(struct device *dev,
218cec0e7bSGrant Likely const struct device_driver *drv)
228cec0e7bSGrant Likely {
23b1608d69SGrant Likely return of_match_device(drv->of_match_table, dev) != NULL;
248cec0e7bSGrant Likely }
258cec0e7bSGrant Likely
260634c295SRob Herring extern ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len);
27dd27dcdaSGrant Likely
289f041c5dSGreg Kroah-Hartman extern void of_device_uevent(const struct device *dev, struct kobj_uevent_env *env);
29a77ad4bfSGreg Kroah-Hartman extern int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env *env);
30dd27dcdaSGrant Likely
31a081bd4aSLorenzo Pieralisi int of_dma_configure_id(struct device *dev,
323d6ce86eSChristoph Hellwig struct device_node *np,
33a081bd4aSLorenzo Pieralisi bool force_dma, const u32 *id);
of_dma_configure(struct device * dev,struct device_node * np,bool force_dma)34a081bd4aSLorenzo Pieralisi static inline int of_dma_configure(struct device *dev,
35a081bd4aSLorenzo Pieralisi struct device_node *np,
36a081bd4aSLorenzo Pieralisi bool force_dma)
37a081bd4aSLorenzo Pieralisi {
38a081bd4aSLorenzo Pieralisi return of_dma_configure_id(dev, np, force_dma, NULL);
39a081bd4aSLorenzo Pieralisi }
407f38b700SMiquel Raynal
417f38b700SMiquel Raynal void of_device_make_bus_id(struct device *dev);
427f38b700SMiquel Raynal
43ba166e90SRob Herring #else /* CONFIG_OF */
448cec0e7bSGrant Likely
of_driver_match_device(struct device * dev,const struct device_driver * drv)458cec0e7bSGrant Likely static inline int of_driver_match_device(struct device *dev,
4635068ce8STomeu Vizoso const struct device_driver *drv)
478cec0e7bSGrant Likely {
488cec0e7bSGrant Likely return 0;
498cec0e7bSGrant Likely }
508cec0e7bSGrant Likely
of_device_uevent(const struct device * dev,struct kobj_uevent_env * env)519f041c5dSGreg Kroah-Hartman static inline void of_device_uevent(const struct device *dev,
5207d57a32SGrant Likely struct kobj_uevent_env *env) { }
5307d57a32SGrant Likely
of_device_modalias(struct device * dev,char * str,ssize_t len)540634c295SRob Herring static inline int of_device_modalias(struct device *dev,
55b9f73067SZhang Rui char *str, ssize_t len)
56b9f73067SZhang Rui {
57b9f73067SZhang Rui return -ENODEV;
58b9f73067SZhang Rui }
59b9f73067SZhang Rui
of_device_uevent_modalias(const struct device * dev,struct kobj_uevent_env * env)60a77ad4bfSGreg Kroah-Hartman static inline int of_device_uevent_modalias(const struct device *dev,
61eca39301SGrant Likely struct kobj_uevent_env *env)
62eca39301SGrant Likely {
63eca39301SGrant Likely return -ENODEV;
64eca39301SGrant Likely }
65eca39301SGrant Likely
of_match_device(const struct of_device_id * matches,const struct device * dev)66c52eef0bSStephen Boyd static inline const struct of_device_id *of_match_device(
67b1608d69SGrant Likely const struct of_device_id *matches, const struct device *dev)
68b1608d69SGrant Likely {
69b1608d69SGrant Likely return NULL;
70b1608d69SGrant Likely }
71bd00860eSSudeep KarkadaNagesha
of_dma_configure_id(struct device * dev,struct device_node * np,bool force_dma,const u32 * id)72a081bd4aSLorenzo Pieralisi static inline int of_dma_configure_id(struct device *dev,
73a081bd4aSLorenzo Pieralisi struct device_node *np,
7440bfe7a8SThierry Reding bool force_dma,
7540bfe7a8SThierry Reding const u32 *id)
76a081bd4aSLorenzo Pieralisi {
77a081bd4aSLorenzo Pieralisi return 0;
78a081bd4aSLorenzo Pieralisi }
of_dma_configure(struct device * dev,struct device_node * np,bool force_dma)793d6ce86eSChristoph Hellwig static inline int of_dma_configure(struct device *dev,
803d6ce86eSChristoph Hellwig struct device_node *np,
813d6ce86eSChristoph Hellwig bool force_dma)
827b07cbefSLaurent Pinchart {
837b07cbefSLaurent Pinchart return 0;
847b07cbefSLaurent Pinchart }
857f38b700SMiquel Raynal
of_device_make_bus_id(struct device * dev)867f38b700SMiquel Raynal static inline void of_device_make_bus_id(struct device *dev) {}
877f38b700SMiquel Raynal
88ba166e90SRob Herring #endif /* CONFIG_OF */
8909e67ca2SStephen Rothwell
90f898f8dbSStephen Rothwell #endif /* _LINUX_OF_DEVICE_H */
91