xref: /linux-6.15/include/linux/of_platform.h (revision 6482f554)
1 #ifndef _LINUX_OF_PLATFORM_H
2 #define _LINUX_OF_PLATFORM_H
3 /*
4  *    Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp.
5  *			 <[email protected]>
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 
14 #ifdef CONFIG_OF_DEVICE
15 #include <linux/module.h>
16 #include <linux/device.h>
17 #include <linux/mod_devicetable.h>
18 #include <linux/pm.h>
19 #include <linux/of_device.h>
20 #include <linux/platform_device.h>
21 
22 /**
23  * of_platform_driver - Legacy of-aware driver for platform devices.
24  *
25  * An of_platform_driver driver is attached to a basic platform_device on
26  * ether the "platform bus" (platform_bus_type), or the ibm ebus
27  * (ibmebus_bus_type).
28  *
29  * of_platform_driver is being phased out when used with the platform_bus_type,
30  * and regular platform_drivers should be used instead.  When the transition
31  * is complete, only ibmebus will be using this structure, and the
32  * platform_driver member of this structure will be removed.
33  */
34 struct of_platform_driver
35 {
36 	int	(*probe)(struct platform_device* dev,
37 			 const struct of_device_id *match);
38 	int	(*remove)(struct platform_device* dev);
39 
40 	int	(*suspend)(struct platform_device* dev, pm_message_t state);
41 	int	(*resume)(struct platform_device* dev);
42 	int	(*shutdown)(struct platform_device* dev);
43 
44 	struct device_driver	driver;
45 	struct platform_driver	platform_driver;
46 };
47 #define	to_of_platform_driver(drv) \
48 	container_of(drv,struct of_platform_driver, driver)
49 
50 extern int of_register_driver(struct of_platform_driver *drv,
51 			      struct bus_type *bus);
52 extern void of_unregister_driver(struct of_platform_driver *drv);
53 
54 /* Platform drivers register/unregister */
55 extern int of_register_platform_driver(struct of_platform_driver *drv);
56 extern void of_unregister_platform_driver(struct of_platform_driver *drv);
57 
58 extern struct platform_device *of_device_alloc(struct device_node *np,
59 					 const char *bus_id,
60 					 struct device *parent);
61 extern struct platform_device *of_find_device_by_node(struct device_node *np);
62 
63 extern int of_bus_type_init(struct bus_type *bus, const char *name);
64 
65 #if !defined(CONFIG_SPARC) /* SPARC has its own device registration method */
66 /* Platform devices and busses creation */
67 extern struct platform_device *of_platform_device_create(struct device_node *np,
68 						   const char *bus_id,
69 						   struct device *parent);
70 
71 /* pseudo "matches" value to not do deep probe */
72 #define OF_NO_DEEP_PROBE ((struct of_device_id *)-1)
73 
74 extern int of_platform_bus_probe(struct device_node *root,
75 				 const struct of_device_id *matches,
76 				 struct device *parent);
77 #endif /* !CONFIG_SPARC */
78 
79 #endif /* CONFIG_OF_DEVICE */
80 
81 #endif	/* _LINUX_OF_PLATFORM_H */
82