me8100.h
changeset 0 c9b8efdb5369
child 3 fc24e3b47731
equal deleted inserted replaced
-1:000000000000 0:c9b8efdb5369
       
     1 /* me8100.h */
       
     2 /* Device driver for Meilhaus me1000 board.
       
     3  * ========================================
       
     4  *
       
     5  *  Copyright (C) 2001 Meilhaus Electronic GmbH (support@meilhaus.de)
       
     6  *  
       
     7  *  This file is free software; you can redistribute it and/or modify
       
     8  *  it under the terms of the GNU General Public License as published by
       
     9  *  the Free Software Foundation; either version 2 of the License, or
       
    10  *  (at your option) any later version.
       
    11  *
       
    12  *  This program is distributed in the hope that it will be useful,
       
    13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    15  *  GNU General Public License for more details.
       
    16  *
       
    17  *  You should have received a copy of the GNU General Public License
       
    18  *  along with this program; if not, write to the Free Software
       
    19  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
       
    20  */
       
    21 
       
    22 
       
    23       
       
    24 /*
       
    25  * Source File : me8100.h
       
    26  * Destination : me8100.o
       
    27  * Author      : GG (Guenter Gebhardt)
       
    28  *
       
    29  * File History: Version   Date       Editor   Action
       
    30  *---------------------------------------------------------------------
       
    31  *               1.00.00   01.01.10   GG       first release
       
    32  *                                                          
       
    33  *               1.00.01   01.02.14   GG       Add new ioctls:
       
    34  *                                              get_board_info
       
    35  *                                              get_int count
       
    36  *
       
    37  *               1.01.00   01.10.08   GG       Port to Kernel 2.4
       
    38  *---------------------------------------------------------------------
       
    39  *
       
    40  * Description:
       
    41  *
       
    42  *   Contains declarations and type definitions for the ME-8100
       
    43  *   driver module.
       
    44  *
       
    45  */
       
    46 
       
    47 
       
    48 /* Please define this to enable debug mode */
       
    49 #undef ME8100_DEBUG
       
    50 
       
    51 #undef PDEBUG // only to be sure
       
    52 
       
    53 #ifdef ME8100_DEBUG
       
    54 # define PDEBUG(fmt, args...) printk(KERN_DEBUG"ME8100:" fmt, ##args)
       
    55 #else 
       
    56 # define PDEBUG(fmt, args...) // no debugging, do nothing
       
    57 #endif
       
    58 
       
    59 
       
    60 /* Meilhaus PCI vendor id */
       
    61 #define PCI_VENDOR_ID_MEILHAUS 0x1402
       
    62 
       
    63 /* ME-8100 device IDs */
       
    64 #define PCI_DEVICE_ID_MEILHAUS_ME8100_A  0x0810A  // Meilhaus ME8100 A
       
    65 #define PCI_DEVICE_ID_MEILHAUS_ME8100_B  0x0810B  // Meilhaus ME8100 B
       
    66 
       
    67 
       
    68 /* Count of different ME-8100 sorts = 2 */
       
    69 #define SORT_COUNT 2
       
    70 
       
    71 
       
    72 /* Device name, for entries in /proc/.. */
       
    73 #define ME8100_NAME "me8100"
       
    74 
       
    75 
       
    76 /* Maximum count of ME-8100 devices */
       
    77 #define ME8100_MAX_DEVICES 16
       
    78 
       
    79 
       
    80 /* Here you can enable the workaround for the plx bug */
       
    81 #define PLX_WORKAROUND_ENABLE 1
       
    82 
       
    83 
       
    84 /* Offset Interrupt Control Status Register of the PLX */
       
    85 #define PLX_ICSR 0x4C
       
    86 
       
    87 
       
    88 /* Size of register bases */
       
    89 #define ME8100_BASE_SIZE 0xFF
       
    90 #define PLX_BASE_SIZE 0x80
       
    91 
       
    92 
       
    93 /**************************************************/
       
    94 /* Bit definition for the ME8100_CTRL_REG_X       */
       
    95 /* it differs from the ISA VERSION !!!            */
       
    96 /* The other registers are similar to ISA VERSION */
       
    97 /**************************************************/
       
    98 // Bit 0-3 dont care
       
    99 // Bit 4   SRC/SINK    1 = SRC  0 = SINK
       
   100 // Bit 5   INTB 1      ISA has here INTB 0
       
   101 // Bit 6   INTB 0      ISA has here INTB 1
       
   102 // Bit 7   ENIO        1 = Enable  0 = high resistance
       
   103 // Bit 8-15 dont care
       
   104 /*********************************************************/
       
   105 /* The ME8100_ID_REG_X contains on PCI boards static 81h */
       
   106 /*********************************************************/
       
   107 
       
   108 /* ME8100 Register Set A */
       
   109 #define ME8100_ID_REG_A			0x00      //(r, )
       
   110 #define ME8100_CTRL_REG_A		0x00      //( ,w)
       
   111 #define ME8100_RES_INT_REG_A		0x02      //(r, )
       
   112 #define ME8100_DI_REG_A			0x04      //(r, )
       
   113 #define ME8100_DO_REG_A                 0x06      //( ,w)
       
   114 #define ME8100_PATTERN_REG_A		0x08      //( ,w)
       
   115 #define ME8100_MASK_REG_A		0x0A      //( ,w)
       
   116 #define ME8100_INT_DI_REG_A		0x0A      //(r, )
       
   117 									
       
   118 /* ME8100 Register Set B */		
       
   119 #define ME8100_ID_REG_B			0x0C      //(r, )
       
   120 #define ME8100_CTRL_REG_B		0x0C      //( ,w)
       
   121 #define ME8100_RES_INT_REG_B		0x0E      //(r, )
       
   122 #define ME8100_DI_REG_B			0x10      //(r, )
       
   123 #define ME8100_DO_REG_B			0x12      //( ,w)
       
   124 #define ME8100_PATTERN_REG_B	        0x14      //( ,w)
       
   125 #define ME8100_MASK_REG_B		0x16      //( ,w)
       
   126 #define ME8100_INT_DI_REG_B		0x16      //(r, )
       
   127 									
       
   128 /* ME8100 82C54 Counter Registers                          */
       
   129 /* 82C54 registers are adressed as 8-bit registers, so the */
       
   130 /* offset is in bytes.                                     */
       
   131 #define ME8100_COUNTER_REG_0		0x18      //(r,w)
       
   132 #define ME8100_COUNTER_REG_1		0x1A      //(r,w)
       
   133 #define ME8100_COUNTER_REG_2		0x1C      //(r,w)
       
   134 #define ME8100_COUNTER_CTRL_REG	        0x1E      //(r,w)
       
   135 
       
   136 /* Bitmasks for the PLX_ICSR register */
       
   137 #define LOCAL_INT1_EN             0x01  // local interrupt 1 enabled  (r,w)
       
   138 #define LOCAL_INT1_POL            0x02  // local interrupt 1 polarity (r,w)
       
   139 #define LOCAL_INT1_STATE          0x04  // local interrupt 1 state    (r, )
       
   140 #define LOCAL_INT2_EN             0x08  // local interrupt 2 enabled  (r,w)
       
   141 #define LOCAL_INT2_POL            0x10  // local interrupt 2 polarity (r,w)
       
   142 #define LOCAL_INT2_STATE          0x20  // local interrupt 2 state    (r, )
       
   143 #define PCI_INT_EN                0x40  // PCI interrupt enable       (r,w)
       
   144 #define SOFT_INT                  0x80  // Software interrupt         (r,w)
       
   145 
       
   146 
       
   147 typedef enum {  
       
   148   ME8100_A, 
       
   149   ME8100_B
       
   150 } me8100_version_enum_type; 
       
   151 
       
   152 
       
   153 typedef struct{
       
   154   int int1;
       
   155   int int2;
       
   156 } me8100_int_occur_type;
       
   157 
       
   158 
       
   159 typedef struct{
       
   160   int board_count;                  /* index of the board after detection    */
       
   161   me8100_version_enum_type version; /* sort of board                         */
       
   162   unsigned int plx_regbase;         /* PLX configuration space base address  */
       
   163   unsigned int me8100_regbase;      /* Base address of the ME8100/2000       */
       
   164   unsigned int plx_regbase_size;    /* Size of PLX space                     */
       
   165   unsigned int me8100_regbase_size; /* Size of ME8100 base address           */
       
   166   unsigned int serial_no;           /* Serial number of the board            */
       
   167   unsigned char hw_revision;        /* Hardware revision of the board        */
       
   168   unsigned short vendor_id;         /* Meilhaus vendor id (0x1402)           */
       
   169   unsigned short device_id;         /* Device ID                             */
       
   170   int pci_bus_no;                   /* PCI bus number                        */
       
   171   int pci_dev_no;                   /* PCI device number                     */
       
   172   int pci_func_no;                  /* PCI function number                   */
       
   173   char int_line;                    /* IRQ assigned from the PCI BIOS        */
       
   174   int int1;                         /* Marks witch interrupt occured         */
       
   175   int int2;                         /* Marks witch interrupt occured         */
       
   176   int int_count_1;                  /* Count of interrupt 1                  */
       
   177   int int_count_2;                  /* Count of interrupt 2                  */
       
   178   int board_in_use;                 /* Indicates if board is already in use  */
       
   179   spinlock_t use_lock;              /* Guards board in use                   */
       
   180   struct file *file_ptr;            /* Pointer to file structure of path     */
       
   181 } me8100_info_type;
       
   182 
       
   183 
       
   184 /* ME8100 IOCTL's */
       
   185 #define ME8100_IOCTL_MAXNR 29
       
   186 #define ME8100_MAGIC 'o'
       
   187 #define ME8100_READ_ID_A        _IOR(ME8100_MAGIC, 0,  unsigned short)
       
   188 #define ME8100_WRITE_CTRL_A     _IOW(ME8100_MAGIC, 1,  unsigned short)
       
   189 #define ME8100_RES_INT_A        _IOR(ME8100_MAGIC, 2,  unsigned short)
       
   190 #define ME8100_READ_DI_A        _IOR(ME8100_MAGIC, 3,  unsigned short)
       
   191 #define ME8100_WRITE_DO_A       _IOW(ME8100_MAGIC, 4,  unsigned short)
       
   192 #define ME8100_WRITE_PATTERN_A  _IOW(ME8100_MAGIC, 5,  unsigned short)
       
   193 #define ME8100_WRITE_MASK_A     _IOW(ME8100_MAGIC, 6,  unsigned short)
       
   194 #define ME8100_READ_INT_DI_A    _IOR(ME8100_MAGIC, 7,  unsigned short)
       
   195 
       
   196 #define ME8100_READ_ID_B        _IOR(ME8100_MAGIC, 8,  unsigned short)
       
   197 #define ME8100_WRITE_CTRL_B     _IOW(ME8100_MAGIC, 9,  unsigned short)
       
   198 #define ME8100_RES_INT_B        _IOR(ME8100_MAGIC, 10, unsigned short)
       
   199 #define ME8100_READ_DI_B        _IOR(ME8100_MAGIC, 11, unsigned short)
       
   200 #define ME8100_WRITE_DO_B       _IOW(ME8100_MAGIC, 12, unsigned short)
       
   201 #define ME8100_WRITE_PATTERN_B  _IOW(ME8100_MAGIC, 13, unsigned short)
       
   202 #define ME8100_WRITE_MASK_B     _IOW(ME8100_MAGIC, 14, unsigned short)
       
   203 #define ME8100_READ_INT_DI_B    _IOR(ME8100_MAGIC, 15, unsigned short)
       
   204 
       
   205 #define ME8100_WRITE_COUNTER_0  _IOW(ME8100_MAGIC, 16, unsigned char)
       
   206 #define ME8100_WRITE_COUNTER_1  _IOW(ME8100_MAGIC, 17, unsigned char)
       
   207 #define ME8100_WRITE_COUNTER_2  _IOW(ME8100_MAGIC, 18, unsigned char)
       
   208 #define ME8100_READ_COUNTER_0   _IOR(ME8100_MAGIC, 19, unsigned char)
       
   209 #define ME8100_READ_COUNTER_1   _IOR(ME8100_MAGIC, 20, unsigned char)
       
   210 #define ME8100_READ_COUNTER_2   _IOR(ME8100_MAGIC, 21, unsigned char)
       
   211 #define ME8100_SETUP_COUNTER    _IOW(ME8100_MAGIC, 22, unsigned char)
       
   212 
       
   213 #define ME8100_GET_SERIAL       _IOR(ME8100_MAGIC, 23, unsigned int)
       
   214 #define ME8100_GET_NAME         _IOR(ME8100_MAGIC, 24,me8100_version_enum_type)
       
   215 #define ME8100_INT_OCCUR        _IOR(ME8100_MAGIC, 25, me8100_int_occur_type)
       
   216 #define ME8100_SETUP_ICSR       _IOW(ME8100_MAGIC, 26, unsigned char)
       
   217 #define ME8100_READ_ICSR        _IOR(ME8100_MAGIC, 27, unsigned char)
       
   218 #define ME8100_GET_BOARD_INFO   _IOR(ME8100_MAGIC, 28, me8100_info_type)
       
   219 #define ME8100_GET_INT_COUNT    _IOR(ME8100_MAGIC, 29, me8100_int_occur_type)