Merge remote-tracking branch 'char-misc/char-misc-next'
[deliverable/linux.git] / drivers / vme / vme_bridge.h
CommitLineData
a17a75e2
MW
1#ifndef _VME_BRIDGE_H_
2#define _VME_BRIDGE_H_
3
ad1bfe41
DK
4#include <linux/vme.h>
5
a17a75e2 6#define VME_CRCSR_BUF_SIZE (508*1024)
a17a75e2
MW
7/*
8 * Resource structures
9 */
10struct vme_master_resource {
11 struct list_head list;
12 struct vme_bridge *parent;
13 /*
14 * We are likely to need to access the VME bus in interrupt context, so
400822fe 15 * protect master routines with a spinlock rather than a mutex.
a17a75e2
MW
16 */
17 spinlock_t lock;
18 int locked;
19 int number;
6af04b06
MW
20 u32 address_attr;
21 u32 cycle_attr;
22 u32 width_attr;
8fafb476 23 struct resource bus_resource;
05997267 24 void __iomem *kern_base;
a17a75e2
MW
25};
26
27struct vme_slave_resource {
28 struct list_head list;
29 struct vme_bridge *parent;
400822fe 30 struct mutex mtx;
a17a75e2
MW
31 int locked;
32 int number;
6af04b06
MW
33 u32 address_attr;
34 u32 cycle_attr;
a17a75e2
MW
35};
36
37struct vme_dma_pattern {
38 u32 pattern;
6af04b06 39 u32 type;
a17a75e2
MW
40};
41
42struct vme_dma_pci {
43 dma_addr_t address;
44};
45
46struct vme_dma_vme {
47 unsigned long long address;
6af04b06
MW
48 u32 aspace;
49 u32 cycle;
50 u32 dwidth;
a17a75e2
MW
51};
52
53struct vme_dma_list {
54 struct list_head list;
55 struct vme_dma_resource *parent;
56 struct list_head entries;
400822fe 57 struct mutex mtx;
a17a75e2
MW
58};
59
60struct vme_dma_resource {
61 struct list_head list;
62 struct vme_bridge *parent;
400822fe 63 struct mutex mtx;
a17a75e2
MW
64 int locked;
65 int number;
66 struct list_head pending;
67 struct list_head running;
6af04b06 68 u32 route_attr;
a17a75e2
MW
69};
70
42fb5031
MW
71struct vme_lm_resource {
72 struct list_head list;
73 struct vme_bridge *parent;
74 struct mutex mtx;
75 int locked;
76 int number;
77 int monitors;
78};
79
0b049662 80struct vme_error_handler {
a17a75e2 81 struct list_head list;
0b049662
DK
82 unsigned long long start; /* Beginning of error window */
83 unsigned long long end; /* End of error window */
84 unsigned long long first_error; /* Address of the first error */
85 u32 aspace; /* Address space of error window*/
86 unsigned num_errors; /* Number of errors */
a17a75e2
MW
87};
88
89struct vme_callback {
90 void (*func)(int, int, void*);
91 void *priv_data;
92};
93
94struct vme_irq {
95 int count;
ad1bfe41 96 struct vme_callback callback[VME_NUM_STATUSID];
a17a75e2
MW
97};
98
99/* Allow 16 characters for name (including null character) */
100#define VMENAMSIZ 16
101
102/* This structure stores all the information about one bridge
103 * The structure should be dynamically allocated by the driver and one instance
104 * of the structure should be present for each VME chip present in the system.
a17a75e2
MW
105 */
106struct vme_bridge {
ead1f3e3 107 char name[VMENAMSIZ];
a17a75e2
MW
108 int num;
109 struct list_head master_resources;
110 struct list_head slave_resources;
111 struct list_head dma_resources;
42fb5031 112 struct list_head lm_resources;
a17a75e2 113
0b049662
DK
114 /* List for registered errors handlers */
115 struct list_head vme_error_handlers;
116 /* List of devices on this bridge */
117 struct list_head devices;
a17a75e2
MW
118
119 /* Bridge Info - XXX Move to private structure? */
7f58f025 120 struct device *parent; /* Parent device (eg. pdev->dev for PCI) */
29848ac9 121 void *driver_priv; /* Private pointer for the bridge driver */
733e3ef0 122 struct list_head bus_list; /* list of VME buses */
a17a75e2 123
a17a75e2
MW
124 /* Interrupt callbacks */
125 struct vme_irq irq[7];
c813f592
MW
126 /* Locking for VME irq callback configuration */
127 struct mutex irq_mtx;
a17a75e2
MW
128
129 /* Slave Functions */
130 int (*slave_get) (struct vme_slave_resource *, int *,
131 unsigned long long *, unsigned long long *, dma_addr_t *,
6af04b06 132 u32 *, u32 *);
a17a75e2 133 int (*slave_set) (struct vme_slave_resource *, int, unsigned long long,
6af04b06 134 unsigned long long, dma_addr_t, u32, u32);
a17a75e2
MW
135
136 /* Master Functions */
137 int (*master_get) (struct vme_master_resource *, int *,
6af04b06
MW
138 unsigned long long *, unsigned long long *, u32 *, u32 *,
139 u32 *);
a17a75e2 140 int (*master_set) (struct vme_master_resource *, int,
6af04b06 141 unsigned long long, unsigned long long, u32, u32, u32);
a17a75e2
MW
142 ssize_t (*master_read) (struct vme_master_resource *, void *, size_t,
143 loff_t);
144 ssize_t (*master_write) (struct vme_master_resource *, void *, size_t,
145 loff_t);
146 unsigned int (*master_rmw) (struct vme_master_resource *, unsigned int,
147 unsigned int, unsigned int, loff_t);
148
149 /* DMA Functions */
150 int (*dma_list_add) (struct vme_dma_list *, struct vme_dma_attr *,
151 struct vme_dma_attr *, size_t);
152 int (*dma_list_exec) (struct vme_dma_list *);
153 int (*dma_list_empty) (struct vme_dma_list *);
154
155 /* Interrupt Functions */
29848ac9
MW
156 void (*irq_set) (struct vme_bridge *, int, int, int);
157 int (*irq_generate) (struct vme_bridge *, int, int);
a17a75e2
MW
158
159 /* Location monitor functions */
6af04b06
MW
160 int (*lm_set) (struct vme_lm_resource *, unsigned long long, u32, u32);
161 int (*lm_get) (struct vme_lm_resource *, unsigned long long *, u32 *,
162 u32 *);
fa54b326
AS
163 int (*lm_attach)(struct vme_lm_resource *, int,
164 void (*callback)(void *), void *);
42fb5031 165 int (*lm_detach) (struct vme_lm_resource *, int);
a17a75e2
MW
166
167 /* CR/CSR space functions */
29848ac9 168 int (*slot_get) (struct vme_bridge *);
7f58f025
MV
169
170 /* Bridge parent interface */
171 void *(*alloc_consistent)(struct device *dev, size_t size,
172 dma_addr_t *dma);
173 void (*free_consistent)(struct device *dev, size_t size,
174 void *vaddr, dma_addr_t dma);
a17a75e2
MW
175};
176
e2c6393f 177void vme_bus_error_handler(struct vme_bridge *bridge,
472f16f3 178 unsigned long long address, int am);
c813f592
MW
179void vme_irq_handler(struct vme_bridge *, int, int);
180
326071b3 181struct vme_bridge *vme_init_bridge(struct vme_bridge *);
ead1f3e3
MW
182int vme_register_bridge(struct vme_bridge *);
183void vme_unregister_bridge(struct vme_bridge *);
0b049662
DK
184struct vme_error_handler *vme_register_error_handler(
185 struct vme_bridge *bridge, u32 aspace,
186 unsigned long long address, size_t len);
187void vme_unregister_error_handler(struct vme_error_handler *handler);
a17a75e2
MW
188
189#endif /* _VME_BRIDGE_H_ */
This page took 0.532401 seconds and 5 git commands to generate.