linux-old/Documentation/isapnp.txt
<<
>>
Prefs
   1ISA Plug & Play support by Jaroslav Kysela <perex@suse.cz>
   2==========================================================
   3
   4Interface /proc/isapnp
   5======================
   6
   7Read commands:
   8--------------
   9
  10No comment.
  11
  12Write commands:
  13---------------
  14
  15With the write interface you can activate or modify the configuration of
  16ISA Plug & Play devices.  It is mainly useful for drivers which have not
  17been rewritten to use the ISA Plug & Play kernel support yet.
  18
  19card <idx> <vendor>     - select PnP device by vendor identification
  20csn <CSN>               - select PnP device by CSN
  21dev <idx> <logdev>      - select logical device
  22auto                    - run autoconfigure
  23activate                - activate logical device
  24deactivate              - deactivate logical device
  25port <idx> <value>      - set port 0-7 to value
  26irq <idx> <value>       - set IRQ 0-1 to value
  27dma <idx> <value>       - set DMA 0-1 to value
  28memory <idx> <value>    - set memory 0-3 to value
  29poke <reg> <value>      - poke configuration byte to selected register
  30pokew <reg> <value>     - poke configuration word to selected register
  31poked <reg> <value>     - poke configuration dword to selected register
  32
  33Explanation:
  34        - variable <idx> begins with zero
  35        - variable <CSN> begins with one
  36        - <vendor> is in the standard format 'ABC1234'
  37        - <logdev> is in the standard format 'ABC1234'
  38
  39Example:
  40
  41cat > /proc/isapnp <<EOF
  42card 0 CSC7537
  43dev 0 CSC0000
  44port 0 0x534
  45port 1 0x388
  46port 2 0x220
  47irq 0 5
  48dma 0 1
  49dma 1 3
  50poke 0x70 9
  51activate
  52logdev 0 CSC0001
  53port 0 0x240
  54activate
  55EOF
  56
  57
  58Information for developers
  59==========================
  60
  61Finding a device
  62----------------
  63
  64extern struct pci_bus *isapnp_find_card(unsigned short vendor,
  65                                        unsigned short device,
  66                                        struct pci_bus *from);
  67
  68This function finds an ISA PnP card.  For the vendor argument, the
  69ISAPNP_VENDOR(a,b,c) macro should be used, where a,b,c are characters or
  70integers.  For the device argument the ISAPNP_DEVICE(x) macro should be
  71used, where x is an integer value.  Both vendor and device arguments
  72can be taken from contents of the /proc/isapnp file.
  73
  74extern struct pci_dev *isapnp_find_dev(struct pci_bus *card,
  75                                       unsigned short vendor,
  76                                       unsigned short function,
  77                                       struct pci_dev *from);
  78
  79This function finds an ISA PnP device. If card is NULL, then the global
  80search mode is used (all devices are used for the searching).  Otherwise
  81only devices which belong to the specified card are checked.  For the
  82function number the ISAPNP_FUNCTION(x) macro can be used; it works
  83similarly to the ISAPNP_DEVICE(x) macro.
  84
  85extern int isapnp_probe_cards(const struct isapnp_card_id *ids,
  86                              int (*probe)(struct pci_bus *card,
  87                              const struct isapnp_card_id *id));
  88
  89
  90This function is a helper for drivers which need to use more than
  91one device from an ISA PnP card.  The probe callback is called with
  92appropriate arguments for each card.
  93
  94Example for ids parameter initialization:
  95
  96static struct isapnp_card_id card_ids[] __devinitdata = {
  97        {
  98                ISAPNP_CARD_ID('A','D','V', 0x550a),
  99                devs: {
 100                        ISAPNP_DEVICE_ID('A', 'D', 'V', 0x0010),
 101                        ISAPNP_DEVICE_ID('A', 'D', 'V', 0x0011)
 102                },
 103                driver_data: 0x1234,
 104        },
 105        {
 106                ISAPNP_CARD_END,
 107        }
 108};
 109ISAPNP_CARD_TABLE(card_ids);
 110
 111extern int isapnp_probe_devs(const struct isapnp_device_id *ids,
 112                             int (*probe)(struct pci_bus *card,
 113                             const struct isapnp_device_id *id));
 114
 115
 116This function is a helper for drivers which need to use one
 117device from an ISA PnP card.  The probe callback is called with
 118appropriate arguments for each matched device.
 119
 120Example for ids parameter initialization:
 121
 122static struct isapnp_device_id device_ids[] __devinitdata = {
 123        { ISAPNP_DEVICE_SINGLE('E','S','S', 0x0968, 'E','S','S', 0x0968), },
 124        { ISAPNP_DEVICE_SINGLE_END, }
 125};
 126MODULE_DEVICE_TABLE(isapnp, device_ids);
 127
 128
 129ISA PnP configuration
 130=====================
 131
 132There are two ways in which the ISA PnP interface can be used.
 133
 134First way: low-level
 135--------------------
 136
 137All ISA PNP configuration registers are accessible via the low-level
 138isapnp_(read|write)_(byte|word|dword) functions.
 139
 140The function isapnp_cfg_begin() must be called before any lowlevel function.
 141The function isapnp_cfg_end() must be always called after configuration
 142otherwise the access to the ISA PnP configuration functions will be blocked.
 143
 144Second way: auto-configuration
 145------------------------------
 146
 147This feature gives to the driver the real power of the ISA PnP driver.
 148The function dev->prepare() initializes the resource members in the device
 149structure.  This structure contains all resources set to auto configuration
 150values after the initialization.  The device driver may modify some resources
 151to skip the auto configuration for a given resource.
 152
 153Once the device structure contains all requested resource values, the function
 154dev->activate() must be called to assign free resources to resource members
 155with the auto configuration value.
 156
 157Function dev->activate() does:
 158   - resources with the auto configuration value are configured
 159   - the auto configuration is created using ISA PnP resource map
 160   - the function writes configuration to ISA PnP configuration registers
 161   - the function returns to the caller actual used resources
 162
 163When the device driver is removed, function dev->deactivate() has to be
 164called to free all assigned resources.
 165
 166Example (game port initialization)
 167==================================
 168
 169/*** initialization ***/
 170
 171        struct pci_dev *dev;
 172
 173        /* find the first game port, use standard PnP IDs */
 174        dev = isapnp_find_dev(NULL,
 175                              ISAPNP_VENDOR('P','N','P'),
 176                              ISAPNP_FUNCTION(0xb02f),
 177                              NULL);
 178        if (!dev)
 179                return -ENODEV;
 180        if (dev->active)
 181                return -EBUSY;
 182        if (dev->prepare(dev)<0)
 183                return -EAGAIN;
 184        if (!(dev->resource[0].flags & IORESOURCE_IO))
 185                return -ENODEV;
 186        if (!dev->ro) {
 187                /* override resource */
 188                if (user_port != USER_PORT_AUTO_VALUE)
 189                        isapnp_resource_change(&dev->resource[0], user_port, 1);
 190        }
 191        if (dev->activate(dev)<0) {
 192                printk("isapnp configure failed (out of resources?)\n");
 193                return -ENOMEM;
 194        }
 195        user_port = dev->resource[0].start;             /* get real port */
 196
 197/*** deactivation ***/
 198
 199        /* to deactivate use: */
 200        if (dev)
 201                dev->deactivate(dev);
 202
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.