ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-ppc64 / vio.h
1 /*
2  * IBM PowerPC Virtual I/O Infrastructure Support.
3  *
4  *    Copyright (c) 2003 IBM Corp.
5  *     Dave Engebretsen engebret@us.ibm.com
6  *     Santiago Leon santil@us.ibm.com
7  *
8  *      This program is free software; you can redistribute it and/or
9  *      modify it under the terms of the GNU General Public License
10  *      as published by the Free Software Foundation; either version
11  *      2 of the License, or (at your option) any later version.
12  */
13
14 #ifndef _ASM_VIO_H
15 #define _ASM_VIO_H
16
17 #include <linux/init.h>
18 #include <linux/errno.h>
19 #include <linux/device.h>
20 #include <linux/dma-mapping.h>
21 #include <asm/hvcall.h>
22 #include <asm/prom.h>
23 #include <asm/scatterlist.h>
24 /* 
25  * Architecture-specific constants for drivers to
26  * extract attributes of the device using vio_get_attribute()
27 */
28 #define VETH_MAC_ADDR "local-mac-address"
29 #define VETH_MCAST_FILTER_SIZE "ibm,mac-address-filters"
30
31 /* End architecture-specific constants */
32
33 #define h_vio_signal(ua, mode) \
34   plpar_hcall_norets(H_VIO_SIGNAL, ua, mode)
35
36 #define VIO_IRQ_DISABLE         0UL
37 #define VIO_IRQ_ENABLE          1UL
38
39 struct vio_dev;
40 struct vio_driver;
41 struct vio_device_id;
42 struct iommu_table;
43
44 int vio_register_driver(struct vio_driver *drv);
45 void vio_unregister_driver(struct vio_driver *drv);
46 const struct vio_device_id * vio_match_device(const struct vio_device_id *ids, 
47                                                 const struct vio_dev *dev);
48
49 struct vio_dev * __devinit vio_register_device(struct device_node *node_vdev);
50 void __devinit vio_unregister_device(struct vio_dev *dev);
51 struct vio_dev *vio_find_node(struct device_node *vnode);
52
53 const void * vio_get_attribute(struct vio_dev *vdev, void* which, int* length);
54 int vio_get_irq(struct vio_dev *dev);
55 struct iommu_table * vio_build_iommu_table(struct vio_dev *dev);
56 int vio_enable_interrupts(struct vio_dev *dev);
57 int vio_disable_interrupts(struct vio_dev *dev);
58
59 dma_addr_t vio_map_single(struct vio_dev *dev, void *vaddr, 
60                           size_t size, enum dma_data_direction direction);
61 void vio_unmap_single(struct vio_dev *dev, dma_addr_t dma_handle, 
62                       size_t size, enum dma_data_direction direction);
63 int vio_map_sg(struct vio_dev *vdev, struct scatterlist *sglist, 
64                int nelems, enum dma_data_direction direction);
65 void vio_unmap_sg(struct vio_dev *vdev, struct scatterlist *sglist, 
66                   int nelems, enum dma_data_direction direction);
67 void *vio_alloc_consistent(struct vio_dev *dev, size_t size, 
68                            dma_addr_t *dma_handle);
69 void vio_free_consistent(struct vio_dev *dev, size_t size, void *vaddr, 
70                          dma_addr_t dma_handle);
71
72 static inline int vio_dma_supported(struct vio_dev *hwdev, u64 mask)
73 {
74         return 1;
75 }
76
77 #define vio_map_page(dev, page, off, size, dir) \
78                 vio_map_single(dev, (page_address(page) + (off)), size, dir)
79 #define vio_unmap_page(dev,addr,sz,dir) vio_unmap_single(dev,addr,sz,dir)
80
81 static inline int vio_set_dma_mask(struct vio_dev *dev, u64 mask)
82 {
83         return -EIO;
84 }
85
86 extern struct bus_type vio_bus_type;
87
88 struct vio_device_id {
89         char *type;
90         char *compat;
91 };
92
93 struct vio_driver {
94         struct list_head node;
95         char *name;
96         const struct vio_device_id *id_table;   /* NULL if wants all devices */
97         int  (*probe)  (struct vio_dev *dev, const struct vio_device_id *id);   /* New device inserted */
98         int (*remove) (struct vio_dev *dev);    /* Device removed (NULL if not a hot-plug capable driver) */
99         unsigned long driver_data;
100
101         struct device_driver driver;
102 };
103
104 static inline struct vio_driver *to_vio_driver(struct device_driver *drv)
105 {
106         return container_of(drv, struct vio_driver, driver);
107 }
108
109 /*
110  * The vio_dev structure is used to describe virtual I/O devices.
111  */
112 struct vio_dev {
113         struct device_node *archdata;   /* Open Firmware node */
114         void *driver_data;              /* data private to the driver */
115         struct iommu_table *iommu_table;     /* vio_map_* uses this */
116         uint32_t unit_address;  
117         unsigned int irq;
118
119         struct device dev;
120 };
121
122 static inline struct vio_dev *to_vio_dev(struct device *dev)
123 {
124         return container_of(dev, struct vio_dev, dev);
125 }
126
127 #endif /* _ASM_VIO_H */