cmd64x: don't clear the other channel's interrupt
[linux-2.6/linux-mips/linux-dm7025.git] / drivers / pnp / system.c
blob55c4563986b38aebc36b158eb7c9a649d7105d5c
1 /*
2 * system.c - a driver for reserving pnp system resources
4 * Some code is based on pnpbios_core.c
5 * Copyright 2002 Adam Belay <ambx1@neo.rr.com>
6 * (c) Copyright 2007 Hewlett-Packard Development Company, L.P.
7 * Bjorn Helgaas <bjorn.helgaas@hp.com>
8 */
10 #include <linux/pnp.h>
11 #include <linux/device.h>
12 #include <linux/init.h>
13 #include <linux/slab.h>
14 #include <linux/kernel.h>
15 #include <linux/ioport.h>
17 static const struct pnp_device_id pnp_dev_table[] = {
18 /* General ID for reserving resources */
19 {"PNP0c02", 0},
20 /* memory controller */
21 {"PNP0c01", 0},
22 {"", 0}
25 static void reserve_range(struct pnp_dev *dev, resource_size_t start,
26 resource_size_t end, int port)
28 char *regionid;
29 const char *pnpid = dev->dev.bus_id;
30 struct resource *res;
32 regionid = kmalloc(16, GFP_KERNEL);
33 if (!regionid)
34 return;
36 snprintf(regionid, 16, "pnp %s", pnpid);
37 if (port)
38 res = request_region(start, end - start + 1, regionid);
39 else
40 res = request_mem_region(start, end - start + 1, regionid);
41 if (res)
42 res->flags &= ~IORESOURCE_BUSY;
43 else
44 kfree(regionid);
47 * Failures at this point are usually harmless. pci quirks for
48 * example do reserve stuff they know about too, so we may well
49 * have double reservations.
51 dev_info(&dev->dev, "%s range 0x%llx-0x%llx %s reserved\n",
52 port ? "ioport" : "iomem",
53 (unsigned long long) start, (unsigned long long) end,
54 res ? "has been" : "could not be");
57 static void reserve_resources_of_dev(struct pnp_dev *dev)
59 int i;
61 for (i = 0; i < PNP_MAX_PORT; i++) {
62 if (!pnp_port_valid(dev, i))
63 continue;
64 if (pnp_port_start(dev, i) == 0)
65 continue; /* disabled */
66 if (pnp_port_start(dev, i) < 0x100)
68 * Below 0x100 is only standard PC hardware
69 * (pics, kbd, timer, dma, ...)
70 * We should not get resource conflicts there,
71 * and the kernel reserves these anyway
72 * (see arch/i386/kernel/setup.c).
73 * So, do nothing
75 continue;
76 if (pnp_port_end(dev, i) < pnp_port_start(dev, i))
77 continue; /* invalid */
79 reserve_range(dev, pnp_port_start(dev, i),
80 pnp_port_end(dev, i), 1);
83 for (i = 0; i < PNP_MAX_MEM; i++) {
84 if (!pnp_mem_valid(dev, i))
85 continue;
87 reserve_range(dev, pnp_mem_start(dev, i),
88 pnp_mem_end(dev, i), 0);
92 static int system_pnp_probe(struct pnp_dev *dev,
93 const struct pnp_device_id *dev_id)
95 reserve_resources_of_dev(dev);
96 return 0;
99 static struct pnp_driver system_pnp_driver = {
100 .name = "system",
101 .id_table = pnp_dev_table,
102 .flags = PNP_DRIVER_RES_DO_NOT_CHANGE,
103 .probe = system_pnp_probe,
106 static int __init pnp_system_init(void)
108 return pnp_register_driver(&system_pnp_driver);
112 * Reserve motherboard resources after PCI claim BARs,
113 * but before PCI assign resources for uninitialized PCI devices
115 fs_initcall(pnp_system_init);