/* * We cannot (yet) probe for an IO mapped card, although we can check that * it's where we were told it was, and even do autoirq. */ static int __init com20020isa_probe(struct net_device *dev) { int ioaddr; unsigned long airqmask; struct arcnet_local *lp = dev->priv; #ifndef MODULE arcnet_init(); #endif BUGLVL(D_NORMAL) printk(VERSION); ioaddr = dev->base_addr; if (!ioaddr) { BUGMSG(D_NORMAL, "No autoprobe (yet) for IO mapped cards; you " "must specify the base address!\n"); return -ENODEV; } if (check_region(ioaddr, ARCNET_TOTAL_SIZE)) { BUGMSG(D_NORMAL, "IO region %xh-%xh already allocated.\n", ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1); return -ENXIO; } if (ASTATUS() == 0xFF) { BUGMSG(D_NORMAL, "IO address %x empty\n", ioaddr); return -ENODEV; } if (com20020_check(dev)) return -ENODEV; if (!dev->irq) { /* if we do this, we're sure to get an IRQ since the * card has just reset and the NORXflag is on until * we tell it to start receiving. */ BUGMSG(D_INIT_REASONS, "intmask was %02Xh\n", inb(_INTMASK)); outb(0, _INTMASK); airqmask = probe_irq_on(); outb(NORXflag, _INTMASK); udelay(1); outb(0, _INTMASK); dev->irq = probe_irq_off(airqmask); if (dev->irq <= 0) { BUGMSG(D_INIT_REASONS, "Autoprobe IRQ failed first time\n"); airqmask = probe_irq_on(); outb(NORXflag, _INTMASK); udelay(5); outb(0, _INTMASK); dev->irq = probe_irq_off(airqmask); if (dev->irq <= 0) { BUGMSG(D_NORMAL, "Autoprobe IRQ failed.\n"); return -ENODEV; } } } lp->card_name = "ISA COM20020"; return com20020_found(dev, 0); }
void short_kernelprobe(void) { int count = 0; do { unsigned long mask; mask = probe_irq_on(); outb_p(0x10,short_base+2); /* enable reporting */ outb_p(0x00,short_base); /* clear the bit */ outb_p(0xFF,short_base); /* set the bit: interrupt! */ outb_p(0x00,short_base+2); /* disable reporting */ udelay(5); /* give it some time */ short_irq = probe_irq_off(mask); if (short_irq == 0) { /* none of them? */ printk(KERN_INFO "short: no irq reported by probe\n"); short_irq = -1; } /* * if more than one line has been activated, the result is * negative. We should service the interrupt (no need for lpt port) * and loop over again. Loop at most five times, then give up */ } while (short_irq < 0 && count++ < 5); if (short_irq < 0) printk("short: probe failed %i times, giving up\n", count); }
static int eepro_grab_irq(struct net_device *dev) { static const int irqlist[] = { 3, 4, 5, 7, 9, 10, 11, 12, 0 }; const int *irqp = irqlist; int temp_reg, ioaddr = dev->base_addr; eepro_sw2bank1(ioaddr); /* be CAREFUL, BANK 1 now */ /* Enable the interrupt line. */ eepro_en_intline(ioaddr); /* be CAREFUL, BANK 0 now */ eepro_sw2bank0(ioaddr); /* clear all interrupts */ eepro_clear_int(ioaddr); /* Let EXEC event to interrupt */ eepro_en_intexec(ioaddr); do { eepro_sw2bank1(ioaddr); /* be CAREFUL, BANK 1 now */ temp_reg = inb(ioaddr + INT_NO_REG); outb((temp_reg & 0xf8) | irqrmap[*irqp], ioaddr + INT_NO_REG); eepro_sw2bank0(ioaddr); /* Switch back to Bank 0 */ if (request_irq (*irqp, NULL, IRQF_SHARED, "bogus", dev) != EBUSY) { unsigned long irq_mask; /* Twinkle the interrupt, and check if it's seen */ irq_mask = probe_irq_on(); eepro_diag(ioaddr); /* RESET the 82595 */ mdelay(20); if (*irqp == probe_irq_off(irq_mask)) /* It's a good IRQ line */ break; /* clear all interrupts */ eepro_clear_int(ioaddr); } } while (*++irqp); eepro_sw2bank1(ioaddr); /* Switch back to Bank 1 */ /* Disable the physical interrupt line. */ eepro_dis_intline(ioaddr); eepro_sw2bank0(ioaddr); /* Switch back to Bank 0 */ /* Mask all the interrupts. */ eepro_dis_int(ioaddr); /* clear all interrupts */ eepro_clear_int(ioaddr); return dev->irq; }
static int g_NCR5380_probe_irq(struct Scsi_Host *instance) { struct NCR5380_hostdata *hostdata = shost_priv(instance); int irq_mask, irq; NCR5380_read(RESET_PARITY_INTERRUPT_REG); irq_mask = probe_irq_on(); g_NCR5380_trigger_irq(instance); irq = probe_irq_off(irq_mask); NCR5380_read(RESET_PARITY_INTERRUPT_REG); if (irq <= 0) return NO_IRQ; return irq; }
/* * We cannot (yet) probe for an IO mapped card, although we can check that * it's where we were told it was, and even do autoirq. */ static int __init com20020isa_probe(struct net_device *dev) { int ioaddr; unsigned long airqmask; struct arcnet_local *lp = netdev_priv(dev); int err; BUGLVL(D_NORMAL) printk(VERSION); ioaddr = dev->base_addr; if (!ioaddr) { BUGMSG(D_NORMAL, "No autoprobe (yet) for IO mapped cards; you " "must specify the base address!\n"); return -ENODEV; } if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "arcnet (COM20020)")) { BUGMSG(D_NORMAL, "IO region %xh-%xh already allocated.\n", ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1); return -ENXIO; } if (ASTATUS() == 0xFF) { BUGMSG(D_NORMAL, "IO address %x empty\n", ioaddr); err = -ENODEV; goto out; } if (com20020_check(dev)) { err = -ENODEV; goto out; } if (!dev->irq) { /* if we do this, we're sure to get an IRQ since the * card has just reset and the NORXflag is on until * we tell it to start receiving. */ BUGMSG(D_INIT_REASONS, "intmask was %02Xh\n", inb(_INTMASK)); outb(0, _INTMASK); airqmask = probe_irq_on(); outb(NORXflag, _INTMASK); udelay(1); outb(0, _INTMASK); dev->irq = probe_irq_off(airqmask); <<<<<<< HEAD
/* * Try to probe our interrupt, rather than relying on lots of * hard-coded machine dependencies. */ static int ucb1400_ts_detect_irq(struct ucb1400_ts *ucb, struct platform_device *pdev) { unsigned long mask, timeout; mask = probe_irq_on(); /* Enable the ADC interrupt. */ ucb1400_reg_write(ucb->ac97, UCB_IE_RIS, UCB_IE_ADC); ucb1400_reg_write(ucb->ac97, UCB_IE_FAL, UCB_IE_ADC); ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0xffff); ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0); /* Cause an ADC interrupt. */ ucb1400_reg_write(ucb->ac97, UCB_ADC_CR, UCB_ADC_ENA); ucb1400_reg_write(ucb->ac97, UCB_ADC_CR, UCB_ADC_ENA | UCB_ADC_START); /* Wait for the conversion to complete. */ timeout = jiffies + HZ/2; while (!(ucb1400_reg_read(ucb->ac97, UCB_ADC_DATA) & UCB_ADC_DAT_VALID)) { cpu_relax(); if (time_after(jiffies, timeout)) { dev_err(&pdev->dev, "timed out in IRQ probe\n"); probe_irq_off(mask); return -ENODEV; } } ucb1400_reg_write(ucb->ac97, UCB_ADC_CR, 0); /* Disable and clear interrupt. */ ucb1400_reg_write(ucb->ac97, UCB_IE_RIS, 0); ucb1400_reg_write(ucb->ac97, UCB_IE_FAL, 0); ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0xffff); ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0); /* Read triggered interrupt. */ ucb->irq = probe_irq_off(mask); if (ucb->irq < 0 || ucb->irq == NO_IRQ) return -ENODEV; return 0; }
/* * Try to probe our interrupt, rather than relying on lots of * hard-coded machine dependencies. For reference, the expected * IRQ mappings are: * * Machine Default IRQ * adsbitsy IRQ_GPCIN4 * cerf IRQ_GPIO_UCB1200_IRQ * flexanet IRQ_GPIO_GUI * freebird IRQ_GPIO_FREEBIRD_UCB1300_IRQ * graphicsclient ADS_EXT_IRQ(8) * graphicsmaster ADS_EXT_IRQ(8) * lart LART_IRQ_UCB1200 * omnimeter IRQ_GPIO23 * pfs168 IRQ_GPIO_UCB1300_IRQ * simpad IRQ_GPIO_UCB1300_IRQ * shannon SHANNON_IRQ_GPIO_IRQ_CODEC * yopy IRQ_GPIO_UCB1200_IRQ */ static int __init ucb1x00_detect_irq(struct ucb1x00 *ucb) { unsigned long mask; mask = probe_irq_on(); if (!mask) return NO_IRQ; /* * Enable the ADC interrupt. */ ucb1x00_reg_write(ucb, UCB_IE_RIS, UCB_IE_ADC); ucb1x00_reg_write(ucb, UCB_IE_FAL, UCB_IE_ADC); ucb1x00_reg_write(ucb, UCB_IE_CLEAR, 0xffff); ucb1x00_reg_write(ucb, UCB_IE_CLEAR, 0); /* * Cause an ADC interrupt. */ ucb1x00_reg_write(ucb, UCB_ADC_CR, UCB_ADC_ENA); ucb1x00_reg_write(ucb, UCB_ADC_CR, UCB_ADC_ENA | UCB_ADC_START); /* * Wait for the conversion to complete. */ while ((ucb1x00_reg_read(ucb, UCB_ADC_DATA) & UCB_ADC_DAT_VAL) == 0); ucb1x00_reg_write(ucb, UCB_ADC_CR, 0); /* * Disable and clear interrupt. */ ucb1x00_reg_write(ucb, UCB_IE_RIS, 0); ucb1x00_reg_write(ucb, UCB_IE_FAL, 0); ucb1x00_reg_write(ucb, UCB_IE_CLEAR, 0xffff); ucb1x00_reg_write(ucb, UCB_IE_CLEAR, 0); /* * Read triggered interrupt. */ return probe_irq_off(mask); }
static int el2_open(struct net_device *dev) { int retval = -EAGAIN; if (dev->irq < 2) { int irqlist[] = {5, 9, 3, 4, 0}; int *irqp = irqlist; outb(EGACFR_NORM, E33G_GACFR); /* Enable RAM and interrupts. */ do { if (request_irq (*irqp, NULL, 0, "bogus", dev) != -EBUSY) { /* Twinkle the interrupt, and check if it's seen. */ unsigned long cookie = probe_irq_on(); outb_p(0x04 << ((*irqp == 9) ? 2 : *irqp), E33G_IDCFR); outb_p(0x00, E33G_IDCFR); if (*irqp == probe_irq_off(cookie) /* It's a good IRQ line! */ && ((retval = request_irq(dev->irq = *irqp, eip_interrupt, 0, dev->name, dev)) == 0)) break; } } while (*++irqp); if (*irqp == 0) { outb(EGACFR_IRQOFF, E33G_GACFR); /* disable interrupts. */ return retval; } } else { if ((retval = request_irq(dev->irq, eip_interrupt, 0, dev->name, dev))) { return retval; } } el2_init_card(dev); eip_open(dev); return 0; }
static int ucb1400_ts_thread(void *_ucb) { struct ucb1400 *ucb = _ucb; struct task_struct *tsk = current; int valid = 0; struct sched_param param = { .sched_priority = 1 }; sched_setscheduler(tsk, SCHED_FIFO, ¶m); set_freezable(); while (!kthread_should_stop()) { unsigned int x, y, p; long timeout; unsigned int i; ucb->ts_restart = 0; if (ucb->irq_pending) { ucb->irq_pending = 0; ucb1400_handle_pending_irq(ucb); } p = 0; x = 0; y = 0; for(i=0; i<8; i++) { ucb1400_adc_enable(ucb); p += ucb1400_ts_read_pressure(ucb); x += ucb1400_ts_read_xpos(ucb); y += ucb1400_ts_read_ypos(ucb); ucb1400_adc_disable(ucb); udelay(30); } x/=i; y/=i; p/=i; /* Switch back to interrupt mode. */ ucb1400_ts_mode_int(ucb); msleep(10); if (ucb1400_ts_pen_down(ucb)) { ucb1400_ts_irq_enable(ucb); /* * If we spat out a valid sample set last time, * spit out a "pen off" sample here. */ if (valid) { ucb1400_ts_event_release(ucb->ts_idev); valid = 0; } timeout = MAX_SCHEDULE_TIMEOUT; } else { valid = 1; ucb1400_ts_evt_add(ucb->ts_idev, p, x, y); timeout = msecs_to_jiffies(10); } wait_event_interruptible_timeout(ucb->ts_wait, ucb->irq_pending || ucb->ts_restart || kthread_should_stop(), timeout); try_to_freeze(); } /* Send the "pen off" if we are stopping with the pen still active */ if (valid) ucb1400_ts_event_release(ucb->ts_idev); ucb->ts_task = NULL; return 0; } /* * A restriction with interrupts exists when using the ucb1400, as * the codec read/write routines may sleep while waiting for codec * access completion and uses semaphores for access control to the * AC97 bus. A complete codec read cycle could take anywhere from * 60 to 100uSec so we *definitely* don't want to spin inside the * interrupt handler waiting for codec access. So, we handle the * interrupt by scheduling a RT kernel thread to run in process * context instead of interrupt context. */ static irqreturn_t ucb1400_hard_irq(int irqnr, void *devid) { struct ucb1400 *ucb = devid; if (irqnr == ucb->irq) { disable_irq(ucb->irq); ucb->irq_pending = 1; wake_up(&ucb->ts_wait); return IRQ_HANDLED; } return IRQ_NONE; } static int ucb1400_ts_open(struct input_dev *idev) { struct ucb1400 *ucb = input_get_drvdata(idev); int ret = 0; BUG_ON(ucb->ts_task); ucb->ts_task = kthread_run(ucb1400_ts_thread, ucb, "UCB1400_ts"); if (IS_ERR(ucb->ts_task)) { ret = PTR_ERR(ucb->ts_task); ucb->ts_task = NULL; } return ret; } static void ucb1400_ts_close(struct input_dev *idev) { struct ucb1400 *ucb = input_get_drvdata(idev); if (ucb->ts_task) { kthread_stop(ucb->ts_task); while(ucb->ts_task!=NULL) udelay(100); } ucb1400_ts_irq_disable(ucb); ucb1400_reg_write(ucb, UCB_TS_CR, 0); } #ifdef CONFIG_PM static int ucb1400_ts_resume(struct device *dev) { struct ucb1400 *ucb = dev_get_drvdata(dev); if (ucb->ts_task) { /* * Restart the TS thread to ensure the * TS interrupt mode is set up again * after sleep. */ ucb->ts_restart = 1; wake_up(&ucb->ts_wait); } return 0; } #else #define ucb1400_ts_resume NULL #endif #ifndef NO_IRQ #define NO_IRQ 0 #endif /* * Try to probe our interrupt, rather than relying on lots of * hard-coded machine dependencies. */ static int ucb1400_detect_irq(struct ucb1400 *ucb) { unsigned long mask, timeout; #if CONFIG_TOUCHSCREEN_UCB1400_IRQ == 0 mask = probe_irq_on(); if (!mask) { probe_irq_off(mask); return -EBUSY; } /* Enable the ADC interrupt. */ ucb1400_reg_write(ucb, UCB_IE_RIS, UCB_IE_ADC); ucb1400_reg_write(ucb, UCB_IE_FAL, UCB_IE_ADC); ucb1400_reg_write(ucb, UCB_IE_CLEAR, 0xffff); ucb1400_reg_write(ucb, UCB_IE_CLEAR, 0); /* Cause an ADC interrupt. */ ucb1400_reg_write(ucb, UCB_ADC_CR, UCB_ADC_ENA); ucb1400_reg_write(ucb, UCB_ADC_CR, UCB_ADC_ENA | UCB_ADC_START); /* Wait for the conversion to complete. */ timeout = jiffies + HZ/2; while (!(ucb1400_reg_read(ucb, UCB_ADC_DATA) & UCB_ADC_DAT_VALID)) { cpu_relax(); if (time_after(jiffies, timeout)) { printk(KERN_ERR "ucb1400: timed out in IRQ probe\n"); probe_irq_off(mask); return -ENODEV; } } ucb1400_reg_write(ucb, UCB_ADC_CR, 0); /* Disable and clear interrupt. */ ucb1400_reg_write(ucb, UCB_IE_RIS, 0); ucb1400_reg_write(ucb, UCB_IE_FAL, 0); ucb1400_reg_write(ucb, UCB_IE_CLEAR, 0xffff); ucb1400_reg_write(ucb, UCB_IE_CLEAR, 0); /* Read triggered interrupt. */ ucb->irq = probe_irq_off(mask); #else ucb->irq = CONFIG_TOUCHSCREEN_UCB1400_IRQ; #endif if (ucb->irq < 0 || ucb->irq == NO_IRQ) return -ENODEV; return 0; }
/* * We cannot probe for an IO mapped card either, although we can check that * it's where we were told it was, and even autoirq */ static int __init com90io_probe(struct net_device *dev) { int ioaddr = dev->base_addr, status; unsigned long airqmask; BUGLVL(D_NORMAL) printk(VERSION); BUGLVL(D_NORMAL) printk("E-mail me if you actually test this driver, please!\n"); if (!ioaddr) { BUGMSG(D_NORMAL, "No autoprobe for IO mapped cards; you " "must specify the base address!\n"); return -ENODEV; } if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "com90io probe")) { BUGMSG(D_INIT_REASONS, "IO request_region %x-%x failed.\n", ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1); return -ENXIO; } if (ASTATUS() == 0xFF) { BUGMSG(D_INIT_REASONS, "IO address %x empty\n", ioaddr); goto err_out; } inb(_RESET); mdelay(RESETtime); status = ASTATUS(); if ((status & 0x9D) != (NORXflag | RECONflag | TXFREEflag | RESETflag)) { BUGMSG(D_INIT_REASONS, "Status invalid (%Xh).\n", status); goto err_out; } BUGMSG(D_INIT_REASONS, "Status after reset: %X\n", status); ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear); BUGMSG(D_INIT_REASONS, "Status after reset acknowledged: %X\n", status); status = ASTATUS(); if (status & RESETflag) { BUGMSG(D_INIT_REASONS, "Eternal reset (status=%Xh)\n", status); goto err_out; } outb((0x16 | IOMAPflag) & ~ENABLE16flag, _CONFIG); /* Read first loc'n of memory */ outb(AUTOINCflag, _ADDR_HI); outb(0, _ADDR_LO); if ((status = inb(_MEMDATA)) != 0xd1) { BUGMSG(D_INIT_REASONS, "Signature byte not found" " (%Xh instead).\n", status); goto err_out; } if (!dev->irq) { /* * if we do this, we're sure to get an IRQ since the * card has just reset and the NORXflag is on until * we tell it to start receiving. */ airqmask = probe_irq_on(); outb(NORXflag, _INTMASK); udelay(1); outb(0, _INTMASK); dev->irq = probe_irq_off(airqmask); if (dev->irq <= 0) { BUGMSG(D_INIT_REASONS, "Autoprobe IRQ failed\n"); goto err_out; } } release_region(ioaddr, ARCNET_TOTAL_SIZE); /* end of probing */ return com90io_found(dev); err_out: release_region(ioaddr, ARCNET_TOTAL_SIZE); return -ENODEV; }
static int __init com20020isa_probe(struct net_device *dev) { int ioaddr; unsigned long airqmask; struct arcnet_local *lp = netdev_priv(dev); int err; BUGLVL(D_NORMAL) printk(VERSION); ioaddr = dev->base_addr; if (!ioaddr) { BUGMSG(D_NORMAL, "No autoprobe (yet) for IO mapped cards; you " "must specify the base address!\n"); return -ENODEV; } if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "arcnet (COM20020)")) { BUGMSG(D_NORMAL, "IO region %xh-%xh already allocated.\n", ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1); return -ENXIO; } if (ASTATUS() == 0xFF) { BUGMSG(D_NORMAL, "IO address %x empty\n", ioaddr); err = -ENODEV; goto out; } if (com20020_check(dev)) { err = -ENODEV; goto out; } if (!dev->irq) { BUGMSG(D_INIT_REASONS, "intmask was %02Xh\n", inb(_INTMASK)); outb(0, _INTMASK); airqmask = probe_irq_on(); outb(NORXflag, _INTMASK); udelay(1); outb(0, _INTMASK); dev->irq = probe_irq_off(airqmask); if ((int)dev->irq <= 0) { BUGMSG(D_INIT_REASONS, "Autoprobe IRQ failed first time\n"); airqmask = probe_irq_on(); outb(NORXflag, _INTMASK); udelay(5); outb(0, _INTMASK); dev->irq = probe_irq_off(airqmask); if ((int)dev->irq <= 0) { BUGMSG(D_NORMAL, "Autoprobe IRQ failed.\n"); err = -ENODEV; goto out; } } } lp->card_name = "ISA COM20020"; if ((err = com20020_found(dev, 0)) != 0) goto out; return 0; out: release_region(ioaddr, ARCNET_TOTAL_SIZE); return err; }
static int __init ni52_probe1(struct net_device *dev, int ioaddr) { int i, size, retval; struct priv *priv = netdev_priv(dev); dev->base_addr = ioaddr; dev->irq = irq; dev->mem_start = memstart; dev->mem_end = memend; spin_lock_init(&priv->spinlock); if (!request_region(ioaddr, NI52_TOTAL_SIZE, DRV_NAME)) return -EBUSY; if (!(inb(ioaddr+NI52_MAGIC1) == NI52_MAGICVAL1) || !(inb(ioaddr+NI52_MAGIC2) == NI52_MAGICVAL2)) { retval = -ENODEV; goto out; } for (i = 0; i < ETH_ALEN; i++) dev->dev_addr[i] = inb(dev->base_addr+i); if (dev->dev_addr[0] != NI52_ADDR0 || dev->dev_addr[1] != NI52_ADDR1 || dev->dev_addr[2] != NI52_ADDR2) { retval = -ENODEV; goto out; } printk(KERN_INFO "%s: NI5210 found at %#3lx, ", dev->name, dev->base_addr); /* */ #ifdef MODULE size = dev->mem_end - dev->mem_start; if (size != 0x2000 && size != 0x4000) { printk("\n"); printk(KERN_ERR "%s: Invalid memory size %d. Allowed is 0x2000 or 0x4000 bytes.\n", dev->name, size); retval = -ENODEV; goto out; } if (!check586(dev, size)) { printk(KERN_ERR "?memcheck, Can't find memory at 0x%lx with size %d!\n", dev->mem_start, size); retval = -ENODEV; goto out; } #else if (dev->mem_start != 0) { /* */ size = 0x4000; /* */ if (!check586(dev, size)) { size = 0x2000; /* */ if (!check586(dev, size)) { printk(KERN_ERR "?memprobe, Can't find memory at 0x%lx!\n", dev->mem_start); retval = -ENODEV; goto out; } } } else { static const unsigned long memaddrs[] = { 0xc8000, 0xca000, 0xcc000, 0xce000, 0xd0000, 0xd2000, 0xd4000, 0xd6000, 0xd8000, 0xda000, 0xdc000, 0 }; for (i = 0;; i++) { if (!memaddrs[i]) { printk(KERN_ERR "?memprobe, Can't find io-memory!\n"); retval = -ENODEV; goto out; } dev->mem_start = memaddrs[i]; size = 0x2000; /* */ if (check586(dev, size)) /* */ break; size = 0x4000; /* */ if (check586(dev, size)) /* */ break; } } /* */ dev->mem_end = dev->mem_start + size; #endif alloc586(dev); /* */ if (size == 0x2000) priv->num_recv_buffs = NUM_RECV_BUFFS_8; else priv->num_recv_buffs = NUM_RECV_BUFFS_16; printk(KERN_DEBUG "Memaddr: 0x%lx, Memsize: %d, ", dev->mem_start, size); if (dev->irq < 2) { unsigned long irq_mask; irq_mask = probe_irq_on(); ni_reset586(); ni_attn586(); mdelay(20); dev->irq = probe_irq_off(irq_mask); if (!dev->irq) { printk("?autoirq, Failed to detect IRQ line!\n"); retval = -EAGAIN; iounmap(priv->mapped); goto out; } printk("IRQ %d (autodetected).\n", dev->irq); } else { if (dev->irq == 2) dev->irq = 9; printk("IRQ %d (assigned and not checked!).\n", dev->irq); } dev->netdev_ops = &ni52_netdev_ops; dev->watchdog_timeo = HZ/20; return 0; out: release_region(ioaddr, NI52_TOTAL_SIZE); return retval; }
static int __init seeq8005_probe1(struct net_device *dev, int ioaddr) { static unsigned version_printed; int i,j; unsigned char SA_prom[32]; int old_cfg1; int old_cfg2; int old_stat; int old_dmaar; int old_rear; int retval; if (!request_region(ioaddr, SEEQ8005_IO_EXTENT, "seeq8005")) return -ENODEV; if (net_debug>1) printk("seeq8005: probing at 0x%x\n",ioaddr); old_stat = inw(SEEQ_STATUS); if (old_stat == 0xffff) { retval = -ENODEV; goto out; } if ( (old_stat & 0x1800) != 0x1800 ) { if (net_debug>1) { printk("seeq8005: reserved stat bits != 0x1800\n"); printk(" == 0x%04x\n",old_stat); } retval = -ENODEV; goto out; } old_rear = inw(SEEQ_REA); if (old_rear == 0xffff) { outw(0,SEEQ_REA); if (inw(SEEQ_REA) == 0xffff) { retval = -ENODEV; goto out; } } else if ((old_rear & 0xff00) != 0xff00) { if (net_debug>1) { printk("seeq8005: unused rear bits != 0xff00\n"); printk(" == 0x%04x\n",old_rear); } retval = -ENODEV; goto out; } old_cfg2 = inw(SEEQ_CFG2); old_cfg1 = inw(SEEQ_CFG1); old_dmaar = inw(SEEQ_DMAAR); if (net_debug>4) { printk("seeq8005: stat = 0x%04x\n",old_stat); printk("seeq8005: cfg1 = 0x%04x\n",old_cfg1); printk("seeq8005: cfg2 = 0x%04x\n",old_cfg2); printk("seeq8005: raer = 0x%04x\n",old_rear); printk("seeq8005: dmaar= 0x%04x\n",old_dmaar); } outw( SEEQCMD_FIFO_WRITE | SEEQCMD_SET_ALL_OFF, SEEQ_CMD); outw( 0, SEEQ_DMAAR); outw( SEEQCFG1_BUFFER_PROM, SEEQ_CFG1); j=0; for(i=0; i <32; i++) { j+= SA_prom[i] = inw(SEEQ_BUFFER) & 0xff; } #if 0 if ( (j&0xff) != 0 ) { if (net_debug>1) { printk("seeq8005: prom sum error\n"); } outw( old_stat, SEEQ_STATUS); outw( old_dmaar, SEEQ_DMAAR); outw( old_cfg1, SEEQ_CFG1); retval = -ENODEV; goto out; } #endif outw( SEEQCFG2_RESET, SEEQ_CFG2); udelay(5); outw( SEEQCMD_SET_ALL_OFF, SEEQ_CMD); if (net_debug) { printk("seeq8005: prom sum = 0x%08x\n",j); for(j=0; j<32; j+=16) { printk("seeq8005: prom %02x: ",j); for(i=0;i<16;i++) { printk("%02x ",SA_prom[j|i]); } printk(" "); for(i=0;i<16;i++) { if ((SA_prom[j|i]>31)&&(SA_prom[j|i]<127)) { printk("%c", SA_prom[j|i]); } else { printk(" "); } } printk("\n"); } } #if 0 if (net_debug>1) { printk("seeq8005: testing packet buffer ... "); outw( SEEQCFG1_BUFFER_BUFFER, SEEQ_CFG1); outw( SEEQCMD_FIFO_WRITE | SEEQCMD_SET_ALL_OFF, SEEQ_CMD); outw( 0 , SEEQ_DMAAR); for(i=0;i<32768;i++) { outw(0x5a5a, SEEQ_BUFFER); } j=jiffies+HZ; while ( ((inw(SEEQ_STATUS) & SEEQSTAT_FIFO_EMPTY) != SEEQSTAT_FIFO_EMPTY) && time_before(jiffies, j) ) mb(); outw( 0 , SEEQ_DMAAR); while ( ((inw(SEEQ_STATUS) & SEEQSTAT_WINDOW_INT) != SEEQSTAT_WINDOW_INT) && time_before(jiffies, j+HZ)) mb(); if ( (inw(SEEQ_STATUS) & SEEQSTAT_WINDOW_INT) == SEEQSTAT_WINDOW_INT) outw( SEEQCMD_WINDOW_INT_ACK | (inw(SEEQ_STATUS)& SEEQCMD_INT_MASK), SEEQ_CMD); outw( SEEQCMD_FIFO_READ | SEEQCMD_SET_ALL_OFF, SEEQ_CMD); j=0; for(i=0;i<32768;i++) { if (inw(SEEQ_BUFFER) != 0x5a5a) j++; } if (j) { printk("%i\n",j); } else { printk("ok.\n"); } } #endif if (net_debug && version_printed++ == 0) printk(version); printk("%s: %s found at %#3x, ", dev->name, "seeq8005", ioaddr); dev->base_addr = ioaddr; dev->irq = irq; for (i = 0; i < 6; i++) dev->dev_addr[i] = SA_prom[i+6]; printk("%pM", dev->dev_addr); if (dev->irq == 0xff) ; else if (dev->irq < 2) { unsigned long cookie = probe_irq_on(); outw( SEEQCMD_RX_INT_EN | SEEQCMD_SET_RX_ON | SEEQCMD_SET_RX_OFF, SEEQ_CMD ); dev->irq = probe_irq_off(cookie); if (net_debug >= 2) printk(" autoirq is %d\n", dev->irq); } else if (dev->irq == 2) dev->irq = 9; #if 0 { int irqval = request_irq(dev->irq, seeq8005_interrupt, 0, "seeq8005", dev); if (irqval) { printk ("%s: unable to get IRQ %d (irqval=%d).\n", dev->name, dev->irq, irqval); retval = -EAGAIN; goto out; } } #endif dev->netdev_ops = &seeq8005_netdev_ops; dev->watchdog_timeo = HZ/20; dev->flags &= ~IFF_MULTICAST; return 0; out: release_region(ioaddr, SEEQ8005_IO_EXTENT); return retval; }
/* device probe routine .. determines if the Tormenta device is present in the system */ static int tor_probe(void) { int i,status; u_char c1,c2; maddr = phys_to_virt(base); status = -1; /* default status return is 'not present' */ clockvals = clockvals_t1; datxlt = datxlt_t1; chseq = chseq_t1; /* initialize control register */ setctlreg(MASTERCLOCK); /* init all the registers in first T-1 chip to 0 */ for(i = 0; i <= 0xff; i++) t1out(1,i,0); /* set register to 0 */ /* simple test that will fail if tried in an array of standard memory */ /* put an 0x55 here */ t1out(1,0x2b,0x55); /* put an 0xaa here */ t1out(1,0x2c,0xaa); /* get input from first location */ c1 = t1in(1,0x2b); /* get input from second location */ c2 = t1in(1,0x2c); /* see if we read back what we put in */ if ((c1 == 0x55) && (c2 == 0xaa)) { /* We now need to determine card type */ /* This test is documented in Dallas app note 341 */ t1out(1, 0x7D, 0); t1out(1, 0x36, 0); t1out(1, 0x15, 0); t1out(1, 0x19, 0); t1out(1, 0x23, 0x55); c1 = t1in(1, 0x23); if (c1 == 0x55) { /* if this is an E-1 card */ clockvals = clockvals_e1; chseq = chseq_e1; channels_per_span = 31; datxlt = datxlt_e1; card_type = TYPE_E1; /* initialize control register */ setctlreg(MASTERCLOCK); } /* Try to get the irq if the user didn't specify one */ if (irq < 1) { #ifdef LINUX26 unsigned long irqs; unsigned long delay = jiffies + 5; irqs = probe_irq_on(); setctlreg(MASTERCLOCK|INTENA); while((long)(jiffies - delay) < 0); irq = probe_irq_off(irqs); #else autoirq_setup(0); setctlreg(MASTERCLOCK|INTENA); /* Wait a jiffie -- that's plenty of time */ irq = autoirq_report(5); #endif } /* disable interrupts having gotten one */ setctlreg(MASTERCLOCK); if (irq == 2) irq = 9; if (irq) { /* init both STPA's to all silence */ for(i = 0; i < 32; i++) maddr[i] = 0x7f7f; status = 0; /* found */ if (debug) printk("ISA Tormenta %s Card found at base addr 0x%lx, irq %d\n", ((card_type == TYPE_E1) ? "E1" : "T1"), base,irq); } else printk("ISA Tormenta %s Card found at base addr 0x%lx, but unable to determine IRQ. Try using irq= option\n", ((card_type == TYPE_E1) ? "E1" : "T1"), base ); } return status; }
static int __init elplus_setup(struct net_device *dev) { elp_device *adapter = dev->priv; int i, tries, tries1, okay; unsigned long timeout; unsigned long cookie = 0; int err = -ENODEV; SET_MODULE_OWNER(dev); /* * setup adapter structure */ dev->base_addr = elp_autodetect(dev); if (!dev->base_addr) return -ENODEV; adapter->send_pcb_semaphore = 0; for (tries1 = 0; tries1 < 3; tries1++) { outb_control((adapter->hcr_val | CMDE) & ~DIR, dev); /* First try to write just one byte, to see if the card is * responding at all normally. */ timeout = jiffies + 5*HZ/100; okay = 0; while (time_before(jiffies, timeout) && !(inb_status(dev->base_addr) & HCRE)); if ((inb_status(dev->base_addr) & HCRE)) { outb_command(0, dev->base_addr); /* send a spurious byte */ timeout = jiffies + 5*HZ/100; while (time_before(jiffies, timeout) && !(inb_status(dev->base_addr) & HCRE)); if (inb_status(dev->base_addr) & HCRE) okay = 1; } if (!okay) { /* Nope, it's ignoring the command register. This means that * either it's still booting up, or it's died. */ printk(KERN_ERR "%s: command register wouldn't drain, ", dev->name); if ((inb_status(dev->base_addr) & 7) == 3) { /* If the adapter status is 3, it *could* still be booting. * Give it the benefit of the doubt for 10 seconds. */ printk("assuming 3c505 still starting\n"); timeout = jiffies + 10*HZ; while (time_before(jiffies, timeout) && (inb_status(dev->base_addr) & 7)); if (inb_status(dev->base_addr) & 7) { printk(KERN_ERR "%s: 3c505 failed to start\n", dev->name); } else { okay = 1; /* It started */ } } else { /* Otherwise, it must just be in a strange * state. We probably need to kick it. */ printk("3c505 is sulking\n"); } } for (tries = 0; tries < 5 && okay; tries++) { /* * Try to set the Ethernet address, to make sure that the board * is working. */ adapter->tx_pcb.command = CMD_STATION_ADDRESS; adapter->tx_pcb.length = 0; cookie = probe_irq_on(); if (!send_pcb(dev, &adapter->tx_pcb)) { printk(KERN_ERR "%s: could not send first PCB\n", dev->name); probe_irq_off(cookie); continue; } if (!receive_pcb(dev, &adapter->rx_pcb)) { printk(KERN_ERR "%s: could not read first PCB\n", dev->name); probe_irq_off(cookie); continue; } if ((adapter->rx_pcb.command != CMD_ADDRESS_RESPONSE) || (adapter->rx_pcb.length != 6)) { printk(KERN_ERR "%s: first PCB wrong (%d, %d)\n", dev->name, adapter->rx_pcb.command, adapter->rx_pcb.length); probe_irq_off(cookie); continue; } goto okay; } /* It's broken. Do a hard reset to re-initialise the board, * and try again. */ printk(KERN_INFO "%s: resetting adapter\n", dev->name); outb_control(adapter->hcr_val | FLSH | ATTN, dev); outb_control(adapter->hcr_val & ~(FLSH | ATTN), dev); } printk(KERN_ERR "%s: failed to initialise 3c505\n", dev->name); goto out; okay: if (dev->irq) { /* Is there a preset IRQ? */ int rpt = probe_irq_off(cookie); if (dev->irq != rpt) { printk(KERN_WARNING "%s: warning, irq %d configured but %d detected\n", dev->name, dev->irq, rpt); } /* if dev->irq == probe_irq_off(cookie), all is well */ } else /* No preset IRQ; just use what we can detect */ dev->irq = probe_irq_off(cookie); switch (dev->irq) { /* Legal, sane? */ case 0: printk(KERN_ERR "%s: IRQ probe failed: check 3c505 jumpers.\n", dev->name); goto out; case 1: case 6: case 8: case 13: printk(KERN_ERR "%s: Impossible IRQ %d reported by probe_irq_off().\n", dev->name, dev->irq); goto out; } /* * Now we have the IRQ number so we can disable the interrupts from * the board until the board is opened. */ outb_control(adapter->hcr_val & ~CMDE, dev); /* * copy Ethernet address into structure */ for (i = 0; i < 6; i++) dev->dev_addr[i] = adapter->rx_pcb.data.eth_addr[i]; /* find a DMA channel */ if (!dev->dma) { if (dev->mem_start) { dev->dma = dev->mem_start & 7; } else { printk(KERN_WARNING "%s: warning, DMA channel not specified, using default\n", dev->name); dev->dma = ELP_DMA; } } /* * print remainder of startup message */ printk(KERN_INFO "%s: 3c505 at %#lx, irq %d, dma %d, ", dev->name, dev->base_addr, dev->irq, dev->dma); printk("addr %02x:%02x:%02x:%02x:%02x:%02x, ", dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2], dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]); /* * read more information from the adapter */ adapter->tx_pcb.command = CMD_ADAPTER_INFO; adapter->tx_pcb.length = 0; if (!send_pcb(dev, &adapter->tx_pcb) || !receive_pcb(dev, &adapter->rx_pcb) || (adapter->rx_pcb.command != CMD_ADAPTER_INFO_RESPONSE) || (adapter->rx_pcb.length != 10)) { printk("not responding to second PCB\n"); } printk("rev %d.%d, %dk\n", adapter->rx_pcb.data.info.major_vers, adapter->rx_pcb.data.info.minor_vers, adapter->rx_pcb.data.info.RAM_sz); /* * reconfigure the adapter memory to better suit our purposes */ adapter->tx_pcb.command = CMD_CONFIGURE_ADAPTER_MEMORY; adapter->tx_pcb.length = 12; adapter->tx_pcb.data.memconf.cmd_q = 8; adapter->tx_pcb.data.memconf.rcv_q = 8; adapter->tx_pcb.data.memconf.mcast = 10; adapter->tx_pcb.data.memconf.frame = 10; adapter->tx_pcb.data.memconf.rcv_b = 10; adapter->tx_pcb.data.memconf.progs = 0; if (!send_pcb(dev, &adapter->tx_pcb) || !receive_pcb(dev, &adapter->rx_pcb) || (adapter->rx_pcb.command != CMD_CONFIGURE_ADAPTER_RESPONSE) || (adapter->rx_pcb.length != 2)) { printk(KERN_ERR "%s: could not configure adapter memory\n", dev->name); } if (adapter->rx_pcb.data.configure) { printk(KERN_ERR "%s: adapter configuration failed\n", dev->name); } dev->open = elp_open; /* local */ dev->stop = elp_close; /* local */ dev->get_stats = elp_get_stats; /* local */ dev->hard_start_xmit = elp_start_xmit; /* local */ dev->tx_timeout = elp_timeout; /* local */ dev->watchdog_timeo = 10*HZ; dev->set_multicast_list = elp_set_mc_list; /* local */ dev->ethtool_ops = &netdev_ethtool_ops; /* local */ memset(&(adapter->stats), 0, sizeof(struct net_device_stats)); dev->mem_start = dev->mem_end = 0; err = register_netdev(dev); if (err) goto out; return 0; out: release_region(dev->base_addr, ELP_IO_EXTENT); return err; }
static int __init el1_probe1(struct net_device *dev, int ioaddr) { struct net_local *lp; const char *mname; /* Vendor name */ unsigned char station_addr[6]; int autoirq = 0; int i; /* * Reserve I/O resource for exclusive use by this driver */ if (!request_region(ioaddr, EL1_IO_EXTENT, DRV_NAME)) return -ENODEV; /* * Read the station address PROM data from the special port. */ for (i = 0; i < 6; i++) { outw(i, ioaddr + EL1_DATAPTR); station_addr[i] = inb(ioaddr + EL1_SAPROM); } /* * Check the first three octets of the S.A. for 3Com's prefix, or * for the Sager NP943 prefix. */ if (station_addr[0] == 0x02 && station_addr[1] == 0x60 && station_addr[2] == 0x8c) mname = "3c501"; else if (station_addr[0] == 0x00 && station_addr[1] == 0x80 && station_addr[2] == 0xC8) mname = "NP943"; else { release_region(ioaddr, EL1_IO_EXTENT); return -ENODEV; } /* * We auto-IRQ by shutting off the interrupt line and letting it * float high. */ dev->irq = irq; if (dev->irq < 2) { unsigned long irq_mask; irq_mask = probe_irq_on(); inb(RX_STATUS); /* Clear pending interrupts. */ inb(TX_STATUS); outb(AX_LOOP + 1, AX_CMD); outb(0x00, AX_CMD); mdelay(20); autoirq = probe_irq_off(irq_mask); if (autoirq == 0) { pr_warning("%s probe at %#x failed to detect IRQ line.\n", mname, ioaddr); release_region(ioaddr, EL1_IO_EXTENT); return -EAGAIN; } } outb(AX_RESET+AX_LOOP, AX_CMD); /* Loopback mode. */ dev->base_addr = ioaddr; memcpy(dev->dev_addr, station_addr, ETH_ALEN); if (mem_start & 0xf) el_debug = mem_start & 0x7; if (autoirq) dev->irq = autoirq; pr_info("%s: %s EtherLink at %#lx, using %sIRQ %d.\n", dev->name, mname, dev->base_addr, autoirq ? "auto":"assigned ", dev->irq); #ifdef CONFIG_IP_MULTICAST pr_warning("WARNING: Use of the 3c501 in a multicast kernel is NOT recommended.\n"); #endif if (el_debug) pr_debug("%s", version); lp = netdev_priv(dev); memset(lp, 0, sizeof(struct net_local)); spin_lock_init(&lp->lock); /* * The EL1-specific entries in the device structure. */ dev->netdev_ops = &el_netdev_ops; dev->watchdog_timeo = HZ; dev->ethtool_ops = &netdev_ethtool_ops; return 0; }
static int __init seeq8005_probe1(struct net_device *dev, int ioaddr) { static unsigned version_printed; int i,j; unsigned char SA_prom[32]; int old_cfg1; int old_cfg2; int old_stat; int old_dmaar; int old_rear; int retval; if (!request_region(ioaddr, SEEQ8005_IO_EXTENT, "seeq8005")) return -ENODEV; if (net_debug>1) printk("seeq8005: probing at 0x%x\n",ioaddr); old_stat = inw(SEEQ_STATUS); /* read status register */ if (old_stat == 0xffff) { retval = -ENODEV; goto out; /* assume that 0xffff == no device */ } if ( (old_stat & 0x1800) != 0x1800 ) { /* assume that unused bits are 1, as my manual says */ if (net_debug>1) { printk("seeq8005: reserved stat bits != 0x1800\n"); printk(" == 0x%04x\n",old_stat); } retval = -ENODEV; goto out; } old_rear = inw(SEEQ_REA); if (old_rear == 0xffff) { outw(0,SEEQ_REA); if (inw(SEEQ_REA) == 0xffff) { /* assume that 0xffff == no device */ retval = -ENODEV; goto out; } } else if ((old_rear & 0xff00) != 0xff00) { /* assume that unused bits are 1 */ if (net_debug>1) { printk("seeq8005: unused rear bits != 0xff00\n"); printk(" == 0x%04x\n",old_rear); } retval = -ENODEV; goto out; } old_cfg2 = inw(SEEQ_CFG2); /* read CFG2 register */ old_cfg1 = inw(SEEQ_CFG1); old_dmaar = inw(SEEQ_DMAAR); if (net_debug>4) { printk("seeq8005: stat = 0x%04x\n",old_stat); printk("seeq8005: cfg1 = 0x%04x\n",old_cfg1); printk("seeq8005: cfg2 = 0x%04x\n",old_cfg2); printk("seeq8005: raer = 0x%04x\n",old_rear); printk("seeq8005: dmaar= 0x%04x\n",old_dmaar); } outw( SEEQCMD_FIFO_WRITE | SEEQCMD_SET_ALL_OFF, SEEQ_CMD); /* setup for reading PROM */ outw( 0, SEEQ_DMAAR); /* set starting PROM address */ outw( SEEQCFG1_BUFFER_PROM, SEEQ_CFG1); /* set buffer to look at PROM */ j=0; for(i=0; i <32; i++) { j+= SA_prom[i] = inw(SEEQ_BUFFER) & 0xff; } #if 0 /* untested because I only have the one card */ if ( (j&0xff) != 0 ) { /* checksum appears to be 8bit = 0 */ if (net_debug>1) { /* check this before deciding that we have a card */ printk("seeq8005: prom sum error\n"); } outw( old_stat, SEEQ_STATUS); outw( old_dmaar, SEEQ_DMAAR); outw( old_cfg1, SEEQ_CFG1); retval = -ENODEV; goto out; } #endif outw( SEEQCFG2_RESET, SEEQ_CFG2); /* reset the card */ udelay(5); outw( SEEQCMD_SET_ALL_OFF, SEEQ_CMD); if (net_debug) { printk("seeq8005: prom sum = 0x%08x\n",j); for(j=0; j<32; j+=16) { printk("seeq8005: prom %02x: ",j); for(i=0;i<16;i++) { printk("%02x ",SA_prom[j|i]); } printk(" "); for(i=0;i<16;i++) { if ((SA_prom[j|i]>31)&&(SA_prom[j|i]<127)) { printk("%c", SA_prom[j|i]); } else { printk(" "); } } printk("\n"); } } #if 0 /* * testing the packet buffer memory doesn't work yet * but all other buffer accesses do * - fixing is not a priority */ if (net_debug>1) { /* test packet buffer memory */ printk("seeq8005: testing packet buffer ... "); outw( SEEQCFG1_BUFFER_BUFFER, SEEQ_CFG1); outw( SEEQCMD_FIFO_WRITE | SEEQCMD_SET_ALL_OFF, SEEQ_CMD); outw( 0 , SEEQ_DMAAR); for(i=0;i<32768;i++) { outw(0x5a5a, SEEQ_BUFFER); } j=jiffies+HZ; while ( ((inw(SEEQ_STATUS) & SEEQSTAT_FIFO_EMPTY) != SEEQSTAT_FIFO_EMPTY) && time_before(jiffies, j) ) mb(); outw( 0 , SEEQ_DMAAR); while ( ((inw(SEEQ_STATUS) & SEEQSTAT_WINDOW_INT) != SEEQSTAT_WINDOW_INT) && time_before(jiffies, j+HZ)) mb(); if ( (inw(SEEQ_STATUS) & SEEQSTAT_WINDOW_INT) == SEEQSTAT_WINDOW_INT) outw( SEEQCMD_WINDOW_INT_ACK | (inw(SEEQ_STATUS)& SEEQCMD_INT_MASK), SEEQ_CMD); outw( SEEQCMD_FIFO_READ | SEEQCMD_SET_ALL_OFF, SEEQ_CMD); j=0; for(i=0;i<32768;i++) { if (inw(SEEQ_BUFFER) != 0x5a5a) j++; } if (j) { printk("%i\n",j); } else { printk("ok.\n"); } } #endif if (net_debug && version_printed++ == 0) printk(version); printk("%s: %s found at %#3x, ", dev->name, "seeq8005", ioaddr); /* Fill in the 'dev' fields. */ dev->base_addr = ioaddr; /* Retrieve and print the ethernet address. */ for (i = 0; i < 6; i++) printk(" %2.2x", dev->dev_addr[i] = SA_prom[i+6]); if (dev->irq == 0xff) ; /* Do nothing: a user-level program will set it. */ else if (dev->irq < 2) { /* "Auto-IRQ" */ unsigned long cookie = probe_irq_on(); outw( SEEQCMD_RX_INT_EN | SEEQCMD_SET_RX_ON | SEEQCMD_SET_RX_OFF, SEEQ_CMD ); dev->irq = probe_irq_off(cookie); if (net_debug >= 2) printk(" autoirq is %d\n", dev->irq); } else if (dev->irq == 2) /* Fixup for users that don't know that IRQ 2 is really IRQ 9, * or don't know which one to set. */ dev->irq = 9; #if 0 { int irqval = request_irq(dev->irq, &seeq8005_interrupt, 0, "seeq8005", dev); if (irqval) { printk ("%s: unable to get IRQ %d (irqval=%d).\n", dev->name, dev->irq, irqval); retval = -EAGAIN; goto out; } } #endif /* Initialize the device structure. */ dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL); if (dev->priv == NULL) return -ENOMEM; memset(dev->priv, 0, sizeof(struct net_local)); dev->open = seeq8005_open; dev->stop = seeq8005_close; dev->hard_start_xmit = seeq8005_send_packet; dev->tx_timeout = seeq8005_timeout; dev->watchdog_timeo = HZ/20; dev->get_stats = seeq8005_get_stats; dev->set_multicast_list = set_multicast_list; /* Fill in the fields of the device structure with ethernet values. */ ether_setup(dev); dev->flags &= ~IFF_MULTICAST; return 0; out: release_region(ioaddr, SEEQ8005_IO_EXTENT); return retval; }
_mali_osk_irq_t *_mali_osk_irq_init( u32 irqnum, _mali_osk_irq_uhandler_t uhandler, _mali_osk_irq_bhandler_t bhandler, _mali_osk_irq_trigger_t trigger_func, _mali_osk_irq_ack_t ack_func, void *data, const char *description ) { mali_osk_irq_object_t *irq_object; irq_object = kmalloc(sizeof(mali_osk_irq_object_t), GFP_KERNEL); if (NULL == irq_object) return NULL; /* workqueue API changed in 2.6.20, support both versions: */ #if defined(INIT_DELAYED_WORK) /* New syntax: INIT_WORK( struct work_struct *work, void (*function)(struct work_struct *)) */ INIT_WORK( &irq_object->work_queue_irq_handle, irq_handler_bottom_half); #else /* Old syntax: INIT_WORK( struct work_struct *work, void (*function)(void *), void *data) */ INIT_WORK( &irq_object->work_queue_irq_handle, irq_handler_bottom_half, irq_object); #endif /* defined(INIT_DELAYED_WORK) */ if (-1 == irqnum) { /* Probe for IRQ */ if ( (NULL != trigger_func) && (NULL != ack_func) ) { unsigned long probe_count = 3; _mali_osk_errcode_t err; int irq; MALI_DEBUG_PRINT(2, ("Probing for irq\n")); do { unsigned long mask; mask = probe_irq_on(); trigger_func(data); _mali_osk_time_ubusydelay(5); irq = probe_irq_off(mask); err = ack_func(data); } while (irq < 0 && (err == _MALI_OSK_ERR_OK) && probe_count--); if (irq < 0 || (_MALI_OSK_ERR_OK != err)) irqnum = -1; else irqnum = irq; } else irqnum = -1; /* no probe functions, fault */ if (-1 != irqnum) { /* found an irq */ MALI_DEBUG_PRINT(2, ("Found irq %d\n", irqnum)); } else { MALI_DEBUG_PRINT(2, ("Probe for irq failed\n")); } } irq_object->irqnum = irqnum; irq_object->uhandler = uhandler; irq_object->bhandler = bhandler; irq_object->data = data; /* Is this a real IRQ handler we need? */ if (!mali_benchmark && irqnum != _MALI_OSK_IRQ_NUMBER_FAKE && irqnum != _MALI_OSK_IRQ_NUMBER_PMM) { if (-1 == irqnum) { MALI_DEBUG_PRINT(2, ("No IRQ for core '%s' found during probe\n", description)); kfree(irq_object); return NULL; } if (0 != request_irq(irqnum, irq_handler_upper_half, IRQF_SHARED, description, irq_object)) { MALI_DEBUG_PRINT(2, ("Unable to install IRQ handler for core '%s'\n", description)); kfree(irq_object); return NULL; } } if (mali_irq_wq == NULL) { mali_irq_wq = create_singlethread_workqueue("mali-pmm-wq"); } return irq_object; }
static int __init elplus_setup(struct net_device *dev) { elp_device *adapter = netdev_priv(dev); int i, tries, tries1, okay; unsigned long timeout; unsigned long cookie = 0; int err = -ENODEV; dev->base_addr = elp_autodetect(dev); if (!dev->base_addr) return -ENODEV; adapter->send_pcb_semaphore = 0; for (tries1 = 0; tries1 < 3; tries1++) { outb_control((adapter->hcr_val | CMDE) & ~DIR, dev); timeout = jiffies + 5*HZ/100; okay = 0; while (time_before(jiffies, timeout) && !(inb_status(dev->base_addr) & HCRE)); if ((inb_status(dev->base_addr) & HCRE)) { outb_command(0, dev->base_addr); timeout = jiffies + 5*HZ/100; while (time_before(jiffies, timeout) && !(inb_status(dev->base_addr) & HCRE)); if (inb_status(dev->base_addr) & HCRE) okay = 1; } if (!okay) { pr_err("%s: command register wouldn't drain, ", dev->name); if ((inb_status(dev->base_addr) & 7) == 3) { pr_cont("assuming 3c505 still starting\n"); timeout = jiffies + 10*HZ; while (time_before(jiffies, timeout) && (inb_status(dev->base_addr) & 7)); if (inb_status(dev->base_addr) & 7) { pr_err("%s: 3c505 failed to start\n", dev->name); } else { okay = 1; } } else { pr_cont("3c505 is sulking\n"); } } for (tries = 0; tries < 5 && okay; tries++) { adapter->tx_pcb.command = CMD_STATION_ADDRESS; adapter->tx_pcb.length = 0; cookie = probe_irq_on(); if (!send_pcb(dev, &adapter->tx_pcb)) { pr_err("%s: could not send first PCB\n", dev->name); probe_irq_off(cookie); continue; } if (!receive_pcb(dev, &adapter->rx_pcb)) { pr_err("%s: could not read first PCB\n", dev->name); probe_irq_off(cookie); continue; } if ((adapter->rx_pcb.command != CMD_ADDRESS_RESPONSE) || (adapter->rx_pcb.length != 6)) { pr_err("%s: first PCB wrong (%d, %d)\n", dev->name, adapter->rx_pcb.command, adapter->rx_pcb.length); probe_irq_off(cookie); continue; } goto okay; } pr_info("%s: resetting adapter\n", dev->name); outb_control(adapter->hcr_val | FLSH | ATTN, dev); outb_control(adapter->hcr_val & ~(FLSH | ATTN), dev); } pr_err("%s: failed to initialise 3c505\n", dev->name); goto out; okay: if (dev->irq) { int rpt = probe_irq_off(cookie); if (dev->irq != rpt) { pr_warning("%s: warning, irq %d configured but %d detected\n", dev->name, dev->irq, rpt); } } else dev->irq = probe_irq_off(cookie); switch (dev->irq) { case 0: pr_err("%s: IRQ probe failed: check 3c505 jumpers.\n", dev->name); goto out; case 1: case 6: case 8: case 13: pr_err("%s: Impossible IRQ %d reported by probe_irq_off().\n", dev->name, dev->irq); goto out; } outb_control(adapter->hcr_val & ~CMDE, dev); for (i = 0; i < 6; i++) dev->dev_addr[i] = adapter->rx_pcb.data.eth_addr[i]; if (!dev->dma) { if (dev->mem_start) { dev->dma = dev->mem_start & 7; } else { pr_warning("%s: warning, DMA channel not specified, using default\n", dev->name); dev->dma = ELP_DMA; } } pr_info("%s: 3c505 at %#lx, irq %d, dma %d, addr %pM, ", dev->name, dev->base_addr, dev->irq, dev->dma, dev->dev_addr); adapter->tx_pcb.command = CMD_ADAPTER_INFO; adapter->tx_pcb.length = 0; if (!send_pcb(dev, &adapter->tx_pcb) || !receive_pcb(dev, &adapter->rx_pcb) || (adapter->rx_pcb.command != CMD_ADAPTER_INFO_RESPONSE) || (adapter->rx_pcb.length != 10)) { pr_cont("not responding to second PCB\n"); } pr_cont("rev %d.%d, %dk\n", adapter->rx_pcb.data.info.major_vers, adapter->rx_pcb.data.info.minor_vers, adapter->rx_pcb.data.info.RAM_sz); adapter->tx_pcb.command = CMD_CONFIGURE_ADAPTER_MEMORY; adapter->tx_pcb.length = 12; adapter->tx_pcb.data.memconf.cmd_q = 8; adapter->tx_pcb.data.memconf.rcv_q = 8; adapter->tx_pcb.data.memconf.mcast = 10; adapter->tx_pcb.data.memconf.frame = 10; adapter->tx_pcb.data.memconf.rcv_b = 10; adapter->tx_pcb.data.memconf.progs = 0; if (!send_pcb(dev, &adapter->tx_pcb) || !receive_pcb(dev, &adapter->rx_pcb) || (adapter->rx_pcb.command != CMD_CONFIGURE_ADAPTER_RESPONSE) || (adapter->rx_pcb.length != 2)) { pr_err("%s: could not configure adapter memory\n", dev->name); } if (adapter->rx_pcb.data.configure) { pr_err("%s: adapter configuration failed\n", dev->name); } dev->netdev_ops = &elp_netdev_ops; dev->watchdog_timeo = 10*HZ; dev->ethtool_ops = &netdev_ethtool_ops; dev->mem_start = dev->mem_end = 0; err = register_netdev(dev); if (err) goto out; return 0; out: release_region(dev->base_addr, ELP_IO_EXTENT); return err; }
static int ucb1400_ts_thread(void *_ucb) { struct ucb1400_ts *ucb = _ucb; struct task_struct *tsk = current; int valid = 0; struct sched_param param = { .sched_priority = 1 }; sched_setscheduler(tsk, SCHED_FIFO, ¶m); set_freezable(); while (!kthread_should_stop()) { unsigned int x, y, p; long timeout; ucb->ts_restart = 0; if (ucb->irq_pending) { ucb->irq_pending = 0; ucb1400_handle_pending_irq(ucb); } ucb1400_adc_enable(ucb->ac97); x = ucb1400_ts_read_xpos(ucb); y = ucb1400_ts_read_ypos(ucb); p = ucb1400_ts_read_pressure(ucb); ucb1400_adc_disable(ucb->ac97); /* Switch back to interrupt mode. */ ucb1400_ts_mode_int(ucb->ac97); msleep(10); if (ucb1400_ts_pen_up(ucb->ac97)) { ucb1400_ts_irq_enable(ucb->ac97); /* * If we spat out a valid sample set last time, * spit out a "pen off" sample here. */ if (valid) { ucb1400_ts_event_release(ucb->ts_idev); valid = 0; } timeout = MAX_SCHEDULE_TIMEOUT; } else { valid = 1; ucb1400_ts_evt_add(ucb->ts_idev, p, x, y); timeout = msecs_to_jiffies(10); } wait_event_freezable_timeout(ucb->ts_wait, ucb->irq_pending || ucb->ts_restart || kthread_should_stop(), timeout); } /* Send the "pen off" if we are stopping with the pen still active */ if (valid) ucb1400_ts_event_release(ucb->ts_idev); ucb->ts_task = NULL; return 0; } static irqreturn_t ucb1400_hard_irq(int irqnr, void *devid) { struct ucb1400_ts *ucb = devid; if (irqnr == ucb->irq) { disable_irq_nosync(ucb->irq); ucb->irq_pending = 1; wake_up(&ucb->ts_wait); return IRQ_HANDLED; } return IRQ_NONE; } static int ucb1400_ts_open(struct input_dev *idev) { struct ucb1400_ts *ucb = input_get_drvdata(idev); int ret = 0; BUG_ON(ucb->ts_task); ucb->ts_task = kthread_run(ucb1400_ts_thread, ucb, "UCB1400_ts"); if (IS_ERR(ucb->ts_task)) { ret = PTR_ERR(ucb->ts_task); ucb->ts_task = NULL; } return ret; } static void ucb1400_ts_close(struct input_dev *idev) { struct ucb1400_ts *ucb = input_get_drvdata(idev); if (ucb->ts_task) kthread_stop(ucb->ts_task); ucb1400_ts_irq_disable(ucb->ac97); ucb1400_reg_write(ucb->ac97, UCB_TS_CR, 0); } #ifndef NO_IRQ #define NO_IRQ 0 #endif static int ucb1400_ts_detect_irq(struct ucb1400_ts *ucb) { unsigned long mask, timeout; mask = probe_irq_on(); /* Enable the ADC interrupt. */ ucb1400_reg_write(ucb->ac97, UCB_IE_RIS, UCB_IE_ADC); ucb1400_reg_write(ucb->ac97, UCB_IE_FAL, UCB_IE_ADC); ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0xffff); ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0); /* Cause an ADC interrupt. */ ucb1400_reg_write(ucb->ac97, UCB_ADC_CR, UCB_ADC_ENA); ucb1400_reg_write(ucb->ac97, UCB_ADC_CR, UCB_ADC_ENA | UCB_ADC_START); /* Wait for the conversion to complete. */ timeout = jiffies + HZ/2; while (!(ucb1400_reg_read(ucb->ac97, UCB_ADC_DATA) & UCB_ADC_DAT_VALID)) { cpu_relax(); if (time_after(jiffies, timeout)) { printk(KERN_ERR "ucb1400: timed out in IRQ probe\n"); probe_irq_off(mask); return -ENODEV; } } ucb1400_reg_write(ucb->ac97, UCB_ADC_CR, 0); /* Disable and clear interrupt. */ ucb1400_reg_write(ucb->ac97, UCB_IE_RIS, 0); ucb1400_reg_write(ucb->ac97, UCB_IE_FAL, 0); ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0xffff); ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0); /* Read triggered interrupt. */ ucb->irq = probe_irq_off(mask); if (ucb->irq < 0 || ucb->irq == NO_IRQ) return -ENODEV; return 0; }
static void __init com90xx_probe(void) { int count, status, ioaddr, numprint, airq, openparen = 0; unsigned long airqmask; int ports[(0x3f0 - 0x200) / 16 + 1] = {0}; unsigned long *shmems; void __iomem **iomem; int numports, numshmems, *port; u_long *p; int index; if (!io && !irq && !shmem && !*device && com90xx_skip_probe) return; shmems = kzalloc(((0x100000-0xa0000) / 0x800) * sizeof(unsigned long), GFP_KERNEL); if (!shmems) return; iomem = kzalloc(((0x100000-0xa0000) / 0x800) * sizeof(void __iomem *), GFP_KERNEL); if (!iomem) { kfree(shmems); return; } BUGLVL(D_NORMAL) printk(VERSION); /* set up the arrays where we'll store the possible probe addresses */ numports = numshmems = 0; if (io) ports[numports++] = io; else for (count = 0x200; count <= 0x3f0; count += 16) ports[numports++] = count; if (shmem) shmems[numshmems++] = shmem; else for (count = 0xA0000; count <= 0xFF800; count += 2048) shmems[numshmems++] = count; /* Stage 1: abandon any reserved ports, or ones with status==0xFF * (empty), and reset any others by reading the reset port. */ numprint = -1; for (port = &ports[0]; port - ports < numports; port++) { numprint++; numprint %= 8; if (!numprint) { BUGMSG2(D_INIT, "\n"); BUGMSG2(D_INIT, "S1: "); } BUGMSG2(D_INIT, "%Xh ", *port); ioaddr = *port; if (!request_region(*port, ARCNET_TOTAL_SIZE, "arcnet (90xx)")) { BUGMSG2(D_INIT_REASONS, "(request_region)\n"); BUGMSG2(D_INIT_REASONS, "S1: "); BUGLVL(D_INIT_REASONS) numprint = 0; *port-- = ports[--numports]; continue; } if (ASTATUS() == 0xFF) { BUGMSG2(D_INIT_REASONS, "(empty)\n"); BUGMSG2(D_INIT_REASONS, "S1: "); BUGLVL(D_INIT_REASONS) numprint = 0; release_region(*port, ARCNET_TOTAL_SIZE); *port-- = ports[--numports]; continue; } inb(_RESET); /* begin resetting card */ BUGMSG2(D_INIT_REASONS, "\n"); BUGMSG2(D_INIT_REASONS, "S1: "); BUGLVL(D_INIT_REASONS) numprint = 0; } BUGMSG2(D_INIT, "\n"); if (!numports) { BUGMSG2(D_NORMAL, "S1: No ARCnet cards found.\n"); kfree(shmems); kfree(iomem); return; } /* Stage 2: we have now reset any possible ARCnet cards, so we can't * do anything until they finish. If D_INIT, print the list of * cards that are left. */ numprint = -1; for (port = &ports[0]; port < ports + numports; port++) { numprint++; numprint %= 8; if (!numprint) { BUGMSG2(D_INIT, "\n"); BUGMSG2(D_INIT, "S2: "); } BUGMSG2(D_INIT, "%Xh ", *port); } BUGMSG2(D_INIT, "\n"); mdelay(RESETtime); /* Stage 3: abandon any shmem addresses that don't have the signature * 0xD1 byte in the right place, or are read-only. */ numprint = -1; for (index = 0, p = &shmems[0]; index < numshmems; p++, index++) { void __iomem *base; numprint++; numprint %= 8; if (!numprint) { BUGMSG2(D_INIT, "\n"); BUGMSG2(D_INIT, "S3: "); } BUGMSG2(D_INIT, "%lXh ", *p); if (!request_mem_region(*p, MIRROR_SIZE, "arcnet (90xx)")) { BUGMSG2(D_INIT_REASONS, "(request_mem_region)\n"); BUGMSG2(D_INIT_REASONS, "Stage 3: "); BUGLVL(D_INIT_REASONS) numprint = 0; goto out; } base = ioremap(*p, MIRROR_SIZE); if (!base) { BUGMSG2(D_INIT_REASONS, "(ioremap)\n"); BUGMSG2(D_INIT_REASONS, "Stage 3: "); BUGLVL(D_INIT_REASONS) numprint = 0; goto out1; } if (readb(base) != TESTvalue) { BUGMSG2(D_INIT_REASONS, "(%02Xh != %02Xh)\n", readb(base), TESTvalue); BUGMSG2(D_INIT_REASONS, "S3: "); BUGLVL(D_INIT_REASONS) numprint = 0; goto out2; } /* By writing 0x42 to the TESTvalue location, we also make * sure no "mirror" shmem areas show up - if they occur * in another pass through this loop, they will be discarded * because *cptr != TESTvalue. */ writeb(0x42, base); if (readb(base) != 0x42) { BUGMSG2(D_INIT_REASONS, "(read only)\n"); BUGMSG2(D_INIT_REASONS, "S3: "); goto out2; } BUGMSG2(D_INIT_REASONS, "\n"); BUGMSG2(D_INIT_REASONS, "S3: "); BUGLVL(D_INIT_REASONS) numprint = 0; iomem[index] = base; continue; out2: iounmap(base); out1: release_mem_region(*p, MIRROR_SIZE); out: *p-- = shmems[--numshmems]; index--; } BUGMSG2(D_INIT, "\n"); if (!numshmems) { BUGMSG2(D_NORMAL, "S3: No ARCnet cards found.\n"); for (port = &ports[0]; port < ports + numports; port++) release_region(*port, ARCNET_TOTAL_SIZE); kfree(shmems); kfree(iomem); return; } /* Stage 4: something of a dummy, to report the shmems that are * still possible after stage 3. */ numprint = -1; for (p = &shmems[0]; p < shmems + numshmems; p++) { numprint++; numprint %= 8; if (!numprint) { BUGMSG2(D_INIT, "\n"); BUGMSG2(D_INIT, "S4: "); } BUGMSG2(D_INIT, "%lXh ", *p); } BUGMSG2(D_INIT, "\n"); /* Stage 5: for any ports that have the correct status, can disable * the RESET flag, and (if no irq is given) generate an autoirq, * register an ARCnet device. * * Currently, we can only register one device per probe, so quit * after the first one is found. */ numprint = -1; for (port = &ports[0]; port < ports + numports; port++) { int found = 0; numprint++; numprint %= 8; if (!numprint) { BUGMSG2(D_INIT, "\n"); BUGMSG2(D_INIT, "S5: "); } BUGMSG2(D_INIT, "%Xh ", *port); ioaddr = *port; status = ASTATUS(); if ((status & 0x9D) != (NORXflag | RECONflag | TXFREEflag | RESETflag)) { BUGMSG2(D_INIT_REASONS, "(status=%Xh)\n", status); BUGMSG2(D_INIT_REASONS, "S5: "); BUGLVL(D_INIT_REASONS) numprint = 0; release_region(*port, ARCNET_TOTAL_SIZE); *port-- = ports[--numports]; continue; } ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear); status = ASTATUS(); if (status & RESETflag) { BUGMSG2(D_INIT_REASONS, " (eternal reset, status=%Xh)\n", status); BUGMSG2(D_INIT_REASONS, "S5: "); BUGLVL(D_INIT_REASONS) numprint = 0; release_region(*port, ARCNET_TOTAL_SIZE); *port-- = ports[--numports]; continue; } /* skip this completely if an IRQ was given, because maybe * we're on a machine that locks during autoirq! */ if (!irq) { /* if we do this, we're sure to get an IRQ since the * card has just reset and the NORXflag is on until * we tell it to start receiving. */ airqmask = probe_irq_on(); AINTMASK(NORXflag); udelay(1); AINTMASK(0); airq = probe_irq_off(airqmask); if (airq <= 0) { BUGMSG2(D_INIT_REASONS, "(airq=%d)\n", airq); BUGMSG2(D_INIT_REASONS, "S5: "); BUGLVL(D_INIT_REASONS) numprint = 0; release_region(*port, ARCNET_TOTAL_SIZE); *port-- = ports[--numports]; continue; } } else { airq = irq; } BUGMSG2(D_INIT, "(%d,", airq); openparen = 1; /* Everything seems okay. But which shmem, if any, puts * back its signature byte when the card is reset? * * If there are multiple cards installed, there might be * multiple shmems still in the list. */ #ifdef FAST_PROBE if (numports > 1 || numshmems > 1) { inb(_RESET); mdelay(RESETtime); } else { /* just one shmem and port, assume they match */ writeb(TESTvalue, iomem[0]); } #else inb(_RESET); mdelay(RESETtime); #endif for (index = 0; index < numshmems; index++) { u_long ptr = shmems[index]; void __iomem *base = iomem[index]; if (readb(base) == TESTvalue) { /* found one */ BUGMSG2(D_INIT, "%lXh)\n", *p); openparen = 0; /* register the card */ if (com90xx_found(*port, airq, ptr, base) == 0) found = 1; numprint = -1; /* remove shmem from the list */ shmems[index] = shmems[--numshmems]; iomem[index] = iomem[numshmems]; break; /* go to the next I/O port */ } else { BUGMSG2(D_INIT_REASONS, "%Xh-", readb(base)); } } if (openparen) { BUGLVL(D_INIT) printk("no matching shmem)\n"); BUGLVL(D_INIT_REASONS) printk("S5: "); BUGLVL(D_INIT_REASONS) numprint = 0; } if (!found) release_region(*port, ARCNET_TOTAL_SIZE); *port-- = ports[--numports]; } BUGLVL(D_INIT_REASONS) printk("\n"); /* Now put back TESTvalue on all leftover shmems. */ for (index = 0; index < numshmems; index++) { writeb(TESTvalue, iomem[index]); iounmap(iomem[index]); release_mem_region(shmems[index], MIRROR_SIZE); } kfree(shmems); kfree(iomem); }
_mali_osk_irq_t *_mali_osk_irq_init( u32 irqnum, _mali_osk_irq_uhandler_t uhandler, void *int_data, _mali_osk_irq_trigger_t trigger_func, _mali_osk_irq_ack_t ack_func, void *probe_data, const char *description ) { mali_osk_irq_object_t *irq_object; irq_object = kmalloc(sizeof(mali_osk_irq_object_t), GFP_KERNEL); if (NULL == irq_object) { return NULL; } if (-1 == irqnum) { /* Probe for IRQ */ if ( (NULL != trigger_func) && (NULL != ack_func) ) { unsigned long probe_count = 3; _mali_osk_errcode_t err; int irq; MALI_DEBUG_PRINT(2, ("Probing for irq\n")); do { unsigned long mask; mask = probe_irq_on(); trigger_func(probe_data); _mali_osk_time_ubusydelay(5); irq = probe_irq_off(mask); err = ack_func(probe_data); } while (irq < 0 && (err == _MALI_OSK_ERR_OK) && probe_count--); if (irq < 0 || (_MALI_OSK_ERR_OK != err)) irqnum = -1; else irqnum = irq; } else irqnum = -1; /* no probe functions, fault */ if (-1 != irqnum) { /* found an irq */ MALI_DEBUG_PRINT(2, ("Found irq %d\n", irqnum)); } else { MALI_DEBUG_PRINT(2, ("Probe for irq failed\n")); } } irq_object->irqnum = irqnum; irq_object->uhandler = uhandler; irq_object->data = int_data; if (-1 == irqnum) { MALI_DEBUG_PRINT(2, ("No IRQ for core '%s' found during probe\n", description)); kfree(irq_object); return NULL; } if (0 != request_irq(irqnum, irq_handler_upper_half, IRQF_TRIGGER_LOW, description, irq_object)) { MALI_DEBUG_PRINT(2, ("Unable to install IRQ handler for core '%s'\n", description)); kfree(irq_object); return NULL; } return irq_object; }
static int __init ni52_probe1(struct net_device *dev,int ioaddr) { int i, size, retval; if (!request_region(ioaddr, NI52_TOTAL_SIZE, dev->name)) return -EBUSY; if( !(inb(ioaddr+NI52_MAGIC1) == NI52_MAGICVAL1) || !(inb(ioaddr+NI52_MAGIC2) == NI52_MAGICVAL2)) { retval = -ENODEV; goto out; } for(i=0;i<ETH_ALEN;i++) dev->dev_addr[i] = inb(dev->base_addr+i); if(dev->dev_addr[0] != NI52_ADDR0 || dev->dev_addr[1] != NI52_ADDR1 || dev->dev_addr[2] != NI52_ADDR2) { retval = -ENODEV; goto out; } printk("%s: NI5210 found at %#3lx, ",dev->name,dev->base_addr); /* * check (or search) IO-Memory, 8K and 16K */ #ifdef MODULE size = dev->mem_end - dev->mem_start; if(size != 0x2000 && size != 0x4000) { printk("\n%s: Illegal memory size %d. Allowed is 0x2000 or 0x4000 bytes.\n",dev->name,size); retval = -ENODEV; goto out; } if(!check586(dev,(char *) dev->mem_start,size)) { printk("?memcheck, Can't find memory at 0x%lx with size %d!\n",dev->mem_start,size); retval = -ENODEV; goto out; } #else if(dev->mem_start != 0) /* no auto-mem-probe */ { size = 0x4000; /* check for 16K mem */ if(!check586(dev,(char *) dev->mem_start,size)) { size = 0x2000; /* check for 8K mem */ if(!check586(dev,(char *) dev->mem_start,size)) { printk("?memprobe, Can't find memory at 0x%lx!\n",dev->mem_start); retval = -ENODEV; goto out; } } } else { static long memaddrs[] = { 0xc8000,0xca000,0xcc000,0xce000,0xd0000,0xd2000, 0xd4000,0xd6000,0xd8000,0xda000,0xdc000, 0 }; for(i=0;;i++) { if(!memaddrs[i]) { printk("?memprobe, Can't find io-memory!\n"); retval = -ENODEV; goto out; } dev->mem_start = memaddrs[i]; size = 0x2000; /* check for 8K mem */ if(check586(dev,(char *)dev->mem_start,size)) /* 8K-check */ break; size = 0x4000; /* check for 16K mem */ if(check586(dev,(char *)dev->mem_start,size)) /* 16K-check */ break; } } dev->mem_end = dev->mem_start + size; /* set mem_end showed by 'ifconfig' */ #endif dev->priv = (void *) kmalloc(sizeof(struct priv),GFP_KERNEL); if(dev->priv == NULL) { printk("%s: Ooops .. can't allocate private driver memory.\n",dev->name); retval = -ENOMEM; goto out; } /* warning: we don't free it on errors */ memset((char *) dev->priv,0,sizeof(struct priv)); ((struct priv *) (dev->priv))->memtop = isa_bus_to_virt(dev->mem_start) + size; ((struct priv *) (dev->priv))->base = (unsigned long) isa_bus_to_virt(dev->mem_start) + size - 0x01000000; alloc586(dev); /* set number of receive-buffs according to memsize */ if(size == 0x2000) ((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_8; else ((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_16; printk("Memaddr: 0x%lx, Memsize: %d, ",dev->mem_start,size); if(dev->irq < 2) { unsigned long irq_mask; irq_mask = probe_irq_on(); ni_reset586(); ni_attn586(); mdelay(20); dev->irq = probe_irq_off(irq_mask); if(!dev->irq) { printk("?autoirq, Failed to detect IRQ line!\n"); kfree(dev->priv); dev->priv = NULL; retval = -EAGAIN; goto out; } printk("IRQ %d (autodetected).\n",dev->irq); } else { if(dev->irq == 2) dev->irq = 9; printk("IRQ %d (assigned and not checked!).\n",dev->irq); } dev->open = ni52_open; dev->stop = ni52_close; dev->get_stats = ni52_get_stats; dev->tx_timeout = ni52_timeout; dev->watchdog_timeo = HZ/20; dev->hard_start_xmit = ni52_send_packet; dev->set_multicast_list = set_multicast_list; dev->if_port = 0; ether_setup(dev); return 0; out: release_region(ioaddr, NI52_TOTAL_SIZE); return retval; }
*/ BUGMSG(D_INIT_REASONS, "intmask was %02Xh\n", inb(_INTMASK)); outb(0, _INTMASK); airqmask = probe_irq_on(); outb(NORXflag, _INTMASK); udelay(1); outb(0, _INTMASK); dev->irq = probe_irq_off(airqmask); <<<<<<< HEAD if ((int)dev->irq <= 0) { ======= if (dev->irq <= 0) { >>>>>>> 296c66da8a02d52243f45b80521febece5ed498a BUGMSG(D_INIT_REASONS, "Autoprobe IRQ failed first time\n"); airqmask = probe_irq_on(); outb(NORXflag, _INTMASK); udelay(5); outb(0, _INTMASK); dev->irq = probe_irq_off(airqmask); <<<<<<< HEAD if ((int)dev->irq <= 0) { ======= if (dev->irq <= 0) { >>>>>>> 296c66da8a02d52243f45b80521febece5ed498a BUGMSG(D_NORMAL, "Autoprobe IRQ failed.\n"); err = -ENODEV; goto out; } } }
/* options[0] Board base address options[1] IRQ options[2] Input configuration 0 == single-ended 1 == differential 2 == pseudo-differential options[3] Analog input range configuration 0 == bipolar 5 (-5V -- +5V) 1 == bipolar 2.5V (-2.5V -- +2.5V) 2 == unipolar 5V (0V -- +5V) options[4] Analog output 0 range configuration 0 == bipolar 5 (-5V -- +5V) 1 == bipolar 2.5V (-2.5V -- +2.5V) 2 == unipolar 5V (0V -- +5V) options[5] Analog output 1 range configuration 0 == bipolar 5 (-5V -- +5V) 1 == bipolar 2.5V (-2.5V -- +2.5V) 2 == unipolar 5V (0V -- +5V) */ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it) { /* int i, irq; */ /* unsigned long irqs; */ /* long flags; */ const struct dt2811_board *board = comedi_board(dev); int ret; struct comedi_subdevice *s; unsigned long iobase; iobase = it->options[0]; printk(KERN_INFO "comedi%d: dt2811:base=0x%04lx\n", dev->minor, iobase); if (!request_region(iobase, DT2811_SIZE, driver_name)) { printk(KERN_ERR "I/O port conflict\n"); return -EIO; } dev->iobase = iobase; dev->board_name = board->name; #if 0 outb(0, dev->iobase + DT2811_ADCSR); udelay(100); i = inb(dev->iobase + DT2811_ADDATLO); i = inb(dev->iobase + DT2811_ADDATHI); #endif #if 0 irq = it->options[1]; if (irq < 0) { save_flags(flags); sti(); irqs = probe_irq_on(); outb(DT2811_CLRERROR | DT2811_INTENB, dev->iobase + DT2811_ADCSR); outb(0, dev->iobase + DT2811_ADGCR); udelay(100); irq = probe_irq_off(irqs); restore_flags(flags); /*outb(DT2811_CLRERROR|DT2811_INTENB, dev->iobase+DT2811_ADCSR);*/ if (inb(dev->iobase + DT2811_ADCSR) & DT2811_ADERROR) printk(KERN_ERR "error probing irq (bad)\n"); dev->irq = 0; if (irq > 0) { i = inb(dev->iobase + DT2811_ADDATLO); i = inb(dev->iobase + DT2811_ADDATHI); printk(KERN_INFO "(irq = %d)\n", irq); ret = request_irq(irq, dt2811_interrupt, 0, driver_name, dev); if (ret < 0) return -EIO; dev->irq = irq; } else if (irq == 0) { printk(KERN_INFO "(no irq)\n"); } else { printk(KERN_ERR "( multiple irq's -- this is bad! )\n"); } } #endif ret = comedi_alloc_subdevices(dev, 4); if (ret) return ret; ret = alloc_private(dev, sizeof(struct dt2811_private)); if (ret < 0) return ret; switch (it->options[2]) { case 0: devpriv->adc_mux = adc_singleended; break; case 1: devpriv->adc_mux = adc_diff; break; case 2: devpriv->adc_mux = adc_pseudo_diff; break; default: devpriv->adc_mux = adc_singleended; break; } switch (it->options[4]) { case 0: devpriv->dac_range[0] = dac_bipolar_5; break; case 1: devpriv->dac_range[0] = dac_bipolar_2_5; break; case 2: devpriv->dac_range[0] = dac_unipolar_5; break; default: devpriv->dac_range[0] = dac_bipolar_5; break; } switch (it->options[5]) { case 0: devpriv->dac_range[1] = dac_bipolar_5; break; case 1: devpriv->dac_range[1] = dac_bipolar_2_5; break; case 2: devpriv->dac_range[1] = dac_unipolar_5; break; default: devpriv->dac_range[1] = dac_bipolar_5; break; } s = &dev->subdevices[0]; /* initialize the ADC subdevice */ s->type = COMEDI_SUBD_AI; s->subdev_flags = SDF_READABLE | SDF_GROUND; s->n_chan = devpriv->adc_mux == adc_diff ? 8 : 16; s->insn_read = dt2811_ai_insn; s->maxdata = 0xfff; switch (it->options[3]) { case 0: default: s->range_table = board->bip_5; break; case 1: s->range_table = board->bip_2_5; break; case 2: s->range_table = board->unip_5; break; } s = &dev->subdevices[1]; /* ao subdevice */ s->type = COMEDI_SUBD_AO; s->subdev_flags = SDF_WRITABLE; s->n_chan = 2; s->insn_write = dt2811_ao_insn; s->insn_read = dt2811_ao_insn_read; s->maxdata = 0xfff; s->range_table_list = devpriv->range_type_list; devpriv->range_type_list[0] = dac_range_types[devpriv->dac_range[0]]; devpriv->range_type_list[1] = dac_range_types[devpriv->dac_range[1]]; s = &dev->subdevices[2]; /* di subdevice */ s->type = COMEDI_SUBD_DI; s->subdev_flags = SDF_READABLE; s->n_chan = 8; s->insn_bits = dt2811_di_insn_bits; s->maxdata = 1; s->range_table = &range_digital; s = &dev->subdevices[3]; /* do subdevice */ s->type = COMEDI_SUBD_DO; s->subdev_flags = SDF_WRITABLE; s->n_chan = 8; s->insn_bits = dt2811_do_insn_bits; s->maxdata = 1; s->state = 0; s->range_table = &range_digital; return 0; }
static void __init com90xx_probe(void) { int count, status, ioaddr, numprint, airq, openparen = 0; unsigned long airqmask; int ports[(0x3f0 - 0x200) / 16 + 1] = {0}; unsigned long *shmems; void __iomem **iomem; int numports, numshmems, *port; u_long *p; int index; if (!io && !irq && !shmem && !*device && com90xx_skip_probe) return; shmems = kzalloc(((0x100000-0xa0000) / 0x800) * sizeof(unsigned long), GFP_KERNEL); if (!shmems) return; iomem = kzalloc(((0x100000-0xa0000) / 0x800) * sizeof(void __iomem *), GFP_KERNEL); if (!iomem) { kfree(shmems); return; } BUGLVL(D_NORMAL) printk(VERSION); numports = numshmems = 0; if (io) ports[numports++] = io; else for (count = 0x200; count <= 0x3f0; count += 16) ports[numports++] = count; if (shmem) shmems[numshmems++] = shmem; else for (count = 0xA0000; count <= 0xFF800; count += 2048) shmems[numshmems++] = count; numprint = -1; for (port = &ports[0]; port - ports < numports; port++) { numprint++; numprint %= 8; if (!numprint) { BUGMSG2(D_INIT, "\n"); BUGMSG2(D_INIT, "S1: "); } BUGMSG2(D_INIT, "%Xh ", *port); ioaddr = *port; if (!request_region(*port, ARCNET_TOTAL_SIZE, "arcnet (90xx)")) { BUGMSG2(D_INIT_REASONS, "(request_region)\n"); BUGMSG2(D_INIT_REASONS, "S1: "); BUGLVL(D_INIT_REASONS) numprint = 0; *port-- = ports[--numports]; continue; } if (ASTATUS() == 0xFF) { BUGMSG2(D_INIT_REASONS, "(empty)\n"); BUGMSG2(D_INIT_REASONS, "S1: "); BUGLVL(D_INIT_REASONS) numprint = 0; release_region(*port, ARCNET_TOTAL_SIZE); *port-- = ports[--numports]; continue; } inb(_RESET); BUGMSG2(D_INIT_REASONS, "\n"); BUGMSG2(D_INIT_REASONS, "S1: "); BUGLVL(D_INIT_REASONS) numprint = 0; } BUGMSG2(D_INIT, "\n"); if (!numports) { BUGMSG2(D_NORMAL, "S1: No ARCnet cards found.\n"); kfree(shmems); kfree(iomem); return; } numprint = -1; for (port = &ports[0]; port < ports + numports; port++) { numprint++; numprint %= 8; if (!numprint) { BUGMSG2(D_INIT, "\n"); BUGMSG2(D_INIT, "S2: "); } BUGMSG2(D_INIT, "%Xh ", *port); } BUGMSG2(D_INIT, "\n"); mdelay(RESETtime); numprint = -1; for (index = 0, p = &shmems[0]; index < numshmems; p++, index++) { void __iomem *base; numprint++; numprint %= 8; if (!numprint) { BUGMSG2(D_INIT, "\n"); BUGMSG2(D_INIT, "S3: "); } BUGMSG2(D_INIT, "%lXh ", *p); if (!request_mem_region(*p, MIRROR_SIZE, "arcnet (90xx)")) { BUGMSG2(D_INIT_REASONS, "(request_mem_region)\n"); BUGMSG2(D_INIT_REASONS, "Stage 3: "); BUGLVL(D_INIT_REASONS) numprint = 0; goto out; } base = ioremap(*p, MIRROR_SIZE); if (!base) { BUGMSG2(D_INIT_REASONS, "(ioremap)\n"); BUGMSG2(D_INIT_REASONS, "Stage 3: "); BUGLVL(D_INIT_REASONS) numprint = 0; goto out1; } if (readb(base) != TESTvalue) { BUGMSG2(D_INIT_REASONS, "(%02Xh != %02Xh)\n", readb(base), TESTvalue); BUGMSG2(D_INIT_REASONS, "S3: "); BUGLVL(D_INIT_REASONS) numprint = 0; goto out2; } writeb(0x42, base); if (readb(base) != 0x42) { BUGMSG2(D_INIT_REASONS, "(read only)\n"); BUGMSG2(D_INIT_REASONS, "S3: "); goto out2; } BUGMSG2(D_INIT_REASONS, "\n"); BUGMSG2(D_INIT_REASONS, "S3: "); BUGLVL(D_INIT_REASONS) numprint = 0; iomem[index] = base; continue; out2: iounmap(base); out1: release_mem_region(*p, MIRROR_SIZE); out: *p-- = shmems[--numshmems]; index--; } BUGMSG2(D_INIT, "\n"); if (!numshmems) { BUGMSG2(D_NORMAL, "S3: No ARCnet cards found.\n"); for (port = &ports[0]; port < ports + numports; port++) release_region(*port, ARCNET_TOTAL_SIZE); kfree(shmems); kfree(iomem); return; } numprint = -1; for (p = &shmems[0]; p < shmems + numshmems; p++) { numprint++; numprint %= 8; if (!numprint) { BUGMSG2(D_INIT, "\n"); BUGMSG2(D_INIT, "S4: "); } BUGMSG2(D_INIT, "%lXh ", *p); } BUGMSG2(D_INIT, "\n"); numprint = -1; for (port = &ports[0]; port < ports + numports; port++) { int found = 0; numprint++; numprint %= 8; if (!numprint) { BUGMSG2(D_INIT, "\n"); BUGMSG2(D_INIT, "S5: "); } BUGMSG2(D_INIT, "%Xh ", *port); ioaddr = *port; status = ASTATUS(); if ((status & 0x9D) != (NORXflag | RECONflag | TXFREEflag | RESETflag)) { BUGMSG2(D_INIT_REASONS, "(status=%Xh)\n", status); BUGMSG2(D_INIT_REASONS, "S5: "); BUGLVL(D_INIT_REASONS) numprint = 0; release_region(*port, ARCNET_TOTAL_SIZE); *port-- = ports[--numports]; continue; } ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear); status = ASTATUS(); if (status & RESETflag) { BUGMSG2(D_INIT_REASONS, " (eternal reset, status=%Xh)\n", status); BUGMSG2(D_INIT_REASONS, "S5: "); BUGLVL(D_INIT_REASONS) numprint = 0; release_region(*port, ARCNET_TOTAL_SIZE); *port-- = ports[--numports]; continue; } if (!irq) { airqmask = probe_irq_on(); AINTMASK(NORXflag); udelay(1); AINTMASK(0); airq = probe_irq_off(airqmask); if (airq <= 0) { BUGMSG2(D_INIT_REASONS, "(airq=%d)\n", airq); BUGMSG2(D_INIT_REASONS, "S5: "); BUGLVL(D_INIT_REASONS) numprint = 0; release_region(*port, ARCNET_TOTAL_SIZE); *port-- = ports[--numports]; continue; } } else { airq = irq; } BUGMSG2(D_INIT, "(%d,", airq); openparen = 1; #ifdef FAST_PROBE if (numports > 1 || numshmems > 1) { inb(_RESET); mdelay(RESETtime); } else { writeb(TESTvalue, iomem[0]); } #else inb(_RESET); mdelay(RESETtime); #endif for (index = 0; index < numshmems; index++) { u_long ptr = shmems[index]; void __iomem *base = iomem[index]; if (readb(base) == TESTvalue) { BUGMSG2(D_INIT, "%lXh)\n", *p); openparen = 0; if (com90xx_found(*port, airq, ptr, base) == 0) found = 1; numprint = -1; shmems[index] = shmems[--numshmems]; iomem[index] = iomem[numshmems]; break; } else { BUGMSG2(D_INIT_REASONS, "%Xh-", readb(base)); } } if (openparen) { BUGLVL(D_INIT) printk("no matching shmem)\n"); BUGLVL(D_INIT_REASONS) printk("S5: "); BUGLVL(D_INIT_REASONS) numprint = 0; } if (!found) release_region(*port, ARCNET_TOTAL_SIZE); *port-- = ports[--numports]; } BUGLVL(D_INIT_REASONS) printk("\n"); for (index = 0; index < numshmems; index++) { writeb(TESTvalue, iomem[index]); iounmap(iomem[index]); release_mem_region(shmems[index], MIRROR_SIZE); } kfree(shmems); kfree(iomem); }
__initfunc(int arc20020_probe(struct device *dev)) { int ioaddr=dev->base_addr,status,delayval; unsigned long airqmask; BUGLVL(D_NORMAL) printk(version); if (ioaddr<0x200) { BUGMSG(D_NORMAL,"No autoprobe for IO mapped cards; you " "must specify the base address!\n"); return -ENODEV; } if (check_region(ioaddr, ARCNET_TOTAL_SIZE)) { BUGMSG(D_NORMAL,"IO region %xh-%xh already allocated.\n", ioaddr,ioaddr+ARCNET_TOTAL_SIZE-1); return -ENXIO; } if (ARCSTATUS == 0xFF) { BUGMSG(D_NORMAL,"IO address %x empty\n",ioaddr); return -ENODEV; } ARCRESET0; JIFFER(RESETtime); status=ARCSTATUS; if ((status & 0x99) != (NORXflag|TXFREEflag|RESETflag)) { BUGMSG(D_NORMAL,"Status invalid (%Xh).\n",status); return -ENODEV; } BUGMSG(D_INIT_REASONS,"Status after reset: %X\n",status); /* Enable TX */ outb(0x39,_CONFIG); outb(inb(ioaddr+8),ioaddr+7); ACOMMAND(CFLAGScmd|RESETclear|CONFIGclear); BUGMSG(D_INIT_REASONS,"Status after reset acknowledged: %X\n",status); /* Reset card. */ outb(0x98,_CONFIG); udelay(5); outb(0x18,_CONFIG); /* Read first loc'n of memory */ outb(0 | RDDATAflag | AUTOINCflag ,_ADDR_HI); outb(0,_ADDR_LO); if ((status=inb(_MEMDATA)) != 0xd1) { BUGMSG(D_NORMAL,"Signature byte not found.\n"); return -ENODEV; } if (!dev->irq) { /* if we do this, we're sure to get an IRQ since the * card has just reset and the NORXflag is on until * we tell it to start receiving. */ BUGMSG(D_INIT_REASONS, "intmask was %d:\n",inb(_INTMASK)); outb(0, _INTMASK); airqmask = probe_irq_on(); outb(NORXflag,_INTMASK); udelay(1); outb(0,_INTMASK); dev->irq = probe_irq_off(airqmask); if (dev->irq<=0) { BUGMSG(D_INIT_REASONS,"Autoprobe IRQ failed first time\n"); airqmask = probe_irq_on(); outb(NORXflag,_INTMASK); udelay(5); outb(0,_INTMASK); dev->irq = probe_irq_off(airqmask); if (dev->irq<=0) { BUGMSG(D_NORMAL,"Autoprobe IRQ failed.\n"); return -ENODEV; } } } return arc20020_found(dev,dev->base_addr,dev->irq); }
struct net_device * __init ltpc_probe(void) { struct net_device *dev; int err = -ENOMEM; int x=0,y=0; int autoirq; unsigned long f; unsigned long timeout; dev = alloc_ltalkdev(sizeof(struct ltpc_private)); if (!dev) goto out; SET_MODULE_OWNER(dev); /* probe for the I/O port address */ if (io != 0x240 && request_region(0x220,8,"ltpc")) { x = inb_p(0x220+6); if ( (x!=0xff) && (x>=0xf0) ) { io = 0x220; goto got_port; } release_region(0x220,8); } if (io != 0x220 && request_region(0x240,8,"ltpc")) { y = inb_p(0x240+6); if ( (y!=0xff) && (y>=0xf0) ){ io = 0x240; goto got_port; } release_region(0x240,8); } /* give up in despair */ printk(KERN_ERR "LocalTalk card not found; 220 = %02x, 240 = %02x.\n", x,y); err = -ENODEV; goto out1; got_port: /* probe for the IRQ line */ if (irq < 2) { unsigned long irq_mask; irq_mask = probe_irq_on(); /* reset the interrupt line */ inb_p(io+7); inb_p(io+7); /* trigger an interrupt (I hope) */ inb_p(io+6); mdelay(2); autoirq = probe_irq_off(irq_mask); if (autoirq == 0) { printk(KERN_ERR "ltpc: probe at %#x failed to detect IRQ line.\n", io); } else { irq = autoirq; } } /* allocate a DMA buffer */ ltdmabuf = (unsigned char *) dma_mem_alloc(1000); if (!ltdmabuf) { printk(KERN_ERR "ltpc: mem alloc failed\n"); err = -ENOMEM; goto out2; } ltdmacbuf = <dmabuf[800]; if(debug & DEBUG_VERBOSE) { printk("ltdmabuf pointer %08lx\n",(unsigned long) ltdmabuf); } /* reset the card */ inb_p(io+1); inb_p(io+3); msleep(20); inb_p(io+0); inb_p(io+2); inb_p(io+7); /* clear reset */ inb_p(io+4); inb_p(io+5); inb_p(io+5); /* enable dma */ inb_p(io+6); /* tri-state interrupt line */ ssleep(1); /* now, figure out which dma channel we're using, unless it's already been specified */ /* well, 0 is a legal DMA channel, but the LTPC card doesn't use it... */ dma = ltpc_probe_dma(io, dma); if (!dma) { /* no dma channel */ printk(KERN_ERR "No DMA channel found on ltpc card.\n"); err = -ENODEV; goto out3; } /* print out friendly message */ if(irq) printk(KERN_INFO "Apple/Farallon LocalTalk-PC card at %03x, IR%d, DMA%d.\n",io,irq,dma); else printk(KERN_INFO "Apple/Farallon LocalTalk-PC card at %03x, DMA%d. Using polled mode.\n",io,dma); /* Fill in the fields of the device structure with ethernet-generic values. */ dev->hard_start_xmit = ltpc_xmit; dev->hard_header = ltpc_hard_header; dev->get_stats = ltpc_get_stats; /* add the ltpc-specific things */ dev->do_ioctl = <pc_ioctl; dev->set_multicast_list = &set_multicast_list; dev->mc_list = NULL; dev->base_addr = io; dev->irq = irq; dev->dma = dma; /* the card will want to send a result at this point */ /* (I think... leaving out this part makes the kernel crash, so I put it back in...) */ f=claim_dma_lock(); disable_dma(dma); clear_dma_ff(dma); set_dma_mode(dma,DMA_MODE_READ); set_dma_addr(dma,virt_to_bus(ltdmabuf)); set_dma_count(dma,0x100); enable_dma(dma); release_dma_lock(f); (void) inb_p(io+3); (void) inb_p(io+2); timeout = jiffies+100*HZ/100; while(time_before(jiffies, timeout)) { if( 0xf9 == inb_p(io+6)) break; schedule(); } if(debug & DEBUG_VERBOSE) { printk("setting up timer and irq\n"); } /* grab it and don't let go :-) */ if (irq && request_irq( irq, <pc_interrupt, 0, "ltpc", dev) >= 0) { (void) inb_p(io+7); /* enable interrupts from board */ (void) inb_p(io+7); /* and reset irq line */ } else { if( irq ) printk(KERN_ERR "ltpc: IRQ already in use, using polled mode.\n"); dev->irq = 0; /* polled mode -- 20 times per second */ /* this is really, really slow... should it poll more often? */ init_timer(<pc_timer); ltpc_timer.function=ltpc_poll; ltpc_timer.data = (unsigned long) dev; ltpc_timer.expires = jiffies + HZ/20; add_timer(<pc_timer); } err = register_netdev(dev); if (err) goto out4; return NULL; out4: del_timer_sync(<pc_timer); if (dev->irq) free_irq(dev->irq, dev); out3: free_pages((unsigned long)ltdmabuf, get_order(1000)); out2: release_region(io, 8); out1: free_netdev(dev); out: return ERR_PTR(err); }
_mali_osk_irq_t *_mali_osk_irq_init(u32 irqnum, _mali_osk_irq_uhandler_t uhandler, void *int_data, _mali_osk_irq_trigger_t trigger_func, _mali_osk_irq_ack_t ack_func, void *probe_data, const char *description) { mali_osk_irq_object_t *irq_object; unsigned long irq_flags = 0; #if defined(CONFIG_MALI_SHARED_INTERRUPTS) irq_flags |= IRQF_SHARED; #endif /* defined(CONFIG_MALI_SHARED_INTERRUPTS) */ irq_object = kmalloc(sizeof(mali_osk_irq_object_t), GFP_KERNEL); if (NULL == irq_object) { return NULL; } if (-1 == irqnum) { /* Probe for IRQ */ if ((NULL != trigger_func) && (NULL != ack_func)) { unsigned long probe_count = 3; _mali_osk_errcode_t err; int irq; MALI_DEBUG_PRINT(2, ("Probing for irq\n")); do { unsigned long mask; mask = probe_irq_on(); trigger_func(probe_data); _mali_osk_time_ubusydelay(5); irq = probe_irq_off(mask); err = ack_func(probe_data); } while (irq < 0 && (err == _MALI_OSK_ERR_OK) && probe_count--); if (irq < 0 || (_MALI_OSK_ERR_OK != err)) irqnum = -1; else irqnum = irq; } else irqnum = -1; /* no probe functions, fault */ if (-1 != irqnum) { /* found an irq */ MALI_DEBUG_PRINT(2, ("Found irq %d\n", irqnum)); } else { MALI_DEBUG_PRINT(2, ("Probe for irq failed\n")); } } irq_object->irqnum = irqnum; irq_object->uhandler = uhandler; irq_object->data = int_data; if (-1 == irqnum) { MALI_DEBUG_PRINT(2, ("No IRQ for core '%s' found during probe\n", description)); kfree(irq_object); return NULL; } #if defined(DEBUG) /* Verify that the configured interrupt settings are working */ if (_MALI_OSK_ERR_OK != test_interrupt(irqnum, trigger_func, ack_func, probe_data, description)) { MALI_DEBUG_PRINT(2, ("Test of IRQ handler for core '%s' failed\n", description)); kfree(irq_object); return NULL; } #endif if (0 != request_irq(irqnum, irq_handler_upper_half, irq_flags, description, irq_object)) { MALI_DEBUG_PRINT(2, ("Unable to install IRQ handler for core '%s'\n", description)); kfree(irq_object); return NULL; } return irq_object; }
int __init com90xx_probe(struct net_device *dev) { int count, status, ioaddr, numprint, airq, retval = -ENODEV, openparen = 0; unsigned long airqmask; int ports[(0x3f0 - 0x200) / 16 + 1] = {0}; u_long shmems[(0xFF800 - 0xA0000) / 2048 + 1] = {0}; int numports, numshmems, *port; u_long *shmem; if (!dev && com90xx_skip_probe) return -ENODEV; #ifndef MODULE arcnet_init(); #endif BUGLVL(D_NORMAL) printk(VERSION); /* set up the arrays where we'll store the possible probe addresses */ numports = numshmems = 0; if (dev && dev->base_addr) ports[numports++] = dev->base_addr; else for (count = 0x200; count <= 0x3f0; count += 16) ports[numports++] = count; if (dev && dev->mem_start) shmems[numshmems++] = dev->mem_start; else for (count = 0xA0000; count <= 0xFF800; count += 2048) shmems[numshmems++] = count; /* Stage 1: abandon any reserved ports, or ones with status==0xFF * (empty), and reset any others by reading the reset port. */ numprint = -1; for (port = &ports[0]; port - ports < numports; port++) { numprint++; numprint %= 8; if (!numprint) { BUGMSG2(D_INIT, "\n"); BUGMSG2(D_INIT, "S1: "); } BUGMSG2(D_INIT, "%Xh ", *port); ioaddr = *port; if (check_region(*port, ARCNET_TOTAL_SIZE)) { BUGMSG2(D_INIT_REASONS, "(check_region)\n"); BUGMSG2(D_INIT_REASONS, "S1: "); BUGLVL(D_INIT_REASONS) numprint = 0; *port = ports[numports - 1]; numports--; port--; continue; } if (ASTATUS() == 0xFF) { BUGMSG2(D_INIT_REASONS, "(empty)\n"); BUGMSG2(D_INIT_REASONS, "S1: "); BUGLVL(D_INIT_REASONS) numprint = 0; *port = ports[numports - 1]; numports--; port--; continue; } inb(_RESET); /* begin resetting card */ BUGMSG2(D_INIT_REASONS, "\n"); BUGMSG2(D_INIT_REASONS, "S1: "); BUGLVL(D_INIT_REASONS) numprint = 0; } BUGMSG2(D_INIT, "\n"); if (!numports) { BUGMSG2(D_NORMAL, "S1: No ARCnet cards found.\n"); return -ENODEV; } /* Stage 2: we have now reset any possible ARCnet cards, so we can't * do anything until they finish. If D_INIT, print the list of * cards that are left. */ numprint = -1; for (port = &ports[0]; port - ports < numports; port++) { numprint++; numprint %= 8; if (!numprint) { BUGMSG2(D_INIT, "\n"); BUGMSG2(D_INIT, "S2: "); } BUGMSG2(D_INIT, "%Xh ", *port); } BUGMSG2(D_INIT, "\n"); mdelay(RESETtime); /* Stage 3: abandon any shmem addresses that don't have the signature * 0xD1 byte in the right place, or are read-only. */ numprint = -1; for (shmem = &shmems[0]; shmem - shmems < numshmems; shmem++) { u_long ptr = *shmem; numprint++; numprint %= 8; if (!numprint) { BUGMSG2(D_INIT, "\n"); BUGMSG2(D_INIT, "S3: "); } BUGMSG2(D_INIT, "%lXh ", *shmem); if (check_mem_region(*shmem, BUFFER_SIZE)) { BUGMSG2(D_INIT_REASONS, "(check_mem_region)\n"); BUGMSG2(D_INIT_REASONS, "Stage 3: "); BUGLVL(D_INIT_REASONS) numprint = 0; *shmem = shmems[numshmems - 1]; numshmems--; shmem--; continue; } if (isa_readb(ptr) != TESTvalue) { BUGMSG2(D_INIT_REASONS, "(%02Xh != %02Xh)\n", isa_readb(ptr), TESTvalue); BUGMSG2(D_INIT_REASONS, "S3: "); BUGLVL(D_INIT_REASONS) numprint = 0; *shmem = shmems[numshmems - 1]; numshmems--; shmem--; continue; } /* By writing 0x42 to the TESTvalue location, we also make * sure no "mirror" shmem areas show up - if they occur * in another pass through this loop, they will be discarded * because *cptr != TESTvalue. */ isa_writeb(0x42, ptr); if (isa_readb(ptr) != 0x42) { BUGMSG2(D_INIT_REASONS, "(read only)\n"); BUGMSG2(D_INIT_REASONS, "S3: "); *shmem = shmems[numshmems - 1]; numshmems--; shmem--; continue; } BUGMSG2(D_INIT_REASONS, "\n"); BUGMSG2(D_INIT_REASONS, "S3: "); BUGLVL(D_INIT_REASONS) numprint = 0; } BUGMSG2(D_INIT, "\n"); if (!numshmems) { BUGMSG2(D_NORMAL, "S3: No ARCnet cards found.\n"); return -ENODEV; } /* Stage 4: something of a dummy, to report the shmems that are * still possible after stage 3. */ numprint = -1; for (shmem = &shmems[0]; shmem - shmems < numshmems; shmem++) { numprint++; numprint %= 8; if (!numprint) { BUGMSG2(D_INIT, "\n"); BUGMSG2(D_INIT, "S4: "); } BUGMSG2(D_INIT, "%lXh ", *shmem); } BUGMSG2(D_INIT, "\n"); /* Stage 5: for any ports that have the correct status, can disable * the RESET flag, and (if no irq is given) generate an autoirq, * register an ARCnet device. * * Currently, we can only register one device per probe, so quit * after the first one is found. */ numprint = -1; for (port = &ports[0]; port - ports < numports; port++) { numprint++; numprint %= 8; if (!numprint) { BUGMSG2(D_INIT, "\n"); BUGMSG2(D_INIT, "S5: "); } BUGMSG2(D_INIT, "%Xh ", *port); ioaddr = *port; status = ASTATUS(); if ((status & 0x9D) != (NORXflag | RECONflag | TXFREEflag | RESETflag)) { BUGMSG2(D_INIT_REASONS, "(status=%Xh)\n", status); BUGMSG2(D_INIT_REASONS, "S5: "); BUGLVL(D_INIT_REASONS) numprint = 0; *port = ports[numports - 1]; numports--; port--; continue; } ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear); status = ASTATUS(); if (status & RESETflag) { BUGMSG2(D_INIT_REASONS, " (eternal reset, status=%Xh)\n", status); BUGMSG2(D_INIT_REASONS, "S5: "); BUGLVL(D_INIT_REASONS) numprint = 0; *port = ports[numports - 1]; numports--; port--; continue; } /* skip this completely if an IRQ was given, because maybe * we're on a machine that locks during autoirq! */ if (!dev || !dev->irq) { /* if we do this, we're sure to get an IRQ since the * card has just reset and the NORXflag is on until * we tell it to start receiving. */ airqmask = probe_irq_on(); AINTMASK(NORXflag); udelay(1); AINTMASK(0); airq = probe_irq_off(airqmask); if (airq <= 0) { BUGMSG2(D_INIT_REASONS, "(airq=%d)\n", airq); BUGMSG2(D_INIT_REASONS, "S5: "); BUGLVL(D_INIT_REASONS) numprint = 0; *port = ports[numports - 1]; numports--; port--; continue; } } else { airq = dev->irq; } BUGMSG2(D_INIT, "(%d,", airq); openparen = 1; /* Everything seems okay. But which shmem, if any, puts * back its signature byte when the card is reset? * * If there are multiple cards installed, there might be * multiple shmems still in the list. */ #ifdef FAST_PROBE if (numports > 1 || numshmems > 1) { inb(_RESET); mdelay(RESETtime); } else { /* just one shmem and port, assume they match */ isa_writeb(TESTvalue, shmems[0]); } #else inb(_RESET); mdelay(RESETtime); #endif for (shmem = &shmems[0]; shmem - shmems < numshmems; shmem++) { u_long ptr = *shmem; if (isa_readb(ptr) == TESTvalue) { /* found one */ BUGMSG2(D_INIT, "%lXh)\n", *shmem); openparen = 0; /* register the card */ retval = com90xx_found(dev, *port, airq, *shmem); numprint = -1; /* remove shmem from the list */ *shmem = shmems[numshmems - 1]; numshmems--; break; /* go to the next I/O port */ } else { BUGMSG2(D_INIT_REASONS, "%Xh-", isa_readb(ptr)); } } if (openparen) { BUGLVL(D_INIT) printk("no matching shmem)\n"); BUGLVL(D_INIT_REASONS) printk("S5: "); BUGLVL(D_INIT_REASONS) numprint = 0; } *port = ports[numports - 1]; numports--; port--; } BUGLVL(D_INIT_REASONS) printk("\n"); /* Now put back TESTvalue on all leftover shmems. */ for (shmem = &shmems[0]; shmem - shmems < numshmems; shmem++) isa_writeb(TESTvalue, *shmem); if (retval && dev && !numcards) BUGMSG2(D_NORMAL, "S5: No ARCnet cards found.\n"); return retval; }