me8100.c
changeset 22 7b722739e329
parent 18 d1686272f84d
child 24 24a49943680f
equal deleted inserted replaced
21:c0042fa5433b 22:7b722739e329
     1 /* me8100.c */
     1 /* me8100.c */
     2 /* Device driver for Meilhaus me8100 board.
     2 /* Device driver for Meilhaus me8100 board.
     3  * ========================================
     3  * ========================================
     4  *
     4  *
     5  *  Copyright (C) 2001 Meilhaus Electronic GmbH (support@meilhaus.de)
     5  *  Copyright (C) 2001 Meilhaus Electronic GmbH (support@meilhaus.de)
       
     6  *  Portions Copyright (C) 2002 Heiko Schlittermann <hs@schlittermann.de>
     6  *  
     7  *  
     7  *  This file is free software; you can redistribute it and/or modify
     8  *  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  *  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  *  the Free Software Foundation; either version 2 of the License, or
    10  *  (at your option) any later version.
    11  *  (at your option) any later version.
   113 /* Include-File for the Meilhaus ME-8100 I/O board */
   114 /* Include-File for the Meilhaus ME-8100 I/O board */
   114 #include "me8100.h"
   115 #include "me8100.h"
   115 
   116 
   116 
   117 
   117 /* Board specific data are kept global */
   118 /* Board specific data are kept global */
   118 static me8100_info_type info_vec[SORT_COUNT * ME8100_MAX_DEVICES];
   119 static me8100_info_t info_vec[SORT_COUNT * ME8100_MAX_DEVICES];
   119   
   120   
   120 
   121 
   121 /* Number of boards, detected from the BIOS */
   122 /* Number of boards, detected from the BIOS */
   122 static int me8100_board_count;
   123 static int me8100_board_count;
   123 
   124 
   134 static void me8100_isr(int, void *, struct pt_regs *);
   135 static void me8100_isr(int, void *, struct pt_regs *);
   135 static ssize_t me8100_read(struct file *, char *, size_t, loff_t *);
   136 static ssize_t me8100_read(struct file *, char *, size_t, loff_t *);
   136 static ssize_t me8100_write(struct file *, const char *, size_t, loff_t *);
   137 static ssize_t me8100_write(struct file *, const char *, size_t, loff_t *);
   137 static unsigned int me8100_poll(struct file *, struct poll_table_struct *);
   138 static unsigned int me8100_poll(struct file *, struct poll_table_struct *);
   138 
   139 
   139 static int me8100_init_board(me8100_info_type *, struct pci_dev *);
   140 static int me8100_init_board(me8100_info_t *, struct pci_dev *);
   140 static int me8100_reset_board(me8100_info_type *);
   141 static int me8100_reset_board(me8100_info_t *);
   141 
   142 
   142 static int me8100_read_id_a(unsigned short *, me8100_info_type *);
   143 static int me8100_read_id_a(unsigned short *, me8100_info_t *);
   143 static int me8100_write_ctrl_a(unsigned short *, me8100_info_type *);
   144 static int me8100_write_ctrl_a(unsigned short *, me8100_info_t *);
   144 static int me8100_res_int_a(me8100_info_type *);
   145 static int me8100_res_int_a(me8100_info_t *);
   145 static int me8100_read_di_a(unsigned short *, me8100_info_type *);
   146 static int me8100_read_di_a(unsigned short *, me8100_info_t *);
   146 static int me8100_write_do_a(unsigned short *, me8100_info_type *);
   147 static int me8100_write_do_a(unsigned short *, me8100_info_t *);
   147 static int me8100_write_pattern_a(unsigned short *, me8100_info_type *);
   148 static int me8100_write_pattern_a(unsigned short *, me8100_info_t *);
   148 static int me8100_write_mask_a(unsigned short *, me8100_info_type *);
   149 static int me8100_write_mask_a(unsigned short *, me8100_info_t *);
   149 static int me8100_read_int_di_a(unsigned short *, me8100_info_type *);
   150 static int me8100_read_int_di_a(unsigned short *, me8100_info_t *);
   150 
   151 
   151 static int me8100_read_id_b(unsigned short *, me8100_info_type *);
   152 static int me8100_read_id_b(unsigned short *, me8100_info_t *);
   152 static int me8100_write_ctrl_b(unsigned short *, me8100_info_type *);
   153 static int me8100_write_ctrl_b(unsigned short *, me8100_info_t *);
   153 static int me8100_res_int_b(me8100_info_type *);
   154 static int me8100_res_int_b(me8100_info_t *);
   154 static int me8100_read_di_b(unsigned short *, me8100_info_type *);
   155 static int me8100_read_di_b(unsigned short *, me8100_info_t *);
   155 static int me8100_write_do_b(unsigned short *, me8100_info_type *);
   156 static int me8100_write_do_b(unsigned short *, me8100_info_t *);
   156 static int me8100_write_pattern_b(unsigned short *, me8100_info_type *);
   157 static int me8100_write_pattern_b(unsigned short *, me8100_info_t *);
   157 static int me8100_write_mask_b(unsigned short *, me8100_info_type *);
   158 static int me8100_write_mask_b(unsigned short *, me8100_info_t *);
   158 static int me8100_read_int_di_b(unsigned short *, me8100_info_type *);
   159 static int me8100_read_int_di_b(unsigned short *, me8100_info_t *);
   159 
   160 
   160 static int me8100_write_counter_0(unsigned char *, me8100_info_type *);
   161 static int me8100_write_counter_0(unsigned char *, me8100_info_t *);
   161 static int me8100_write_counter_1(unsigned char *, me8100_info_type *);
   162 static int me8100_write_counter_1(unsigned char *, me8100_info_t *);
   162 static int me8100_write_counter_2(unsigned char *, me8100_info_type *);
   163 static int me8100_write_counter_2(unsigned char *, me8100_info_t *);
   163 static int me8100_read_counter_0(unsigned char *, me8100_info_type *);
   164 static int me8100_read_counter_0(unsigned char *, me8100_info_t *);
   164 static int me8100_read_counter_1(unsigned char *, me8100_info_type *);
   165 static int me8100_read_counter_1(unsigned char *, me8100_info_t *);
   165 static int me8100_read_counter_2(unsigned char *, me8100_info_type *);
   166 static int me8100_read_counter_2(unsigned char *, me8100_info_t *);
   166 static int me8100_setup_counter(unsigned char *, me8100_info_type *);
   167 static int me8100_setup_counter(unsigned char *, me8100_info_t *);
   167 
   168 
   168 static int me8100_get_serial(unsigned int *, me8100_info_type *);
   169 static int me8100_get_serial(unsigned int *, me8100_info_t *);
   169 static int me8100_get_name(me8100_version_enum_type *, me8100_info_type *);
   170 static int me8100_get_name(me8100_version_enum_type *, me8100_info_t *);
   170 static int me8100_int_occur(me8100_int_occur_type *, me8100_info_type *);
   171 static int me8100_int_occur(me8100_int_occur_type *, me8100_info_t *);
   171 static int me8100_setup_icsr(unsigned char *, me8100_info_type *);
   172 static int me8100_setup_icsr(unsigned char *, me8100_info_t *);
   172 static int me8100_read_icsr(unsigned char *, me8100_info_type *);
   173 static int me8100_read_icsr(unsigned char *, me8100_info_t *);
   173 static int me8100_get_board_info(me8100_info_type *, me8100_info_type *);
   174 static int me8100_get_board_info(me8100_info_t *, me8100_info_t *);
   174 static int me8100_get_int_count(me8100_int_occur_type *, me8100_info_type *);
   175 static int me8100_get_int_count(me8100_int_occur_type *, me8100_info_t *);
   175 
   176 
   176 static inline int DEVICE(int i) { return i & 0x0f; }
   177 static inline int DEVICE(int i) { return i & 0x0f; }
   177 static inline int SUBDEVICE(int i) { return (i >> 4) - 1; }
   178 static inline int SUBDEVICE(int i) { return (i >> 4) - 1; }
   178 
   179 
   179 
   180 
   324  *                                                                          
   325  *                                                                          
   325  * Parameter list:                                                          
   326  * Parameter list:                                                          
   326  *   Name           Type                 Access Description                 
   327  *   Name           Type                 Access Description                 
   327  *--------------------------------------------------------------------------
   328  *--------------------------------------------------------------------------
   328  *   *pci_dev_ptr   struct pci_dev       read   List with all pci devices.
   329  *   *pci_dev_ptr   struct pci_dev       read   List with all pci devices.
   329  *   *info          me8100_info_type     read   Global board context.
   330  *   *info          me8100_info_t     read   Global board context.
   330  *                                                                          
   331  *                                                                          
   331  * Result:                                                                  
   332  * Result:                                                                  
   332  *   On success the return value is 0, else failure.                          
   333  *   On success the return value is 0, else failure.                          
   333  *--------------------------------------------------------------------------
   334  *--------------------------------------------------------------------------
   334  * Author: GG                                                               
   335  * Author: GG                                                               
   336  * Modification:                                                            
   337  * Modification:                                                            
   337  *   01.09.14  Don't get baseaddresses from struct pci_dev, 
   338  *   01.09.14  Don't get baseaddresses from struct pci_dev, 
   338  *             for compatibility. (GG)
   339  *             for compatibility. (GG)
   339  *
   340  *
   340  */
   341  */
   341 static int me8100_init_board(me8100_info_type *info, 
   342 static int me8100_init_board(me8100_info_t *info, 
   342 			     struct pci_dev *pci_dev_ptr){
   343 			     struct pci_dev *pci_dev_ptr){
   343   int i;
   344   int i;
   344   int result = 0;
   345   int result = 0;
   345   unsigned int plx_regbase_tmp;
   346   unsigned int plx_regbase_tmp;
   346   unsigned int me8100_regbase_tmp;
   347   unsigned int me8100_regbase_tmp;
   478 
   479 
   479   /* Set default values for the subinfo. */
   480   /* Set default values for the subinfo. */
   480   info->subinfo[0].regbase = info->me8100_regbase;
   481   info->subinfo[0].regbase = info->me8100_regbase;
   481   info->subinfo[1].regbase = info->me8100_regbase + 0x0C;
   482   info->subinfo[1].regbase = info->me8100_regbase + 0x0C;
   482 
   483 
   483   for (i = 0; i <= 1; ++i) {
   484   for (i = 0; i < MAX_SUBDEVICES; ++i) {
   484     info->subinfo[i].int_seen = jiffies;    /* suppose we got just the first irq */
   485     info->subinfo[i].int_seen = jiffies;    /* suppose we got just the first irq */
   485     info->subinfo[i].fasync_ptr = NULL;
   486     info->subinfo[i].fasync_ptr = NULL;
   486     init_waitqueue_head(&info->subinfo[i].readq);
   487     init_waitqueue_head(&info->subinfo[i].readq);
   487   }
   488   }
   488   
   489   
   527  *   On success the return value is 0, else is failure.                     
   528  *   On success the return value is 0, else is failure.                     
   528  *--------------------------------------------------------------------------
   529  *--------------------------------------------------------------------------
   529  * Author: GG                                                               
   530  * Author: GG                                                               
   530  * Modification:                                                            
   531  * Modification:                                                            
   531  */
   532  */
   532 static int me8100_reset_board(me8100_info_type *info){
   533 static int me8100_reset_board(me8100_info_t *info){
   533   int i;
   534   int i;
   534   unsigned char icsr = 0x12;
   535   unsigned char icsr = 0x12;
   535 
   536 
   536   PDEBUG("me8100_reset_board() is executed\n");
   537   PDEBUG("me8100_reset_board() is executed\n");
   537 
   538 
   538   /* Disable the Interrupt logic of the plx */
   539   /* Disable the Interrupt logic of the plx */
   539   PDEBUG("me8100_reset_board(): plx_mode = 0x%X\n", icsr);
   540   PDEBUG("me8100_reset_board(): plx_mode = 0x%X\n", icsr);
   540   outb(icsr, info->plx_regbase + PLX_ICSR);
   541   outb(icsr, info->plx_regbase + PLX_ICSR);
   541   
   542   
   542   for (i = 0; i <= 1; ++i) {
   543   for (i = 0; i < MAX_SUBDEVICES; ++i) {
   543     /* Ports to high impedance, interrupts deactivated */
   544     /* Ports to high impedance, interrupts deactivated */
   544     outw(0x00, info->subinfo[i].regbase + ME8100_CTRL_REG);
   545     outw(0x00, info->subinfo[i].regbase + ME8100_CTRL_REG);
   545     /* Reset any pending interrupt */
   546     /* Reset any pending interrupt */
   546     inw(info->subinfo[i].regbase + ME8100_RES_INT_REG);
   547     inw(info->subinfo[i].regbase + ME8100_RES_INT_REG);
   547   }
   548   }
   572  *--------------------------------------------------------------------------
   573  *--------------------------------------------------------------------------
   573  * Author: GG                                                               
   574  * Author: GG                                                               
   574  */
   575  */
   575 static int me8100_open(struct inode *inode_ptr, struct file *file_ptr){
   576 static int me8100_open(struct inode *inode_ptr, struct file *file_ptr){
   576   int device, subdevice;
   577   int device, subdevice;
   577   me8100_info_type *info;
   578   me8100_info_t *info;
   578   struct me8100_subinfo *subinfo;
   579   me8100_subinfo_t *subinfo;
   579 
   580   me8100_private_data_t *priv;
   580   PDEBUG("*** me8100_open() is executed\n");
   581 
   581 
   582 
   582   device = DEVICE(MINOR(inode_ptr->i_rdev));
   583   device = DEVICE(MINOR(inode_ptr->i_rdev));
   583   subdevice = SUBDEVICE(MINOR(inode_ptr->i_rdev));
   584   subdevice = SUBDEVICE(MINOR(inode_ptr->i_rdev));
   584   PDEBUG("*** device: %d, subdevice %d with flags %0x\n", device, subdevice, file_ptr->f_flags);
   585 
       
   586   PDEBUG("me8100_open() device: %d.%d\n", device, subdevice);
   585 
   587 
   586   if(device >= me8100_board_count){
   588   if(device >= me8100_board_count){
   587     printk(KERN_ERR"ME8100:me8100_open():Board %d doesn't exist\n", device);
   589     printk(KERN_ERR"ME8100:me8100_open():Board %d doesn't exist\n", device);
   588     return -ENODEV;
   590     return -ENODEV;
   589   }
   591   }
   590 
   592 
   591   /* Currently we can't support the old style minor numbers. */
   593   /* Currently we can't support the old style minor numbers. .hs */
   592   if (subdevice < 0) {
   594   if (subdevice < 0) {
   593     printk(KERN_ERR "ME8100:me8100_open(): Bad subdevice %d\n", subdevice);
   595     printk(KERN_ERR "ME8100:me8100_open(): Bad device %d.%d\n", device, subdevice);
   594     return -ENODEV;
   596     return -ENODEV;
   595   }
   597   }
       
   598 
       
   599   if (NULL == (priv = kmalloc(sizeof(*priv), GFP_KERNEL))) {
       
   600     printk(KERN_ERR "ME8100: me8100_open(): kmalloc() failed\n");
       
   601     return -EIO;
       
   602   }
       
   603   file_ptr->private_data = priv;
       
   604 
       
   605   memset(priv, 0, sizeof(*priv));
   596 
   606 
   597   info = &info_vec[device];
   607   info = &info_vec[device];
   598   subinfo = &info->subinfo[subdevice];
   608   subinfo = &info->subinfo[subdevice];
       
   609   priv->info = info;
       
   610   priv->subinfo = subinfo;
   599 
   611 
   600   MOD_INC_USE_COUNT;
   612   MOD_INC_USE_COUNT;
   601 
   613 
   602   if (file_ptr->f_mode & FMODE_WRITE) {
   614   if (file_ptr->f_mode & FMODE_WRITE) {
   603     /* If we're the first writer, the control register has to be
   615     /* If we're the first writer, the control register has to be
   620     /* If we're a reader, the IRQ should be setup -- if not done already
   632     /* If we're a reader, the IRQ should be setup -- if not done already
   621      * (might be done by some ioctl()s.  The file_ptr get a private data
   633      * (might be done by some ioctl()s.  The file_ptr get a private data
   622      * pointer passed.  We need this to keep track of timestamps for
   634      * pointer passed.  We need this to keep track of timestamps for
   623      * read data. */
   635      * read data. */
   624 
   636 
   625     struct me8100_private_data *priv;
       
   626 
       
   627     PDEBUG("*** open for reading\n");
   637     PDEBUG("*** open for reading\n");
   628 
       
   629     /* Allocate memory for the private data.  If allocating fails,
       
   630      * call m8100_release() (which in turn decrements the mod-in-use-count)
       
   631      * and return IO error. */
       
   632     if (NULL == (priv = kmalloc(sizeof(*priv), GFP_KERNEL))) {	  
       
   633       printk(KERN_ERR"ME8100:me8100_open: kmalloc() failed.\n");
       
   634       me8100_release(inode_ptr, file_ptr);  
       
   635       return -EIO;
       
   636     }
       
   637 
       
   638     priv->last_read = 0;
       
   639     file_ptr->private_data = priv;
       
   640 
   638 
   641     /* The first reader should setup the IRQs (enabling IRQ handling
   639     /* The first reader should setup the IRQs (enabling IRQ handling
   642      * with the full bit mask.  It might be modified later. */
   640      * with the full bit mask.  It might be modified later. */
   643     if (0 == subinfo->num_reader++) {
   641     if (0 == subinfo->num_reader++) {
   644       int mask;
   642       int mask;
   700  * Modification:                                                            
   698  * Modification:                                                            
   701  */
   699  */
   702 static int me8100_release(struct inode *inode_ptr, struct file *file_ptr){
   700 static int me8100_release(struct inode *inode_ptr, struct file *file_ptr){
   703   int device;
   701   int device;
   704   int err;
   702   int err;
   705   me8100_info_type *info;
   703   me8100_info_t *info = ((me8100_private_data_t*)file_ptr->private_data)->info;
   706   struct me8100_subinfo* subinfo;
   704   me8100_subinfo_t* subinfo = ((me8100_private_data_t*)file_ptr->private_data)->subinfo;
   707 
   705 
   708   
   706   
   709   PDEBUG("me8100_release() is executed\n");
   707   PDEBUG("me8100_release()\n");
   710 
       
   711   device = DEVICE(MINOR(inode_ptr->i_rdev));
   708   device = DEVICE(MINOR(inode_ptr->i_rdev));
   712   info = &info_vec[device];
       
   713   subinfo = &info->subinfo[SUBDEVICE(MINOR(inode_ptr->i_rdev))];
       
   714 
   709 
   715   /* Resetting write mode if last writer is gone */
   710   /* Resetting write mode if last writer is gone */
   716   if (file_ptr->f_mode & FMODE_WRITE) {
   711   if (file_ptr->f_mode & FMODE_WRITE) {
   717     PDEBUG("*** writer closes\n");
   712     PDEBUG("*** writer closes\n");
   718     if (0 == --subinfo->num_writer) {
   713     if (0 == --subinfo->num_writer) {
   868   case ME8100_SETUP_ICSR:
   863   case ME8100_SETUP_ICSR:
   869     return me8100_setup_icsr((unsigned char *) arg, &info_vec[device]);
   864     return me8100_setup_icsr((unsigned char *) arg, &info_vec[device]);
   870   case ME8100_READ_ICSR:
   865   case ME8100_READ_ICSR:
   871     return me8100_read_icsr((unsigned char *) arg, &info_vec[device]);
   866     return me8100_read_icsr((unsigned char *) arg, &info_vec[device]);
   872   case ME8100_GET_BOARD_INFO:
   867   case ME8100_GET_BOARD_INFO:
   873     return me8100_get_board_info((me8100_info_type *)arg, &info_vec[device]);
   868     return me8100_get_board_info((me8100_info_t *)arg, &info_vec[device]);
   874   case ME8100_GET_INT_COUNT:
   869   case ME8100_GET_INT_COUNT:
   875     return me8100_get_int_count((me8100_int_occur_type *)arg,&info_vec[device]);
   870     return me8100_get_int_count((me8100_int_occur_type *)arg,&info_vec[device]);
   876   default:
   871   default:
   877     return -EINVAL;
   872     return -EINVAL;
   878   }
   873   }
   907  *--------------------------------------------------------------------------
   902  *--------------------------------------------------------------------------
   908  * Author: GG                                                               
   903  * Author: GG                                                               
   909  * Modufication:                                                            
   904  * Modufication:                                                            
   910  */
   905  */
   911 static int me8100_fasync(int fd, struct file *file_ptr, int mode){
   906 static int me8100_fasync(int fd, struct file *file_ptr, int mode){
   912   int val;
   907   me8100_subinfo_t *subinfo;
   913   int device, subdevice;
   908 
   914   me8100_info_type *info;
   909   subinfo = ((me8100_private_data_t*) file_ptr->private_data)->subinfo;
   915   struct me8100_subinfo *subinfo;
   910 
   916 
   911   PDEBUG("me8100_fasync()\n");
   917   device = DEVICE(MINOR(file_ptr->f_dentry->d_inode->i_rdev));
   912   return fasync_helper(fd, file_ptr, mode, &subinfo->fasync_ptr);
   918   subdevice = SUBDEVICE(MINOR(file_ptr->f_dentry->d_inode->i_rdev));
       
   919   info = &info_vec[device];
       
   920   subinfo = &info_vec[device].subinfo[subdevice];
       
   921 
       
   922   PDEBUG("me8100_fasync() is executed\n");
       
   923   PDEBUG("** fasync_ptr: %p\n", subinfo->fasync_ptr);
       
   924   val = fasync_helper(fd, file_ptr, mode, &subinfo->fasync_ptr);
       
   925   PDEBUG("** fasync_ptr: %p\n", subinfo->fasync_ptr);
       
   926   return val;
       
   927 }
   913 }
   928 
   914 
   929 
   915 
   930 
   916 
   931 /*
   917 /*
   936  *   This function is called by me8100_ioctl, in order to get the global    
   922  *   This function is called by me8100_ioctl, in order to get the global    
   937  *   variables for a specific board from the info_vec.                      
   923  *   variables for a specific board from the info_vec.                      
   938  * Parameter list:                                                          
   924  * Parameter list:                                                          
   939  *   Name    Type                      Access  Description                  
   925  *   Name    Type                      Access  Description                  
   940  *--------------------------------------------------------------------------
   926  *--------------------------------------------------------------------------
   941  *   *arg    me8100_info_type          w       Carries the value to user.
   927  *   *arg    me8100_info_t          w       Carries the value to user.
   942  *   *info   me8100_info_type          r       Global board context.
   928  *   *info   me8100_info_t          r       Global board context.
   943  *                                                                          
   929  *                                                                          
   944  * Result:                                                                  
   930  * Result:                                                                  
   945  *   On success the return value is 0, else is failure.
   931  *   On success the return value is 0, else is failure.
   946  *--------------------------------------------------------------------------
   932  *--------------------------------------------------------------------------
   947  * Author: GG                                                               
   933  * Author: GG                                                               
   948  * Modification:                                                            
   934  * Modification:                                                            
   949  */
   935  */
   950 static int me8100_get_board_info(me8100_info_type *arg, 
   936 static int me8100_get_board_info(me8100_info_t *arg, 
   951 				 me8100_info_type *info){
   937 				 me8100_info_t *info){
   952 
   938 
   953   PDEBUG("me8100_get_board_info() is executed\n");
   939   PDEBUG("me8100_get_board_info() is executed\n");
   954   
   940   
   955   if(copy_to_user(arg, info, sizeof(me8100_info_type)))
   941   if(copy_to_user(arg, info, sizeof(me8100_info_t)))
   956     return -EFAULT;
   942     return -EFAULT;
   957   return 0;
   943   return 0;
   958 }
   944 }
   959 
   945 
   960 
   946 
   970  *                                                                          
   956  *                                                                          
   971  * Parameter list:                                                          
   957  * Parameter list:                                                          
   972  *   Name    Type                      Access  Description                 
   958  *   Name    Type                      Access  Description                 
   973  *--------------------------------------------------------------------------
   959  *--------------------------------------------------------------------------
   974  *   *arg    unsigned short            w       Carries the value to user.
   960  *   *arg    unsigned short            w       Carries the value to user.
   975  *   *info   me8100_info_type          r       Global board context.
   961  *   *info   me8100_info_t          r       Global board context.
   976  *                                                                          
   962  *                                                                          
   977  * Result:                                                                  
   963  * Result:                                                                  
   978  *   On success the return value is 0, else is failure.
   964  *   On success the return value is 0, else is failure.
   979  *--------------------------------------------------------------------------
   965  *--------------------------------------------------------------------------
   980  * Author: GG                                                               
   966  * Author: GG                                                               
   981  * Modification:                                                            
   967  * Modification:                                                            
   982  */
   968  */
   983 static int me8100_read_id_a(unsigned short *arg, me8100_info_type *info){
   969 static int me8100_read_id_a(unsigned short *arg, me8100_info_t *info){
   984   int err = 0;  
   970   int err = 0;  
   985   unsigned short id_a;  
   971   unsigned short id_a;  
   986 
   972 
   987   PDEBUG("me8100_read_id_a() is executed\n");
   973   PDEBUG("me8100_read_id_a() is executed\n");
   988   
   974   
  1008  *                                                                          
   994  *                                                                          
  1009  * Parameter list:                                                          
   995  * Parameter list:                                                          
  1010  *   Name    Type                      Access  Description                 
   996  *   Name    Type                      Access  Description                 
  1011  *--------------------------------------------------------------------------
   997  *--------------------------------------------------------------------------
  1012  *   *arg    unsigned short            r       Carries the value from user.
   998  *   *arg    unsigned short            r       Carries the value from user.
  1013  *   *info   me8100_info_type          r       Global board context.
   999  *   *info   me8100_info_t          r       Global board context.
  1014  *                                                                          
  1000  *                                                                          
  1015  * Result:                                                                  
  1001  * Result:                                                                  
  1016  *   On success the return value is 0, else is failure.
  1002  *   On success the return value is 0, else is failure.
  1017  *--------------------------------------------------------------------------
  1003  *--------------------------------------------------------------------------
  1018  * Author: GG                                                               
  1004  * Author: GG                                                               
  1019  * Modification:                                                            
  1005  * Modification:                                                            
  1020  */
  1006  */
  1021 static int me8100_write_ctrl_a(unsigned short *arg, me8100_info_type *info){
  1007 static int me8100_write_ctrl_a(unsigned short *arg, me8100_info_t *info){
  1022   int err = 0;
  1008   int err = 0;
  1023   unsigned short ctrl_a = 0;  
  1009   unsigned short ctrl_a = 0;  
  1024 
  1010 
  1025   PDEBUG("me8100_write_ctrl_a() is executed\n");
  1011   PDEBUG("me8100_write_ctrl_a() is executed\n");
  1026   
  1012   
  1047  *   INTR bit a.                                                            
  1033  *   INTR bit a.                                                            
  1048  *                                                                          
  1034  *                                                                          
  1049  * Parameter list:                                                          
  1035  * Parameter list:                                                          
  1050  *   Name    Type                      Access  Description                 
  1036  *   Name    Type                      Access  Description                 
  1051  *--------------------------------------------------------------------------
  1037  *--------------------------------------------------------------------------
  1052  *   *info   me8100_info_type          r       Global board context.
  1038  *   *info   me8100_info_t          r       Global board context.
  1053  *                                                                          
  1039  *                                                                          
  1054  * Result:                                                                  
  1040  * Result:                                                                  
  1055  *   On success the return value is 0, else is failure.
  1041  *   On success the return value is 0, else is failure.
  1056  *--------------------------------------------------------------------------
  1042  *--------------------------------------------------------------------------
  1057  * Author: GG                                                               
  1043  * Author: GG                                                               
  1058  * Modification:                                                            
  1044  * Modification:                                                            
  1059  */
  1045  */
  1060 static int me8100_res_int_a(me8100_info_type *info){
  1046 static int me8100_res_int_a(me8100_info_t *info){
  1061 
  1047 
  1062   PDEBUG("me8100_res_int_a() is executed\n");
  1048   PDEBUG("me8100_res_int_a() is executed\n");
  1063   
  1049   
  1064   inw(info->me8100_regbase + ME8100_RES_INT_REG_A);    
  1050   inw(info->me8100_regbase + ME8100_RES_INT_REG_A);    
  1065 
  1051 
  1079  *                                                                          
  1065  *                                                                          
  1080  * Parameter list:                                                          
  1066  * Parameter list:                                                          
  1081  *   Name    Type                       Access  Description                 
  1067  *   Name    Type                       Access  Description                 
  1082  *--------------------------------------------------------------------------
  1068  *--------------------------------------------------------------------------
  1083  *   *arg    unsigned short             w       Carries the value to user.
  1069  *   *arg    unsigned short             w       Carries the value to user.
  1084  *   *info   me8100_info_type           r       Global board context.
  1070  *   *info   me8100_info_t           r       Global board context.
  1085  *                                                                          
  1071  *                                                                          
  1086  * Result:                                                                  
  1072  * Result:                                                                  
  1087  *   On success the return value is 0, else is failure.
  1073  *   On success the return value is 0, else is failure.
  1088  *--------------------------------------------------------------------------
  1074  *--------------------------------------------------------------------------
  1089  * Author: GG                                                               
  1075  * Author: GG                                                               
  1090  * Modification:                                                            
  1076  * Modification:                                                            
  1091  */
  1077  */
  1092 static int me8100_read_di_a(unsigned short *arg, me8100_info_type *info){
  1078 static int me8100_read_di_a(unsigned short *arg, me8100_info_t *info){
  1093   int err = 0;  
  1079   int err = 0;  
  1094   unsigned short di_a;  
  1080   unsigned short di_a;  
  1095 
  1081 
  1096   PDEBUG("me8100_read_di_a() is executed\n");
  1082   PDEBUG("me8100_read_di_a() is executed\n");
  1097   
  1083   
  1116  *                                                                          
  1102  *                                                                          
  1117  * Parameter list:                                                          
  1103  * Parameter list:                                                          
  1118  *   Name    Type                       Access  Description                 
  1104  *   Name    Type                       Access  Description                 
  1119  *--------------------------------------------------------------------------
  1105  *--------------------------------------------------------------------------
  1120  *   *arg    unsigned short             r       Carries the value from user.
  1106  *   *arg    unsigned short             r       Carries the value from user.
  1121  *   *info   me8100_info_type           r       Global board context.
  1107  *   *info   me8100_info_t           r       Global board context.
  1122  *                                                                          
  1108  *                                                                          
  1123  * Result:                                                                  
  1109  * Result:                                                                  
  1124  *   On success the return value is 0, else is failure                      
  1110  *   On success the return value is 0, else is failure                      
  1125  *--------------------------------------------------------------------------
  1111  *--------------------------------------------------------------------------
  1126  * Author: GG                                                               
  1112  * Author: GG                                                               
  1127  * Modification:                                                            
  1113  * Modification:                                                            
  1128  */
  1114  */
  1129 static int me8100_write_do_a(unsigned short *arg, me8100_info_type *info){
  1115 static int me8100_write_do_a(unsigned short *arg, me8100_info_t *info){
  1130   int err = 0;
  1116   int err = 0;
  1131   unsigned short do_a = 0;  
  1117   unsigned short do_a = 0;  
  1132 
  1118 
  1133   PDEBUG("me8100_write_do_a() is executed\n");
  1119   PDEBUG("me8100_write_do_a() is executed\n");
  1134   
  1120   
  1153  *                                                                          
  1139  *                                                                          
  1154  * Parameter list:                                                          
  1140  * Parameter list:                                                          
  1155  *   Name    Type                       Access  Description                 
  1141  *   Name    Type                       Access  Description                 
  1156  *--------------------------------------------------------------------------
  1142  *--------------------------------------------------------------------------
  1157  *   *arg    unsigned short             r       Carries the value from user.
  1143  *   *arg    unsigned short             r       Carries the value from user.
  1158  *   *info   me8100_info_type           r       Global board context.
  1144  *   *info   me8100_info_t           r       Global board context.
  1159  *                                                                          
  1145  *                                                                          
  1160  * Result:                                                                  
  1146  * Result:                                                                  
  1161  *   On success the return value is 0, else is failure.
  1147  *   On success the return value is 0, else is failure.
  1162  *--------------------------------------------------------------------------
  1148  *--------------------------------------------------------------------------
  1163  * Author: GG                                                               
  1149  * Author: GG                                                               
  1164  * Modification:                                                            
  1150  * Modification:                                                            
  1165  */
  1151  */
  1166 static int me8100_write_pattern_a(unsigned short *arg, me8100_info_type *info){
  1152 static int me8100_write_pattern_a(unsigned short *arg, me8100_info_t *info){
  1167   int err = 0;
  1153   int err = 0;
  1168   unsigned short pattern_a = 0;  
  1154   unsigned short pattern_a = 0;  
  1169 
  1155 
  1170   PDEBUG("me8100_write_pattern_a() is executed\n");
  1156   PDEBUG("me8100_write_pattern_a() is executed\n");
  1171   
  1157   
  1193  *                                                                          
  1179  *                                                                          
  1194  * Parameter list:                                                          
  1180  * Parameter list:                                                          
  1195  *   Name    Type                       Access  Description                 
  1181  *   Name    Type                       Access  Description                 
  1196  *--------------------------------------------------------------------------
  1182  *--------------------------------------------------------------------------
  1197  *   *arg    unsigned short             r       Carries the value from user.
  1183  *   *arg    unsigned short             r       Carries the value from user.
  1198  *   *info   me8100_info_type           r       Global board context.
  1184  *   *info   me8100_info_t           r       Global board context.
  1199  *                                                                          
  1185  *                                                                          
  1200  * Result:                                                                  
  1186  * Result:                                                                  
  1201  *   On success the return value is 0, else is failure.
  1187  *   On success the return value is 0, else is failure.
  1202  *--------------------------------------------------------------------------
  1188  *--------------------------------------------------------------------------
  1203  * Author: GG                                                               
  1189  * Author: GG                                                               
  1204  * Modification:                                                            
  1190  * Modification:                                                            
  1205  */
  1191  */
  1206 static int me8100_write_mask_a(unsigned short *arg, me8100_info_type *info){
  1192 static int me8100_write_mask_a(unsigned short *arg, me8100_info_t *info){
  1207   int err = 0;
  1193   int err = 0;
  1208   unsigned short mask_a = 0;  
  1194   unsigned short mask_a = 0;  
  1209 
  1195 
  1210   PDEBUG("me8100_write_mask_a() is executed\n");
  1196   PDEBUG("me8100_write_mask_a() is executed\n");
  1211   
  1197   
  1234  *                                                                          
  1220  *                                                                          
  1235  * Parameter list:                                                          
  1221  * Parameter list:                                                          
  1236  *   Name    Type                       Access  Description                 
  1222  *   Name    Type                       Access  Description                 
  1237  *--------------------------------------------------------------------------
  1223  *--------------------------------------------------------------------------
  1238  *   *arg    unsigned short             w       Carries the value to user.
  1224  *   *arg    unsigned short             w       Carries the value to user.
  1239  *   *info   me8100_info_type           r       Global board context.
  1225  *   *info   me8100_info_t           r       Global board context.
  1240  *                                                                          
  1226  *                                                                          
  1241  * Result:                                                                  
  1227  * Result:                                                                  
  1242  *   On success the return value is 0, else is failure.
  1228  *   On success the return value is 0, else is failure.
  1243  *--------------------------------------------------------------------------
  1229  *--------------------------------------------------------------------------
  1244  * Author: GG                                                               
  1230  * Author: GG                                                               
  1245  * Modification:                                                            
  1231  * Modification:                                                            
  1246  */
  1232  */
  1247 static int me8100_read_int_di_a(unsigned short *arg, me8100_info_type *info){
  1233 static int me8100_read_int_di_a(unsigned short *arg, me8100_info_t *info){
  1248   int err = 0;  
  1234   int err = 0;  
  1249   unsigned short int_di_a;  
  1235   unsigned short int_di_a;  
  1250 
  1236 
  1251   PDEBUG("me8100_read_int_di_a() is executed\n");
  1237   PDEBUG("me8100_read_int_di_a() is executed\n");
  1252   
  1238   
  1273  *                                                                          
  1259  *                                                                          
  1274  * Parameter list:                                                          
  1260  * Parameter list:                                                          
  1275  *   Name    Type                       Access  Description                 
  1261  *   Name    Type                       Access  Description                 
  1276  *--------------------------------------------------------------------------
  1262  *--------------------------------------------------------------------------
  1277  *   *arg    unsigned short             w       Carries the value to user.
  1263  *   *arg    unsigned short             w       Carries the value to user.
  1278  *   *info   me8100_info_type           r       Global board context.
  1264  *   *info   me8100_info_t           r       Global board context.
  1279  *                                                                          
  1265  *                                                                          
  1280  * Result:                                                                  
  1266  * Result:                                                                  
  1281  *   On success the return value is 0, else is failure.
  1267  *   On success the return value is 0, else is failure.
  1282  *--------------------------------------------------------------------------
  1268  *--------------------------------------------------------------------------
  1283  * Author: GG                                                               
  1269  * Author: GG                                                               
  1284  * Modification:                                                            
  1270  * Modification:                                                            
  1285  */
  1271  */
  1286 static int me8100_read_id_b(unsigned short *arg, me8100_info_type *info){
  1272 static int me8100_read_id_b(unsigned short *arg, me8100_info_t *info){
  1287   int err = 0;  
  1273   int err = 0;  
  1288   unsigned short id_b;  
  1274   unsigned short id_b;  
  1289 
  1275 
  1290   PDEBUG("me8100_read_id_b() is executed\n");
  1276   PDEBUG("me8100_read_id_b() is executed\n");
  1291   
  1277   
  1319  *   On success the return value is 0, else is failure.
  1305  *   On success the return value is 0, else is failure.
  1320  *--------------------------------------------------------------------------
  1306  *--------------------------------------------------------------------------
  1321  * Author: GG                                                               
  1307  * Author: GG                                                               
  1322  * Modification:                                                            
  1308  * Modification:                                                            
  1323  */
  1309  */
  1324 static int me8100_write_ctrl_b(unsigned short *arg, me8100_info_type *info){
  1310 static int me8100_write_ctrl_b(unsigned short *arg, me8100_info_t *info){
  1325   int err = 0;
  1311   int err = 0;
  1326   unsigned short ctrl_b = 0;  
  1312   unsigned short ctrl_b = 0;  
  1327 
  1313 
  1328   PDEBUG("me8100_write_ctrl_b() is executed\n");
  1314   PDEBUG("me8100_write_ctrl_b() is executed\n");
  1329   
  1315   
  1350  *   INTR bit b.                                                            
  1336  *   INTR bit b.                                                            
  1351  *                                                                          
  1337  *                                                                          
  1352  * Parameter list:                                                          
  1338  * Parameter list:                                                          
  1353  *   Name    Type                       Access  Description                 
  1339  *   Name    Type                       Access  Description                 
  1354  *--------------------------------------------------------------------------
  1340  *--------------------------------------------------------------------------
  1355  *   *info   me8100_info_type           r       Global board context.
  1341  *   *info   me8100_info_t           r       Global board context.
  1356  *                                                                          
  1342  *                                                                          
  1357  * Result:                                                                  
  1343  * Result:                                                                  
  1358  *   On success the return value is 0, else is failure.
  1344  *   On success the return value is 0, else is failure.
  1359  *--------------------------------------------------------------------------
  1345  *--------------------------------------------------------------------------
  1360  * Author: GG                                                               
  1346  * Author: GG                                                               
  1361  * Modification:                                                            
  1347  * Modification:                                                            
  1362  */
  1348  */
  1363 static int me8100_res_int_b(me8100_info_type *info){
  1349 static int me8100_res_int_b(me8100_info_t *info){
  1364 
  1350 
  1365   PDEBUG("me8100_res_int_b() is executed\n");
  1351   PDEBUG("me8100_res_int_b() is executed\n");
  1366   inw(info->me8100_regbase + ME8100_RES_INT_REG_B);    
  1352   inw(info->me8100_regbase + ME8100_RES_INT_REG_B);    
  1367 
  1353 
  1368   return 0;
  1354   return 0;
  1381  *                                                                          
  1367  *                                                                          
  1382  * Parameter list:                                                          
  1368  * Parameter list:                                                          
  1383  *   Name    Type                       Access  Description                 
  1369  *   Name    Type                       Access  Description                 
  1384  *--------------------------------------------------------------------------
  1370  *--------------------------------------------------------------------------
  1385  *   *arg    unsigned short             w       Carries the value to user.
  1371  *   *arg    unsigned short             w       Carries the value to user.
  1386  *   *info   me8100_info_type           r       Global board context.
  1372  *   *info   me8100_info_t           r       Global board context.
  1387  *                                                                          
  1373  *                                                                          
  1388  * Result:                                                                  
  1374  * Result:                                                                  
  1389  *   On success the return value is 0, else is failure.
  1375  *   On success the return value is 0, else is failure.
  1390  *--------------------------------------------------------------------------
  1376  *--------------------------------------------------------------------------
  1391  * Author: GG                                                               
  1377  * Author: GG                                                               
  1392  * Modification:                                                            
  1378  * Modification:                                                            
  1393  */
  1379  */
  1394 static int me8100_read_di_b(unsigned short *arg, me8100_info_type *info){
  1380 static int me8100_read_di_b(unsigned short *arg, me8100_info_t *info){
  1395   int err = 0;  
  1381   int err = 0;  
  1396   unsigned short di_b;  
  1382   unsigned short di_b;  
  1397 
  1383 
  1398   PDEBUG("me8100_read_di_b() is executed\n");
  1384   PDEBUG("me8100_read_di_b() is executed\n");
  1399   
  1385   
  1418  *                                                                          
  1404  *                                                                          
  1419  * Parameter list:                                                          
  1405  * Parameter list:                                                          
  1420  *   Name    Type                       Access  Description                 
  1406  *   Name    Type                       Access  Description                 
  1421  *--------------------------------------------------------------------------
  1407  *--------------------------------------------------------------------------
  1422  *   *arg    unsigned short             r       Carries the value from user.
  1408  *   *arg    unsigned short             r       Carries the value from user.
  1423  *   *info   me8100_info_type           r       Global board context.
  1409  *   *info   me8100_info_t           r       Global board context.
  1424  *                                                                          
  1410  *                                                                          
  1425  * Result:                                                                  
  1411  * Result:                                                                  
  1426  *   On success the return value is 0, else is failure.
  1412  *   On success the return value is 0, else is failure.
  1427  *--------------------------------------------------------------------------
  1413  *--------------------------------------------------------------------------
  1428  * Author: GG                                                               
  1414  * Author: GG                                                               
  1429  * Modification:                                                            
  1415  * Modification:                                                            
  1430  */
  1416  */
  1431 static int me8100_write_do_b(unsigned short *arg, me8100_info_type *info){
  1417 static int me8100_write_do_b(unsigned short *arg, me8100_info_t *info){
  1432   int err = 0;
  1418   int err = 0;
  1433   unsigned short do_b = 0;  
  1419   unsigned short do_b = 0;  
  1434 
  1420 
  1435   PDEBUG("me8100_write_do_b() is executed\n");
  1421   PDEBUG("me8100_write_do_b() is executed\n");
  1436   
  1422   
  1457  *                                                                          
  1443  *                                                                          
  1458  * Parameter list:                                                          
  1444  * Parameter list:                                                          
  1459  *   Name    Type                       Access  Description                 
  1445  *   Name    Type                       Access  Description                 
  1460  *--------------------------------------------------------------------------
  1446  *--------------------------------------------------------------------------
  1461  *   *arg    unsigned short             r       Carries the value from user.
  1447  *   *arg    unsigned short             r       Carries the value from user.
  1462  *   *info   me8100_info_type           r       Global board context.
  1448  *   *info   me8100_info_t           r       Global board context.
  1463  *                                                                          
  1449  *                                                                          
  1464  * Result:                                                                  
  1450  * Result:                                                                  
  1465  *   On success the return value is 0, else is failure.
  1451  *   On success the return value is 0, else is failure.
  1466  *--------------------------------------------------------------------------
  1452  *--------------------------------------------------------------------------
  1467  * Author: GG                                                               
  1453  * Author: GG                                                               
  1468  * Modification:                                                            
  1454  * Modification:                                                            
  1469  */
  1455  */
  1470 static int me8100_write_pattern_b(unsigned short *arg, me8100_info_type *info){
  1456 static int me8100_write_pattern_b(unsigned short *arg, me8100_info_t *info){
  1471   int err = 0;
  1457   int err = 0;
  1472   unsigned short pattern_b = 0;  
  1458   unsigned short pattern_b = 0;  
  1473 
  1459 
  1474   PDEBUG("me8100_write_pattern_b() is executed\n");
  1460   PDEBUG("me8100_write_pattern_b() is executed\n");
  1475   
  1461   
  1497  *                                                                          
  1483  *                                                                          
  1498  * Parameter list:                                                          
  1484  * Parameter list:                                                          
  1499  *   Name    Type                       Access  Description                 
  1485  *   Name    Type                       Access  Description                 
  1500  *--------------------------------------------------------------------------
  1486  *--------------------------------------------------------------------------
  1501  *   *arg    unsigned short             r       Carries the value from user.
  1487  *   *arg    unsigned short             r       Carries the value from user.
  1502  *   *info   me8100_info_type           r       Global board context.
  1488  *   *info   me8100_info_t           r       Global board context.
  1503  *                                                                          
  1489  *                                                                          
  1504  * Result:                                                                  
  1490  * Result:                                                                  
  1505  *   On success the return value is 0, else is failure.
  1491  *   On success the return value is 0, else is failure.
  1506  *--------------------------------------------------------------------------
  1492  *--------------------------------------------------------------------------
  1507  * Author: GG                                                               
  1493  * Author: GG                                                               
  1508  * Modification:                                                            
  1494  * Modification:                                                            
  1509  */
  1495  */
  1510 static int me8100_write_mask_b(unsigned short *arg, me8100_info_type *info){
  1496 static int me8100_write_mask_b(unsigned short *arg, me8100_info_t *info){
  1511   int err = 0;
  1497   int err = 0;
  1512   unsigned short mask_b = 0;  
  1498   unsigned short mask_b = 0;  
  1513 
  1499 
  1514   PDEBUG("me8100_write_mask_b() is executed\n");
  1500   PDEBUG("me8100_write_mask_b() is executed\n");
  1515   
  1501   
  1538  *                                                                          
  1524  *                                                                          
  1539  * Parameter list:                                                          
  1525  * Parameter list:                                                          
  1540  *   Name    Type                       Access  Description                 
  1526  *   Name    Type                       Access  Description                 
  1541  *--------------------------------------------------------------------------
  1527  *--------------------------------------------------------------------------
  1542  *   *arg    unsigned short             w       Carries the value to user.
  1528  *   *arg    unsigned short             w       Carries the value to user.
  1543  *   *info   me8100_info_type           r       Global board context.
  1529  *   *info   me8100_info_t           r       Global board context.
  1544  *                                                                          
  1530  *                                                                          
  1545  * Result:                                                                  
  1531  * Result:                                                                  
  1546  *   On success the return value is 0, else is failure.
  1532  *   On success the return value is 0, else is failure.
  1547  *--------------------------------------------------------------------------
  1533  *--------------------------------------------------------------------------
  1548  * Author: GG                                                               
  1534  * Author: GG                                                               
  1549  * Modification:                                                            
  1535  * Modification:                                                            
  1550  */
  1536  */
  1551 static int me8100_read_int_di_b(unsigned short *arg, me8100_info_type *info){
  1537 static int me8100_read_int_di_b(unsigned short *arg, me8100_info_t *info){
  1552   int err = 0;  
  1538   int err = 0;  
  1553   unsigned short int_di_b;  
  1539   unsigned short int_di_b;  
  1554 
  1540 
  1555   PDEBUG("me8100_read_int_di_b() is executed\n");
  1541   PDEBUG("me8100_read_int_di_b() is executed\n");
  1556   
  1542   
  1577  *                                                                          
  1563  *                                                                          
  1578  * Parameter list:                                                          
  1564  * Parameter list:                                                          
  1579  *   Name    Type                       Access  Description                 
  1565  *   Name    Type                       Access  Description                 
  1580  *--------------------------------------------------------------------------
  1566  *--------------------------------------------------------------------------
  1581  *   *arg    unsigned char              r       Carries the value from user.
  1567  *   *arg    unsigned char              r       Carries the value from user.
  1582  *   *info   me8100_info_type           r       Global board context.
  1568  *   *info   me8100_info_t           r       Global board context.
  1583  *                                                                          
  1569  *                                                                          
  1584  * Result:                                                                  
  1570  * Result:                                                                  
  1585  *   On success the return value is 0, else is failure.
  1571  *   On success the return value is 0, else is failure.
  1586  *--------------------------------------------------------------------------
  1572  *--------------------------------------------------------------------------
  1587  * Author: GG                                                               
  1573  * Author: GG                                                               
  1588  * Modification:                                                            
  1574  * Modification:                                                            
  1589  */
  1575  */
  1590 static int me8100_write_counter_0(unsigned char *arg, me8100_info_type *info){
  1576 static int me8100_write_counter_0(unsigned char *arg, me8100_info_t *info){
  1591   int err = 0;
  1577   int err = 0;
  1592   unsigned char value = 0;  
  1578   unsigned char value = 0;  
  1593 
  1579 
  1594   PDEBUG("me8100_write_counter_0() is executed\n");
  1580   PDEBUG("me8100_write_counter_0() is executed\n");
  1595   
  1581   
  1619  *                                                                          
  1605  *                                                                          
  1620  * Parameter list:                                                          
  1606  * Parameter list:                                                          
  1621  *   Name    Type                       Access  Description                 
  1607  *   Name    Type                       Access  Description                 
  1622  *--------------------------------------------------------------------------
  1608  *--------------------------------------------------------------------------
  1623  *   *arg    unsigned char              r       Carries the value from user.
  1609  *   *arg    unsigned char              r       Carries the value from user.
  1624  *   *info   me8100_info_type           r       Global board context.
  1610  *   *info   me8100_info_t           r       Global board context.
  1625  *                                                                          
  1611  *                                                                          
  1626  * Result:                                                                  
  1612  * Result:                                                                  
  1627  *   On success the return value is 0, else is failure.
  1613  *   On success the return value is 0, else is failure.
  1628  *--------------------------------------------------------------------------
  1614  *--------------------------------------------------------------------------
  1629  * Author: GG                                                               
  1615  * Author: GG                                                               
  1630  * Modification:                                                            
  1616  * Modification:                                                            
  1631  */
  1617  */
  1632 static int me8100_write_counter_1(unsigned char *arg, me8100_info_type *info){
  1618 static int me8100_write_counter_1(unsigned char *arg, me8100_info_t *info){
  1633   int err = 0;
  1619   int err = 0;
  1634   unsigned char value = 0;  
  1620   unsigned char value = 0;  
  1635 
  1621 
  1636   PDEBUG("me8100_write_counter_1() is executed\n");
  1622   PDEBUG("me8100_write_counter_1() is executed\n");
  1637   
  1623   
  1661  *                                                                          
  1647  *                                                                          
  1662  * Parameter list:                                                          
  1648  * Parameter list:                                                          
  1663  *   Name    Type                       Access  Description                 
  1649  *   Name    Type                       Access  Description                 
  1664  *--------------------------------------------------------------------------
  1650  *--------------------------------------------------------------------------
  1665  *   *arg    unsigned char              r       Carries the value from user.
  1651  *   *arg    unsigned char              r       Carries the value from user.
  1666  *   *info   me8100_info_type           r       Global board context.
  1652  *   *info   me8100_info_t           r       Global board context.
  1667  *                                                                          
  1653  *                                                                          
  1668  * Result:                                                                  
  1654  * Result:                                                                  
  1669  *   On success the return value is 0, else is failure.
  1655  *   On success the return value is 0, else is failure.
  1670  *--------------------------------------------------------------------------
  1656  *--------------------------------------------------------------------------
  1671  * Author: GG                                                               
  1657  * Author: GG                                                               
  1672  * Modification:                                                            
  1658  * Modification:                                                            
  1673  */
  1659  */
  1674 static int me8100_write_counter_2(unsigned char *arg, me8100_info_type *info){
  1660 static int me8100_write_counter_2(unsigned char *arg, me8100_info_t *info){
  1675   int err = 0;
  1661   int err = 0;
  1676   unsigned char value = 0;  
  1662   unsigned char value = 0;  
  1677 
  1663 
  1678   PDEBUG("me8100_write_counter_2() is executed\n");
  1664   PDEBUG("me8100_write_counter_2() is executed\n");
  1679   
  1665   
  1702  *                                                                          
  1688  *                                                                          
  1703  * Parameter list:                                                          
  1689  * Parameter list:                                                          
  1704  *   Name    Type                       Access  Description                 
  1690  *   Name    Type                       Access  Description                 
  1705  *--------------------------------------------------------------------------
  1691  *--------------------------------------------------------------------------
  1706  *   *arg    unsigned char              r       Carries the value to user.
  1692  *   *arg    unsigned char              r       Carries the value to user.
  1707  *   *info   me8100_info_type           r       Global board context.
  1693  *   *info   me8100_info_t           r       Global board context.
  1708  *                                                                          
  1694  *                                                                          
  1709  * Result:                                                                  
  1695  * Result:                                                                  
  1710  *   On success the return value is 0, else is failure.
  1696  *   On success the return value is 0, else is failure.
  1711  *--------------------------------------------------------------------------
  1697  *--------------------------------------------------------------------------
  1712  * Author: GG                                                               
  1698  * Author: GG                                                               
  1713  * Modification:                                                            
  1699  * Modification:                                                            
  1714  */
  1700  */
  1715 static int me8100_read_counter_0(unsigned char *arg, me8100_info_type *info){
  1701 static int me8100_read_counter_0(unsigned char *arg, me8100_info_t *info){
  1716   int err = 0;  
  1702   int err = 0;  
  1717   unsigned char value;  
  1703   unsigned char value;  
  1718 
  1704 
  1719   PDEBUG("me8100_read_counter_0() is executed\n");
  1705   PDEBUG("me8100_read_counter_0() is executed\n");
  1720   
  1706   
  1740  *                                                                          
  1726  *                                                                          
  1741  * Parameter list:                                                          
  1727  * Parameter list:                                                          
  1742  *   Name    Type                       Access  Description                 
  1728  *   Name    Type                       Access  Description                 
  1743  *--------------------------------------------------------------------------
  1729  *--------------------------------------------------------------------------
  1744  *   *arg    unsigned char              r       Carries the value to user.
  1730  *   *arg    unsigned char              r       Carries the value to user.
  1745  *   *info   me8100_info_type           r       Global board context.
  1731  *   *info   me8100_info_t           r       Global board context.
  1746  *                                                                          
  1732  *                                                                          
  1747  * Result:                                                                  
  1733  * Result:                                                                  
  1748  *   On success the return value is 0, else is failure.
  1734  *   On success the return value is 0, else is failure.
  1749  *--------------------------------------------------------------------------
  1735  *--------------------------------------------------------------------------
  1750  * Author: GG                                                               
  1736  * Author: GG                                                               
  1751  * Modification:                                                            
  1737  * Modification:                                                            
  1752  */
  1738  */
  1753 static int me8100_read_counter_1(unsigned char *arg, me8100_info_type *info){
  1739 static int me8100_read_counter_1(unsigned char *arg, me8100_info_t *info){
  1754   int err = 0;  
  1740   int err = 0;  
  1755   unsigned char value;  
  1741   unsigned char value;  
  1756 
  1742 
  1757   PDEBUG("me8100_read_counter_1() is executed\n");
  1743   PDEBUG("me8100_read_counter_1() is executed\n");
  1758   
  1744   
  1786  *   On success the return value is 0, else is failure.
  1772  *   On success the return value is 0, else is failure.
  1787  *--------------------------------------------------------------------------
  1773  *--------------------------------------------------------------------------
  1788  * Author: GG                                                               
  1774  * Author: GG                                                               
  1789  * Modification:                                                            
  1775  * Modification:                                                            
  1790  */
  1776  */
  1791 static int me8100_read_counter_2(unsigned char *arg, me8100_info_type *info){
  1777 static int me8100_read_counter_2(unsigned char *arg, me8100_info_t *info){
  1792   int err = 0;  
  1778   int err = 0;  
  1793   unsigned char value;  
  1779   unsigned char value;  
  1794 
  1780 
  1795   PDEBUG("me8100_read_counter_2() is executed\n");
  1781   PDEBUG("me8100_read_counter_2() is executed\n");
  1796   
  1782   
  1814  *                                                                           
  1800  *                                                                           
  1815  * Parameter list:                                                           
  1801  * Parameter list:                                                           
  1816  *   Name    Type                       Access  Description                  
  1802  *   Name    Type                       Access  Description                  
  1817  *-------------------------------------------------------------------------- 
  1803  *-------------------------------------------------------------------------- 
  1818  *   *arg    unsigned char              r       Carries the value from user.
  1804  *   *arg    unsigned char              r       Carries the value from user.
  1819  *   *info   me8100_info_type           r       Global board context.
  1805  *   *info   me8100_info_t           r       Global board context.
  1820  *                                                                           
  1806  *                                                                           
  1821  * Result:                                                                   
  1807  * Result:                                                                   
  1822  *   On success the return value is 0, else is failure.
  1808  *   On success the return value is 0, else is failure.
  1823  *-------------------------------------------------------------------------- 
  1809  *-------------------------------------------------------------------------- 
  1824  * Author: GG                                                                
  1810  * Author: GG                                                                
  1825  * Modification:                                                             
  1811  * Modification:                                                             
  1826  */
  1812  */
  1827 static int me8100_setup_counter(unsigned char *arg, me8100_info_type *info){
  1813 static int me8100_setup_counter(unsigned char *arg, me8100_info_t *info){
  1828   int err = 0;
  1814   int err = 0;
  1829   unsigned char value = 0;  
  1815   unsigned char value = 0;  
  1830 
  1816 
  1831   PDEBUG("me8100_setup_counter() is executed\n");
  1817   PDEBUG("me8100_setup_counter() is executed\n");
  1832   
  1818   
  1854  *                                                                          
  1840  *                                                                          
  1855  * Parameter list:                                                          
  1841  * Parameter list:                                                          
  1856  *   Name    Type                       Access  Description                 
  1842  *   Name    Type                       Access  Description                 
  1857  *--------------------------------------------------------------------------
  1843  *--------------------------------------------------------------------------
  1858  *   *arg    unsigned int               w       Carries the value to user.
  1844  *   *arg    unsigned int               w       Carries the value to user.
  1859  *   *info   me8100_info_type           r       Global board context.
  1845  *   *info   me8100_info_t           r       Global board context.
  1860  *                                                                          
  1846  *                                                                          
  1861  * Result:                                                                  
  1847  * Result:                                                                  
  1862  *   On success the return value is 0, else is failure.
  1848  *   On success the return value is 0, else is failure.
  1863  *--------------------------------------------------------------------------
  1849  *--------------------------------------------------------------------------
  1864  * Author: GG                                                               
  1850  * Author: GG                                                               
  1865  * Modification:                                                            
  1851  * Modification:                                                            
  1866  */
  1852  */
  1867 static int me8100_get_serial(unsigned int *arg, me8100_info_type *info){
  1853 static int me8100_get_serial(unsigned int *arg, me8100_info_t *info){
  1868   int err = 0;  
  1854   int err = 0;  
  1869   unsigned int value;  
  1855   unsigned int value;  
  1870 
  1856 
  1871   PDEBUG("me8100_get_serial() is executed\n");
  1857   PDEBUG("me8100_get_serial() is executed\n");
  1872   
  1858   
  1891  *                                                                          
  1877  *                                                                          
  1892  * Parameter list:                                                          
  1878  * Parameter list:                                                          
  1893  *   Name    Type                       Access  Description                 
  1879  *   Name    Type                       Access  Description                 
  1894  *--------------------------------------------------------------------------
  1880  *--------------------------------------------------------------------------
  1895  *   *arg    unsigned int               w       Carries the value to user.
  1881  *   *arg    unsigned int               w       Carries the value to user.
  1896  *   *info   me8100_info_type           r       Global board context.
  1882  *   *info   me8100_info_t           r       Global board context.
  1897  *                                                                          
  1883  *                                                                          
  1898  * Result:                                                                  
  1884  * Result:                                                                  
  1899  *   On success the return value is 0, else is failure.
  1885  *   On success the return value is 0, else is failure.
  1900  *--------------------------------------------------------------------------
  1886  *--------------------------------------------------------------------------
  1901  * Author: GG                                                               
  1887  * Author: GG                                                               
  1902  * Modification:                                                            
  1888  * Modification:                                                            
  1903  */
  1889  */
  1904 static int me8100_get_name(me8100_version_enum_type *arg, me8100_info_type *info){
  1890 static int me8100_get_name(me8100_version_enum_type *arg, me8100_info_t *info){
  1905   int err = 0;  
  1891   int err = 0;  
  1906   unsigned int value;  
  1892   unsigned int value;  
  1907 
  1893 
  1908   PDEBUG("me8100_get_name() is executed\n");
  1894   PDEBUG("me8100_get_name() is executed\n");
  1909   
  1895   
  1928  *                                                                          
  1914  *                                                                          
  1929  * Parameter list:                                                          
  1915  * Parameter list:                                                          
  1930  *   Name    Type                       Access  Description                 
  1916  *   Name    Type                       Access  Description                 
  1931  *--------------------------------------------------------------------------
  1917  *--------------------------------------------------------------------------
  1932  *   *arg    me8100_int_occur_type      w       Carries the value to user.
  1918  *   *arg    me8100_int_occur_type      w       Carries the value to user.
  1933  *   *info   me8100_info_type           r       Global board context.
  1919  *   *info   me8100_info_t           r       Global board context.
  1934  *                                                                          
  1920  *                                                                          
  1935  * Result:                                                                  
  1921  * Result:                                                                  
  1936  *   On success the return value is 0, else is failure.
  1922  *   On success the return value is 0, else is failure.
  1937  *--------------------------------------------------------------------------
  1923  *--------------------------------------------------------------------------
  1938  * Author: GG                                                               
  1924  * Author: GG                                                               
  1939  * Modification:                                                            
  1925  * Modification:                                                            
  1940  */
  1926  */
  1941 static int me8100_int_occur(me8100_int_occur_type *arg, me8100_info_type *info){
  1927 static int me8100_int_occur(me8100_int_occur_type *arg, me8100_info_t *info){
  1942   int err = 0;
  1928   int err = 0;
  1943   unsigned long flags;
  1929   unsigned long flags;
  1944   me8100_int_occur_type int_occur;
  1930   me8100_int_occur_type int_occur;
  1945 
  1931 
  1946   PDEBUG("me8100_read_int_occur() is executed\n");
  1932   PDEBUG("me8100_read_int_occur() is executed\n");
  1970  *                                                                          
  1956  *                                                                          
  1971  * Parameter list:                                                          
  1957  * Parameter list:                                                          
  1972  *   Name    Type                       Access  Description                 
  1958  *   Name    Type                       Access  Description                 
  1973  *--------------------------------------------------------------------------
  1959  *--------------------------------------------------------------------------
  1974  *   *arg    unsigned char              r       Carries the value from user.
  1960  *   *arg    unsigned char              r       Carries the value from user.
  1975  *   *info   me8100_info_type           r       Global board context.
  1961  *   *info   me8100_info_t           r       Global board context.
  1976  *                                                                          
  1962  *                                                                          
  1977  * Result:                                                                  
  1963  * Result:                                                                  
  1978  *   On success the return value is 0, else is failure.
  1964  *   On success the return value is 0, else is failure.
  1979  *--------------------------------------------------------------------------
  1965  *--------------------------------------------------------------------------
  1980  * Author: GG                                                               
  1966  * Author: GG                                                               
  1981  * Modification:                                                            
  1967  * Modification:                                                            
  1982  */
  1968  */
  1983 static int me8100_setup_icsr(unsigned char *arg, me8100_info_type *info){
  1969 static int me8100_setup_icsr(unsigned char *arg, me8100_info_t *info){
  1984   int err = 0;
  1970   int err = 0;
  1985   unsigned char value = 0;  
  1971   unsigned char value = 0;  
  1986 
  1972 
  1987   PDEBUG("me8100_setup_icsr() is executed\n");
  1973   PDEBUG("me8100_setup_icsr() is executed\n");
  1988   
  1974   
  2010  *                                                                          
  1996  *                                                                          
  2011  * Parameter list:                                                          
  1997  * Parameter list:                                                          
  2012  *   Name    Type                       Access  Description                 
  1998  *   Name    Type                       Access  Description                 
  2013  *--------------------------------------------------------------------------
  1999  *--------------------------------------------------------------------------
  2014  *   *arg    unsigned char              w       Carries the value to user.
  2000  *   *arg    unsigned char              w       Carries the value to user.
  2015  *   *info   me8100_info_type           r       Global board context.
  2001  *   *info   me8100_info_t           r       Global board context.
  2016  *                                                                          
  2002  *                                                                          
  2017  * Result:                                                                  
  2003  * Result:                                                                  
  2018  *   On success the return value is 0, else is failure.
  2004  *   On success the return value is 0, else is failure.
  2019  *--------------------------------------------------------------------------
  2005  *--------------------------------------------------------------------------
  2020  * Author: GG                                                               
  2006  * Author: GG                                                               
  2021  * Modification:                                                            
  2007  * Modification:                                                            
  2022  */
  2008  */
  2023 static int me8100_read_icsr(unsigned char *arg, me8100_info_type *info){
  2009 static int me8100_read_icsr(unsigned char *arg, me8100_info_t *info){
  2024   int err = 0;  
  2010   int err = 0;  
  2025   unsigned char value;  
  2011   unsigned char value;  
  2026 
  2012 
  2027   PDEBUG("me8100_read_icsr() is executed\n");
  2013   PDEBUG("me8100_read_icsr() is executed\n");
  2028   
  2014   
  2046  *                                                                          
  2032  *                                                                          
  2047  * Parameter list:                                                          
  2033  * Parameter list:                                                          
  2048  *   Name    Type                      Access  Description                  
  2034  *   Name    Type                      Access  Description                  
  2049  *--------------------------------------------------------------------------
  2035  *--------------------------------------------------------------------------
  2050  *   *arg    int                       w       Carries the value to user.
  2036  *   *arg    int                       w       Carries the value to user.
  2051  *   *info   me8100_info_type          r       Global board context.
  2037  *   *info   me8100_info_t          r       Global board context.
  2052  *                                                                          
  2038  *                                                                          
  2053  * Result:                                                                  
  2039  * Result:                                                                  
  2054  *   On success the return value is 0, else is failure.
  2040  *   On success the return value is 0, else is failure.
  2055  *--------------------------------------------------------------------------
  2041  *--------------------------------------------------------------------------
  2056  * Author: GG                                                               
  2042  * Author: GG                                                               
  2057  * Modification:                                                            
  2043  * Modification:                                                            
  2058  */
  2044  */
  2059 static int me8100_get_int_count(me8100_int_occur_type *arg, 
  2045 static int me8100_get_int_count(me8100_int_occur_type *arg, 
  2060 				me8100_info_type *info){
  2046 				me8100_info_t *info){
  2061   me8100_int_occur_type int_count;
  2047   me8100_int_occur_type int_count;
  2062   unsigned long flags;
  2048   unsigned long flags;
  2063 
  2049 
  2064   PDEBUG("me8100_get_int_count() is executed\n");
  2050   PDEBUG("me8100_get_int_count() is executed\n");
  2065 
  2051 
  2105  * Modification:                                                            
  2091  * Modification:                                                            
  2106  */
  2092  */
  2107 static void me8100_isr(int irq, void *dev_id, struct pt_regs *regs){
  2093 static void me8100_isr(int irq, void *dev_id, struct pt_regs *regs){
  2108   int i;
  2094   int i;
  2109   unsigned char icsr;
  2095   unsigned char icsr;
  2110   me8100_info_type *info;
  2096   me8100_info_t *info;
  2111 
  2097 
  2112   /* A: 0x04 & 0x40 & 0x01 */
  2098   /* A: 0x04 & 0x40 & 0x01 for irq at port A */
  2113   /* B: 0x20 & 0x40 & 0x08 */
  2099   /* B: 0x20 & 0x40 & 0x08 for irq at port B */
  2114   unsigned short icsr_mask[] = { 0x45, 0x68 };
  2100   unsigned short icsr_mask[] = { 0x45, 0x68 };
  2115 
  2101 
  2116   info = (me8100_info_type *) dev_id;
  2102   info = (me8100_info_t *) dev_id;
  2117 
  2103 
  2118   PDEBUG("=====> me8100_isr() is executed\n");
  2104   PDEBUG("INT: me8100_isr()\n");
  2119 
       
  2120 
  2105 
  2121   if(irq != info->int_line){
  2106   if(irq != info->int_line){
  2122     PDEBUG("me8100_isr():incorrect interrupt num: %d\n", irq);
  2107     PDEBUG("me8100_isr():incorrect interrupt num: %d\n", irq);
  2123     return;
  2108     return;
  2124   }
  2109   }
  2125 
  2110 
  2126 
  2111 
  2127   icsr = inb(info->plx_regbase + PLX_ICSR);
  2112   icsr = inb(info->plx_regbase + PLX_ICSR);
  2128   PDEBUG("== ICSR: 0x%04x\n", icsr);
  2113   PDEBUG("ICSR: 0x%04x\n", icsr);
  2129 
  2114 
  2130   /* We got an interrupt.  Now try each possible subdevice in turn.
  2115   /* We got an interrupt.  Now try each possible subdevice in turn.
  2131    * (There is the possibility that all subdevices raised an intterupt
  2116    * (There is the possibility that all subdevices raised an interupt
  2132    * at the same time.  I don't know how this is resolved by the board.
  2117    * at the same time.  I don't know how this is resolved by the board.
  2133    * So we've to try each subdevice in turn.) */
  2118    * So we've to try each subdevice in turn.) */
  2134   for (i = 0; i <= 1; ++i) {
  2119   for (i = 0; i < MAX_SUBDEVICES; ++i) {
  2135     if ((icsr & icsr_mask[i]) == icsr_mask[i]) {
  2120     if ((icsr & icsr_mask[i]) == icsr_mask[i]) {
  2136 
  2121 
  2137       struct me8100_subinfo *subinfo = &info->subinfo[i];
  2122       me8100_subinfo_t *subinfo = &info->subinfo[i];
  2138       subinfo->int_seen = jiffies;
  2123       subinfo->int_seen = jiffies;
  2139       ++subinfo->int_count;
  2124       ++subinfo->int_count;
  2140 
  2125 
  2141       subinfo->int_di = inw(subinfo->regbase + ME8100_INT_DI_REG);
  2126       subinfo->int_di = inw(subinfo->regbase + ME8100_INT_DI_REG);
  2142       inw(subinfo->regbase + ME8100_RES_INT_REG);	  // dummy read
  2127       inw(subinfo->regbase + ME8100_RES_INT_REG);	  // dummy read
  2203  */
  2188  */
  2204 ssize_t me8100_read(struct file * file_ptr, char *buffer, size_t len, loff_t *offset) 
  2189 ssize_t me8100_read(struct file * file_ptr, char *buffer, size_t len, loff_t *offset) 
  2205 {
  2190 {
  2206   int err;
  2191   int err;
  2207   unsigned short val;
  2192   unsigned short val;
  2208   int minor;
  2193   me8100_subinfo_t *subinfo;
  2209   struct me8100_private_data *priv;
  2194   me8100_private_data_t *priv;
  2210   struct me8100_subinfo *subinfo;
  2195 
  2211 
       
  2212   PDEBUG("me8100_read() called\n");
       
  2213 
       
  2214   minor = MINOR(file_ptr->f_dentry->d_inode->i_rdev);
       
  2215   subinfo = &info_vec[DEVICE(minor)].subinfo[SUBDEVICE(minor)];
       
  2216   priv = file_ptr->private_data;
  2196   priv = file_ptr->private_data;
  2217   
  2197   subinfo = priv->subinfo;
       
  2198 
       
  2199   PDEBUG("me8100_read()\n");
       
  2200 
  2218   if (len == 0) return 0;	/* do we really need this check? */
  2201   if (len == 0) return 0;	/* do we really need this check? */
  2219   if (len < 0) return -EINVAL;	/* do we really need this check? */
  2202   if (len < 0) return -EINVAL;	/* do we really need this check? */
  2220 
  2203 
  2221   /* If the time we did the last read operation is more recent than the
  2204   /* If the time we did the last read operation is more recent than the
  2222    * last interupt, we have to go to sleep (or return -EAGAIN in non blockin
  2205    * last interupt, we have to go to sleep (or return -EAGAIN in non blockin
  2263  */
  2246  */
  2264 ssize_t me8100_write(struct file * file_ptr, const char *buffer, size_t len, loff_t *offset) 
  2247 ssize_t me8100_write(struct file * file_ptr, const char *buffer, size_t len, loff_t *offset) 
  2265 {
  2248 {
  2266   int err;
  2249   int err;
  2267   unsigned short val;
  2250   unsigned short val;
  2268   int minor;
  2251   me8100_subinfo_t *subinfo;
  2269   
  2252 
  2270   minor = MINOR(file_ptr->f_dentry->d_inode->i_rdev);
  2253   subinfo = ((me8100_private_data_t*) file_ptr->private_data)->subinfo;
       
  2254 
  2271   PDEBUG("me8100_write(%d) called\n", len);
  2255   PDEBUG("me8100_write(%d) called\n", len);
  2272 
  2256 
  2273   if (len == 0) return 0;	  /* do we need this? */
  2257   if (len == 0) return 0;	  /* do we need this? */
  2274   if (len < 0) return -EINVAL;	  /* do we need this? */
  2258   if (len < 0) return -EINVAL;	  /* do we need this? */
  2275 
  2259 
  2283   }
  2267   }
  2284 
  2268 
  2285   if (err) return err;
  2269   if (err) return err;
  2286 
  2270 
  2287   PDEBUG("*** me8100_write: val=0x%04x\n", val);
  2271   PDEBUG("*** me8100_write: val=0x%04x\n", val);
  2288   outw(val, info_vec[DEVICE(minor)].subinfo[SUBDEVICE(minor)].regbase + ME8100_DO_REG);
  2272   outw(val, subinfo->regbase + ME8100_DO_REG);
  2289 
  2273 
  2290   return len;
  2274   return len;
  2291 }
  2275 }
  2292 
  2276 
  2293 static unsigned int me8100_poll(struct file *file_ptr, struct poll_table_struct *wait)
  2277 static unsigned int me8100_poll(struct file *file_ptr, struct poll_table_struct *wait)
  2294 {
  2278 {
  2295   int minor = MINOR(file_ptr->f_dentry->d_inode->i_rdev);
  2279   me8100_private_data_t *priv;
  2296   me8100_info_type *info = &info_vec[DEVICE(minor)];
  2280   me8100_subinfo_t *subinfo;
  2297   struct me8100_subinfo *subinfo = &info->subinfo[SUBDEVICE(minor)];
  2281 
  2298   struct me8100_private_data *priv = file_ptr->private_data;
  2282   priv = file_ptr->private_data;
  2299 
  2283   subinfo = priv->subinfo;
  2300   PDEBUG("***  me8100_poll()\n");
  2284 
       
  2285   PDEBUG("me8100_poll()\n");
  2301   poll_wait(file_ptr, &subinfo->readq, wait);
  2286   poll_wait(file_ptr, &subinfo->readq, wait);
  2302   PDEBUG("***  me8100_poll()\n");
       
  2303 
  2287 
  2304   if (priv->last_read >= subinfo->int_seen) return 0;
  2288   if (priv->last_read >= subinfo->int_seen) return 0;
  2305   return POLLIN | POLLRDNORM;
  2289   return POLLIN | POLLRDNORM;
  2306 
  2290 
  2307 }
  2291 }