blob: 68048cb20688fc826923b04109472fa3f5ce613c [file] [log] [blame]
David S. Millera2bd4fd2006-06-23 01:44:10 -07001#ifndef _ASM_SPARC64_OF_DEVICE_H
2#define _ASM_SPARC64_OF_DEVICE_H
3#ifdef __KERNEL__
4
5#include <linux/device.h>
Stephen Rothwellf898f8d2007-05-01 16:49:51 +10006#include <linux/of.h>
David S. Millera2bd4fd2006-06-23 01:44:10 -07007#include <linux/mod_devicetable.h>
David S. Millercf44bbc2006-06-29 14:34:50 -07008#include <asm/openprom.h>
David S. Millera2bd4fd2006-06-23 01:44:10 -07009
10extern struct bus_type isa_bus_type;
11extern struct bus_type ebus_bus_type;
12extern struct bus_type sbus_bus_type;
David S. Millercf44bbc2006-06-29 14:34:50 -070013extern struct bus_type of_bus_type;
David S. Millera2bd4fd2006-06-23 01:44:10 -070014
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{
David S. Millercf44bbc2006-06-29 14:34:50 -070022 struct device_node *node;
23 struct device dev;
24 struct resource resource[PROMREG_MAX];
David S. Miller2b1e5972006-06-29 15:07:37 -070025 unsigned int irqs[PROMINTR_MAX];
26 int num_irqs;
David S. Millercf44bbc2006-06-29 14:34:50 -070027
28 void *sysdata;
29
30 int slot;
31 int portid;
32 int clock_freq;
David S. Millera2bd4fd2006-06-23 01:44:10 -070033};
David S. Millera2bd4fd2006-06-23 01:44:10 -070034
David S. Miller3ca9fab2006-06-29 14:35:33 -070035extern void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name);
David S. Millere3a411a2006-12-28 21:01:32 -080036extern void of_iounmap(struct resource *res, void __iomem *base, unsigned long size);
David S. Miller3ca9fab2006-06-29 14:35:33 -070037
David S. Miller2b1e5972006-06-29 15:07:37 -070038extern struct of_device *of_find_device_by_node(struct device_node *);
39
David S. Millera2bd4fd2006-06-23 01:44:10 -070040/*
41 * An of_platform_driver driver is attached to a basic of_device on
42 * the ISA, EBUS, and SBUS busses on sparc64.
43 */
44struct of_platform_driver
45{
46 char *name;
47 struct of_device_id *match_table;
48 struct module *owner;
49
50 int (*probe)(struct of_device* dev, const struct of_device_id *match);
51 int (*remove)(struct of_device* dev);
52
53 int (*suspend)(struct of_device* dev, pm_message_t state);
54 int (*resume)(struct of_device* dev);
55 int (*shutdown)(struct of_device* dev);
56
57 struct device_driver driver;
58};
59#define to_of_platform_driver(drv) container_of(drv,struct of_platform_driver, driver)
60
61extern int of_register_driver(struct of_platform_driver *drv,
62 struct bus_type *bus);
63extern void of_unregister_driver(struct of_platform_driver *drv);
David S. Millera2bd4fd2006-06-23 01:44:10 -070064extern struct of_device *of_platform_device_create(struct device_node *np,
65 const char *bus_id,
66 struct device *parent,
67 struct bus_type *bus);
Stephen Rothwellf898f8d2007-05-01 16:49:51 +100068
69/* This is just here during the transition */
70#include <linux/of_device.h>
David S. Millera2bd4fd2006-06-23 01:44:10 -070071
72#endif /* __KERNEL__ */
David S. Millerfd531432006-06-23 15:55:17 -070073#endif /* _ASM_SPARC64_OF_DEVICE_H */