blob: ddb16aae0bd656aba9b37f6cfef77be192a0402b [file] [log] [blame]
Paul Mackerras2e686bc2005-10-06 13:22:17 +10001#ifndef _ASM_POWERPC_OF_DEVICE_H
2#define _ASM_POWERPC_OF_DEVICE_H
Linus Torvalds1da177e2005-04-16 15:20:36 -07003
4#include <linux/device.h>
Benjamin Herrenschmidt0365ba72005-09-22 21:44:06 -07005#include <linux/mod_devicetable.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006#include <asm/prom.h>
7
8/*
9 * The of_platform_bus_type is a bus type used by drivers that do not
10 * attach to a macio or similar bus but still use OF probing
11 * mecanism
12 */
13extern struct bus_type of_platform_bus_type;
14
15/*
16 * The of_device is a kind of "base class" that is a superset of
17 * struct device for use by devices attached to an OF node and
18 * probed using OF properties
19 */
20struct of_device
21{
22 struct device_node *node; /* OF device node */
23 u64 dma_mask; /* DMA mask */
24 struct device dev; /* Generic device interface */
25};
26#define to_of_device(d) container_of(d, struct of_device, dev)
27
Jeff Mahoney5e655772005-07-06 15:44:41 -040028extern const struct of_device_id *of_match_device(
29 const struct of_device_id *matches, const struct of_device *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
31extern struct of_device *of_dev_get(struct of_device *dev);
32extern void of_dev_put(struct of_device *dev);
33
34/*
35 * An of_platform_driver driver is attached to a basic of_device on
36 * the "platform bus" (of_platform_bus_type)
37 */
38struct of_platform_driver
39{
40 char *name;
Jeff Mahoney5e655772005-07-06 15:44:41 -040041 struct of_device_id *match_table;
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 struct module *owner;
43
Jeff Mahoney5e655772005-07-06 15:44:41 -040044 int (*probe)(struct of_device* dev, const struct of_device_id *match);
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 int (*remove)(struct of_device* dev);
46
Pavel Machekb1c42852005-04-16 15:25:34 -070047 int (*suspend)(struct of_device* dev, pm_message_t state);
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 int (*resume)(struct of_device* dev);
49 int (*shutdown)(struct of_device* dev);
50
51 struct device_driver driver;
52};
53#define to_of_platform_driver(drv) container_of(drv,struct of_platform_driver, driver)
54
55extern int of_register_driver(struct of_platform_driver *drv);
56extern void of_unregister_driver(struct of_platform_driver *drv);
57extern int of_device_register(struct of_device *ofdev);
58extern void of_device_unregister(struct of_device *ofdev);
Benjamin Herrenschmidt0365ba72005-09-22 21:44:06 -070059extern struct of_device *of_platform_device_create(struct device_node *np,
60 const char *bus_id,
61 struct device *parent);
Linus Torvalds1da177e2005-04-16 15:20:36 -070062extern void of_release_dev(struct device *dev);
63
Paul Mackerras2e686bc2005-10-06 13:22:17 +100064#endif /* _ASM_POWERPC_OF_DEVICE_H */