Staging: VME Framework for the Linux Kernel
[deliverable/linux.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 #define VME_SLOTS_MAX 32
6 /*
7 * Resource structures
8 */
9 struct vme_master_resource {
10 struct list_head list;
11 struct vme_bridge *parent;
12 /*
13 * We are likely to need to access the VME bus in interrupt context, so
14 * protect master routines with a spinlock rather than a semaphore.
15 */
16 spinlock_t lock;
17 int locked;
18 int number;
19 vme_address_t address_attr;
20 vme_cycle_t cycle_attr;
21 vme_width_t width_attr;
22 struct resource pci_resource; /* XXX Rename to be bus agnostic */
23 void *kern_base;
24 };
25
26 struct vme_slave_resource {
27 struct list_head list;
28 struct vme_bridge *parent;
29 struct semaphore sem;
30 int locked;
31 int number;
32 vme_address_t address_attr;
33 vme_cycle_t cycle_attr;
34 };
35
36 struct vme_dma_pattern {
37 u32 pattern;
38 vme_pattern_t type;
39 };
40
41 struct vme_dma_pci {
42 dma_addr_t address;
43 };
44
45 struct vme_dma_vme {
46 unsigned long long address;
47 vme_address_t aspace;
48 vme_cycle_t cycle;
49 vme_width_t dwidth;
50 };
51
52 struct vme_dma_list {
53 struct list_head list;
54 struct vme_dma_resource *parent;
55 struct list_head entries;
56 struct semaphore sem;
57 };
58
59 struct vme_dma_resource {
60 struct list_head list;
61 struct vme_bridge *parent;
62 struct semaphore sem;
63 int locked;
64 int number;
65 struct list_head pending;
66 struct list_head running;
67 };
68
69 struct vme_bus_error {
70 struct list_head list;
71 unsigned long long address;
72 u32 attributes;
73 };
74
75 struct vme_callback {
76 void (*func)(int, int, void*);
77 void *priv_data;
78 };
79
80 struct vme_irq {
81 int count;
82 struct vme_callback callback[255];
83 };
84
85 /* Allow 16 characters for name (including null character) */
86 #define VMENAMSIZ 16
87
88 /* This structure stores all the information about one bridge
89 * The structure should be dynamically allocated by the driver and one instance
90 * of the structure should be present for each VME chip present in the system.
91 *
92 * Currently we assume that all chips are PCI-based
93 */
94 struct vme_bridge {
95 char name[VMENAMSIZ];
96 int num;
97 struct list_head master_resources;
98 struct list_head slave_resources;
99 struct list_head dma_resources;
100
101 struct list_head vme_errors; /* List for errors generated on VME */
102
103 /* Bridge Info - XXX Move to private structure? */
104 struct device *parent; /* Generic device struct (pdev->dev for PCI) */
105 void * base; /* Base Address of device registers */
106
107 struct device dev[VME_SLOTS_MAX]; /* Device registered with
108 * device model on VME bus
109 */
110
111 /* Interrupt callbacks */
112 struct vme_irq irq[7];
113
114 /* Slave Functions */
115 int (*slave_get) (struct vme_slave_resource *, int *,
116 unsigned long long *, unsigned long long *, dma_addr_t *,
117 vme_address_t *, vme_cycle_t *);
118 int (*slave_set) (struct vme_slave_resource *, int, unsigned long long,
119 unsigned long long, dma_addr_t, vme_address_t, vme_cycle_t);
120
121 /* Master Functions */
122 int (*master_get) (struct vme_master_resource *, int *,
123 unsigned long long *, unsigned long long *, vme_address_t *,
124 vme_cycle_t *, vme_width_t *);
125 int (*master_set) (struct vme_master_resource *, int,
126 unsigned long long, unsigned long long, vme_address_t,
127 vme_cycle_t, vme_width_t);
128 ssize_t (*master_read) (struct vme_master_resource *, void *, size_t,
129 loff_t);
130 ssize_t (*master_write) (struct vme_master_resource *, void *, size_t,
131 loff_t);
132 unsigned int (*master_rmw) (struct vme_master_resource *, unsigned int,
133 unsigned int, unsigned int, loff_t);
134
135 /* DMA Functions */
136 int (*dma_list_add) (struct vme_dma_list *, struct vme_dma_attr *,
137 struct vme_dma_attr *, size_t);
138 int (*dma_list_exec) (struct vme_dma_list *);
139 int (*dma_list_empty) (struct vme_dma_list *);
140
141 /* Interrupt Functions */
142 int (*request_irq) (int, int, void (*cback)(int, int, void*), void *);
143 void (*free_irq) (int, int);
144 int (*generate_irq) (int, int);
145
146 /* Location monitor functions */
147 int (*lm_set) (unsigned long long, vme_address_t, vme_cycle_t);
148 int (*lm_get) (unsigned long long *, vme_address_t *, vme_cycle_t *);
149 int (*lm_attach) (int, void (*callback)(int));
150 int (*lm_detach) (int);
151
152 /* CR/CSR space functions */
153 int (*slot_get) (void);
154 /* Use standard master read and write functions to access CR/CSR */
155
156 #if 0
157 int (*set_prefetch) (void);
158 int (*get_prefetch) (void);
159 int (*set_arbiter) (void);
160 int (*get_arbiter) (void);
161 int (*set_requestor) (void);
162 int (*get_requestor) (void);
163 #endif
164 };
165
166 int vme_register_bridge (struct vme_bridge *);
167 void vme_unregister_bridge (struct vme_bridge *);
168
169 #endif /* _VME_BRIDGE_H_ */
170
171 #if 0
172 /*
173 * VMEbus GET INFO Arg Structure
174 */
175 struct vmeInfoCfg {
176 int vmeSlotNum; /* VME slot number of interest */
177 int boardResponded; /* Board responded */
178 char sysConFlag; /* System controller flag */
179 int vmeControllerID; /* Vendor/device ID of VME bridge */
180 int vmeControllerRev; /* Revision of VME bridge */
181 char osName[8]; /* Name of OS e.g. "Linux" */
182 int vmeSharedDataValid; /* Validity of data struct */
183 int vmeDriverRev; /* Revision of VME driver */
184 unsigned int vmeAddrHi[8]; /* Address on VME bus */
185 unsigned int vmeAddrLo[8]; /* Address on VME bus */
186 unsigned int vmeSize[8]; /* Size on VME bus */
187 unsigned int vmeAm[8]; /* Address modifier on VME bus */
188 int reserved; /* For future use */
189 };
190 typedef struct vmeInfoCfg vmeInfoCfg_t;
191
192 /*
193 * VMEbus Requester Arg Structure
194 */
195 struct vmeRequesterCfg {
196 int requestLevel; /* Requester Bus Request Level */
197 char fairMode; /* Requester Fairness Mode Indicator */
198 int releaseMode; /* Requester Bus Release Mode */
199 int timeonTimeoutTimer; /* Master Time-on Time-out Timer */
200 int timeoffTimeoutTimer; /* Master Time-off Time-out Timer */
201 int reserved; /* For future use */
202 };
203 typedef struct vmeRequesterCfg vmeRequesterCfg_t;
204
205 /*
206 * VMEbus Arbiter Arg Structure
207 */
208 struct vmeArbiterCfg {
209 vme_arbitration_t arbiterMode; /* Arbitration Scheduling Algorithm */
210 char arbiterTimeoutFlag; /* Arbiter Time-out Timer Indicator */
211 int globalTimeoutTimer; /* VMEbus Global Time-out Timer */
212 char noEarlyReleaseFlag; /* No Early Release on BBUSY */
213 int reserved; /* For future use */
214 };
215 typedef struct vmeArbiterCfg vmeArbiterCfg_t;
216
217
218 /*
219 * VMEbus RMW Configuration Data
220 */
221 struct vmeRmwCfg {
222 unsigned int targetAddrU; /* VME Address (Upper) to trigger RMW cycle */
223 unsigned int targetAddr; /* VME Address (Lower) to trigger RMW cycle */
224 vme_address_t addrSpace; /* VME Address Space */
225 int enableMask; /* Bit mask defining the bits of interest */
226 int compareData; /* Data to be compared with the data read */
227 int swapData; /* Data written to the VMEbus on success */
228 int maxAttempts; /* Maximum times to try */
229 int numAttempts; /* Number of attempts before success */
230 int reserved; /* For future use */
231
232 };
233 typedef struct vmeRmwCfg vmeRmwCfg_t;
234
235 /*
236 * VMEbus Location Monitor Arg Structure
237 */
238 struct vmeLmCfg {
239 unsigned int addrU; /* Location Monitor Address upper */
240 unsigned int addr; /* Location Monitor Address lower */
241 vme_address_t addrSpace; /* Address Space */
242 int userAccessType; /* User/Supervisor Access Type */
243 int dataAccessType; /* Data/Program Access Type */
244 int lmWait; /* Time to wait for access */
245 int lmEvents; /* Lm event mask */
246 int reserved; /* For future use */
247 };
248 typedef struct vmeLmCfg vmeLmCfg_t;
249 #endif
This page took 0.044517 seconds and 5 git commands to generate.