3 * \brief PCI-VME public API
4 * \author Sébastien Dugué
7 * This API presents in fact 2 APIs with some common definitions. One for
8 * drivers and one for user applications. User applications cannot use the
9 * driver specific parts enclosed in \#ifdef __KERNEL__ sections.
11 * Copyright (c) 2009 \em Sébastien \em Dugué
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
25 * VME window attributes
29 * \brief Read prefetch size
31 enum vme_read_prefetch_size {
49 * \brief 2eSST data transfer speed
58 * \brief Address modifiers
60 enum vme_address_modifier {
61 VME_A64_MBLT = 0, /* 0x00 */
62 VME_A64_SCT, /* 0x01 */
63 VME_A64_BLT = 3, /* 0x03 */
64 VME_A64_LCK, /* 0x04 */
65 VME_A32_LCK, /* 0x05 */
66 VME_A32_USER_MBLT = 8, /* 0x08 */
67 VME_A32_USER_DATA_SCT, /* 0x09 */
68 VME_A32_USER_PRG_SCT, /* 0x0a */
69 VME_A32_USER_BLT, /* 0x0b */
70 VME_A32_SUP_MBLT, /* 0x0c */
71 VME_A32_SUP_DATA_SCT, /* 0x0d */
72 VME_A32_SUP_PRG_SCT, /* 0x0e */
73 VME_A32_SUP_BLT, /* 0x0f */
74 VME_2e6U = 0x20, /* 0x20 */
76 VME_A16_USER = 0x29, /* 0x29 */
77 VME_A16_LCK = 0x2c, /* 0x2c */
78 VME_A16_SUP = 0x2d, /* 0x2d */
79 VME_CR_CSR = 0x2f, /* 0x2f */
80 VME_A40_SCT = 0x34, /* 0x34 */
81 VME_A40_LCK, /* 0x35 */
82 VME_A40_BLT = 0x37, /* 0x37 */
83 VME_A24_USER_MBLT, /* 0x38 */
84 VME_A24_USER_DATA_SCT, /* 0x39 */
85 VME_A24_USER_PRG_SCT, /* 0x3a */
86 VME_A24_USER_BLT, /* 0x3b */
87 VME_A24_SUP_MBLT, /* 0x3c */
88 VME_A24_SUP_DATA_SCT, /* 0x3d */
89 VME_A24_SUP_PRG_SCT, /* 0x3e */
90 VME_A24_SUP_BLT, /* 0x3f */
96 * \brief PCI-VME mapping descriptor
97 * \param window_num Hardware window number
98 * \param kernel_va Kernel virtual address of the mapping for use by drivers
99 * \param user_va User virtual address of the mapping for use by applications
100 * \param fd User file descriptor for this mapping
101 * \param window_enabled State of the hardware window
102 * \param data_width VME data width
103 * \param am VME address modifier
104 * \param read_prefetch_enabled PCI read prefetch enabled state
105 * \param read_prefetch_size PCI read prefetch size (in cache lines)
106 * \param v2esst_mode VME 2eSST transfer speed
107 * \param bcast_select VME 2eSST broadcast select
108 * \param pci_addru PCI bus start address upper 32 bits
109 * \param pci_addrl PCI bus start address lower 32 bits
110 * \param sizeu Window size upper 32 bits
111 * \param sizel Window size lower 32 bits
112 * \param vme_addru VME bus start address upper 32 bits
113 * \param vme_addrl VME bus start address lower 32 bits
115 * This data structure is used for describing both a hardware window
116 * and a logical mapping on top of a hardware window. Therefore some of
117 * the fields are only relevant to one of those two entities.
122 /* Reserved for kernel use */
125 /* Reserved for userspace */
129 /* Window settings */
131 enum vme_data_width data_width;
132 enum vme_address_modifier am;
133 int read_prefetch_enabled;
134 enum vme_read_prefetch_size read_prefetch_size;
135 enum vme_2esst_mode v2esst_mode;
137 unsigned int pci_addru;
138 unsigned int pci_addrl;
141 unsigned int vme_addru;
142 unsigned int vme_addrl;
146 * \brief VME RMW descriptor
147 * \param vme_addru VME address for the RMW cycle upper 32 bits
148 * \param vme_addrl VME address for the RMW cycle lower 32 bits
149 * \param am VME address modifier
150 * \param enable_mask Bitmask of the bit
151 * \param compare_data
156 unsigned int vme_addru;
157 unsigned int vme_addrl;
158 enum vme_address_modifier am;
159 unsigned int enable_mask;
160 unsigned int compare_data;
161 unsigned int swap_data;
165 * \brief DMA endpoint attributes
166 * \param data_width VME data width (only used if endpoint is on the VME bus)
167 * \param am VME address modifier (ditto)
168 * \param v2esst_mode VME 2eSST transfer speed (ditto)
169 * \param bcast_select VME 2eSST broadcast select (ditto)
170 * \param addru Address upper 32 bits
171 * \param addrl Address lower 32 bits
173 * This data structure is used for describing the attributes of a DMA endpoint.
174 * All the field excepted for the address are only relevant for an endpoint
177 struct vme_dma_attr {
178 enum vme_data_width data_width;
179 enum vme_address_modifier am;
180 enum vme_2esst_mode v2esst_mode;
181 unsigned int bcast_select;
186 /** \brief DMA block size on the PCI or VME bus */
187 enum vme_dma_block_size {
188 VME_DMA_BSIZE_32 = 0,
198 /** \brief DMA backoff time (us) on the PCI or VME bus */
199 enum vme_dma_backoff {
200 VME_DMA_BACKOFF_0 = 0,
212 * \param vme_block_size VME bus block size when the source is VME
213 * \param vme_backoff_time VME bus backoff time when the source is VME
214 * \param pci_block_size PCI/X bus block size when the source is PCI
215 * \param pci_backoff_time PCI bus backoff time when the source is PCI
218 struct vme_dma_ctrl {
219 enum vme_dma_block_size vme_block_size;
220 enum vme_dma_backoff vme_backoff_time;
221 enum vme_dma_block_size pci_block_size;
222 enum vme_dma_backoff pci_backoff_time;
225 /** \brief DMA transfer direction */
227 VME_DMA_TO_DEVICE = 1,
232 * \brief VME DMA transfer descriptor
233 * \param status Transfer status
234 * \param length Transfer size in bytes
235 * \param novmeinc Must be set to 1 when accessing a FIFO like device on the VME
236 * \param dir Transfer direction
237 * \param src Transfer source attributes
238 * \param dst Transfer destination attributes
239 * \param opt Transfer control
245 unsigned int novmeinc;
246 enum vme_dma_dir dir;
248 struct vme_dma_attr src;
249 struct vme_dma_attr dst;
251 struct vme_dma_ctrl ctrl;
256 /*! @name VME single access swapping policy
259 #define SINGLE_NO_SWAP 0
260 #define SINGLE_AUTO_SWAP 1
261 #define SINGLE_WORD_SWAP 2
262 #define SINGLE_BYTEWORD_SWAP 3
266 /*! @name page qualifier
270 #define VME_PG_SHARED 0x00
271 #define VME_PG_PRIVATE 0x02
276 * \brief VME mapping attributes
277 * \param iack VME IACK 0 -> IACK pages
278 * \param rdpref VME read prefetch option 0 -> Disable
279 * \param wrpost VME write posting option
280 * \param swap VME swap options
281 * \param sgmin page descriptor number returned by find_controller
282 * \param dum -- dum[0] page qualifier (shared/private), dum[1] XPC ADP-type
283 * dum[2] - reserved, _must_ be 0.
285 * This structure is used for the find_controller() and return_controller()
286 * LynxOS CES driver emulation.
288 struct pdparam_master
291 unsigned long rdpref;
292 unsigned long wrpost;
295 unsigned long dum[3];
301 * \name Window management ioctl numbers
304 /** Get a physical window attributes */
305 #define VME_IOCTL_GET_WINDOW_ATTR _IOWR('V', 0, struct vme_mapping)
306 /** Create a physical window */
307 #define VME_IOCTL_CREATE_WINDOW _IOW( 'V', 1, struct vme_mapping)
308 /** Destroy a physical window */
309 #define VME_IOCTL_DESTROY_WINDOW _IOW( 'V', 2, int)
310 /** Create a mapping over a physical window */
311 #define VME_IOCTL_FIND_MAPPING _IOWR('V', 3, struct vme_mapping)
312 /** Remove a mapping */
313 #define VME_IOCTL_RELEASE_MAPPING _IOW( 'V', 4, struct vme_mapping)
314 /** Get the create on find failed flag */
315 #define VME_IOCTL_GET_CREATE_ON_FIND_FAIL _IOR( 'V', 5, unsigned int)
316 /** Set the create on find failed flag */
317 #define VME_IOCTL_SET_CREATE_ON_FIND_FAIL _IOW( 'V', 6, unsigned int)
318 /** Get the destroy on remove flag */
319 #define VME_IOCTL_GET_DESTROY_ON_REMOVE _IOR( 'V', 7, unsigned int)
320 /** Set the destroy on remove flag */
321 #define VME_IOCTL_SET_DESTROY_ON_REMOVE _IOW( 'V', 8, unsigned int)
322 /** Get bus error status */
323 #define VME_IOCTL_GET_BUS_ERROR _IOR( 'V', 9, unsigned int)
330 /** Start a DMA transfer */
331 #define VME_IOCTL_START_DMA _IOWR('V', 10, struct vme_dma)
338 * Those definitions are for drivers only and are not visible to userspace.
341 /* API for new drivers */
342 extern int vme_request_irq(unsigned int, int (*)(void *),
343 void *, const char *);
344 extern int vme_free_irq(unsigned int );
345 extern int vme_generate_interrupt(int, int, signed long);
347 extern struct vme_mapping* find_vme_mapping_from_addr(unsigned);
348 extern int vme_get_window_attr(struct vme_mapping *);
349 extern int vme_create_window(struct vme_mapping *);
350 extern int vme_destroy_window(int);
351 extern int vme_find_mapping(struct vme_mapping *, int);
352 extern int vme_release_mapping(struct vme_mapping *, int);
354 extern int vme_do_dma(struct vme_dma *);
357 extern int vme_bus_error_check(int);
359 /* API providing an emulation of the CES VME driver for legacy drivers */
360 extern unsigned long find_controller(unsigned long, unsigned long,
361 unsigned long, unsigned long,
362 unsigned long, struct pdparam_master *);
363 extern unsigned long return_controller(unsigned, unsigned);
364 extern int vme_intset(int, int (*)(void *), void *, void *);
365 extern int vme_intclr(int, void *);
368 #endif /* __KERNEL__ */