vmedrv.h

Go to the documentation of this file.
00001 /*
00002 ===============================================================================
00003                             COPYRIGHT NOTICE
00004 
00005     Copyright (c) 2007, GE Fanuc Embedded Systems, Inc.
00006     All Rights Reserved.
00007 
00008 -------------------------------------------------------------------------------
00009 
00010 Redistribution and use in source and binary forms, with or without
00011 modification, are permitted provided that the following conditions are met:
00012 
00013    o Redistributions of source code must retain the above copyright notice, this
00014      list of conditions and the following disclaimer.
00015    o Redistributions in binary form must reproduce the above copyright notice,
00016      this list of conditions and the following disclaimer in the documentation
00017      and/or other materials provided with the distribution.
00018    o Neither the name of GE Fanuc nor the names of its contributors may be used
00019      to endorse or promote products derived from this software without specific
00020      prior written permission.
00021 
00022 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00023 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00024 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00025 DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
00026 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00027 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00029 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00030 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00031 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00032 -------------------------------------------------------------------------------
00033 
00034     $Workfile: vmedrv.h $
00035     $Revision: 5 $
00036     $Modtime: 2/24/07 10:17a $
00037 
00038 ===============================================================================
00039 */
00040 
00041 /*
00042  * Module name: vmedrv.h
00043  *      Application interface to VME device nodes.
00044  */
00045 
00046 /*
00047  * The reserved elements in the following structures are 
00048  * intended to allow future versions of the driver to 
00049  * maintain backwards compatibility.  Applications should 
00050  * initialize reserved locations to zero.
00051  */
00052 
00053 #ifndef VMEDRV_H
00054 #define VMEDRV_H
00055 
00056 #define VMEDRV_REV      0x0301
00057 
00058 #define VME_MINOR_TYPE_MASK     0xF0
00059 #define VME_MINOR_OUT   0x00
00060 #define VME_MINOR_DMA   0x10
00061 #define VME_MINOR_MISC  0x20
00062 #define VME_MINOR_SLOTS1        0x30
00063 #define VME_MINOR_SLOTS2        0x40
00064 
00065 #define VME_MINOR_CTL   0x20
00066 #define VME_MINOR_REGS  0x21
00067 #define VME_MINOR_RMW   0x22
00068 #define VME_MINOR_LM    0x23
00069 #ifndef PAGESIZE
00070 #define PAGESIZE 4096
00071 #endif
00072 #ifndef LINESIZE
00073 #define LINESIZE 0x20
00074 #endif
00075 #define VME_MAX_WINDOWS 8
00076 #ifndef PCI_DEVICE_ID_TUNDRA_TEMPE
00077 #define PCI_DEVICE_ID_TUNDRA_TEMPE 0x148
00078 #endif
00079 
00080 /* All registers above 0x100 must be byteswapped in the Tempe on x86 platforms */
00081 #ifdef PPC
00082 #define longswap(x) (x)
00083 #else
00084 #define longswap(x) ((uint32_t) ( \
00085                      ((x<<24) & 0xff000000) | \
00086                      ((x<<8)  & 0x00ff0000) | \
00087                      ((x>>8)  & 0x0000ff00) | \
00088                      ((x>>24) & 0x000000ff)  \
00089                     ))
00090 #endif
00091 
00092 #ifndef iowrite32
00093   #define iowrite32 writel
00094 #endif
00095 #ifndef iowrite16
00096   #define iowrite16 writew
00097 #endif
00098 #ifndef iowrite8
00099   #define iowrite8 writeb
00100 #endif
00101 
00102 #ifndef ioread32
00103   #define ioread32 readl
00104 #endif
00105 #ifndef ioread16
00106   #define ioread16 readw
00107 #endif
00108 #ifndef ioread8
00109   #define ioread8 readb
00110 #endif
00111 
00112 
00113 /************************************************************************
00114  * COMMON definitions 
00115  */
00116 
00117 /*
00118  *  VME access type definitions
00119  */
00120 #define VME_DATA                1
00121 #define VME_PROG                2
00122 #define VME_USER                4
00123 #define VME_SUPER               8
00124 
00125 /*
00126  *  VME address type definitions
00127  */
00128 typedef enum {
00129         VME_A16,
00130         VME_A24,
00131         VME_A32,
00132         VME_A64,
00133         VME_CRCSR,
00134         VME_USER1,
00135         VME_USER2,
00136         VME_USER3,
00137         VME_USER4
00138 } addressMode_t;
00139 
00140 /*
00141  *  VME Transfer Protocol Definitions
00142  */
00143 #define VME_SCT                 0x1
00144 #define VME_BLT                 0x2
00145 #define VME_MBLT                0x4
00146 #define VME_2eVME               0x8
00147 #define VME_2eSST               0x10
00148 #define VME_2eSSTB              0x20
00149 
00150 /*
00151  *  Data Widths 
00152  */
00153 typedef enum {
00154         VME_D8 = 8,
00155         VME_D16 = 16,
00156         VME_D32 = 32,
00157         VME_D64 = 64
00158 } dataWidth_t;
00159 
00160 /*
00161  *  2eSST Data Transfer Rate Codes
00162  */
00163 typedef enum {
00164         VME_SSTNONE = 0,
00165         VME_SST160 = 160,
00166         VME_SST267 = 267,
00167         VME_SST320 = 320
00168 } vme2esstRate_t;
00169 
00170 
00171 /*
00172  *  Arbitration Scheduling Modes
00173  */
00174 typedef enum {
00175         VME_R_ROBIN_MODE,
00176         VME_PRIORITY_MODE
00177 } vme2ArbMode_t;
00178 
00179 
00180 /************************************************************************
00181  *  /dev/vme_m* Outbound Window Ioctl Commands
00182  */
00183 #define VME_IOCTL_SET_OUTBOUND          0x10
00184 #define VME_IOCTL_GET_OUTBOUND          0x11
00185 /*
00186  *  VMEbus OutBound Window Arg Structure
00187  *  NOTE:
00188  *      If pciBusAddr[U,L] are 0, then kernel will dynamically assign
00189  *      pci start address on PCI bus.
00190  */
00191 struct  vmeOutWindowCfg
00192 {
00193         int             windowNbr;      /*  Window Number */
00194         char            windowEnable;   /*  State of Window */
00195         unsigned int    pciBusAddrU;    /*  Start Address on the PCI Bus */
00196         unsigned int    pciBusAddrL;    /*  Start Address on the PCI Bus */
00197         unsigned int    windowSizeU;    /*  Window Size */
00198         unsigned int    windowSizeL;    /*  Window Size */
00199         unsigned int    xlatedAddrU;    /*  Starting Address on the VMEbus */
00200         unsigned int    xlatedAddrL;    /*  Starting Address on the VMEbus */
00201         int             bcastSelect2esst;       /*  2eSST Broadcast Select */
00202         char            wrPostEnable;           /*  Write Post State */
00203         char            prefetchEnable; /*  Prefetch Read Enable State */
00204         int             prefetchSize;   /*  Prefetch Read Size (in Cache Lines) */
00205         vme2esstRate_t  xferRate2esst;  /*  2eSST Transfer Rate */
00206         addressMode_t   addrSpace;      /*  Address Space */
00207         dataWidth_t     maxDataWidth;   /*  Maximum Data Width */
00208         int             xferProtocol;   /*  Transfer Protocol */
00209         int             userAccessType; /*  User/Supervisor Access Type */
00210         int             dataAccessType; /*  Data/Program Access Type */
00211         int             reserved;       /* For future use */
00212 
00213 };
00214 typedef struct  vmeOutWindowCfg vmeOutWindowCfg_t;
00215 
00216 
00217 
00218 /************************************************************************
00219  *  /dev/vme_dma* DMA commands
00220  */
00221 #define VME_IOCTL_START_DMA             0x30
00222 #define VME_IOCTL_PAUSE_DMA             0x31
00223 #define VME_IOCTL_CONTINUE_DMA          0x32
00224 #define VME_IOCTL_ABORT_DMA             0x33
00225 #define VME_IOCTL_WAIT_DMA              0x34
00226 
00227 typedef enum {
00228         /* NOTE: PATTERN entries only valid as source of data */
00229         VME_DMA_PATTERN_BYTE,
00230         VME_DMA_PATTERN_BYTE_INCREMENT,
00231         VME_DMA_PATTERN_WORD,
00232         VME_DMA_PATTERN_WORD_INCREMENT,
00233         VME_DMA_USER,
00234         VME_DMA_KERNEL,
00235         VME_DMA_PCI,
00236         VME_DMA_VME
00237 } dmaData_t;
00238 
00239 /*
00240  *  VMEbus Transfer Attributes 
00241  */
00242 struct  vmeAttr
00243 {
00244         dataWidth_t     maxDataWidth;   /*  Maximum Data Width */
00245         vme2esstRate_t  xferRate2esst;  /*  2eSST Transfer Rate */
00246         int             bcastSelect2esst; /*  2eSST Broadcast Select */
00247         addressMode_t   addrSpace;      /*  Address Space */
00248         int             userAccessType; /*  User/Supervisor Access Type */
00249         int             dataAccessType; /*  Data/Program Access Type */
00250         int             xferProtocol;   /*  Transfer Protocol */
00251         int             reserved;       /* For future use */
00252 };
00253 typedef struct  vmeAttr vmeAttr_t;
00254 
00255 /*
00256  *  DMA arg info
00257  *  NOTE: 
00258  *      structure contents relating to VME are don't care for 
00259  *       PCI transactions
00260  *      structure contents relating to PCI are don't care for 
00261  *       VME transactions
00262  *      If source or destination is user memory and transaction
00263  *      will cross page boundary, the DMA request will be split
00264  *      into multiple DMA transactions.
00265  */
00266 typedef struct  vmeDmaPacket
00267 {
00268         int             vmeDmaToken;    /*  Token for driver use */
00269         int             vmeDmaWait;     /*  Time to wait for completion */
00270         unsigned int    vmeDmaStartTick; /*  Time DMA started */
00271         unsigned int    vmeDmaStopTick; /*  Time DMA stopped */
00272         unsigned int    vmeDmaElapsedTime; /*  Elapsed time */
00273         int             vmeDmaStatus;   /*  DMA completion status */
00274 
00275         int     byteCount;      /*  Byte Count */
00276         int     bcastSelect2esst;       /*  2eSST Broadcast Select */
00277 
00278         /*
00279          *  DMA Source Data
00280          */
00281         dmaData_t       srcBus;
00282         unsigned int            srcAddrU;
00283         unsigned int            srcAddr;
00284         int             pciReadCmd;
00285         struct          vmeAttr srcVmeAttr;
00286         char            srcfifoEnable;
00287 
00288         /*
00289          *  DMA Destination Data
00290          */
00291         dmaData_t       dstBus;
00292         unsigned int            dstAddrU;
00293         unsigned int            dstAddr;
00294         int             pciWriteCmd;
00295         struct          vmeAttr dstVmeAttr;
00296         char            dstfifoEnable;
00297 
00298 
00299         /*
00300          *  BUS usage control
00301          */
00302         int             maxCpuBusBlkSz; /*  CPU Bus Maximum Block Size */
00303         int             maxPciBlockSize;        /* PCI Bus Maximum Block Size */
00304         int             pciBackOffTimer;        /* PCI Bus Back-Off Timer */
00305         int             maxVmeBlockSize;        /* VMEbus Maximum Block Size */
00306         int             vmeBackOffTimer;        /* VMEbus Back-Off Timer */
00307 
00308         int             channel_number; /* Channel number */
00309         int             reserved;       /* For future use */
00310         /*
00311          *      Ptr to next Packet
00312          *      (NULL == No more Packets)
00313          */
00314         struct          vmeDmaPacket *  pNextPacket;
00315 
00316 } vmeDmaPacket_t;
00317 
00318 
00319 /************************************************************************
00320  *  /dev/vme_ctl ioctl Commands
00321  */
00322 #define VME_IOCTL_GET_SLOT_VME_INFO     0x41
00323 /*
00324  *  VMEbus GET INFO Arg Structure
00325  */
00326 struct  vmeInfoCfg
00327 {
00328         int             vmeSlotNum;     /*  VME slot number of interest */
00329         int             boardResponded; /* Board responded */
00330         char            sysConFlag;     /*  System controller flag */
00331         int             vmeControllerID; /*  Vendor/device ID of VME bridge */
00332         int             vmeControllerRev; /*  Revision of VME bridge */
00333         char            osName[8];      /*  Name of OS e.g. "Linux" */
00334         int             vmeSharedDataValid;     /*  Validity of data struct */
00335         int             vmeDriverRev;   /*  Revision of VME driver */
00336         unsigned        int vmeAddrHi[8];  /* Address on VME bus */
00337         unsigned        int vmeAddrLo[8];  /* Address on VME bus */
00338         unsigned        int vmeSize[8];  /* Size on VME bus */
00339         unsigned        int vmeAm[8];  /* Address modifier on VME bus */
00340         int             reserved;       /* For future use */
00341 };
00342 typedef struct  vmeInfoCfg      vmeInfoCfg_t;
00343 
00344 #define VME_IOCTL_SET_REQUESTOR         0x42
00345 #define VME_IOCTL_GET_REQUESTOR         0x43
00346 /*
00347  *  VMEbus Requester Arg Structure
00348  */
00349 struct  vmeRequesterCfg
00350 {
00351         int             requestLevel;   /*  Requester Bus Request Level */
00352         char            fairMode;       /*  Requester Fairness Mode Indicator */
00353         int             releaseMode;    /*  Requester Bus Release Mode */
00354         int             timeonTimeoutTimer;     /*  Master Time-on Time-out Timer */
00355         int             timeoffTimeoutTimer;    /*  Master Time-off Time-out Timer */
00356         int             reserved;       /* For future use */
00357 };
00358 typedef struct  vmeRequesterCfg vmeRequesterCfg_t;
00359 
00360 #define VME_IOCTL_SET_CONTROLLER        0x44
00361 #define VME_IOCTL_GET_CONTROLLER        0x45
00362 /*
00363  *  VMEbus Arbiter Arg Structure
00364  */
00365 struct  vmeArbiterCfg
00366 {
00367         vme2ArbMode_t   arbiterMode;    /*  Arbitration Scheduling Algorithm */
00368         char            arbiterTimeoutFlag;     /*  Arbiter Time-out Timer Indicator */
00369         int             globalTimeoutTimer;     /*  VMEbus Global Time-out Timer */
00370         char            noEarlyReleaseFlag;     /*  No Early Release on BBUSY */
00371         int             reserved;       /* For future use */
00372 };
00373 typedef struct  vmeArbiterCfg   vmeArbiterCfg_t;
00374 
00375 #define VME_IOCTL_GENERATE_IRQ          0x46
00376 #define VME_IOCTL_GET_IRQ_STATUS        0x47
00377 #define VME_IOCTL_CLR_IRQ_STATUS        0x48
00378 /*
00379  *  VMEbus IRQ Info
00380  */
00381 typedef struct  virqInfo
00382 {
00383         /*
00384          *  Time to wait for Event to occur (in clock ticks)
00385          */
00386         short                   waitTime;
00387         short                   timeOutFlag;
00388 
00389         /*
00390          *  VMEbus Interrupt Level and Vector Data
00391          */
00392         int             level;
00393         int             vector;
00394         int             reserved;       /* For future use */
00395 
00396 } virqInfo_t;
00397 
00398 #define VME_IOCTL_SET_INBOUND           0x49
00399 #define VME_IOCTL_GET_INBOUND           0x50
00400 /*
00401  *  VMEbus InBound Window Arg Structure
00402  *  NOTE:
00403  *      If pciBusAddr[U,L] and windowSize[U,L] are 0, then kernel 
00404  *      will dynamically assign inbound window to map to a kernel
00405  *      supplied buffer.
00406  */
00407 struct  vmeInWindowCfg
00408 {
00409         int             windowNbr;      /*  Window Number */
00410         char            windowEnable;   /*  State of Window */
00411         unsigned int            vmeAddrU;       /*  Start Address responded to on the VMEbus */
00412         unsigned int            vmeAddrL;       /*  Start Address responded to on the VMEbus */
00413         unsigned int            windowSizeU;    /*  Window Size */
00414         unsigned int            windowSizeL;    /*  Window Size */
00415         unsigned int            pciAddrU;       /*  Start Address appearing on the PCI Bus */
00416         unsigned int            pciAddrL;       /*  Start Address appearing on the PCI Bus */
00417         char            wrPostEnable;   /*  Write Post State */
00418         char            prefetchEnable; /*  Prefetch Read State */
00419         char            prefetchThreshold;      /*  Prefetch Read Threshold State */
00420         int             prefetchSize;   /*  Prefetch Read Size */
00421         char            rmwLock;        /*  Lock PCI during RMW Cycles */
00422         char            data64BitCapable;       /*  non-VMEbus capable of 64-bit Data */
00423         addressMode_t   addrSpace;      /*  Address Space */
00424         int             userAccessType; /*  User/Supervisor Access Type */
00425         int             dataAccessType; /*  Data/Program Access Type */
00426         int             xferProtocol;   /*  Transfer Protocol */
00427         vme2esstRate_t  xferRate2esst;  /*  2eSST Transfer Rate */
00428         char            bcastRespond2esst;      /*  Respond to 2eSST Broadcast */
00429         int             reserved;       /* For future use */
00430 
00431 };
00432 typedef struct  vmeInWindowCfg  vmeInWindowCfg_t;
00433 
00434 
00435 /************************************************************************
00436  *  /dev/vme_rmw RMW Ioctl Commands
00437  */
00438 #define VME_IOCTL_DO_RMW                0x60
00439 /*
00440  *  VMEbus RMW Configuration Data
00441  */
00442 struct  vmeRmwCfg
00443 {
00444         unsigned int    targetAddrU;    /*  VME Address (Upper) to trigger RMW cycle */
00445         unsigned int    targetAddr;     /*  VME Address (Lower) to trigger RMW cycle */
00446         addressMode_t   addrSpace;      /*  VME Address Space */
00447         int     enableMask;     /*  Bit mask defining the bits of interest */
00448         int     compareData;    /*  Data to be compared with the data read */
00449         int     swapData;       /*  Data written to the VMEbus on success */
00450         int     maxAttempts;    /*  Maximum times to try */
00451         int     numAttempts;    /*  Number of attempts before success */
00452         int     reserved;       /* For future use */
00453 
00454 } ;
00455 typedef struct vmeRmwCfg        vmeRmwCfg_t;
00456 
00457 
00458 /************************************************************************
00459  *  /dev/vme_lm location Monitor Ioctl Commands
00460  */
00461 #define VME_IOCTL_SETUP_LM              0x70
00462 #define VME_IOCTL_WAIT_LM               0x71
00463 /*
00464  *  VMEbus Location Monitor Arg Structure
00465  */
00466 struct  vmeLmCfg
00467 {
00468         unsigned int            addrU;  /*  Location Monitor Address upper */
00469         unsigned int            addr;   /*  Location Monitor Address lower */
00470         addressMode_t   addrSpace;      /*  Address Space */
00471         int             userAccessType; /*  User/Supervisor Access Type */
00472         int             dataAccessType; /*  Data/Program Access Type */
00473         int             lmWait;         /* Time to wait for access */
00474         int             lmEvents;       /* Lm event mask */
00475         int             reserved;       /* For future use */
00476 };
00477 typedef struct  vmeLmCfg        vmeLmCfg_t;
00478 
00479 /*
00480  *  Data structure created for each board in CS/CSR space.  
00481  */
00482 struct  vmeSharedData {
00483         /*
00484          * Public elements
00485          */
00486         char    validity1[4];   /* "VME" when contents are valid */
00487         char    validity2[4];   /* "RDY" when contents are valid */
00488         int     structureRev;   /* Revision of this structure */
00489         int     reserved1;
00490 
00491         char    osname[8];      /* OS name string */
00492         int     driverRev;      /* Revision of VME driver */
00493         int     reserved2;
00494 
00495         char    boardString[16];        /* type of board */
00496 
00497         int     vmeControllerType;
00498         int     vmeControllerRev;
00499         int     boardSemaphore[8];      /* for use by remote */
00500         unsigned int    inBoundVmeAddrHi[8];    /* This boards VME windows */
00501         unsigned int    inBoundVmeAddrLo[8];    /* This boards VME windows */
00502         addressMode_t   inBoundVmeAM[8];        /* Address modifier */
00503         int     inBoundVmeSize[8];      /* size available to remotes */
00504         char    reserved3[0x1000-248];  /* Pad to 4k boundary */
00505 
00506         int     readTestPatterns[1024];
00507         int     remoteScratchArea[24][256];     /* 1k scratch for each remote*/
00508         /*
00509          * Private areas for use by driver only.
00510          */
00511         char    driverScratch[4096];
00512         struct  {
00513                 char    Eye[4];
00514                 int     Offset;
00515                 int     Head;
00516                 int     Tail;
00517                 int     Size;
00518                 int     Reserved1;
00519                 int     Reserved2;
00520                 int     Reserved3;
00521                 char    Data[4096-32];
00522         } boardFifo[23];
00523 };
00524 
00525 
00526 /*
00527  *  Driver errors reported back to the Application (other than the
00528  *  stanard Linux errnos...).
00529  */
00530 #define VME_ERR_VERR            1       /* VME bus error detected */
00531 #define VME_ERR_PERR            2       /* PCI bus error detected */
00532 
00533 #endif  /* VMEDRV_H */
00534 

Midas DOC Version 3.0.0 ---- PSI Stefan Ritt ----
Contributions: Pierre-Andre Amaudruz - Sergio Ballestrero - Suzannah Daviel - Doxygen - Peter Green - Qing Gu - Greg Hackman - Gertjan Hofman - Paul Knowles - Exaos Lee - Rudi Meier - Glenn Moloney - Dave Morris - John M O'Donnell - Konstantin Olchanski - Renee Poutissou - Tamsen Schurman - Andreas Suter - Jan M.Wouters - Piotr Adam Zolnierczuk