| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
 | 2 |  * File:	pci-acpi.c | 
| Len Brown | a406d9e | 2005-03-23 16:16:03 -0500 | [diff] [blame] | 3 |  * Purpose:	Provide PCI support in ACPI | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 |  * | 
| David Shaohua Li | 84df749 | 2005-03-18 18:53:36 -0500 | [diff] [blame] | 5 |  * Copyright (C) 2005 David Shaohua Li <shaohua.li@intel.com> | 
 | 6 |  * Copyright (C) 2004 Tom Long Nguyen <tom.l.nguyen@intel.com> | 
 | 7 |  * Copyright (C) 2004 Intel Corp. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 |  */ | 
 | 9 |  | 
 | 10 | #include <linux/delay.h> | 
 | 11 | #include <linux/init.h> | 
 | 12 | #include <linux/pci.h> | 
 | 13 | #include <linux/module.h> | 
 | 14 | #include <acpi/acpi.h> | 
 | 15 | #include <acpi/acnamesp.h> | 
 | 16 | #include <acpi/acresrc.h> | 
 | 17 | #include <acpi/acpi_bus.h> | 
 | 18 |  | 
 | 19 | #include <linux/pci-acpi.h> | 
| David Shaohua Li | 0f64474 | 2005-03-19 00:15:48 -0500 | [diff] [blame] | 20 | #include "pci.h" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 |  | 
 | 22 | static u32 ctrlset_buf[3] = {0, 0, 0}; | 
 | 23 | static u32 global_ctrlsets = 0; | 
| Greg KH | bc56b9e | 2005-04-08 14:53:31 +0900 | [diff] [blame] | 24 | static u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66}; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 |  | 
 | 26 | static acpi_status   | 
 | 27 | acpi_query_osc ( | 
 | 28 | 	acpi_handle	handle, | 
 | 29 | 	u32		level, | 
 | 30 | 	void		*context, | 
 | 31 | 	void		**retval ) | 
 | 32 | { | 
 | 33 | 	acpi_status		status; | 
 | 34 | 	struct acpi_object_list	input; | 
 | 35 | 	union acpi_object 	in_params[4]; | 
| Kristen Accardi | 593ee20 | 2006-05-20 15:00:08 -0700 | [diff] [blame] | 36 | 	struct acpi_buffer	output = {ACPI_ALLOCATE_BUFFER, NULL}; | 
 | 37 | 	union acpi_object 	*out_obj; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | 	u32			osc_dw0; | 
| Kristen Carlson Accardi | 0dcb2b7 | 2006-10-30 13:08:12 -0800 | [diff] [blame] | 39 | 	acpi_status *ret_status = (acpi_status *)retval; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | 	 | 
 | 42 | 	/* Setting up input parameters */ | 
 | 43 | 	input.count = 4; | 
 | 44 | 	input.pointer = in_params; | 
 | 45 | 	in_params[0].type 		= ACPI_TYPE_BUFFER; | 
 | 46 | 	in_params[0].buffer.length 	= 16; | 
 | 47 | 	in_params[0].buffer.pointer	= OSC_UUID; | 
 | 48 | 	in_params[1].type 		= ACPI_TYPE_INTEGER; | 
 | 49 | 	in_params[1].integer.value 	= 1; | 
 | 50 | 	in_params[2].type 		= ACPI_TYPE_INTEGER; | 
 | 51 | 	in_params[2].integer.value	= 3; | 
 | 52 | 	in_params[3].type		= ACPI_TYPE_BUFFER; | 
 | 53 | 	in_params[3].buffer.length 	= 12; | 
 | 54 | 	in_params[3].buffer.pointer 	= (u8 *)context; | 
 | 55 |  | 
 | 56 | 	status = acpi_evaluate_object(handle, "_OSC", &input, &output); | 
 | 57 | 	if (ACPI_FAILURE (status)) { | 
 | 58 | 		printk(KERN_DEBUG   | 
 | 59 | 			"Evaluate _OSC Set fails. Status = 0x%04x\n", status); | 
| Kristen Carlson Accardi | 0dcb2b7 | 2006-10-30 13:08:12 -0800 | [diff] [blame] | 60 | 		*ret_status = status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | 		return status; | 
 | 62 | 	} | 
| Kristen Accardi | 593ee20 | 2006-05-20 15:00:08 -0700 | [diff] [blame] | 63 | 	out_obj = output.pointer; | 
 | 64 |  | 
 | 65 | 	if (out_obj->type != ACPI_TYPE_BUFFER) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | 		printk(KERN_DEBUG   | 
 | 67 | 			"Evaluate _OSC returns wrong type\n"); | 
| Kristen Accardi | 593ee20 | 2006-05-20 15:00:08 -0700 | [diff] [blame] | 68 | 		status = AE_TYPE; | 
 | 69 | 		goto query_osc_out; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | 	} | 
| Kristen Accardi | 593ee20 | 2006-05-20 15:00:08 -0700 | [diff] [blame] | 71 | 	osc_dw0 = *((u32 *) out_obj->buffer.pointer); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | 	if (osc_dw0) { | 
 | 73 | 		if (osc_dw0 & OSC_REQUEST_ERROR) | 
 | 74 | 			printk(KERN_DEBUG "_OSC request fails\n");  | 
 | 75 | 		if (osc_dw0 & OSC_INVALID_UUID_ERROR) | 
 | 76 | 			printk(KERN_DEBUG "_OSC invalid UUID\n");  | 
 | 77 | 		if (osc_dw0 & OSC_INVALID_REVISION_ERROR) | 
 | 78 | 			printk(KERN_DEBUG "_OSC invalid revision\n");  | 
 | 79 | 		if (osc_dw0 & OSC_CAPABILITIES_MASK_ERROR) { | 
 | 80 | 			/* Update Global Control Set */ | 
| Kristen Accardi | 593ee20 | 2006-05-20 15:00:08 -0700 | [diff] [blame] | 81 | 			global_ctrlsets = *((u32 *)(out_obj->buffer.pointer+8)); | 
 | 82 | 			status = AE_OK; | 
 | 83 | 			goto query_osc_out; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | 		} | 
| Kristen Accardi | 593ee20 | 2006-05-20 15:00:08 -0700 | [diff] [blame] | 85 | 		status = AE_ERROR; | 
 | 86 | 		goto query_osc_out; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | 	} | 
 | 88 |  | 
 | 89 | 	/* Update Global Control Set */ | 
| Kristen Accardi | 593ee20 | 2006-05-20 15:00:08 -0700 | [diff] [blame] | 90 | 	global_ctrlsets = *((u32 *)(out_obj->buffer.pointer + 8)); | 
 | 91 | 	status = AE_OK; | 
 | 92 |  | 
 | 93 | query_osc_out: | 
 | 94 | 	kfree(output.pointer); | 
| Kristen Carlson Accardi | 0dcb2b7 | 2006-10-30 13:08:12 -0800 | [diff] [blame] | 95 | 	*ret_status = status; | 
| Kristen Accardi | 593ee20 | 2006-05-20 15:00:08 -0700 | [diff] [blame] | 96 | 	return status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | } | 
 | 98 |  | 
 | 99 |  | 
 | 100 | static acpi_status   | 
 | 101 | acpi_run_osc ( | 
 | 102 | 	acpi_handle	handle, | 
| rajesh.shah@intel.com | 427bf53 | 2005-10-31 16:20:11 -0800 | [diff] [blame] | 103 | 	void		*context) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | { | 
 | 105 | 	acpi_status		status; | 
 | 106 | 	struct acpi_object_list	input; | 
 | 107 | 	union acpi_object 	in_params[4]; | 
| Kristen Accardi | 593ee20 | 2006-05-20 15:00:08 -0700 | [diff] [blame] | 108 | 	struct acpi_buffer	output = {ACPI_ALLOCATE_BUFFER, NULL}; | 
 | 109 | 	union acpi_object 	*out_obj; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | 	u32			osc_dw0; | 
 | 111 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | 	/* Setting up input parameters */ | 
 | 113 | 	input.count = 4; | 
 | 114 | 	input.pointer = in_params; | 
 | 115 | 	in_params[0].type 		= ACPI_TYPE_BUFFER; | 
 | 116 | 	in_params[0].buffer.length 	= 16; | 
 | 117 | 	in_params[0].buffer.pointer	= OSC_UUID; | 
 | 118 | 	in_params[1].type 		= ACPI_TYPE_INTEGER; | 
 | 119 | 	in_params[1].integer.value 	= 1; | 
 | 120 | 	in_params[2].type 		= ACPI_TYPE_INTEGER; | 
 | 121 | 	in_params[2].integer.value	= 3; | 
 | 122 | 	in_params[3].type		= ACPI_TYPE_BUFFER; | 
 | 123 | 	in_params[3].buffer.length 	= 12; | 
 | 124 | 	in_params[3].buffer.pointer 	= (u8 *)context; | 
 | 125 |  | 
 | 126 | 	status = acpi_evaluate_object(handle, "_OSC", &input, &output); | 
 | 127 | 	if (ACPI_FAILURE (status)) { | 
 | 128 | 		printk(KERN_DEBUG   | 
 | 129 | 			"Evaluate _OSC Set fails. Status = 0x%04x\n", status); | 
 | 130 | 		return status; | 
 | 131 | 	} | 
| Kristen Accardi | 593ee20 | 2006-05-20 15:00:08 -0700 | [diff] [blame] | 132 | 	out_obj = output.pointer; | 
 | 133 | 	if (out_obj->type != ACPI_TYPE_BUFFER) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | 		printk(KERN_DEBUG   | 
 | 135 | 			"Evaluate _OSC returns wrong type\n"); | 
| Kristen Accardi | 593ee20 | 2006-05-20 15:00:08 -0700 | [diff] [blame] | 136 | 		status = AE_TYPE; | 
 | 137 | 		goto run_osc_out; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | 	} | 
| Kristen Accardi | 593ee20 | 2006-05-20 15:00:08 -0700 | [diff] [blame] | 139 | 	osc_dw0 = *((u32 *) out_obj->buffer.pointer); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | 	if (osc_dw0) { | 
 | 141 | 		if (osc_dw0 & OSC_REQUEST_ERROR) | 
 | 142 | 			printk(KERN_DEBUG "_OSC request fails\n");  | 
 | 143 | 		if (osc_dw0 & OSC_INVALID_UUID_ERROR) | 
 | 144 | 			printk(KERN_DEBUG "_OSC invalid UUID\n");  | 
 | 145 | 		if (osc_dw0 & OSC_INVALID_REVISION_ERROR) | 
 | 146 | 			printk(KERN_DEBUG "_OSC invalid revision\n");  | 
 | 147 | 		if (osc_dw0 & OSC_CAPABILITIES_MASK_ERROR) { | 
 | 148 | 			printk(KERN_DEBUG "_OSC FW not grant req. control\n"); | 
| Kristen Accardi | 593ee20 | 2006-05-20 15:00:08 -0700 | [diff] [blame] | 149 | 			status = AE_SUPPORT; | 
 | 150 | 			goto run_osc_out; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | 		} | 
| Kristen Accardi | 593ee20 | 2006-05-20 15:00:08 -0700 | [diff] [blame] | 152 | 		status = AE_ERROR; | 
 | 153 | 		goto run_osc_out; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | 	} | 
| Kristen Accardi | 593ee20 | 2006-05-20 15:00:08 -0700 | [diff] [blame] | 155 | 	status = AE_OK; | 
 | 156 |  | 
 | 157 | run_osc_out: | 
 | 158 | 	kfree(output.pointer); | 
 | 159 | 	return status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | } | 
 | 161 |  | 
 | 162 | /** | 
 | 163 |  * pci_osc_support_set - register OS support to Firmware | 
 | 164 |  * @flags: OS support bits | 
 | 165 |  * | 
 | 166 |  * Update OS support fields and doing a _OSC Query to obtain an update | 
 | 167 |  * from Firmware on supported control bits. | 
 | 168 |  **/ | 
 | 169 | acpi_status pci_osc_support_set(u32 flags) | 
 | 170 | { | 
 | 171 | 	u32 temp; | 
| Kristen Carlson Accardi | 0dcb2b7 | 2006-10-30 13:08:12 -0800 | [diff] [blame] | 172 | 	acpi_status retval; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 |  | 
 | 174 | 	if (!(flags & OSC_SUPPORT_MASKS)) { | 
 | 175 | 		return AE_TYPE; | 
 | 176 | 	} | 
 | 177 | 	ctrlset_buf[OSC_SUPPORT_TYPE] |= (flags & OSC_SUPPORT_MASKS); | 
 | 178 |  | 
 | 179 | 	/* do _OSC query for all possible controls */ | 
 | 180 | 	temp = ctrlset_buf[OSC_CONTROL_TYPE]; | 
 | 181 | 	ctrlset_buf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE; | 
 | 182 | 	ctrlset_buf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS; | 
 | 183 | 	acpi_get_devices ( PCI_ROOT_HID_STRING, | 
 | 184 | 			acpi_query_osc, | 
 | 185 | 			ctrlset_buf, | 
| Kristen Carlson Accardi | 0dcb2b7 | 2006-10-30 13:08:12 -0800 | [diff] [blame] | 186 | 			(void **) &retval ); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | 	ctrlset_buf[OSC_QUERY_TYPE] = !OSC_QUERY_ENABLE; | 
 | 188 | 	ctrlset_buf[OSC_CONTROL_TYPE] = temp; | 
| Kristen Carlson Accardi | 0dcb2b7 | 2006-10-30 13:08:12 -0800 | [diff] [blame] | 189 | 	if (ACPI_FAILURE(retval)) { | 
 | 190 | 		/* no osc support at all */ | 
 | 191 | 		ctrlset_buf[OSC_SUPPORT_TYPE] = 0; | 
 | 192 | 	} | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | 	return AE_OK; | 
 | 194 | } | 
 | 195 | EXPORT_SYMBOL(pci_osc_support_set); | 
 | 196 |  | 
 | 197 | /** | 
 | 198 |  * pci_osc_control_set - commit requested control to Firmware | 
| Randy Dunlap | f366633 | 2005-11-23 15:45:04 -0800 | [diff] [blame] | 199 |  * @handle: acpi_handle for the target ACPI object | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 |  * @flags: driver's requested control bits | 
 | 201 |  * | 
 | 202 |  * Attempt to take control from Firmware on requested control bits. | 
 | 203 |  **/ | 
| rajesh.shah@intel.com | 427bf53 | 2005-10-31 16:20:11 -0800 | [diff] [blame] | 204 | acpi_status pci_osc_control_set(acpi_handle handle, u32 flags) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | { | 
 | 206 | 	acpi_status	status; | 
 | 207 | 	u32		ctrlset; | 
 | 208 |  | 
 | 209 | 	ctrlset = (flags & OSC_CONTROL_MASKS); | 
 | 210 | 	if (!ctrlset) { | 
 | 211 | 		return AE_TYPE; | 
 | 212 | 	} | 
 | 213 | 	if (ctrlset_buf[OSC_SUPPORT_TYPE] &&  | 
 | 214 | 	 	((global_ctrlsets & ctrlset) != ctrlset)) { | 
 | 215 | 		return AE_SUPPORT; | 
 | 216 | 	} | 
 | 217 | 	ctrlset_buf[OSC_CONTROL_TYPE] |= ctrlset; | 
| rajesh.shah@intel.com | 427bf53 | 2005-10-31 16:20:11 -0800 | [diff] [blame] | 218 | 	status = acpi_run_osc(handle, ctrlset_buf); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | 	if (ACPI_FAILURE (status)) { | 
 | 220 | 		ctrlset_buf[OSC_CONTROL_TYPE] &= ~ctrlset; | 
 | 221 | 	} | 
 | 222 | 	 | 
 | 223 | 	return status; | 
 | 224 | } | 
 | 225 | EXPORT_SYMBOL(pci_osc_control_set); | 
| David Shaohua Li | 84df749 | 2005-03-18 18:53:36 -0500 | [diff] [blame] | 226 |  | 
| David Shaohua Li | 0f64474 | 2005-03-19 00:15:48 -0500 | [diff] [blame] | 227 | /* | 
 | 228 |  * _SxD returns the D-state with the highest power | 
 | 229 |  * (lowest D-state number) supported in the S-state "x". | 
 | 230 |  * | 
 | 231 |  * If the devices does not have a _PRW | 
 | 232 |  * (Power Resources for Wake) supporting system wakeup from "x" | 
 | 233 |  * then the OS is free to choose a lower power (higher number | 
 | 234 |  * D-state) than the return value from _SxD. | 
 | 235 |  * | 
 | 236 |  * But if _PRW is enabled at S-state "x", the OS | 
 | 237 |  * must not choose a power lower than _SxD -- | 
 | 238 |  * unless the device has an _SxW method specifying | 
 | 239 |  * the lowest power (highest D-state number) the device | 
 | 240 |  * may enter while still able to wake the system. | 
 | 241 |  * | 
 | 242 |  * ie. depending on global OS policy: | 
 | 243 |  * | 
 | 244 |  * if (_PRW at S-state x) | 
 | 245 |  *	choose from highest power _SxD to lowest power _SxW | 
 | 246 |  * else // no _PRW at S-state x | 
 | 247 |  * 	choose highest power _SxD or any lower power | 
 | 248 |  * | 
 | 249 |  * currently we simply return _SxD, if present. | 
 | 250 |  */ | 
 | 251 |  | 
 | 252 | static int acpi_pci_choose_state(struct pci_dev *pdev, pm_message_t state) | 
 | 253 | { | 
| Len Brown | a406d9e | 2005-03-23 16:16:03 -0500 | [diff] [blame] | 254 | 	/* TBD */ | 
| David Shaohua Li | 0f64474 | 2005-03-19 00:15:48 -0500 | [diff] [blame] | 255 |  | 
| David Shaohua Li | 0f64474 | 2005-03-19 00:15:48 -0500 | [diff] [blame] | 256 | 	return -ENODEV; | 
 | 257 | } | 
 | 258 |  | 
| David Shaohua Li | b913100 | 2005-03-19 00:16:18 -0500 | [diff] [blame] | 259 | static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state) | 
 | 260 | { | 
 | 261 | 	acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev); | 
 | 262 | 	static int state_conv[] = { | 
 | 263 | 		[0] = 0, | 
 | 264 | 		[1] = 1, | 
 | 265 | 		[2] = 2, | 
 | 266 | 		[3] = 3, | 
 | 267 | 		[4] = 3 | 
 | 268 | 	}; | 
 | 269 | 	int acpi_state = state_conv[(int __force) state]; | 
 | 270 |  | 
 | 271 | 	if (!handle) | 
 | 272 | 		return -ENODEV; | 
 | 273 | 	return acpi_bus_set_power(handle, acpi_state); | 
 | 274 | } | 
 | 275 |  | 
 | 276 |  | 
| David Shaohua Li | 84df749 | 2005-03-18 18:53:36 -0500 | [diff] [blame] | 277 | /* ACPI bus type */ | 
| Muthu Kumar | 9c273b9 | 2006-04-28 00:42:21 -0700 | [diff] [blame] | 278 | static int acpi_pci_find_device(struct device *dev, acpi_handle *handle) | 
| David Shaohua Li | 84df749 | 2005-03-18 18:53:36 -0500 | [diff] [blame] | 279 | { | 
 | 280 | 	struct pci_dev * pci_dev; | 
 | 281 | 	acpi_integer	addr; | 
 | 282 |  | 
 | 283 | 	pci_dev = to_pci_dev(dev); | 
 | 284 | 	/* Please ref to ACPI spec for the syntax of _ADR */ | 
 | 285 | 	addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn); | 
 | 286 | 	*handle = acpi_get_child(DEVICE_ACPI_HANDLE(dev->parent), addr); | 
 | 287 | 	if (!*handle) | 
 | 288 | 		return -ENODEV; | 
 | 289 | 	return 0; | 
 | 290 | } | 
 | 291 |  | 
| Muthu Kumar | 9c273b9 | 2006-04-28 00:42:21 -0700 | [diff] [blame] | 292 | static int acpi_pci_find_root_bridge(struct device *dev, acpi_handle *handle) | 
| David Shaohua Li | 84df749 | 2005-03-18 18:53:36 -0500 | [diff] [blame] | 293 | { | 
 | 294 | 	int num; | 
 | 295 | 	unsigned int seg, bus; | 
 | 296 |  | 
 | 297 | 	/* | 
 | 298 | 	 * The string should be the same as root bridge's name | 
 | 299 | 	 * Please look at 'pci_scan_bus_parented' | 
 | 300 | 	 */ | 
 | 301 | 	num = sscanf(dev->bus_id, "pci%04x:%02x", &seg, &bus); | 
 | 302 | 	if (num != 2) | 
 | 303 | 		return -ENODEV; | 
 | 304 | 	*handle = acpi_get_pci_rootbridge_handle(seg, bus); | 
 | 305 | 	if (!*handle) | 
 | 306 | 		return -ENODEV; | 
 | 307 | 	return 0; | 
 | 308 | } | 
 | 309 |  | 
| Muthu Kumar | 9c273b9 | 2006-04-28 00:42:21 -0700 | [diff] [blame] | 310 | static struct acpi_bus_type acpi_pci_bus = { | 
| David Shaohua Li | 84df749 | 2005-03-18 18:53:36 -0500 | [diff] [blame] | 311 | 	.bus = &pci_bus_type, | 
| Muthu Kumar | 9c273b9 | 2006-04-28 00:42:21 -0700 | [diff] [blame] | 312 | 	.find_device = acpi_pci_find_device, | 
 | 313 | 	.find_bridge = acpi_pci_find_root_bridge, | 
| David Shaohua Li | 84df749 | 2005-03-18 18:53:36 -0500 | [diff] [blame] | 314 | }; | 
 | 315 |  | 
| Muthu Kumar | 9c273b9 | 2006-04-28 00:42:21 -0700 | [diff] [blame] | 316 | static int __init acpi_pci_init(void) | 
| David Shaohua Li | 84df749 | 2005-03-18 18:53:36 -0500 | [diff] [blame] | 317 | { | 
 | 318 | 	int ret; | 
 | 319 |  | 
| Muthu Kumar | 9c273b9 | 2006-04-28 00:42:21 -0700 | [diff] [blame] | 320 | 	ret = register_acpi_bus_type(&acpi_pci_bus); | 
| David Shaohua Li | 84df749 | 2005-03-18 18:53:36 -0500 | [diff] [blame] | 321 | 	if (ret) | 
 | 322 | 		return 0; | 
| David Shaohua Li | 0f64474 | 2005-03-19 00:15:48 -0500 | [diff] [blame] | 323 | 	platform_pci_choose_state = acpi_pci_choose_state; | 
| David Shaohua Li | b913100 | 2005-03-19 00:16:18 -0500 | [diff] [blame] | 324 | 	platform_pci_set_power_state = acpi_pci_set_power_state; | 
| David Shaohua Li | 84df749 | 2005-03-18 18:53:36 -0500 | [diff] [blame] | 325 | 	return 0; | 
 | 326 | } | 
| Muthu Kumar | 9c273b9 | 2006-04-28 00:42:21 -0700 | [diff] [blame] | 327 | arch_initcall(acpi_pci_init); |