Merge branch 'x86-rdrand-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[pandora-kernel.git] / drivers / staging / vme / vme_bridge.h
1 #ifndef _VME_BRIDGE_H_
2 #define _VME_BRIDGE_H_
3
4 #define VME_CRCSR_BUF_SIZE (508*1024)
5 /*
6  * Resource structures
7  */
8 struct vme_master_resource {
9         struct list_head list;
10         struct vme_bridge *parent;
11         /*
12          * We are likely to need to access the VME bus in interrupt context, so
13          * protect master routines with a spinlock rather than a mutex.
14          */
15         spinlock_t lock;
16         int locked;
17         int number;
18         vme_address_t address_attr;
19         vme_cycle_t cycle_attr;
20         vme_width_t width_attr;
21         struct resource bus_resource;
22         void __iomem *kern_base;
23 };
24
25 struct vme_slave_resource {
26         struct list_head list;
27         struct vme_bridge *parent;
28         struct mutex mtx;
29         int locked;
30         int number;
31         vme_address_t address_attr;
32         vme_cycle_t cycle_attr;
33 };
34
35 struct vme_dma_pattern {
36         u32 pattern;
37         vme_pattern_t type;
38 };
39
40 struct vme_dma_pci {
41         dma_addr_t address;
42 };
43
44 struct vme_dma_vme {
45         unsigned long long address;
46         vme_address_t aspace;
47         vme_cycle_t cycle;
48         vme_width_t dwidth;
49 };
50
51 struct vme_dma_list {
52         struct list_head list;
53         struct vme_dma_resource *parent;
54         struct list_head entries;
55         struct mutex mtx;
56 };
57
58 struct vme_dma_resource {
59         struct list_head list;
60         struct vme_bridge *parent;
61         struct mutex mtx;
62         int locked;
63         int number;
64         struct list_head pending;
65         struct list_head running;
66         vme_dma_route_t route_attr;
67 };
68
69 struct vme_lm_resource {
70         struct list_head list;
71         struct vme_bridge *parent;
72         struct mutex mtx;
73         int locked;
74         int number;
75         int monitors;
76 };
77
78 struct vme_bus_error {
79         struct list_head list;
80         unsigned long long address;
81         u32 attributes;
82 };
83
84 struct vme_callback {
85         void (*func)(int, int, void*);
86         void *priv_data;
87 };
88
89 struct vme_irq {
90         int count;
91         struct vme_callback callback[255];
92 };
93
94 /* Allow 16 characters for name (including null character) */
95 #define VMENAMSIZ 16
96
97 /* This structure stores all the information about one bridge
98  * The structure should be dynamically allocated by the driver and one instance
99  * of the structure should be present for each VME chip present in the system.
100  */
101 struct vme_bridge {
102         char name[VMENAMSIZ];
103         int num;
104         struct list_head master_resources;
105         struct list_head slave_resources;
106         struct list_head dma_resources;
107         struct list_head lm_resources;
108
109         struct list_head vme_errors;    /* List for errors generated on VME */
110         struct list_head devices;       /* List of devices on this bridge */
111
112         /* Bridge Info - XXX Move to private structure? */
113         struct device *parent;  /* Parent device (eg. pdev->dev for PCI) */
114         void *driver_priv;      /* Private pointer for the bridge driver */
115         struct list_head bus_list; /* list of VME buses */
116
117         /* Interrupt callbacks */
118         struct vme_irq irq[7];
119         /* Locking for VME irq callback configuration */
120         struct mutex irq_mtx;
121
122         /* Slave Functions */
123         int (*slave_get) (struct vme_slave_resource *, int *,
124                 unsigned long long *, unsigned long long *, dma_addr_t *,
125                 vme_address_t *, vme_cycle_t *);
126         int (*slave_set) (struct vme_slave_resource *, int, unsigned long long,
127                 unsigned long long, dma_addr_t, vme_address_t, vme_cycle_t);
128
129         /* Master Functions */
130         int (*master_get) (struct vme_master_resource *, int *,
131                 unsigned long long *, unsigned long long *, vme_address_t *,
132                 vme_cycle_t *, vme_width_t *);
133         int (*master_set) (struct vme_master_resource *, int,
134                 unsigned long long, unsigned long long,  vme_address_t,
135                 vme_cycle_t, vme_width_t);
136         ssize_t (*master_read) (struct vme_master_resource *, void *, size_t,
137                 loff_t);
138         ssize_t (*master_write) (struct vme_master_resource *, void *, size_t,
139                 loff_t);
140         unsigned int (*master_rmw) (struct vme_master_resource *, unsigned int,
141                 unsigned int, unsigned int, loff_t);
142
143         /* DMA Functions */
144         int (*dma_list_add) (struct vme_dma_list *, struct vme_dma_attr *,
145                 struct vme_dma_attr *, size_t);
146         int (*dma_list_exec) (struct vme_dma_list *);
147         int (*dma_list_empty) (struct vme_dma_list *);
148
149         /* Interrupt Functions */
150         void (*irq_set) (struct vme_bridge *, int, int, int);
151         int (*irq_generate) (struct vme_bridge *, int, int);
152
153         /* Location monitor functions */
154         int (*lm_set) (struct vme_lm_resource *, unsigned long long,
155                 vme_address_t, vme_cycle_t);
156         int (*lm_get) (struct vme_lm_resource *, unsigned long long *,
157                 vme_address_t *, vme_cycle_t *);
158         int (*lm_attach) (struct vme_lm_resource *, int, void (*callback)(int));
159         int (*lm_detach) (struct vme_lm_resource *, int);
160
161         /* CR/CSR space functions */
162         int (*slot_get) (struct vme_bridge *);
163
164         /* Bridge parent interface */
165         void *(*alloc_consistent)(struct device *dev, size_t size,
166                 dma_addr_t *dma);
167         void (*free_consistent)(struct device *dev, size_t size,
168                 void *vaddr, dma_addr_t dma);
169 };
170
171 void vme_irq_handler(struct vme_bridge *, int, int);
172
173 int vme_register_bridge(struct vme_bridge *);
174 void vme_unregister_bridge(struct vme_bridge *);
175
176 #endif /* _VME_BRIDGE_H_ */