cleanup
[linux-2.4.git] / include / asm-ppc64 / vio.h
1 /*
2  * IBM PowerPC Virtual I/O Infrastructure Support.
3  *
4  * Dave Engebretsen engebret@us.ibm.com
5  *    Copyright (c) 2003 Dave Engebretsen
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 #ifndef _VIO_H
14 #define _VIO_H
15
16 #include <linux/init.h>
17 #include <linux/errno.h>
18 #include <asm/hvcall.h>
19 #include <asm/prom.h>
20 #include <asm/scatterlist.h>
21 /*
22  * Architecture-specific constants for drivers to
23  * extract attributes of the device using vio_get_attribute()
24 */
25 #define VETH_MAC_ADDR "local-mac-address"
26 #define VETH_MCAST_FILTER_SIZE "ibm,mac-address-filters"
27
28 /* End architecture-specific constants */
29
30 #define h_vio_signal(ua, mode) \
31   plpar_hcall_norets(H_VIO_SIGNAL, ua, mode)
32
33 #define VIO_IRQ_DISABLE         0UL
34 #define VIO_IRQ_ENABLE          1UL
35
36 struct vio_dev;
37 struct vio_driver;
38 struct vio_device_id;
39 struct TceTable;
40
41 int vio_register_driver(struct vio_driver *drv);
42 int vio_unregister_driver(struct vio_driver *drv);
43 const struct vio_device_id * vio_match_device(const struct vio_device_id *ids,
44                                                 const struct vio_dev *dev);
45 struct vio_dev * __devinit vio_register_device(struct device_node *node_vdev);
46 struct vio_driver * __devinit vio_find_driver(struct vio_dev* dev);
47 const void * vio_get_attribute(struct vio_dev *vdev, void* which, int* length);
48 int vio_get_irq(struct vio_dev *dev);
49 struct TceTable * vio_build_tce_table(struct vio_dev *dev);
50 int vio_enable_interrupts(struct vio_dev *dev);
51 int vio_disable_interrupts(struct vio_dev *dev);
52
53 dma_addr_t vio_map_single(struct vio_dev *dev, void *vaddr,
54                           size_t size, int direction);
55 void vio_unmap_single(struct vio_dev *dev, dma_addr_t dma_handle,
56                       size_t size, int direction);
57 int vio_map_sg(struct vio_dev *vdev, struct scatterlist *sglist,
58                int nelems, int direction);
59 void vio_unmap_sg(struct vio_dev *vdev, struct scatterlist *sglist,
60                   int nelems, int direction);
61 void *vio_alloc_consistent(struct vio_dev *dev, size_t size,
62                            dma_addr_t *dma_handle);
63 void vio_free_consistent(struct vio_dev *dev, size_t size, void *vaddr,
64                          dma_addr_t dma_handle);
65
66 struct vio_device_id {
67         char *type;
68         char *compat;
69 /* I don't think we need this
70         unsigned long driver_data;      */ /* Data private to the driver */
71 };
72
73 struct vio_driver {
74         struct list_head node;
75         char *name;
76         const struct vio_device_id *id_table;   /* NULL if wants all devices */
77         int  (*probe)  (struct vio_dev *dev, const struct vio_device_id *id);   /* New device inserted */
78         void (*remove) (struct vio_dev *dev);   /* Device removed (NULL if not a hot-plug capable driver) */
79         unsigned long driver_data;
80 };
81
82 struct vio_bus;
83 /*
84  * The vio_dev structure is used to describe virtual I/O devices.
85  */
86 struct vio_dev {
87         struct list_head devices_list;   /* node in list of all vio devices */
88         struct device_node *archdata;    /* Open Firmware node */
89         struct vio_bus *bus;            /* bus this device is on */
90         struct vio_driver *driver;      /* owning driver */
91         void *driver_data;              /* data private to the driver */
92         unsigned long unit_address;
93
94         struct TceTable *tce_table; /* vio_map_* uses this */
95         unsigned int irq;
96         struct proc_dir_entry *procent; /* device entry in /proc/bus/vio */
97 };
98
99 struct vio_bus {
100         struct list_head devices;       /* list of virtual devices */
101 };
102
103
104 static inline int vio_module_init(struct vio_driver *drv)
105 {
106         int rc = vio_register_driver (drv);
107
108         if (rc > 0)
109                 return 0;
110
111         /* iff CONFIG_HOTPLUG and built into kernel, we should
112          * leave the driver around for future hotplug events.
113          * For the module case, a hotplug daemon of some sort
114          * should load a module in response to an insert event. */
115 #if defined(CONFIG_HOTPLUG) && !defined(MODULE)
116         if (rc == 0)
117                 return 0;
118 #else
119         if (rc == 0)
120                 rc = -ENODEV;
121 #endif
122
123         /* if we get here, we need to clean up vio driver instance
124          * and return some sort of error */
125
126         return rc;
127 }
128
129 #endif /* _PHYP_H */