linux-bk/drivers/net/auto_irq.c
<<
>>
Prefs
   1/* auto_irq.c: Auto-configure IRQ lines for linux. */
   2/*
   3    Written 1994 by Donald Becker.
   4
   5    The author may be reached as becker@scyld.com
   6
   7    This code is a general-purpose IRQ line detector for devices with
   8    jumpered IRQ lines.  If you can make the device raise an IRQ (and
   9    that IRQ line isn't already being used), these routines will tell
  10    you what IRQ line it's using -- perfect for those oh-so-cool boot-time
  11    device probes!
  12
  13    To use this, first call autoirq_setup(timeout). TIMEOUT is how many
  14    'jiffies' (1/100 sec.) to detect other devices that have active IRQ lines,
  15    and can usually be zero at boot.  'autoirq_setup()' returns the bit
  16    vector of nominally-available IRQ lines (lines may be physically in-use,
  17    but not yet registered to a device).
  18    Next, set up your device to trigger an interrupt.
  19    Finally call autoirq_report(TIMEOUT) to find out which IRQ line was
  20    most recently active.  The TIMEOUT should usually be zero, but may
  21    be set to the number of jiffies to wait for a slow device to raise an IRQ.
  22
  23    The idea of using the setup timeout to filter out bogus IRQs came from
  24    the serial driver.
  25*/
  26
  27
  28#ifdef version
  29static const char *version=
  30"auto_irq.c:v1.11 Donald Becker (becker@scyld.com)";
  31#endif
  32
  33#include <linux/module.h>
  34#include <linux/jiffies.h>
  35#include <linux/delay.h>
  36#include <asm/bitops.h>
  37#include <asm/io.h>
  38#include <asm/irq.h>
  39#include <linux/netdevice.h>
  40
  41static unsigned long irqs;
  42
  43void autoirq_setup(int waittime)
  44{
  45        irqs = probe_irq_on();
  46}
  47
  48#define BUSY_LOOP_UNTIL(j) while ((long)(jiffies-(j)) < 0) ;
  49int autoirq_report(int waittime)
  50{
  51        unsigned long delay = jiffies + waittime;
  52        BUSY_LOOP_UNTIL(delay)
  53        return probe_irq_off(irqs);
  54}
  55
  56EXPORT_SYMBOL(autoirq_setup);
  57EXPORT_SYMBOL(autoirq_report);
  58
  59
  60/*
  61 * Local variables:
  62 *  compile-command: "gcc -DKERNEL -Wall -O6 -fomit-frame-pointer -I/usr/src/linux/net/tcp -c auto_irq.c"
  63 *  version-control: t
  64 *  kept-new-versions: 5
  65 *  c-indent-level: 4
  66 *  tab-width: 4
  67 * End:
  68 */
  69
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.