added isapnp id of AT-MIO-16XE-50 to driver
authorFrank Mori Hess <fmhess@speakeasy.net>
Thu, 13 Mar 2003 18:34:12 +0000 (18:34 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Thu, 13 Mar 2003 18:34:12 +0000 (18:34 +0000)
comedi/drivers/ni_atmio.c
comedi/drivers/ni_stc.h

index c054087212391cb622567d50d2b772294f2552ad..bbfea26a5e63e9c8b86e0d39701834cd53c53864 100644 (file)
@@ -105,6 +105,7 @@ are not supported.
 
 static ni_board ni_boards[]={
        {       device_id:      44,
+               isapnp_id:      0x1900, /* probably wrong */
                name:           "at-mio-16e-1",
                n_adchan:       16,
                adbits:         12,
@@ -120,6 +121,7 @@ static ni_board ni_boards[]={
                caldac:         {mb88341},
        },
        {       device_id:      25,
+               isapnp_id:      0x1900, /* probably wrong */
                name:           "at-mio-16e-2",
                n_adchan:       16,
                adbits:         12,
@@ -135,6 +137,7 @@ static ni_board ni_boards[]={
                caldac:         {mb88341},
        },
        {       device_id:      36,
+               isapnp_id:      0x1900, /* probably wrong */
                name:           "at-mio-16e-10",
                n_adchan:       16,
                adbits:         12,
@@ -150,6 +153,7 @@ static ni_board ni_boards[]={
                has_8255:       0,
        },
        {       device_id:      37,
+               isapnp_id:      0x1900, /* probably wrong */
                name:           "at-mio-16de-10",
                n_adchan:       16,
                adbits:         12,
@@ -165,6 +169,7 @@ static ni_board ni_boards[]={
                has_8255:       1,
        },
        {       device_id:      38,
+               isapnp_id:      0x1900, /* probably wrong */
                name:           "at-mio-64e-3",
                n_adchan:       64,
                adbits:         12,
@@ -180,6 +185,7 @@ static ni_board ni_boards[]={
                caldac:         {mb88341},
        },
        {       device_id:      39,
+               isapnp_id:      0x2700,
                name:           "at-mio-16xe-50",
                n_adchan:       16,
                adbits:         16,
@@ -195,6 +201,7 @@ static ni_board ni_boards[]={
                has_8255:       0,
        },
        {       device_id:      50,
+               isapnp_id:      0x1900, /* probably wrong */
                name:           "at-mio-16xe-10",
                n_adchan:       16,
                adbits:         16,
@@ -210,6 +217,7 @@ static ni_board ni_boards[]={
                has_8255:       0,
        },
        {       device_id:      51,
+               isapnp_id:      0x1900, /* probably wrong */
                name:           "at-ai-16xe-10",
                n_adchan:       16,
                adbits:         16,
@@ -226,7 +234,7 @@ static ni_board ni_boards[]={
                has_8255:       0,
        }
 };
-
+static const int num_ni_boards = sizeof( ni_boards ) / sizeof( ni_board );
 
 static int ni_irqpin[]={-1,-1,-1,0,1,2,-1,3,-1,-1,4,5,6,-1,-1,7};
 
@@ -299,7 +307,8 @@ static inline unsigned short __win_in(comedi_device *dev, int addr)
 
 #ifdef __ISAPNP__
 static struct isapnp_device_id device_ids[] = {
-       { ISAPNP_DEVICE_SINGLE('N','I','C',0x1900,'N','I','C',0x0000), },
+       { ISAPNP_DEVICE_SINGLE('N','I','C',0x1900,'N','I','C',0x1900), },
+       { ISAPNP_DEVICE_SINGLE('N','I','C',0x2700,'N','I','C',0x2700), },
        { ISAPNP_DEVICE_SINGLE_END, },
 };
 MODULE_DEVICE_TABLE(isapnp, device_ids);
@@ -344,30 +353,21 @@ static int ni_atmio_detach(comedi_device *dev)
        return 0;
 }
 
-static int ni_atmio_attach(comedi_device *dev,comedi_devconfig *it)
+static int ni_isapnp_find_board( struct pci_dev **dev )
 {
-       struct pci_dev *isapnp_dev;
-       int             ret;
-       int             iobase;
-       int             board;
-       int             irq;
+#ifdef __ISAPNP__
+       struct pci_dev *isapnp_dev = NULL;
 
-       iobase=it->options[0];
-       irq=it->options[1];
-       isapnp_dev = NULL;
-       if( iobase == 0 )
+       for( i = 0; i < num_ni_boards; i++ )
        {
-#ifdef __ISAPNP__
                isapnp_dev = isapnp_find_dev(NULL,
                        ISAPNP_VENDOR('N','I','C'),
-                       ISAPNP_FUNCTION(0x1900),
+                       ISAPNP_FUNCTION( ni_boards[ i ].isapnp_id ),
                        NULL);
 
-               if(!isapnp_dev)
-                       return -ENODEV;
+               if(!isapnp_dev) continue;
 
-               if(isapnp_dev->active)
-                       return -EBUSY;
+               if(isapnp_dev->active) continue;
 
                if(isapnp_dev->prepare(isapnp_dev)<0)
                        return -EAGAIN;
@@ -375,20 +375,51 @@ static int ni_atmio_attach(comedi_device *dev,comedi_devconfig *it)
                if(!(isapnp_dev->resource[0].flags & IORESOURCE_IO))
                        return -ENODEV;
 
+#if 0
                if(!isapnp_dev->ro){
                        /* override resource */
                        if(it->options[0] != 0){
                                isapnp_resource_change(&isapnp_dev->resource[0],
-                                       it->options[0], 1);
+                                       it->options[0], NI_SIZE);
                        }
                }
+#endif
                if(isapnp_dev->activate(isapnp_dev)<0){
                        printk("isapnp configure failed!\n");
                        return -ENOMEM;
                }
+               break;
+       }
+       if( i == num_ni_boards ) return -ENODEV;
+       *dev = isapnp_dev;
+       return 0;
+#else
+       return -EIO;
+#endif
+}
+
+static int ni_atmio_attach(comedi_device *dev,comedi_devconfig *it)
+{
+       struct pci_dev *isapnp_dev;
+       int             ret;
+       int             iobase;
+       int             board;
+       int             irq;
+
+       iobase=it->options[0];
+       irq=it->options[1];
+       isapnp_dev = NULL;
+       if( iobase == 0 )
+       {
+               ret = ni_isapnp_find_board( &isapnp_dev );
+               if( ret < 0 ) return ret;
+
+#ifdef __ISAPNP__
                iobase = isapnp_dev->resource[0].start;
                irq = isapnp_dev->irq_resource[0].start;
                devpriv->isapnp_dev = isapnp_dev;
+#else
+               return -EIO;
 #endif
        }
 
index 15b61aec773553a5644fd938f7a2e20607135676..835a940c6251399d59afd2253db55ddce6cf7c15 100644 (file)
@@ -693,6 +693,7 @@ enum caldac_enum { caldac_none=0, mb88341, dac8800, dac8043, ad8522,
 
 typedef struct ni_board_struct{
        int device_id;
+       int isapnp_id;
        char *name;
 
        int n_adchan;