2 * ISA Plug & Play support
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * 2000-01-01 Added quirks handling for buggy hardware
22 * Peter Denison <peterd@pnd-pc.demon.co.uk>
23 * 2000-06-14 Added isapnp_probe_devs() and isapnp_activate_dev()
24 * Christoph Hellwig <hch@infradead.org>
25 * 2001-06-03 Added release_region calls to correspond with
26 * request_region calls when a failure occurs. Also
27 * added KERN_* constants to printk() calls.
28 * 2001-11-07 Added isapnp_{,un}register_driver calls along the lines
29 * of the pci driver interface
30 * Kai Germaschewski <kai.germaschewski@gmx.de>
31 * 2002-06-06 Made the use of dma channel 0 configurable
32 * Gerald Teschl <gerald.teschl@univie.ac.at>
33 * 2002-10-06 Ported to PnP Layer - Adam Belay <ambx1@neo.rr.com>
34 * 2003-08-11 Resource Management Updates - Adam Belay <ambx1@neo.rr.com>
37 #include <linux/module.h>
38 #include <linux/kernel.h>
39 #include <linux/errno.h>
40 #include <linux/slab.h>
41 #include <linux/delay.h>
42 #include <linux/init.h>
43 #include <linux/isapnp.h>
44 #include <linux/mutex.h>
48 #define ISAPNP_REGION_OK
54 int isapnp_disable; /* Disable ISA PnP */
55 static int isapnp_rdp; /* Read Data Port */
56 static int isapnp_reset = 1; /* reset all PnP cards (deactivate) */
57 static int isapnp_verbose = 1; /* verbose mode */
59 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
60 MODULE_DESCRIPTION("Generic ISA Plug & Play support");
61 module_param(isapnp_disable, int, 0);
62 MODULE_PARM_DESC(isapnp_disable, "ISA Plug & Play disable");
63 module_param(isapnp_rdp, int, 0);
64 MODULE_PARM_DESC(isapnp_rdp, "ISA Plug & Play read data port");
65 module_param(isapnp_reset, int, 0);
66 MODULE_PARM_DESC(isapnp_reset, "ISA Plug & Play reset all cards");
67 module_param(isapnp_verbose, int, 0);
68 MODULE_PARM_DESC(isapnp_verbose, "ISA Plug & Play verbose mode");
69 MODULE_LICENSE("GPL");
75 #define _STAG_PNPVERNO 0x01
76 #define _STAG_LOGDEVID 0x02
77 #define _STAG_COMPATDEVID 0x03
78 #define _STAG_IRQ 0x04
79 #define _STAG_DMA 0x05
80 #define _STAG_STARTDEP 0x06
81 #define _STAG_ENDDEP 0x07
82 #define _STAG_IOPORT 0x08
83 #define _STAG_FIXEDIO 0x09
84 #define _STAG_VENDOR 0x0e
85 #define _STAG_END 0x0f
87 #define _LTAG_MEMRANGE 0x81
88 #define _LTAG_ANSISTR 0x82
89 #define _LTAG_UNICODESTR 0x83
90 #define _LTAG_VENDOR 0x84
91 #define _LTAG_MEM32RANGE 0x85
92 #define _LTAG_FIXEDMEM32RANGE 0x86
94 static unsigned char isapnp_checksum_value;
95 static DEFINE_MUTEX(isapnp_cfg_mutex);
96 static int isapnp_detected;
97 static int isapnp_csn_count;
101 static inline void write_data(unsigned char x)
106 static inline void write_address(unsigned char x)
112 static inline unsigned char read_data(void)
114 unsigned char val = inb(isapnp_rdp);
118 unsigned char isapnp_read_byte(unsigned char idx)
124 static unsigned short isapnp_read_word(unsigned char idx)
128 val = isapnp_read_byte(idx);
129 val = (val << 8) + isapnp_read_byte(idx + 1);
133 void isapnp_write_byte(unsigned char idx, unsigned char val)
139 static void isapnp_write_word(unsigned char idx, unsigned short val)
141 isapnp_write_byte(idx, val >> 8);
142 isapnp_write_byte(idx + 1, val);
145 static void isapnp_key(void)
147 unsigned char code = 0x6a, msb;
156 for (i = 1; i < 32; i++) {
157 msb = ((code & 0x01) ^ ((code & 0x02) >> 1)) << 7;
158 code = (code >> 1) | msb;
163 /* place all pnp cards in wait-for-key state */
164 static void isapnp_wait(void)
166 isapnp_write_byte(0x02, 0x02);
169 static void isapnp_wake(unsigned char csn)
171 isapnp_write_byte(0x03, csn);
174 static void isapnp_device(unsigned char logdev)
176 isapnp_write_byte(0x07, logdev);
179 static void isapnp_activate(unsigned char logdev)
181 isapnp_device(logdev);
182 isapnp_write_byte(ISAPNP_CFG_ACTIVATE, 1);
186 static void isapnp_deactivate(unsigned char logdev)
188 isapnp_device(logdev);
189 isapnp_write_byte(ISAPNP_CFG_ACTIVATE, 0);
193 static void __init isapnp_peek(unsigned char *data, int bytes)
198 for (i = 1; i <= bytes; i++) {
199 for (j = 0; j < 20; j++) {
200 d = isapnp_read_byte(0x05);
210 d = isapnp_read_byte(0x04); /* PRESDI */
211 isapnp_checksum_value += d;
217 #define RDP_STEP 32 /* minimum is 4 */
219 static int isapnp_next_rdp(void)
221 int rdp = isapnp_rdp;
222 static int old_rdp = 0;
225 release_region(old_rdp, 1);
228 while (rdp <= 0x3ff) {
230 * We cannot use NE2000 probe spaces for ISAPnP or we
231 * will lock up machines.
233 if ((rdp < 0x280 || rdp > 0x380)
234 && request_region(rdp, 1, "ISAPnP")) {
244 /* Set read port address */
245 static inline void isapnp_set_rdp(void)
247 isapnp_write_byte(0x00, isapnp_rdp >> 2);
252 * Perform an isolation. The port selection code now tries to avoid
253 * "dangerous to read" ports.
255 static int __init isapnp_isolate_rdp_select(void)
260 /* Control: reset CSN and conditionally everything else too */
261 isapnp_write_byte(0x02, isapnp_reset ? 0x05 : 0x04);
268 if (isapnp_next_rdp() < 0) {
281 * Isolate (assign uniqued CSN) to all ISA PnP devices.
283 static int __init isapnp_isolate(void)
285 unsigned char checksum = 0x6a;
286 unsigned char chksum = 0x00;
287 unsigned char bit = 0x00;
294 if (isapnp_isolate_rdp_select() < 0)
298 for (i = 1; i <= 64; i++) {
299 data = read_data() << 8;
301 data = data | read_data();
306 ((((checksum ^ (checksum >> 1)) & 0x01) ^ bit) << 7)
310 for (i = 65; i <= 72; i++) {
311 data = read_data() << 8;
313 data = data | read_data();
316 chksum |= (1 << (i - 65));
318 if (checksum != 0x00 && checksum == chksum) {
321 isapnp_write_byte(0x06, csn);
331 if (iteration == 1) {
332 isapnp_rdp += RDP_STEP;
333 if (isapnp_isolate_rdp_select() < 0)
335 } else if (iteration > 1) {
346 isapnp_csn_count = csn;
351 * Read one tag from stream.
353 static int __init isapnp_read_tag(unsigned char *type, unsigned short *size)
355 unsigned char tag, tmp[2];
357 isapnp_peek(&tag, 1);
358 if (tag == 0) /* invalid tag */
360 if (tag & 0x80) { /* large item */
363 *size = (tmp[1] << 8) | tmp[0];
365 *type = (tag >> 3) & 0x0f;
369 printk(KERN_DEBUG "tag = 0x%x, type = 0x%x, size = %i\n", tag, *type,
372 if (*type == 0xff && *size == 0xffff) /* probably invalid data */
378 * Skip specified number of bytes from stream.
380 static void __init isapnp_skip_bytes(int count)
382 isapnp_peek(NULL, count);
388 static void isapnp_parse_id(struct pnp_dev *dev, unsigned short vendor,
389 unsigned short device)
395 id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
398 sprintf(id->id, "%c%c%c%x%x%x%x",
399 'A' + ((vendor >> 2) & 0x3f) - 1,
400 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1,
401 'A' + ((vendor >> 8) & 0x1f) - 1,
402 (device >> 4) & 0x0f,
403 device & 0x0f, (device >> 12) & 0x0f, (device >> 8) & 0x0f);
408 * Parse logical device tag.
410 static struct pnp_dev *__init isapnp_parse_device(struct pnp_card *card,
411 int size, int number)
413 unsigned char tmp[6];
416 isapnp_peek(tmp, size);
417 dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL);
420 dev->number = number;
421 isapnp_parse_id(dev, (tmp[1] << 8) | tmp[0], (tmp[3] << 8) | tmp[2]);
425 dev->regs |= tmp[5] << 8;
426 dev->protocol = &isapnp_protocol;
427 dev->capabilities |= PNP_CONFIGURABLE;
428 dev->capabilities |= PNP_READ;
429 dev->capabilities |= PNP_WRITE;
430 dev->capabilities |= PNP_DISABLE;
431 pnp_init_resource_table(&dev->res);
436 * Add IRQ resource to resources list.
438 static void __init isapnp_parse_irq_resource(struct pnp_option *option,
441 unsigned char tmp[3];
445 isapnp_peek(tmp, size);
446 irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL);
449 bits = (tmp[1] << 8) | tmp[0];
450 bitmap_copy(irq->map, &bits, 16);
454 irq->flags = IORESOURCE_IRQ_HIGHEDGE;
455 pnp_register_irq_resource(option, irq);
459 * Add DMA resource to resources list.
461 static void __init isapnp_parse_dma_resource(struct pnp_option *option,
464 unsigned char tmp[2];
467 isapnp_peek(tmp, size);
468 dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL);
473 pnp_register_dma_resource(option, dma);
477 * Add port resource to resources list.
479 static void __init isapnp_parse_port_resource(struct pnp_option *option,
482 unsigned char tmp[7];
483 struct pnp_port *port;
485 isapnp_peek(tmp, size);
486 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
489 port->min = (tmp[2] << 8) | tmp[1];
490 port->max = (tmp[4] << 8) | tmp[3];
491 port->align = tmp[5];
493 port->flags = tmp[0] ? PNP_PORT_FLAG_16BITADDR : 0;
494 pnp_register_port_resource(option, port);
498 * Add fixed port resource to resources list.
500 static void __init isapnp_parse_fixed_port_resource(struct pnp_option *option,
503 unsigned char tmp[3];
504 struct pnp_port *port;
506 isapnp_peek(tmp, size);
507 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
510 port->min = port->max = (tmp[1] << 8) | tmp[0];
513 port->flags = PNP_PORT_FLAG_FIXED;
514 pnp_register_port_resource(option, port);
518 * Add memory resource to resources list.
520 static void __init isapnp_parse_mem_resource(struct pnp_option *option,
523 unsigned char tmp[9];
526 isapnp_peek(tmp, size);
527 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
530 mem->min = ((tmp[2] << 8) | tmp[1]) << 8;
531 mem->max = ((tmp[4] << 8) | tmp[3]) << 8;
532 mem->align = (tmp[6] << 8) | tmp[5];
533 mem->size = ((tmp[8] << 8) | tmp[7]) << 8;
535 pnp_register_mem_resource(option, mem);
539 * Add 32-bit memory resource to resources list.
541 static void __init isapnp_parse_mem32_resource(struct pnp_option *option,
544 unsigned char tmp[17];
547 isapnp_peek(tmp, size);
548 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
551 mem->min = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1];
552 mem->max = (tmp[8] << 24) | (tmp[7] << 16) | (tmp[6] << 8) | tmp[5];
554 (tmp[12] << 24) | (tmp[11] << 16) | (tmp[10] << 8) | tmp[9];
556 (tmp[16] << 24) | (tmp[15] << 16) | (tmp[14] << 8) | tmp[13];
558 pnp_register_mem_resource(option, mem);
562 * Add 32-bit fixed memory resource to resources list.
564 static void __init isapnp_parse_fixed_mem32_resource(struct pnp_option *option,
567 unsigned char tmp[9];
570 isapnp_peek(tmp, size);
571 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
574 mem->min = mem->max =
575 (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1];
576 mem->size = (tmp[8] << 24) | (tmp[7] << 16) | (tmp[6] << 8) | tmp[5];
579 pnp_register_mem_resource(option, mem);
583 * Parse card name for ISA PnP device.
586 isapnp_parse_name(char *name, unsigned int name_max, unsigned short *size)
588 if (name[0] == '\0') {
589 unsigned short size1 =
590 *size >= name_max ? (name_max - 1) : *size;
591 isapnp_peek(name, size1);
595 /* clean whitespace from end of string */
596 while (size1 > 0 && name[--size1] == ' ')
602 * Parse resource map for logical device.
604 static int __init isapnp_create_device(struct pnp_card *card,
607 int number = 0, skip = 0, priority = 0, compat = 0;
608 unsigned char type, tmp[17];
609 struct pnp_option *option;
612 if ((dev = isapnp_parse_device(card, size, number++)) == NULL)
614 option = pnp_register_independent_option(dev);
619 pnp_add_card_device(card, dev);
622 if (isapnp_read_tag(&type, &size) < 0)
624 if (skip && type != _STAG_LOGDEVID && type != _STAG_END)
628 if (size >= 5 && size <= 6) {
630 isapnp_parse_device(card, size,
635 option = pnp_register_independent_option(dev);
640 pnp_add_card_device(card, dev);
647 case _STAG_COMPATDEVID:
648 if (size == 4 && compat < DEVICE_COUNT_COMPATIBLE) {
650 isapnp_parse_id(dev, (tmp[1] << 8) | tmp[0],
651 (tmp[3] << 8) | tmp[2]);
657 if (size < 2 || size > 3)
659 isapnp_parse_irq_resource(option, size);
665 isapnp_parse_dma_resource(option, size);
671 priority = 0x100 | PNP_RES_PRIORITY_ACCEPTABLE;
673 isapnp_peek(tmp, size);
674 priority = 0x100 | tmp[0];
677 option = pnp_register_dependent_option(dev, priority);
689 isapnp_parse_port_resource(option, size);
695 isapnp_parse_fixed_port_resource(option, size);
703 isapnp_parse_mem_resource(option, size);
707 isapnp_parse_name(dev->name, sizeof(dev->name), &size);
709 case _LTAG_UNICODESTR:
710 /* silently ignore */
711 /* who use unicode for hardware identification? */
715 case _LTAG_MEM32RANGE:
718 isapnp_parse_mem32_resource(option, size);
721 case _LTAG_FIXEDMEM32RANGE:
724 isapnp_parse_fixed_mem32_resource(option, size);
729 isapnp_skip_bytes(size);
733 "isapnp: unexpected or unknown tag type 0x%x for logical device %i (device %i), ignored\n",
734 type, dev->number, card->number);
738 isapnp_skip_bytes(size);
744 * Parse resource map for ISA PnP card.
746 static void __init isapnp_parse_resource_map(struct pnp_card *card)
748 unsigned char type, tmp[17];
752 if (isapnp_read_tag(&type, &size) < 0)
759 card->pnpver = tmp[0];
760 card->productver = tmp[1];
764 if (size >= 5 && size <= 6) {
765 if (isapnp_create_device(card, size) == 1)
773 isapnp_parse_name(card->name, sizeof(card->name),
776 case _LTAG_UNICODESTR:
777 /* silently ignore */
778 /* who use unicode for hardware identification? */
784 isapnp_skip_bytes(size);
788 "isapnp: unexpected or unknown tag type 0x%x for device %i, ignored\n",
793 isapnp_skip_bytes(size);
798 * Compute ISA PnP checksum for first eight bytes.
800 static unsigned char __init isapnp_checksum(unsigned char *data)
803 unsigned char checksum = 0x6a, bit, b;
805 for (i = 0; i < 8; i++) {
807 for (j = 0; j < 8; j++) {
812 ((((checksum ^ (checksum >> 1)) & 0x01) ^ bit) << 7)
820 * Parse EISA id for ISA PnP card.
822 static void isapnp_parse_card_id(struct pnp_card *card, unsigned short vendor,
823 unsigned short device)
825 struct pnp_id *id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
829 sprintf(id->id, "%c%c%c%x%x%x%x",
830 'A' + ((vendor >> 2) & 0x3f) - 1,
831 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1,
832 'A' + ((vendor >> 8) & 0x1f) - 1,
833 (device >> 4) & 0x0f,
834 device & 0x0f, (device >> 12) & 0x0f, (device >> 8) & 0x0f);
835 pnp_add_card_id(id, card);
839 * Build device list for all present ISA PnP devices.
841 static int __init isapnp_build_device_list(void)
844 unsigned char header[9], checksum;
845 struct pnp_card *card;
849 for (csn = 1; csn <= isapnp_csn_count; csn++) {
851 isapnp_peek(header, 9);
852 checksum = isapnp_checksum(header);
855 "vendor: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
856 header[0], header[1], header[2], header[3], header[4],
857 header[5], header[6], header[7], header[8]);
858 printk(KERN_DEBUG "checksum = 0x%x\n", checksum);
861 kzalloc(sizeof(struct pnp_card), GFP_KERNEL)) == NULL)
865 INIT_LIST_HEAD(&card->devices);
866 isapnp_parse_card_id(card, (header[1] << 8) | header[0],
867 (header[3] << 8) | header[2]);
869 (header[7] << 24) | (header[6] << 16) | (header[5] << 8) |
871 isapnp_checksum_value = 0x00;
872 isapnp_parse_resource_map(card);
873 if (isapnp_checksum_value != 0x00)
875 "isapnp: checksum for device %i is not valid (0x%x)\n",
876 csn, isapnp_checksum_value);
877 card->checksum = isapnp_checksum_value;
878 card->protocol = &isapnp_protocol;
887 * Basic configuration routines.
890 int isapnp_present(void)
892 struct pnp_card *card;
894 pnp_for_each_card(card) {
895 if (card->protocol == &isapnp_protocol)
901 int isapnp_cfg_begin(int csn, int logdev)
903 if (csn < 1 || csn > isapnp_csn_count || logdev > 10)
905 mutex_lock(&isapnp_cfg_mutex);
910 /* to avoid malfunction when the isapnptools package is used */
911 /* we must set RDP to our value again */
912 /* it is possible to set RDP only in the isolation phase */
913 /* Jens Thoms Toerring <Jens.Toerring@physik.fu-berlin.de> */
914 isapnp_write_byte(0x02, 0x04); /* clear CSN of card */
915 mdelay(2); /* is this necessary? */
916 isapnp_wake(csn); /* bring card into sleep state */
917 isapnp_wake(0); /* bring card into isolation state */
918 isapnp_set_rdp(); /* reset the RDP port */
919 udelay(1000); /* delay 1000us */
920 isapnp_write_byte(0x06, csn); /* reset CSN to previous value */
921 udelay(250); /* is this necessary? */
924 isapnp_device(logdev);
928 int isapnp_cfg_end(void)
931 mutex_unlock(&isapnp_cfg_mutex);
939 EXPORT_SYMBOL(isapnp_protocol);
940 EXPORT_SYMBOL(isapnp_present);
941 EXPORT_SYMBOL(isapnp_cfg_begin);
942 EXPORT_SYMBOL(isapnp_cfg_end);
944 EXPORT_SYMBOL(isapnp_read_byte);
946 EXPORT_SYMBOL(isapnp_write_byte);
948 static int isapnp_read_resources(struct pnp_dev *dev,
949 struct pnp_resource_table *res)
953 dev->active = isapnp_read_byte(ISAPNP_CFG_ACTIVATE);
955 for (tmp = 0; tmp < PNP_MAX_PORT; tmp++) {
956 ret = isapnp_read_word(ISAPNP_CFG_PORT + (tmp << 1));
959 res->port_resource[tmp].start = ret;
960 res->port_resource[tmp].flags = IORESOURCE_IO;
962 for (tmp = 0; tmp < PNP_MAX_MEM; tmp++) {
964 isapnp_read_word(ISAPNP_CFG_MEM + (tmp << 3)) << 8;
967 res->mem_resource[tmp].start = ret;
968 res->mem_resource[tmp].flags = IORESOURCE_MEM;
970 for (tmp = 0; tmp < PNP_MAX_IRQ; tmp++) {
972 (isapnp_read_word(ISAPNP_CFG_IRQ + (tmp << 1)) >>
976 res->irq_resource[tmp].start =
977 res->irq_resource[tmp].end = ret;
978 res->irq_resource[tmp].flags = IORESOURCE_IRQ;
980 for (tmp = 0; tmp < PNP_MAX_DMA; tmp++) {
981 ret = isapnp_read_byte(ISAPNP_CFG_DMA + tmp);
984 res->dma_resource[tmp].start =
985 res->dma_resource[tmp].end = ret;
986 res->dma_resource[tmp].flags = IORESOURCE_DMA;
992 static int isapnp_get_resources(struct pnp_dev *dev,
993 struct pnp_resource_table *res)
996 pnp_init_resource_table(res);
997 isapnp_cfg_begin(dev->card->number, dev->number);
998 ret = isapnp_read_resources(dev, res);
1003 static int isapnp_set_resources(struct pnp_dev *dev,
1004 struct pnp_resource_table *res)
1008 isapnp_cfg_begin(dev->card->number, dev->number);
1012 && (res->port_resource[tmp].
1013 flags & (IORESOURCE_IO | IORESOURCE_UNSET)) == IORESOURCE_IO;
1015 isapnp_write_word(ISAPNP_CFG_PORT + (tmp << 1),
1016 res->port_resource[tmp].start);
1019 && (res->irq_resource[tmp].
1020 flags & (IORESOURCE_IRQ | IORESOURCE_UNSET)) == IORESOURCE_IRQ;
1022 int irq = res->irq_resource[tmp].start;
1025 isapnp_write_byte(ISAPNP_CFG_IRQ + (tmp << 1), irq);
1029 && (res->dma_resource[tmp].
1030 flags & (IORESOURCE_DMA | IORESOURCE_UNSET)) == IORESOURCE_DMA;
1032 isapnp_write_byte(ISAPNP_CFG_DMA + tmp,
1033 res->dma_resource[tmp].start);
1036 && (res->mem_resource[tmp].
1037 flags & (IORESOURCE_MEM | IORESOURCE_UNSET)) == IORESOURCE_MEM;
1039 isapnp_write_word(ISAPNP_CFG_MEM + (tmp << 3),
1040 (res->mem_resource[tmp].start >> 8) & 0xffff);
1041 /* FIXME: We aren't handling 32bit mems properly here */
1042 isapnp_activate(dev->number);
1047 static int isapnp_disable_resources(struct pnp_dev *dev)
1049 if (!dev || !dev->active)
1051 isapnp_cfg_begin(dev->card->number, dev->number);
1052 isapnp_deactivate(dev->number);
1058 struct pnp_protocol isapnp_protocol = {
1059 .name = "ISA Plug and Play",
1060 .get = isapnp_get_resources,
1061 .set = isapnp_set_resources,
1062 .disable = isapnp_disable_resources,
1065 static int __init isapnp_init(void)
1068 struct pnp_card *card;
1069 struct pnp_dev *dev;
1071 if (isapnp_disable) {
1072 isapnp_detected = 0;
1073 printk(KERN_INFO "isapnp: ISA Plug & Play support disabled\n");
1076 #ifdef CONFIG_PPC_MERGE
1077 if (check_legacy_ioport(_PIDXR) || check_legacy_ioport(_PNPWRP))
1080 #ifdef ISAPNP_REGION_OK
1081 if (!request_region(_PIDXR, 1, "isapnp index")) {
1082 printk(KERN_ERR "isapnp: Index Register 0x%x already used\n",
1087 if (!request_region(_PNPWRP, 1, "isapnp write")) {
1089 "isapnp: Write Data Register 0x%x already used\n",
1091 #ifdef ISAPNP_REGION_OK
1092 release_region(_PIDXR, 1);
1097 if (pnp_register_protocol(&isapnp_protocol) < 0)
1101 * Print a message. The existing ISAPnP code is hanging machines
1102 * so let the user know where.
1105 printk(KERN_INFO "isapnp: Scanning for PnP cards...\n");
1106 if (isapnp_rdp >= 0x203 && isapnp_rdp <= 0x3ff) {
1108 if (!request_region(isapnp_rdp, 1, "isapnp read")) {
1110 "isapnp: Read Data Register 0x%x already used\n",
1112 #ifdef ISAPNP_REGION_OK
1113 release_region(_PIDXR, 1);
1115 release_region(_PNPWRP, 1);
1120 isapnp_detected = 1;
1121 if (isapnp_rdp < 0x203 || isapnp_rdp > 0x3ff) {
1122 cards = isapnp_isolate();
1123 if (cards < 0 || (isapnp_rdp < 0x203 || isapnp_rdp > 0x3ff)) {
1124 #ifdef ISAPNP_REGION_OK
1125 release_region(_PIDXR, 1);
1127 release_region(_PNPWRP, 1);
1128 isapnp_detected = 0;
1130 "isapnp: No Plug & Play device found\n");
1133 request_region(isapnp_rdp, 1, "isapnp read");
1135 isapnp_build_device_list();
1138 protocol_for_each_card(&isapnp_protocol, card) {
1140 if (isapnp_verbose) {
1141 printk(KERN_INFO "isapnp: Card '%s'\n",
1142 card->name[0] ? card->name : "Unknown");
1143 if (isapnp_verbose < 2)
1145 card_for_each_dev(card, dev) {
1146 printk(KERN_INFO "isapnp: Device '%s'\n",
1147 dev->name[0] ? dev->name : "Unknown");
1153 "isapnp: %i Plug & Play card%s detected total\n", cards,
1154 cards > 1 ? "s" : "");
1156 printk(KERN_INFO "isapnp: No Plug & Play card found\n");
1163 device_initcall(isapnp_init);
1165 /* format is: noisapnp */
1167 static int __init isapnp_setup_disable(char *str)
1173 __setup("noisapnp", isapnp_setup_disable);
1175 /* format is: isapnp=rdp,reset,skip_pci_scan,verbose */
1177 static int __init isapnp_setup_isapnp(char *str)
1179 (void)((get_option(&str, &isapnp_rdp) == 2) &&
1180 (get_option(&str, &isapnp_reset) == 2) &&
1181 (get_option(&str, &isapnp_verbose) == 2));
1185 __setup("isapnp=", isapnp_setup_isapnp);