Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line | 
|---|---|---|---|
| 9 | f9daq | 1 | #ifndef __PCIVME_H__ | 
        
| 2 | #define __PCIVME_H__ | 
        ||
| 3 | |||
| 4 | //**************************************************************************** | 
        ||
| 5 | // Copyright (C) 2000-2004  ARW Elektronik Germany | 
        ||
| 6 | // | 
        ||
| 7 | // | 
        ||
| 8 | // This program is free software; you can redistribute it and/or modify | 
        ||
| 9 | // it under the terms of the GNU General Public License as published by | 
        ||
| 10 | // the Free Software Foundation; either version 2 of the License, or | 
        ||
| 11 | // (at your option) any later version. | 
        ||
| 12 | // | 
        ||
| 13 | // This program is distributed in the hope that it will be useful, | 
        ||
| 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | 
        ||
| 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
        ||
| 16 | // GNU General Public License for more details. | 
        ||
| 17 | // | 
        ||
| 18 | // You should have received a copy of the GNU General Public License | 
        ||
| 19 | // along with this program; if not, write to the Free Software | 
        ||
| 20 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 
        ||
| 21 | // | 
        ||
| 22 | // This product is not authorized for use as critical component in  | 
        ||
| 23 | // life support systems without the express written approval of  | 
        ||
| 24 | // ARW Elektronik Germany. | 
        ||
| 25 | //   | 
        ||
| 26 | // Please announce changes and hints to ARW Elektronik | 
        ||
| 27 | // | 
        ||
| 28 | // Maintainer(s): Klaus Hitschler (klaus.hitschler@gmx.de) | 
        ||
| 29 | // | 
        ||
| 30 | //**************************************************************************** | 
        ||
| 31 | |||
| 32 | //**************************************************************************** | 
        ||
| 33 | // | 
        ||
| 34 | // pcivme.h -- the common header for driver and applications for the PCIVME  | 
        ||
| 35 | //             PCI to VME Interface | 
        ||
| 36 | //             All commands and constants are similiar to WIN?? drivers, but | 
        ||
| 37 | //             not equal. Please check if you cross-port or develop. | 
        ||
| 38 | // | 
        ||
| 39 | // $Log: pcivme.h,v $ | 
        ||
| 40 | // Revision 1.9  2004/08/13 19:23:26  klaus | 
        ||
| 41 | // conversion to kernel-version 2.6, released version 3.0 | 
        ||
| 42 | // | 
        ||
| 43 | // Revision 1.8  2003/06/27 17:25:52  klaus | 
        ||
| 44 | // incomplete try to get mmap() with nopage() running for automatic page switch | 
        ||
| 45 | // | 
        ||
| 46 | // Revision 1.7  2002/10/20 18:06:51  klaus | 
        ||
| 47 | // changed error handling | 
        ||
| 48 | // | 
        ||
| 49 | // Revision 1.6  2002/10/18 21:56:28  klaus | 
        ||
| 50 | // completed functional features, untested | 
        ||
| 51 | // | 
        ||
| 52 | // Revision 1.5  2002/10/18 21:56:28  klaus | 
        ||
| 53 | // completed functional features, untested | 
        ||
| 54 | // | 
        ||
| 55 | // Revision 1.4  2002/10/17 19:05:03  klaus | 
        ||
| 56 | // VME access is working through test to lib to driver | 
        ||
| 57 | // | 
        ||
| 58 | //**************************************************************************** | 
        ||
| 59 | |||
| 60 | #include <linux/types.h> | 
        ||
| 61 | #include <asm/ioctl.h> | 
        ||
| 62 | |||
| 63 | #define PCIVME_MAGIC ' ' | 
        ||
| 64 | |||
| 65 | #define MAX_INIT_ELEMENTS 20  // maximum number of init in PCIVME_(DE)INIT_HARDWARE | 
        ||
| 66 | |||
| 67 | #ifndef __KERNEL__ | 
        ||
| 68 |     #define u8  __u8 | 
        ||
| 69 |     #define u16 __u16 | 
        ||
| 70 |     #define u32 __u32 | 
        ||
| 71 | #endif | 
        ||
| 72 | |||
| 73 | //---------------------------------------------------------------------------- | 
        ||
| 74 | // shared structures between driver & app to support ioctls ------------------ | 
        ||
| 75 | typedef struct // one command element to initialize interface or deinitialize  | 
        ||
| 76 | { | 
        ||
| 77 | u8 bDestination; // 0 = lcr, 1 = vme-interface, -1 = stop  | 
        ||
| 78 | u8 bAccessType; // 1 = byte access, 2 = word access, 4 = long access  | 
        ||
| 79 | u16 wOffset; // offset into interface address range for initialisation  | 
        ||
| 80 | u32 dwValue; // value to initialize  | 
        ||
| 81 | } PCIVME_INIT_ELEMENT;  | 
        ||
| 82 | |||
| 83 | typedef struct  | 
        ||
| 84 | { | 
        ||
| 85 | PCIVME_INIT_ELEMENT sVie[MAX_INIT_ELEMENTS]; // at least one zero element must be the last  | 
        ||
| 86 | } PCIVME_INIT_COMMAND;  | 
        ||
| 87 | |||
| 88 | typedef struct  | 
        ||
| 89 | { | 
        ||
| 90 | u8 bModifier; // set the current modifier  | 
        ||
| 91 | u8 bAccessType; // set the current access type (1,2,4), not used  | 
        ||
| 92 | u8 bIncrement; // set the current byte increment count, not used  | 
        ||
| 93 | u8 bDummy; // reserved  | 
        ||
| 94 | } PCIVME_ACCESS_COMMAND;  | 
        ||
| 95 | |||
| 96 | typedef struct  | 
        ||
| 97 | { | 
        ||
| 98 | u32 dwAddress; // tas to address  | 
        ||
| 99 | u8 bModifier; // VME address modifier for this window  | 
        ||
| 100 | u8 bContent; // content to store and get back  | 
        ||
| 101 | } PCIVME_TAS_STRUCT;  | 
        ||
| 102 | |||
| 103 | typedef struct  | 
        ||
| 104 | { | 
        ||
| 105 | u16 wRegisterAddress; // address offset of vic68a register  | 
        ||
| 106 | u8 bAccessMode; // read, write, or, and  | 
        ||
| 107 | u8 bContent; // content to write, and, or  | 
        ||
| 108 | u8 bDummy; // reserved  | 
        ||
| 109 | } PCIVME_VIC68A_ACTION;  | 
        ||
| 110 | |||
| 111 | typedef struct  | 
        ||
| 112 | { | 
        ||
| 113 | u8 bEnable; // set to 0 to disable, != 0 to enable  | 
        ||
| 114 | u8 bDummy; // reserved  | 
        ||
| 115 | } PCIVME_IRQ_CONTROL;  | 
        ||
| 116 | |||
| 117 | typedef struct  | 
        ||
| 118 | { | 
        ||
| 119 | u8 bCommand; // makes and reads different reset commands  | 
        ||
| 120 | u8 bResult; // return result, == 0 if command has finished  | 
        ||
| 121 | } PCIVME_RESET_COMMAND;  | 
        ||
| 122 | |||
| 123 | typedef struct // static information about status of PCIADA & VMEMM  | 
        ||
| 124 | { | 
        ||
| 125 | u8 bConnected; // is it or it was software connected  | 
        ||
| 126 | u8 cModuleNumber; // module number  | 
        ||
| 127 | u8 cFPGAVersion; // FPGA Version number  | 
        ||
| 128 | u8 cSystemController; // set if VMEMM is system controller  | 
        ||
| 129 | u8 cWordMode; // set if VMEMM is jumpered to word mode  | 
        ||
| 130 | u8 bDummy; // reserved  | 
        ||
| 131 | } PCIVME_STATIC_STATUS;  | 
        ||
| 132 | |||
| 133 | typedef struct // dynamic information about status of PCIADA & VMEMM  | 
        ||
| 134 | { | 
        ||
| 135 | u8 bConnected; // the current cable connection state  | 
        ||
| 136 | u8 bPCIADAIrq; // interrupt pending due to timeout or connection fail  | 
        ||
| 137 | u8 bVMEMMIrq; // interrupt pending due to VMEMM event  | 
        ||
| 138 | u8 bDummy; // reserved  | 
        ||
| 139 | } PCIVME_DYNAMIC_STATUS;  | 
        ||
| 140 | |||
| 141 | typedef struct  | 
        ||
| 142 | { | 
        ||
| 143 | u32 dwStatusID; // interrupt-vector (byte, word, long)  | 
        ||
| 144 | u8 bLevel; // interrupt-level  | 
        ||
| 145 | u8 bPCIADAIrq; // pending PCIADA Irq detected and cleared  | 
        ||
| 146 | } PCIVME_VECTOR_LEVEL;  | 
        ||
| 147 | |||
| 148 | //---------------------------------------------------------------------------- | 
        ||
| 149 | // commands to support ioctls ------------------------------------------------ | 
        ||
| 150 | #define PCIVME_INIT_HARDWARE       _IOW(PCIVME_MAGIC,   1, PCIVME_INIT_COMMAND)   // initializes the hardware with given parameters | 
        ||
| 151 | #define PCIVME_DEINIT_HARDWARE     _IOW(PCIVME_MAGIC,   2, PCIVME_INIT_COMMAND)   // uninitializes the hardware | 
        ||
| 152 | |||
| 153 | #define PCIVME_SET_ACCESS_PARA     _IOWR(PCIVME_MAGIC,  3, PCIVME_ACCESS_COMMAND) // set the address modifier for this path | 
        ||
| 154 | |||
| 155 | #define PCIVME_GET_STATIC_STATUS   _IOR(PCIVME_MAGIC,   4, PCIVME_STATIC_STATUS)  // asks for static status of PCIADA & connected VMEMM | 
        ||
| 156 | #define PCIVME_GET_DYNAMIC_STATUS  _IOR(PCIVME_MAGIC,   5, PCIVME_DYNAMIC_STATUS) // asks for dynamic status of PCIADA & connected VMEMM | 
        ||
| 157 | |||
| 158 | #define PCIVME_READ_VECTOR_POLL    _IOR(PCIVME_MAGIC,   6, PCIVME_VECTOR_LEVEL)   // reads the level and vector of IRQ | 
        ||
| 159 | #define PCIVME_READ_VECTOR_BLOCK   _IOR(PCIVME_MAGIC,   7, PCIVME_VECTOR_LEVEL)   // reads blocking the level and vector of IRQ | 
        ||
| 160 | |||
| 161 | #define PCIVME_CONTROL_INTERRUPTS  _IOWR(PCIVME_MAGIC,  8, PCIVME_IRQ_CONTROL)    // set, clear interrupt enable | 
        ||
| 162 | #define PCIVME_TAS                 _IOWR(PCIVME_MAGIC,  9, PCIVME_TAS_STRUCT)     // make test and set | 
        ||
| 163 | #define PCIVME_RESET               _IOWR(PCIVME_MAGIC, 10, PCIVME_RESET_COMMAND)  // make a reset to VME or global | 
        ||
| 164 | |||
| 165 | #define PCIVME_ACCESS_VIC68A       _IOWR(PCIVME_MAGIC, 11, PCIVME_VIC68A_ACTION)  // access vic68a register (interface depended) | 
        ||
| 166 | |||
| 167 | //---------------------------------------------------------------------------- | 
        ||
| 168 | // input constants of ioctls ------------------------------------------------- | 
        ||
| 169 | |||
| 170 | // switches for PCIVME_INIT and DEINIT_COMMAND  | 
        ||
| 171 | #define LCR   (u8)0           // destination is PCIADA (LCR) register | 
        ||
| 172 | #define IFR   (u8)1           // destination is VMEMM-Interface register | 
        ||
| 173 | #define VIC   (u8)2           // destination is VIC68A register | 
        ||
| 174 | #define STOP  (u8)255         // this command stops the init machine | 
        ||
| 175 | |||
| 176 | #define BYTE_ACCESS (u8)1     // write byte wise | 
        ||
| 177 | #define WORD_ACCESS (u8)2     //       word | 
        ||
| 178 | #define LONG_ACCESS (u8)4     //       long | 
        ||
| 179 | |||
| 180 | // switches for PCIVME_ACCESS_VIC68A | 
        ||
| 181 | #define VIC68A_READ       0   // read only access | 
        ||
| 182 | #define VIC68A_WRITE      1   // write and read back access | 
        ||
| 183 | #define VIC68A_OR         2   // read, bitwise 'or' content and read back access | 
        ||
| 184 | #define VIC68A_AND        3   // read, bitwise 'and' content and read back access | 
        ||
| 185 | #define VIC68A_WRITE_ONLY 4   // do not read back after write | 
        ||
| 186 | |||
| 187 | // switches for PCIVME_VECTOR_CMD | 
        ||
| 188 | #define READ_CURRENT_LEVEL 0  // try to get the current irq level | 
        ||
| 189 | #define READ_VECTOR        1  // (if level == 0) read vector @ current LEVEL else @ level | 
        ||
| 190 | |||
| 191 | // switches for the PCIVME_RESET | 
        ||
| 192 | #define VME_RESET_CMD      0  // raise a VME reset only | 
        ||
| 193 | #define LOCAL_RESET_CMD    1  // raise a local reset only | 
        ||
| 194 | #define GLOBAL_RESET_CMD   2  // raise a global reset | 
        ||
| 195 | #define POLL_RESET_CMD     3  // ask if reset is finished | 
        ||
| 196 | |||
| 197 | // address masks for the pager - to use for offset and size @ window alignment | 
        ||
| 198 | #define HI_ADDRESS_MASK   (u32)0xFFFFF000       // masks the high part of a vme address | 
        ||
| 199 | #define LO_ADDRESS_MASK   (~HI_ADDRESS_MASK)    // masks the low  part of a vme address | 
        ||
| 200 | #define ONE_PAGE_SIZE     (LO_ADDRESS_MASK + 1) // size of 1 page (hardware related) | 
        ||
| 201 | |||
| 202 | // macros to calculate the real base and the real size of demand pages | 
        ||
| 203 | #define PCIVME_PAGE_BASE(base)       (base & HI_ADDRESS_MASK)  // makes an aligned base for a page | 
        ||
| 204 | #define PCIVME_PAGE_SIZE(base, size) (((base + size + LO_ADDRESS_MASK) / ONE_PAGE_SIZE) * ONE_PAGE_SIZE) | 
        ||
| 205 | |||
| 206 | //---------------------------------------------------------------------------- | 
        ||
| 207 | // results of ioctls --------------------------------------------------------- | 
        ||
| 208 | #define NOT_MY_INTERRUPT   0 | 
        ||
| 209 | #define PCIADA_INTERRUPT   1 | 
        ||
| 210 | #define VMEMM_INTERRUPT    2 | 
        ||
| 211 | |||
| 212 | #endif /* __PCIVME_H__ */ |