10 #include <linux/module.h>
11 #include <linux/slab.h>
12 #include <linux/errno.h>
14 #include <linux/kernel.h>
18 #include <linux/pci.h>
25 static int pnp_reserve_irq[16] = {[0 ... 15] = -1 };
26 static int pnp_reserve_dma[8] = {[0 ... 7] = -1 };
27 static int pnp_reserve_io[16] = {[0 ... 15] = -1 };
28 static int pnp_reserve_mem[16] = {[0 ... 15] = -1 };
35 unsigned int option_flags)
43 option->
flags = option_flags;
68 for (i = 0; i < 16; i++)
79 unsigned char map,
unsigned char flags)
108 port = &option->
u.
port;
131 mem = &option->
u.
mem;
156 #define length(start, end) (*(end) - *(start) + 1)
159 #define ranged_conflict(starta, enda, startb, endb) \
160 !((*(enda) < *(startb)) || (*(endb) < *(starta)))
162 #define cannot_compare(flags) \
163 ((flags) & IORESOURCE_DISABLED)
187 for (i = 0; i < 8; i++) {
188 int rport = pnp_reserve_io[i << 1];
189 int rend = pnp_reserve_io[(i << 1) + 1] + rport - 1;
197 tport = &tres->
start;
216 tport = &tres->
start;
249 for (i = 0; i < 8; i++) {
250 int raddr = pnp_reserve_mem[i << 1];
251 int rend = pnp_reserve_mem[(i << 1) + 1] + raddr - 1;
259 taddr = &tres->
start;
278 taddr = &tres->
start;
295 static int pci_dev_uses_irq(
struct pnp_dev *pnp,
struct pci_dev *pci,
301 if (pci->
irq == irq) {
302 pnp_dbg(&pnp->
dev,
" device %s using irq %d\n",
313 progif =
class & 0xff;
321 if ((progif & 0x5) != 0x5)
322 if (pci_get_legacy_ide_irq(pci, 0) == irq ||
323 pci_get_legacy_ide_irq(pci, 1) == irq) {
325 "using irq %d\n", pci_name(pci), irq);
334 static int pci_uses_irq(
struct pnp_dev *pnp,
unsigned int irq)
340 if (pci_dev_uses_irq(pnp, pci, irq)) {
363 if (*irq < 0 || *irq > 15)
367 for (i = 0; i < 16; i++) {
368 if (pnp_reserve_irq[i] == *irq)
375 if (tres->
start == *irq)
381 if (pci_uses_irq(dev, *irq))
403 if (tres->
start == *irq)
412 #ifdef CONFIG_ISA_DMA_API
427 if (*dma < 0 || *dma == 4 || *dma > 7)
431 for (i = 0; i < 8; i++) {
432 if (pnp_reserve_dma[i] == *dma)
439 if (tres->
start == *dma)
462 if (tres->
start == *dma)
480 unsigned long type,
unsigned int num)
512 pnp_res = pnp_new_resource(dev);
514 dev_err(&dev->
dev,
"can't add resource for IRQ %d\n", irq);
533 pnp_res = pnp_new_resource(dev);
535 dev_err(&dev->
dev,
"can't add resource for DMA %d\n", dma);
555 pnp_res = pnp_new_resource(dev);
557 dev_err(&dev->
dev,
"can't add resource for IO %#llx-%#llx\n",
558 (
unsigned long long) start,
559 (
unsigned long long) end);
579 pnp_res = pnp_new_resource(dev);
581 dev_err(&dev->
dev,
"can't add resource for MEM %#llx-%#llx\n",
582 (
unsigned long long) start,
583 (
unsigned long long) end);
603 pnp_res = pnp_new_resource(dev);
605 dev_err(&dev->
dev,
"can't add resource for BUS %#llx-%#llx\n",
606 (
unsigned long long) start,
607 (
unsigned long long) end);
634 if (option->
type != type)
637 switch (option->
type) {
639 port = &option->
u.
port;
640 if (port->
min == start && port->
size == size)
644 mem = &option->
u.
mem;
645 if (mem->
min == start && mem->
size == size)
649 irq = &option->
u.
irq;
655 dma = &option->
u.
dma;
656 if (dma->
map & (1 << start))
674 dev_start = &pnp_res->
res.start;
675 dev_end = &pnp_res->
res.end;
685 static int __init pnp_setup_reserve_irq(
char *
str)
689 for (i = 0; i < 16; i++)
690 if (
get_option(&str, &pnp_reserve_irq[i]) != 2)
695 __setup(
"pnp_reserve_irq=", pnp_setup_reserve_irq);
698 static int __init pnp_setup_reserve_dma(
char *str)
702 for (i = 0; i < 8; i++)
703 if (
get_option(&str, &pnp_reserve_dma[i]) != 2)
708 __setup(
"pnp_reserve_dma=", pnp_setup_reserve_dma);
711 static int __init pnp_setup_reserve_io(
char *str)
715 for (i = 0; i < 16; i++)
716 if (
get_option(&str, &pnp_reserve_io[i]) != 2)
721 __setup(
"pnp_reserve_io=", pnp_setup_reserve_io);
724 static int __init pnp_setup_reserve_mem(
char *str)
728 for (i = 0; i < 16; i++)
729 if (
get_option(&str, &pnp_reserve_mem[i]) != 2)
734 __setup(
"pnp_reserve_mem=", pnp_setup_reserve_mem);