typedef struct{
+ dev_link_t *link;
+
int dio;
int ao0p,ao1p;
int lastchan;
unsigned short gpct_input_select0;
unsigned short gpct_input_select1;
+ unsigned int ai_n_chans;
unsigned int ai_chanlistptr;
unsigned short ai_xorlist[512];
}ni_private;
static int mio_cs_detach(comedi_device *dev);
comedi_driver driver_ni_mio_cs={
driver_name: "ni_mio_cs",
- module: &__this_module,
+ module: THIS_MODULE,
attach: mio_cs_attach,
detach: mio_cs_detach,
};
#include "ni_mio_common.c"
-static int ni_getboardtype(comedi_device *dev);
+static int ni_getboardtype(comedi_device *dev,dev_link_t *link);
/* clean up allocated resources */
-int atmio_E_free(comedi_device *dev)
+static int mio_cs_free(comedi_device *dev)
{
if(dev->iobase)
release_region(dev->iobase,NI_SIZE);
/* called when driver is removed */
static int mio_cs_detach(comedi_device *dev)
{
- return atmio_E_free(dev);
+ return mio_cs_free(dev);
}
void mio_cs_config(dev_link_t *link);
dev_link_t **linkp;
- printk("cs_detach\n");
-
for(linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
if (*linkp == link) break;
if (*linkp==NULL)
switch(event){
case CS_EVENT_CARD_REMOVAL:
-printk("removal event\n");
link->state &= ~DEV_PRESENT;
if(link->state & DEV_CONFIG) {
link->release.expires = jiffies+HZ/20;
}
break;
case CS_EVENT_CARD_INSERTION:
-printk("insertion event\n");
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
mio_cs_config(link);
break;
case CS_EVENT_PM_SUSPEND:
-printk("suspend event\n");
link->state |= DEV_SUSPEND;
/* fall through */
case CS_EVENT_RESET_PHYSICAL:
-printk("physreset event\n");
if(link->state & DEV_CONFIG)
CardServices(ReleaseConfiguration, link->handle);
break;
case CS_EVENT_PM_RESUME:
-printk("resume event\n");
link->state &= ~DEV_SUSPEND;
/* fall through */
case CS_EVENT_CARD_RESET:
-printk("reset event\n");
if(DEV_OK(link))
CardServices(RequestConfiguration, link->handle, &link->conf);
break;
cisparse_t parse;
int manfid = 0, prodid = 0;
int ret;
- comedi_device *dev;
config_info_t conf;
tuple.TupleData = (cisdata_t *)buf;
tuple.DesiredTuple = CISTPL_CONFIG;
ret=CardServices(GetFirstTuple, handle, &tuple);
- printk("GFT %d\n",ret);
ret=CardServices(GetTupleData, handle, &tuple);
- printk("GTD %d\n",ret);
ret=CardServices(ParseTuple, handle, &tuple, &parse);
- printk("PT %d\n",ret);
link->conf.ConfigBase = parse.config.base;
- printk("config_base: 0x%x\n",parse.config.base);
link->conf.Present = parse.config.rmask[0];
link->state |= DEV_CONFIG;
manfid = le16_to_cpu(buf[0]);
prodid = le16_to_cpu(buf[1]);
}
- printk("manfid = 0x%04x, 0x%04x\n",manfid,prodid);
+ //printk("manfid = 0x%04x, 0x%04x\n",manfid,prodid);
tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
tuple.Attributes = 0;
ret=CardServices(GetFirstTuple, handle, &tuple);
- printk("GFT %d\n",ret);
ret=CardServices(GetTupleData, handle, &tuple);
- printk("GTD %d\n",ret);
ret=CardServices(ParseTuple, handle, &tuple, &parse);
- printk("PT %d\n",ret);
- printk("cftable:\n");
#if 0
printk(" index: 0x%x\n",parse.cftable_entry.index);
printk(" flags: 0x%x\n",parse.cftable_entry.flags);
printk(" subtuples: 0x%x\n",parse.cftable_entry.subtuples);
#endif
-{
- int base;
#if 0
link->io.NumPorts1=0x20;
link->io.IOAddrLines=parse.cftable_entry.io.flags & CISTPL_IO_LINES_MASK;
link->io.NumPorts2=0;
- for(base=0x300;base<0x400;base+=0x20){
- link->io.BasePort1=base;
- ret=CardServices(RequestIO, handle, &link->io);
- printk("RequestIO 0x%02x\n",ret);
- if(!ret)break;
+ {
+ int base;
+ for(base=0x300;base<0x400;base+=0x20){
+ link->io.BasePort1=base;
+ ret=CardServices(RequestIO, handle, &link->io);
+ //printk("RequestIO 0x%02x\n",ret);
+ if(!ret)break;
+ }
}
-}
link->irq.IRQInfo1=parse.cftable_entry.irq.IRQInfo1;
link->irq.IRQInfo2=parse.cftable_entry.irq.IRQInfo2;
ret=CardServices(RequestIRQ, handle, &link->irq);
- printk("RequestIRQ 0x%02x\n",ret);
+ //printk("RequestIRQ 0x%02x\n",ret);
link->conf.ConfigIndex=1;
ret=CardServices(RequestConfiguration, handle, &link->conf);
- printk("RequestConfiguration %d\n",ret);
+ //printk("RequestConfiguration %d\n",ret);
link->dev = &dev_node;
link->state &= ~DEV_CONFIG_PENDING;
dev->irq=link->irq.AssignedIRQ;
- printk("comedi%d: %s: DAQCard: io %#3lx, irq %d, ",
+ printk("comedi%d: %s: DAQCard: io 0x%04x, irq %d, ",
dev->minor,dev->driver->driver_name,dev->iobase,
dev->irq);
}
#endif
- //printk("boardtype=%d\n",ni_getboardtype(dev));
- //if(board<0)return -EIO;
- dev->board=0;
+ dev->board=ni_getboardtype(dev,link);
printk(" %s",ni_boards[dev->board].name);
dev->board_name=ni_boards[dev->board].name;
}
+static int get_prodid(comedi_device *dev,dev_link_t *link)
+{
+ client_handle_t handle = link->handle;
+ tuple_t tuple;
+ u_short buf[128];
+ int prodid = 0;
+
+ tuple.TupleData = (cisdata_t *)buf;
+ tuple.TupleOffset = 0;
+ tuple.TupleDataMax = 255;
+ tuple.DesiredTuple = CISTPL_MANFID;
+ tuple.Attributes = TUPLE_RETURN_COMMON;
+ if((CardServices(GetFirstTuple,handle, &tuple) == CS_SUCCESS) &&
+ (CardServices(GetTupleData,handle,&tuple) == CS_SUCCESS)){
+ prodid = le16_to_cpu(buf[1]);
+ }
+ //printk("manfid = 0x%04x, 0x%04x\n",manfid,prodid);
+
+ return prodid;
+}
-static int ni_getboardtype(comedi_device *dev)
+static int ni_getboardtype(comedi_device *dev,dev_link_t *link)
{
- int device_id=ni_read_eeprom(dev,511);
+ int id;
int i;
+ id = get_prodid(dev,link);
+
for(i=0;i<n_ni_boards;i++){
- if(ni_boards[i].device_id==device_id){
+ if(ni_boards[i].device_id==id){
return i;
}
}
- if(device_id==255){
- printk(" can't find board\n");
- }else if(device_id == 0){
- printk(" EEPROM read error (?) or device not found\n");
- }else{
- printk(" unknown device ID %d -- contact author\n",device_id);
- }
+
return -1;
}