aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2007-02-03 01:38:16 -0500
committerLen Brown <len.brown@intel.com>2007-02-03 01:38:16 -0500
commiteee3c859c486d4f110f154807430eaf825ff4a3d (patch)
tree8b378d16103b3d77a673e26fab0a6812459bab77
parent547352660506ab99d6b0bad58dea495bf3718cee (diff)
parentfb5c3e1b6d304bcf5f8d697471e36f2fa8d53f1c (diff)
Pull motherboard into test branch
Conflicts: drivers/acpi/motherboard.c Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--arch/i386/defconfig3
-rw-r--r--drivers/acpi/Makefile2
-rw-r--r--drivers/acpi/motherboard.c180
-rw-r--r--drivers/acpi/osl.c48
-rw-r--r--drivers/pnp/pnpacpi/Kconfig4
-rw-r--r--drivers/pnp/system.c52
6 files changed, 80 insertions, 209 deletions
diff --git a/arch/i386/defconfig b/arch/i386/defconfig
index 5d80edfc61b7..bb0c376b62b3 100644
--- a/arch/i386/defconfig
+++ b/arch/i386/defconfig
@@ -466,7 +466,8 @@ CONFIG_FW_LOADER=y
466# 466#
467# Plug and Play support 467# Plug and Play support
468# 468#
469# CONFIG_PNP is not set 469CONFIG_PNP=y
470CONFIG_PNPACPI=y
470 471
471# 472#
472# Block devices 473# Block devices
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 399b0e8c41c4..856c32bccacb 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -37,7 +37,7 @@ endif
37 37
38obj-y += sleep/ 38obj-y += sleep/
39obj-y += bus.o glue.o 39obj-y += bus.o glue.o
40obj-y += scan.o motherboard.o 40obj-y += scan.o
41obj-$(CONFIG_ACPI_AC) += ac.o 41obj-$(CONFIG_ACPI_AC) += ac.o
42obj-$(CONFIG_ACPI_BATTERY) += battery.o 42obj-$(CONFIG_ACPI_BATTERY) += battery.o
43obj-$(CONFIG_ACPI_BUTTON) += button.o 43obj-$(CONFIG_ACPI_BUTTON) += button.o
diff --git a/drivers/acpi/motherboard.c b/drivers/acpi/motherboard.c
deleted file mode 100644
index 8f13b4f3e906..000000000000
--- a/drivers/acpi/motherboard.c
+++ /dev/null
@@ -1,180 +0,0 @@
1/*
2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or (at
6 * your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
16 *
17 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 */
19
20/* Purpose: Prevent PCMCIA cards from using motherboard resources. */
21
22#include <linux/kernel.h>
23#include <linux/init.h>
24#include <linux/types.h>
25#include <linux/pci.h>
26#include <linux/ioport.h>
27#include <asm/io.h>
28
29#include <acpi/acpi_bus.h>
30#include <acpi/acpi_drivers.h>
31
32#define _COMPONENT ACPI_SYSTEM_COMPONENT
33ACPI_MODULE_NAME("acpi_motherboard")
34
35/* Dell use PNP0C01 instead of PNP0C02 */
36#define ACPI_MB_HID "PNP0C01,PNP0C02"
37/**
38 * Doesn't care about legacy IO ports, only IO ports beyond 0x1000 are reserved
39 * Doesn't care about the failure of 'request_region', since other may reserve
40 * the io ports as well
41 */
42#define IS_RESERVED_ADDR(base, len) \
43 (((len) > 0) && ((base) > 0) && ((base) + (len) < IO_SPACE_LIMIT) \
44 && ((base) + (len) > PCIBIOS_MIN_IO))
45/*
46 * Clearing the flag (IORESOURCE_BUSY) allows drivers to use
47 * the io ports if they really know they can use it, while
48 * still preventing hotplug PCI devices from using it.
49 */
50
51/*
52 * When CONFIG_PNP is enabled, pnp/system.c binds to PNP0C01
53 * and PNP0C02, redundant with acpi_reserve_io_ranges().
54 * But acpi_reserve_io_ranges() is necessary for !CONFIG_PNP.
55 */
56static acpi_status acpi_reserve_io_ranges(struct acpi_resource *res, void *data)
57{
58 struct resource *requested_res = NULL;
59
60
61 if (res->type == ACPI_RESOURCE_TYPE_IO) {
62 struct acpi_resource_io *io_res = &res->data.io;
63
64 if (io_res->minimum != io_res->maximum)
65 return AE_OK;
66 if (IS_RESERVED_ADDR
67 (io_res->minimum, io_res->address_length)) {
68 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
69 "Motherboard resources 0x%08x - 0x%08x\n",
70 io_res->minimum,
71 io_res->minimum +
72 io_res->address_length));
73 requested_res =
74 request_region(io_res->minimum,
75 io_res->address_length, "motherboard");
76 }
77 } else if (res->type == ACPI_RESOURCE_TYPE_FIXED_IO) {
78 struct acpi_resource_fixed_io *fixed_io_res =
79 &res->data.fixed_io;
80
81 if (IS_RESERVED_ADDR
82 (fixed_io_res->address, fixed_io_res->address_length)) {
83 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
84 "Motherboard resources 0x%08x - 0x%08x\n",
85 fixed_io_res->address,
86 fixed_io_res->address +
87 fixed_io_res->address_length));
88 requested_res =
89 request_region(fixed_io_res->address,
90 fixed_io_res->address_length,
91 "motherboard");
92 }
93 } else {
94 /* Memory mapped IO? */
95 }
96
97 if (requested_res)
98 requested_res->flags &= ~IORESOURCE_BUSY;
99 return AE_OK;
100}
101
102static int acpi_motherboard_add(struct acpi_device *device)
103{
104 if (!device)
105 return -EINVAL;
106 acpi_walk_resources(device->handle, METHOD_NAME__CRS,
107 acpi_reserve_io_ranges, NULL);
108
109 return 0;
110}
111
112static struct acpi_driver acpi_motherboard_driver = {
113 .name = "motherboard",
114 .class = "",
115 .ids = ACPI_MB_HID,
116 .ops = {
117 .add = acpi_motherboard_add,
118 },
119};
120
121static void __init acpi_request_region (struct acpi_generic_address *addr,
122 unsigned int length, char *desc)
123{
124 if (!addr->address || !length)
125 return;
126
127 if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_IO)
128 request_region(addr->address, length, desc);
129 else if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
130 request_mem_region(addr->address, length, desc);
131}
132
133static void __init acpi_reserve_resources(void)
134{
135 acpi_request_region(&acpi_gbl_FADT.xpm1a_event_block,
136 acpi_gbl_FADT.pm1_event_length, "ACPI PM1a_EVT_BLK");
137
138 acpi_request_region(&acpi_gbl_FADT.xpm1b_event_block,
139 acpi_gbl_FADT.pm1_event_length, "ACPI PM1b_EVT_BLK");
140
141 acpi_request_region(&acpi_gbl_FADT.xpm1a_control_block,
142 acpi_gbl_FADT.pm1_control_length, "ACPI PM1a_CNT_BLK");
143
144 acpi_request_region(&acpi_gbl_FADT.xpm1b_control_block,
145 acpi_gbl_FADT.pm1_control_length, "ACPI PM1b_CNT_BLK");
146
147 if (acpi_gbl_FADT.pm_timer_length == 4)
148 acpi_request_region(&acpi_gbl_FADT.xpm_timer_block, 4, "ACPI PM_TMR");
149
150 acpi_request_region(&acpi_gbl_FADT.xpm2_control_block,
151 acpi_gbl_FADT.pm2_control_length, "ACPI PM2_CNT_BLK");
152
153 /* Length of GPE blocks must be a non-negative multiple of 2 */
154
155 if (!(acpi_gbl_FADT.gpe0_block_length & 0x1))
156 acpi_request_region(&acpi_gbl_FADT.xgpe0_block,
157 acpi_gbl_FADT.gpe0_block_length, "ACPI GPE0_BLK");
158
159 if (!(acpi_gbl_FADT.gpe1_block_length & 0x1))
160 acpi_request_region(&acpi_gbl_FADT.xgpe1_block,
161 acpi_gbl_FADT.gpe1_block_length, "ACPI GPE1_BLK");
162}
163
164static int __init acpi_motherboard_init(void)
165{
166 acpi_bus_register_driver(&acpi_motherboard_driver);
167 /*
168 * Guarantee motherboard IO reservation first
169 * This module must run after scan.c
170 */
171 if (!acpi_disabled)
172 acpi_reserve_resources();
173 return 0;
174}
175
176/**
177 * Reserve motherboard resources after PCI claim BARs,
178 * but before PCI assign resources for uninitialized PCI devices
179 */
180fs_initcall(acpi_motherboard_init);
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index a28f5b8972b4..0f6f3bcbc8eb 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -76,6 +76,54 @@ static acpi_osd_handler acpi_irq_handler;
76static void *acpi_irq_context; 76static void *acpi_irq_context;
77static struct workqueue_struct *kacpid_wq; 77static struct workqueue_struct *kacpid_wq;
78 78
79static void __init acpi_request_region (struct acpi_generic_address *addr,
80 unsigned int length, char *desc)
81{
82 struct resource *res;
83
84 if (!addr->address || !length)
85 return;
86
87 if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_IO)
88 res = request_region(addr->address, length, desc);
89 else if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
90 res = request_mem_region(addr->address, length, desc);
91}
92
93static int __init acpi_reserve_resources(void)
94{
95 acpi_request_region(&acpi_gbl_FADT.xpm1a_event_block, acpi_gbl_FADT.pm1_event_length,
96 "ACPI PM1a_EVT_BLK");
97
98 acpi_request_region(&acpi_gbl_FADT.xpm1b_event_block, acpi_gbl_FADT.pm1_event_length,
99 "ACPI PM1b_EVT_BLK");
100
101 acpi_request_region(&acpi_gbl_FADT.xpm1a_control_block, acpi_gbl_FADT.pm1_control_length,
102 "ACPI PM1a_CNT_BLK");
103
104 acpi_request_region(&acpi_gbl_FADT.xpm1b_control_block, acpi_gbl_FADT.pm1_control_length,
105 "ACPI PM1b_CNT_BLK");
106
107 if (acpi_gbl_FADT.pm_timer_length == 4)
108 acpi_request_region(&acpi_gbl_FADT.xpm_timer_block, 4, "ACPI PM_TMR");
109
110 acpi_request_region(&acpi_gbl_FADT.xpm2_control_block, acpi_gbl_FADT.pm2_control_length,
111 "ACPI PM2_CNT_BLK");
112
113 /* Length of GPE blocks must be a non-negative multiple of 2 */
114
115 if (!(acpi_gbl_FADT.gpe0_block_length & 0x1))
116 acpi_request_region(&acpi_gbl_FADT.xgpe0_block,
117 acpi_gbl_FADT.gpe0_block_length, "ACPI GPE0_BLK");
118
119 if (!(acpi_gbl_FADT.gpe1_block_length & 0x1))
120 acpi_request_region(&acpi_gbl_FADT.xgpe1_block,
121 acpi_gbl_FADT.gpe1_block_length, "ACPI GPE1_BLK");
122
123 return 0;
124}
125device_initcall(acpi_reserve_resources);
126
79acpi_status acpi_os_initialize(void) 127acpi_status acpi_os_initialize(void)
80{ 128{
81 return AE_OK; 129 return AE_OK;
diff --git a/drivers/pnp/pnpacpi/Kconfig b/drivers/pnp/pnpacpi/Kconfig
index b1854171b963..ad27e5e0101f 100644
--- a/drivers/pnp/pnpacpi/Kconfig
+++ b/drivers/pnp/pnpacpi/Kconfig
@@ -2,8 +2,8 @@
2# Plug and Play ACPI configuration 2# Plug and Play ACPI configuration
3# 3#
4config PNPACPI 4config PNPACPI
5 bool "Plug and Play ACPI support (EXPERIMENTAL)" 5 bool "Plug and Play ACPI support"
6 depends on PNP && ACPI && EXPERIMENTAL 6 depends on PNP && ACPI
7 default y 7 default y
8 ---help--- 8 ---help---
9 Linux uses the PNPACPI to autodetect built-in 9 Linux uses the PNPACPI to autodetect built-in
diff --git a/drivers/pnp/system.c b/drivers/pnp/system.c
index d42015c382af..2065e74bb63f 100644
--- a/drivers/pnp/system.c
+++ b/drivers/pnp/system.c
@@ -3,7 +3,8 @@
3 * 3 *
4 * Some code is based on pnpbios_core.c 4 * Some code is based on pnpbios_core.c
5 * Copyright 2002 Adam Belay <ambx1@neo.rr.com> 5 * Copyright 2002 Adam Belay <ambx1@neo.rr.com>
6 * 6 * (c) Copyright 2007 Hewlett-Packard Development Company, L.P.
7 * Bjorn Helgaas <bjorn.helgaas@hp.com>
7 */ 8 */
8 9
9#include <linux/pnp.h> 10#include <linux/pnp.h>
@@ -21,18 +22,21 @@ static const struct pnp_device_id pnp_dev_table[] = {
21 { "", 0 } 22 { "", 0 }
22}; 23};
23 24
24static void reserve_ioport_range(char *pnpid, int start, int end) 25static void reserve_range(char *pnpid, int start, int end, int port)
25{ 26{
26 struct resource *res; 27 struct resource *res;
27 char *regionid; 28 char *regionid;
28 29
29 regionid = kmalloc(16, GFP_KERNEL); 30 regionid = kmalloc(16, GFP_KERNEL);
30 if ( regionid == NULL ) 31 if (regionid == NULL)
31 return; 32 return;
32 snprintf(regionid, 16, "pnp %s", pnpid); 33 snprintf(regionid, 16, "pnp %s", pnpid);
33 res = request_region(start,end-start+1,regionid); 34 if (port)
34 if ( res == NULL ) 35 res = request_region(start,end-start+1,regionid);
35 kfree( regionid ); 36 else
37 res = request_mem_region(start,end-start+1,regionid);
38 if (res == NULL)
39 kfree(regionid);
36 else 40 else
37 res->flags &= ~IORESOURCE_BUSY; 41 res->flags &= ~IORESOURCE_BUSY;
38 /* 42 /*
@@ -41,26 +45,20 @@ static void reserve_ioport_range(char *pnpid, int start, int end)
41 * have double reservations. 45 * have double reservations.
42 */ 46 */
43 printk(KERN_INFO 47 printk(KERN_INFO
44 "pnp: %s: ioport range 0x%x-0x%x %s reserved\n", 48 "pnp: %s: %s range 0x%x-0x%x %s reserved\n",
45 pnpid, start, end, 49 pnpid, port ? "ioport" : "iomem", start, end,
46 NULL != res ? "has been" : "could not be" 50 NULL != res ? "has been" : "could not be");
47 );
48
49 return;
50} 51}
51 52
52static void reserve_resources_of_dev( struct pnp_dev *dev ) 53static void reserve_resources_of_dev(struct pnp_dev *dev)
53{ 54{
54 int i; 55 int i;
55 56
56 for (i=0;i<PNP_MAX_PORT;i++) { 57 for (i = 0; i < PNP_MAX_PORT; i++) {
57 if (!pnp_port_valid(dev, i)) 58 if (!pnp_port_valid(dev, i))
58 /* end of resources */
59 continue; 59 continue;
60 if (pnp_port_start(dev, i) == 0) 60 if (pnp_port_start(dev, i) == 0)
61 /* disabled */ 61 continue; /* disabled */
62 /* Do nothing */
63 continue;
64 if (pnp_port_start(dev, i) < 0x100) 62 if (pnp_port_start(dev, i) < 0x100)
65 /* 63 /*
66 * Below 0x100 is only standard PC hardware 64 * Below 0x100 is only standard PC hardware
@@ -72,14 +70,18 @@ static void reserve_resources_of_dev( struct pnp_dev *dev )
72 */ 70 */
73 continue; 71 continue;
74 if (pnp_port_end(dev, i) < pnp_port_start(dev, i)) 72 if (pnp_port_end(dev, i) < pnp_port_start(dev, i))
75 /* invalid endpoint */ 73 continue; /* invalid */
76 /* Do nothing */ 74
75 reserve_range(dev->dev.bus_id, pnp_port_start(dev, i),
76 pnp_port_end(dev, i), 1);
77 }
78
79 for (i = 0; i < PNP_MAX_MEM; i++) {
80 if (!pnp_mem_valid(dev, i))
77 continue; 81 continue;
78 reserve_ioport_range( 82
79 dev->dev.bus_id, 83 reserve_range(dev->dev.bus_id, pnp_mem_start(dev, i),
80 pnp_port_start(dev, i), 84 pnp_mem_end(dev, i), 0);
81 pnp_port_end(dev, i)
82 );
83 } 85 }
84 86
85 return; 87 return;