Device subsystem improvements.
[tinyx.git] / include / tinyx / device.h
blob29169252b98d243ec63158825504d1994709751d
1 #ifndef __TINYX_DEVICE_H
2 #define __TINYX_DEVICE_H
4 #include <tinyx/list.h>
6 struct bus_type;
7 struct device_driver;
8 struct device;
10 struct resource_mem {
11 unsigned long start;
12 unsigned long end;
15 struct resource_irq {
16 unsigned int start;
19 struct resource {
20 union {
21 struct resource_mem mem;
22 struct resource_irq irq;
26 struct bus_type {
27 struct list_head queue;
28 unsigned int type;
29 void *private_data;
31 int (*probe) (struct bus_type *bus);
32 int (*remove) (struct bus_type *bus);
33 int (*match) (struct bus_type *bus,
34 struct device *dev, struct device_driver *drv);
36 /* These write* and read* exists in order to avoid if's
37 * inside critial buses. */
38 void (*writeb) (struct device *dev,
39 unsigned char val, unsigned long addr);
40 void (*writew) (struct device *dev,
41 unsigned int val, unsigned long addr);
42 void (*writel) (struct device *dev,
43 unsigned long val, unsigned long addr);
45 unsigned char (*readb) (struct device *dev, unsigned long addr);
46 unsigned int (*readw) (struct device *dev, unsigned long addr);
47 unsigned long (*readl) (struct device *dev, unsigned long addr);
49 void (*ioctl) (struct device *dev, void *data, int type);
52 struct device_driver {
53 struct list_head queue;
54 const char *name;
56 int (*probe) (struct device *dev);
57 int (*remove) (struct device *dev);
60 struct device {
61 struct list_head queue;
62 const char *name;
63 int id;
64 struct device_driver *drv;
65 struct bus_type *bus;
66 void *private_data;
67 struct resource *res;
70 int register_bus_type(struct bus_type *bus);
71 int register_device_driver(struct device_driver *drv);
72 int register_device(struct device *dev, struct bus_type *bus);
74 #endif /* __TINYX_DEVICE_H */