blob: a64677e0a31a54fc5da8a1c3956205232b27dcf3 [file] [log] [blame]
Martyn Welcha17a75e2009-07-31 09:28:17 +01001#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 */
9struct 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
Martyn Welch400822f2009-08-11 16:20:22 +010014 * protect master routines with a spinlock rather than a mutex.
Martyn Welcha17a75e2009-07-31 09:28:17 +010015 */
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
26struct vme_slave_resource {
27 struct list_head list;
28 struct vme_bridge *parent;
Martyn Welch400822f2009-08-11 16:20:22 +010029 struct mutex mtx;
Martyn Welcha17a75e2009-07-31 09:28:17 +010030 int locked;
31 int number;
32 vme_address_t address_attr;
33 vme_cycle_t cycle_attr;
34};
35
36struct vme_dma_pattern {
37 u32 pattern;
38 vme_pattern_t type;
39};
40
41struct vme_dma_pci {
42 dma_addr_t address;
43};
44
45struct 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
52struct vme_dma_list {
53 struct list_head list;
54 struct vme_dma_resource *parent;
55 struct list_head entries;
Martyn Welch400822f2009-08-11 16:20:22 +010056 struct mutex mtx;
Martyn Welcha17a75e2009-07-31 09:28:17 +010057};
58
59struct vme_dma_resource {
60 struct list_head list;
61 struct vme_bridge *parent;
Martyn Welch400822f2009-08-11 16:20:22 +010062 struct mutex mtx;
Martyn Welcha17a75e2009-07-31 09:28:17 +010063 int locked;
64 int number;
65 struct list_head pending;
66 struct list_head running;
67};
68
Martyn Welch42fb5032009-08-11 17:44:56 +010069struct 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
Martyn Welcha17a75e2009-07-31 09:28:17 +010078struct vme_bus_error {
79 struct list_head list;
80 unsigned long long address;
81 u32 attributes;
82};
83
84struct vme_callback {
85 void (*func)(int, int, void*);
86 void *priv_data;
87};
88
89struct 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 * Currently we assume that all chips are PCI-based
102 */
103struct vme_bridge {
Martyn Welchead1f3e2009-12-15 08:43:02 +0000104 char name[VMENAMSIZ];
Martyn Welcha17a75e2009-07-31 09:28:17 +0100105 int num;
106 struct list_head master_resources;
107 struct list_head slave_resources;
108 struct list_head dma_resources;
Martyn Welch42fb5032009-08-11 17:44:56 +0100109 struct list_head lm_resources;
Martyn Welcha17a75e2009-07-31 09:28:17 +0100110
111 struct list_head vme_errors; /* List for errors generated on VME */
112
113 /* Bridge Info - XXX Move to private structure? */
114 struct device *parent; /* Generic device struct (pdev->dev for PCI) */
Martyn Welchead1f3e2009-12-15 08:43:02 +0000115 void *base; /* Base Address of device registers */
Martyn Welcha17a75e2009-07-31 09:28:17 +0100116
117 struct device dev[VME_SLOTS_MAX]; /* Device registered with
118 * device model on VME bus
119 */
120
121 /* Interrupt callbacks */
122 struct vme_irq irq[7];
Martyn Welchc813f592009-10-29 16:34:54 +0000123 /* Locking for VME irq callback configuration */
124 struct mutex irq_mtx;
Martyn Welcha17a75e2009-07-31 09:28:17 +0100125
126 /* Slave Functions */
127 int (*slave_get) (struct vme_slave_resource *, int *,
128 unsigned long long *, unsigned long long *, dma_addr_t *,
129 vme_address_t *, vme_cycle_t *);
130 int (*slave_set) (struct vme_slave_resource *, int, unsigned long long,
131 unsigned long long, dma_addr_t, vme_address_t, vme_cycle_t);
132
133 /* Master Functions */
134 int (*master_get) (struct vme_master_resource *, int *,
135 unsigned long long *, unsigned long long *, vme_address_t *,
136 vme_cycle_t *, vme_width_t *);
137 int (*master_set) (struct vme_master_resource *, int,
138 unsigned long long, unsigned long long, vme_address_t,
139 vme_cycle_t, vme_width_t);
140 ssize_t (*master_read) (struct vme_master_resource *, void *, size_t,
141 loff_t);
142 ssize_t (*master_write) (struct vme_master_resource *, void *, size_t,
143 loff_t);
144 unsigned int (*master_rmw) (struct vme_master_resource *, unsigned int,
145 unsigned int, unsigned int, loff_t);
146
147 /* DMA Functions */
148 int (*dma_list_add) (struct vme_dma_list *, struct vme_dma_attr *,
149 struct vme_dma_attr *, size_t);
150 int (*dma_list_exec) (struct vme_dma_list *);
151 int (*dma_list_empty) (struct vme_dma_list *);
152
153 /* Interrupt Functions */
Martyn Welchc813f592009-10-29 16:34:54 +0000154 void (*irq_set) (int, int, int);
155 int (*irq_generate) (int, int);
Martyn Welcha17a75e2009-07-31 09:28:17 +0100156
157 /* Location monitor functions */
Martyn Welch42fb5032009-08-11 17:44:56 +0100158 int (*lm_set) (struct vme_lm_resource *, unsigned long long,
159 vme_address_t, vme_cycle_t);
160 int (*lm_get) (struct vme_lm_resource *, unsigned long long *,
161 vme_address_t *, vme_cycle_t *);
162 int (*lm_attach) (struct vme_lm_resource *, int, void (*callback)(int));
163 int (*lm_detach) (struct vme_lm_resource *, int);
Martyn Welcha17a75e2009-07-31 09:28:17 +0100164
165 /* CR/CSR space functions */
166 int (*slot_get) (void);
167 /* Use standard master read and write functions to access CR/CSR */
168
169#if 0
170 int (*set_prefetch) (void);
171 int (*get_prefetch) (void);
172 int (*set_arbiter) (void);
173 int (*get_arbiter) (void);
174 int (*set_requestor) (void);
175 int (*get_requestor) (void);
176#endif
177};
178
Martyn Welchc813f592009-10-29 16:34:54 +0000179void vme_irq_handler(struct vme_bridge *, int, int);
180
Martyn Welchead1f3e2009-12-15 08:43:02 +0000181int vme_register_bridge(struct vme_bridge *);
182void vme_unregister_bridge(struct vme_bridge *);
Martyn Welcha17a75e2009-07-31 09:28:17 +0100183
184#endif /* _VME_BRIDGE_H_ */
185
186#if 0
187/*
188 * VMEbus GET INFO Arg Structure
189 */
190struct vmeInfoCfg {
191 int vmeSlotNum; /* VME slot number of interest */
192 int boardResponded; /* Board responded */
193 char sysConFlag; /* System controller flag */
194 int vmeControllerID; /* Vendor/device ID of VME bridge */
195 int vmeControllerRev; /* Revision of VME bridge */
196 char osName[8]; /* Name of OS e.g. "Linux" */
197 int vmeSharedDataValid; /* Validity of data struct */
198 int vmeDriverRev; /* Revision of VME driver */
199 unsigned int vmeAddrHi[8]; /* Address on VME bus */
200 unsigned int vmeAddrLo[8]; /* Address on VME bus */
201 unsigned int vmeSize[8]; /* Size on VME bus */
202 unsigned int vmeAm[8]; /* Address modifier on VME bus */
203 int reserved; /* For future use */
204};
205typedef struct vmeInfoCfg vmeInfoCfg_t;
206
207/*
208 * VMEbus Requester Arg Structure
209 */
210struct vmeRequesterCfg {
211 int requestLevel; /* Requester Bus Request Level */
212 char fairMode; /* Requester Fairness Mode Indicator */
213 int releaseMode; /* Requester Bus Release Mode */
214 int timeonTimeoutTimer; /* Master Time-on Time-out Timer */
215 int timeoffTimeoutTimer; /* Master Time-off Time-out Timer */
216 int reserved; /* For future use */
217};
218typedef struct vmeRequesterCfg vmeRequesterCfg_t;
219
220/*
221 * VMEbus Arbiter Arg Structure
222 */
223struct vmeArbiterCfg {
224 vme_arbitration_t arbiterMode; /* Arbitration Scheduling Algorithm */
225 char arbiterTimeoutFlag; /* Arbiter Time-out Timer Indicator */
226 int globalTimeoutTimer; /* VMEbus Global Time-out Timer */
227 char noEarlyReleaseFlag; /* No Early Release on BBUSY */
228 int reserved; /* For future use */
229};
230typedef struct vmeArbiterCfg vmeArbiterCfg_t;
231
232
233/*
234 * VMEbus RMW Configuration Data
235 */
236struct vmeRmwCfg {
237 unsigned int targetAddrU; /* VME Address (Upper) to trigger RMW cycle */
238 unsigned int targetAddr; /* VME Address (Lower) to trigger RMW cycle */
239 vme_address_t addrSpace; /* VME Address Space */
240 int enableMask; /* Bit mask defining the bits of interest */
241 int compareData; /* Data to be compared with the data read */
242 int swapData; /* Data written to the VMEbus on success */
243 int maxAttempts; /* Maximum times to try */
244 int numAttempts; /* Number of attempts before success */
245 int reserved; /* For future use */
246
247};
248typedef struct vmeRmwCfg vmeRmwCfg_t;
249
250/*
251 * VMEbus Location Monitor Arg Structure
252 */
253struct vmeLmCfg {
254 unsigned int addrU; /* Location Monitor Address upper */
255 unsigned int addr; /* Location Monitor Address lower */
256 vme_address_t addrSpace; /* Address Space */
257 int userAccessType; /* User/Supervisor Access Type */
258 int dataAccessType; /* Data/Program Access Type */
259 int lmWait; /* Time to wait for access */
260 int lmEvents; /* Lm event mask */
261 int reserved; /* For future use */
262};
263typedef struct vmeLmCfg vmeLmCfg_t;
264#endif