blob: 4b264cfd39987cb368843ae346199c6cf2822e97 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __OF_DEVICE_H__
2#define __OF_DEVICE_H__
3
4#include <linux/device.h>
5#include <asm/prom.h>
6
7/*
8 * The of_platform_bus_type is a bus type used by drivers that do not
9 * attach to a macio or similar bus but still use OF probing
10 * mecanism
11 */
12extern struct bus_type of_platform_bus_type;
13
14/*
15 * The of_device is a kind of "base class" that is a superset of
16 * struct device for use by devices attached to an OF node and
17 * probed using OF properties
18 */
19struct of_device
20{
21 struct device_node *node; /* OF device node */
22 u64 dma_mask; /* DMA mask */
23 struct device dev; /* Generic device interface */
24};
25#define to_of_device(d) container_of(d, struct of_device, dev)
26
Jeff Mahoney5e655772005-07-06 15:44:41 -040027extern const struct of_device_id *of_match_device(
28 const struct of_device_id *matches, const struct of_device *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
30extern struct of_device *of_dev_get(struct of_device *dev);
31extern void of_dev_put(struct of_device *dev);
32
33/*
34 * An of_platform_driver driver is attached to a basic of_device on
35 * the "platform bus" (of_platform_bus_type)
36 */
37struct of_platform_driver
38{
39 char *name;
Jeff Mahoney5e655772005-07-06 15:44:41 -040040 struct of_device_id *match_table;
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 struct module *owner;
42
Jeff Mahoney5e655772005-07-06 15:44:41 -040043 int (*probe)(struct of_device* dev, const struct of_device_id *match);
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 int (*remove)(struct of_device* dev);
45
Pavel Machekb1c42852005-04-16 15:25:34 -070046 int (*suspend)(struct of_device* dev, pm_message_t state);
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 int (*resume)(struct of_device* dev);
48 int (*shutdown)(struct of_device* dev);
49
50 struct device_driver driver;
51};
52#define to_of_platform_driver(drv) container_of(drv,struct of_platform_driver, driver)
53
54extern int of_register_driver(struct of_platform_driver *drv);
55extern void of_unregister_driver(struct of_platform_driver *drv);
56extern int of_device_register(struct of_device *ofdev);
57extern void of_device_unregister(struct of_device *ofdev);
58extern struct of_device *of_platform_device_create(struct device_node *np, const char *bus_id);
59extern void of_release_dev(struct device *dev);
60
61#endif /* __OF_DEVICE_H__ */
62