diff options
Diffstat (limited to 'drivers/acpi/acpica/tbfadt.c')
-rw-r--r-- | drivers/acpi/acpica/tbfadt.c | 363 |
1 files changed, 206 insertions, 157 deletions
diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c index 3636e4f8fb73..71e655d14cb0 100644 --- a/drivers/acpi/acpica/tbfadt.c +++ b/drivers/acpi/acpica/tbfadt.c | |||
@@ -57,6 +57,8 @@ static void acpi_tb_convert_fadt(void); | |||
57 | 57 | ||
58 | static void acpi_tb_validate_fadt(void); | 58 | static void acpi_tb_validate_fadt(void); |
59 | 59 | ||
60 | static void acpi_tb_setup_fadt_registers(void); | ||
61 | |||
60 | /* Table for conversion of FADT to common internal format and FADT validation */ | 62 | /* Table for conversion of FADT to common internal format and FADT validation */ |
61 | 63 | ||
62 | typedef struct acpi_fadt_info { | 64 | typedef struct acpi_fadt_info { |
@@ -130,7 +132,38 @@ static struct acpi_fadt_info fadt_info_table[] = { | |||
130 | ACPI_FADT_SEPARATE_LENGTH} | 132 | ACPI_FADT_SEPARATE_LENGTH} |
131 | }; | 133 | }; |
132 | 134 | ||
133 | #define ACPI_FADT_INFO_ENTRIES (sizeof (fadt_info_table) / sizeof (struct acpi_fadt_info)) | 135 | #define ACPI_FADT_INFO_ENTRIES \ |
136 | (sizeof (fadt_info_table) / sizeof (struct acpi_fadt_info)) | ||
137 | |||
138 | /* Table used to split Event Blocks into separate status/enable registers */ | ||
139 | |||
140 | typedef struct acpi_fadt_pm_info { | ||
141 | struct acpi_generic_address *target; | ||
142 | u8 source; | ||
143 | u8 register_num; | ||
144 | |||
145 | } acpi_fadt_pm_info; | ||
146 | |||
147 | static struct acpi_fadt_pm_info fadt_pm_info_table[] = { | ||
148 | {&acpi_gbl_xpm1a_status, | ||
149 | ACPI_FADT_OFFSET(xpm1a_event_block), | ||
150 | 0}, | ||
151 | |||
152 | {&acpi_gbl_xpm1a_enable, | ||
153 | ACPI_FADT_OFFSET(xpm1a_event_block), | ||
154 | 1}, | ||
155 | |||
156 | {&acpi_gbl_xpm1b_status, | ||
157 | ACPI_FADT_OFFSET(xpm1b_event_block), | ||
158 | 0}, | ||
159 | |||
160 | {&acpi_gbl_xpm1b_enable, | ||
161 | ACPI_FADT_OFFSET(xpm1b_event_block), | ||
162 | 1} | ||
163 | }; | ||
164 | |||
165 | #define ACPI_FADT_PM_INFO_ENTRIES \ | ||
166 | (sizeof (fadt_pm_info_table) / sizeof (struct acpi_fadt_pm_info)) | ||
134 | 167 | ||
135 | /******************************************************************************* | 168 | /******************************************************************************* |
136 | * | 169 | * |
@@ -172,7 +205,6 @@ acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, | |||
172 | * FUNCTION: acpi_tb_parse_fadt | 205 | * FUNCTION: acpi_tb_parse_fadt |
173 | * | 206 | * |
174 | * PARAMETERS: table_index - Index for the FADT | 207 | * PARAMETERS: table_index - Index for the FADT |
175 | * Flags - Flags | ||
176 | * | 208 | * |
177 | * RETURN: None | 209 | * RETURN: None |
178 | * | 210 | * |
@@ -181,7 +213,7 @@ acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, | |||
181 | * | 213 | * |
182 | ******************************************************************************/ | 214 | ******************************************************************************/ |
183 | 215 | ||
184 | void acpi_tb_parse_fadt(u32 table_index, u8 flags) | 216 | void acpi_tb_parse_fadt(u32 table_index) |
185 | { | 217 | { |
186 | u32 length; | 218 | u32 length; |
187 | struct acpi_table_header *table; | 219 | struct acpi_table_header *table; |
@@ -208,7 +240,7 @@ void acpi_tb_parse_fadt(u32 table_index, u8 flags) | |||
208 | */ | 240 | */ |
209 | (void)acpi_tb_verify_checksum(table, length); | 241 | (void)acpi_tb_verify_checksum(table, length); |
210 | 242 | ||
211 | /* Obtain a local copy of the FADT in common ACPI 2.0+ format */ | 243 | /* Create a local copy of the FADT in common ACPI 2.0+ format */ |
212 | 244 | ||
213 | acpi_tb_create_local_fadt(table, length); | 245 | acpi_tb_create_local_fadt(table, length); |
214 | 246 | ||
@@ -219,10 +251,10 @@ void acpi_tb_parse_fadt(u32 table_index, u8 flags) | |||
219 | /* Obtain the DSDT and FACS tables via their addresses within the FADT */ | 251 | /* Obtain the DSDT and FACS tables via their addresses within the FADT */ |
220 | 252 | ||
221 | acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.Xdsdt, | 253 | acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.Xdsdt, |
222 | flags, ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT); | 254 | ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT); |
223 | 255 | ||
224 | acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.Xfacs, | 256 | acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.Xfacs, |
225 | flags, ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS); | 257 | ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS); |
226 | } | 258 | } |
227 | 259 | ||
228 | /******************************************************************************* | 260 | /******************************************************************************* |
@@ -266,11 +298,17 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length) | |||
266 | ACPI_MEMCPY(&acpi_gbl_FADT, table, | 298 | ACPI_MEMCPY(&acpi_gbl_FADT, table, |
267 | ACPI_MIN(length, sizeof(struct acpi_table_fadt))); | 299 | ACPI_MIN(length, sizeof(struct acpi_table_fadt))); |
268 | 300 | ||
269 | /* | 301 | /* Convert the local copy of the FADT to the common internal format */ |
270 | * 1) Convert the local copy of the FADT to the common internal format | 302 | |
271 | * 2) Validate some of the important values within the FADT | ||
272 | */ | ||
273 | acpi_tb_convert_fadt(); | 303 | acpi_tb_convert_fadt(); |
304 | |||
305 | /* Validate FADT values now, before we make any changes */ | ||
306 | |||
307 | acpi_tb_validate_fadt(); | ||
308 | |||
309 | /* Initialize the global ACPI register structures */ | ||
310 | |||
311 | acpi_tb_setup_fadt_registers(); | ||
274 | } | 312 | } |
275 | 313 | ||
276 | /******************************************************************************* | 314 | /******************************************************************************* |
@@ -282,31 +320,35 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length) | |||
282 | * RETURN: None | 320 | * RETURN: None |
283 | * | 321 | * |
284 | * DESCRIPTION: Converts all versions of the FADT to a common internal format. | 322 | * DESCRIPTION: Converts all versions of the FADT to a common internal format. |
285 | * Expand all 32-bit addresses to 64-bit. | 323 | * Expand 32-bit addresses to 64-bit as necessary. |
286 | * | 324 | * |
287 | * NOTE: acpi_gbl_FADT must be of size (struct acpi_table_fadt), | 325 | * NOTE: acpi_gbl_FADT must be of size (struct acpi_table_fadt), |
288 | * and must contain a copy of the actual FADT. | 326 | * and must contain a copy of the actual FADT. |
289 | * | 327 | * |
290 | * ACPICA will use the "X" fields of the FADT for all addresses. | 328 | * Notes on 64-bit register addresses: |
329 | * | ||
330 | * After this FADT conversion, later ACPICA code will only use the 64-bit "X" | ||
331 | * fields of the FADT for all ACPI register addresses. | ||
291 | * | 332 | * |
292 | * "X" fields are optional extensions to the original V1.0 fields. Even if | 333 | * The 64-bit "X" fields are optional extensions to the original 32-bit FADT |
293 | * they are present in the structure, they can be optionally not used by | 334 | * V1.0 fields. Even if they are present in the FADT, they are optional and |
294 | * setting them to zero. Therefore, we must selectively expand V1.0 fields | 335 | * are unused if the BIOS sets them to zero. Therefore, we must copy/expand |
295 | * if the corresponding X field is zero. | 336 | * 32-bit V1.0 fields if the corresponding X field is zero. |
296 | * | 337 | * |
297 | * For ACPI 1.0 FADTs, all address fields are expanded to the corresponding | 338 | * For ACPI 1.0 FADTs, all 32-bit address fields are expanded to the |
298 | * "X" fields. | 339 | * corresponding "X" fields in the internal FADT. |
299 | * | 340 | * |
300 | * For ACPI 2.0 FADTs, any "X" fields that are NULL are filled in by | 341 | * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded |
301 | * expanding the corresponding ACPI 1.0 field. | 342 | * to the corresponding 64-bit X fields. For compatibility with other ACPI |
343 | * implementations, we ignore the 64-bit field if the 32-bit field is valid, | ||
344 | * regardless of whether the host OS is 32-bit or 64-bit. | ||
302 | * | 345 | * |
303 | ******************************************************************************/ | 346 | ******************************************************************************/ |
304 | 347 | ||
305 | static void acpi_tb_convert_fadt(void) | 348 | static void acpi_tb_convert_fadt(void) |
306 | { | 349 | { |
307 | u8 pm1_register_bit_width; | 350 | struct acpi_generic_address *address64; |
308 | u8 pm1_register_byte_width; | 351 | u32 address32; |
309 | struct acpi_generic_address *target64; | ||
310 | u32 i; | 352 | u32 i; |
311 | 353 | ||
312 | /* Update the local FADT table header length */ | 354 | /* Update the local FADT table header length */ |
@@ -355,140 +397,56 @@ static void acpi_tb_convert_fadt(void) | |||
355 | * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X" | 397 | * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X" |
356 | * generic address structures as necessary. Later code will always use | 398 | * generic address structures as necessary. Later code will always use |
357 | * the 64-bit address structures. | 399 | * the 64-bit address structures. |
400 | * | ||
401 | * March 2009: | ||
402 | * We now always use the 32-bit address if it is valid (non-null). This | ||
403 | * is not in accordance with the ACPI specification which states that | ||
404 | * the 64-bit address supersedes the 32-bit version, but we do this for | ||
405 | * compatibility with other ACPI implementations. Most notably, in the | ||
406 | * case where both the 32 and 64 versions are non-null, we use the 32-bit | ||
407 | * version. This is the only address that is guaranteed to have been | ||
408 | * tested by the BIOS manufacturer. | ||
358 | */ | 409 | */ |
359 | for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { | 410 | for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { |
360 | target64 = | 411 | address32 = *ACPI_ADD_PTR(u32, |
361 | ACPI_ADD_PTR(struct acpi_generic_address, &acpi_gbl_FADT, | 412 | &acpi_gbl_FADT, |
362 | fadt_info_table[i].address64); | 413 | fadt_info_table[i].address32); |
363 | 414 | ||
364 | /* Expand only if the 64-bit X target is null */ | 415 | address64 = ACPI_ADD_PTR(struct acpi_generic_address, |
416 | &acpi_gbl_FADT, | ||
417 | fadt_info_table[i].address64); | ||
365 | 418 | ||
366 | if (!target64->address) { | 419 | /* |
420 | * If both 32- and 64-bit addresses are valid (non-zero), | ||
421 | * they must match. | ||
422 | */ | ||
423 | if (address64->address && address32 && | ||
424 | (address64->address != (u64) address32)) { | ||
425 | ACPI_ERROR((AE_INFO, | ||
426 | "32/64X address mismatch in %s: %8.8X/%8.8X%8.8X, using 32", | ||
427 | fadt_info_table[i].name, address32, | ||
428 | ACPI_FORMAT_UINT64(address64->address))); | ||
429 | } | ||
367 | 430 | ||
368 | /* The space_id is always I/O for the 32-bit legacy address fields */ | 431 | /* Always use 32-bit address if it is valid (non-null) */ |
369 | 432 | ||
370 | acpi_tb_init_generic_address(target64, | 433 | if (address32) { |
434 | /* | ||
435 | * Copy the 32-bit address to the 64-bit GAS structure. The | ||
436 | * Space ID is always I/O for 32-bit legacy address fields | ||
437 | */ | ||
438 | acpi_tb_init_generic_address(address64, | ||
371 | ACPI_ADR_SPACE_SYSTEM_IO, | 439 | ACPI_ADR_SPACE_SYSTEM_IO, |
372 | *ACPI_ADD_PTR(u8, | 440 | *ACPI_ADD_PTR(u8, |
373 | &acpi_gbl_FADT, | 441 | &acpi_gbl_FADT, |
374 | fadt_info_table | 442 | fadt_info_table |
375 | [i].length), | 443 | [i].length), |
376 | (u64) * ACPI_ADD_PTR(u32, | 444 | address32); |
377 | &acpi_gbl_FADT, | ||
378 | fadt_info_table | ||
379 | [i]. | ||
380 | address32)); | ||
381 | } | ||
382 | } | ||
383 | |||
384 | /* Validate FADT values now, before we make any changes */ | ||
385 | |||
386 | acpi_tb_validate_fadt(); | ||
387 | |||
388 | /* | ||
389 | * Optionally check all register lengths against the default values and | ||
390 | * update them if they are incorrect. | ||
391 | */ | ||
392 | if (acpi_gbl_use_default_register_widths) { | ||
393 | for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { | ||
394 | target64 = | ||
395 | ACPI_ADD_PTR(struct acpi_generic_address, | ||
396 | &acpi_gbl_FADT, | ||
397 | fadt_info_table[i].address64); | ||
398 | |||
399 | /* | ||
400 | * If a valid register (Address != 0) and the (default_length > 0) | ||
401 | * (Not a GPE register), then check the width against the default. | ||
402 | */ | ||
403 | if ((target64->address) && | ||
404 | (fadt_info_table[i].default_length > 0) && | ||
405 | (fadt_info_table[i].default_length != | ||
406 | target64->bit_width)) { | ||
407 | ACPI_WARNING((AE_INFO, | ||
408 | "Invalid length for %s: %d, using default %d", | ||
409 | fadt_info_table[i].name, | ||
410 | target64->bit_width, | ||
411 | fadt_info_table[i]. | ||
412 | default_length)); | ||
413 | |||
414 | /* Incorrect size, set width to the default */ | ||
415 | |||
416 | target64->bit_width = | ||
417 | fadt_info_table[i].default_length; | ||
418 | } | ||
419 | } | 445 | } |
420 | } | 446 | } |
421 | |||
422 | /* | ||
423 | * Get the length of the individual PM1 registers (enable and status). | ||
424 | * Each register is defined to be (event block length / 2). | ||
425 | */ | ||
426 | pm1_register_bit_width = | ||
427 | (u8)ACPI_DIV_2(acpi_gbl_FADT.xpm1a_event_block.bit_width); | ||
428 | pm1_register_byte_width = (u8)ACPI_DIV_8(pm1_register_bit_width); | ||
429 | |||
430 | /* | ||
431 | * Adjust the lengths of the PM1 Event Blocks so that they can be used to | ||
432 | * access the PM1 status register(s). Use (width / 2) | ||
433 | */ | ||
434 | acpi_gbl_FADT.xpm1a_event_block.bit_width = pm1_register_bit_width; | ||
435 | acpi_gbl_FADT.xpm1b_event_block.bit_width = pm1_register_bit_width; | ||
436 | |||
437 | /* | ||
438 | * Calculate separate GAS structs for the PM1 Enable registers. | ||
439 | * These addresses do not appear (directly) in the FADT, so it is | ||
440 | * useful to calculate them once, here. | ||
441 | * | ||
442 | * The PM event blocks are split into two register blocks, first is the | ||
443 | * PM Status Register block, followed immediately by the PM Enable | ||
444 | * Register block. Each is of length (xpm1x_event_block.bit_width/2). | ||
445 | * | ||
446 | * On various systems the v2 fields (and particularly the bit widths) | ||
447 | * cannot be relied upon, though. Hence resort to using the v1 length | ||
448 | * here (and warn about the inconsistency). | ||
449 | */ | ||
450 | if (acpi_gbl_FADT.xpm1a_event_block.bit_width | ||
451 | != acpi_gbl_FADT.pm1_event_length * 8) | ||
452 | printk(KERN_WARNING "FADT: " | ||
453 | "X_PM1a_EVT_BLK.bit_width (%u) does not match" | ||
454 | " PM1_EVT_LEN (%u)\n", | ||
455 | acpi_gbl_FADT.xpm1a_event_block.bit_width, | ||
456 | acpi_gbl_FADT.pm1_event_length); | ||
457 | |||
458 | /* The PM1A register block is required */ | ||
459 | |||
460 | acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable, | ||
461 | acpi_gbl_FADT.xpm1a_event_block.space_id, | ||
462 | pm1_register_byte_width, | ||
463 | (acpi_gbl_FADT.xpm1a_event_block.address + | ||
464 | pm1_register_byte_width)); | ||
465 | /* Don't forget to copy space_id of the GAS */ | ||
466 | acpi_gbl_xpm1a_enable.space_id = | ||
467 | acpi_gbl_FADT.xpm1a_event_block.space_id; | ||
468 | |||
469 | /* The PM1B register block is optional, ignore if not present */ | ||
470 | |||
471 | if (acpi_gbl_FADT.xpm1b_event_block.address) { | ||
472 | if (acpi_gbl_FADT.xpm1b_event_block.bit_width | ||
473 | != acpi_gbl_FADT.pm1_event_length * 8) | ||
474 | printk(KERN_WARNING "FADT: " | ||
475 | "X_PM1b_EVT_BLK.bit_width (%u) does not match" | ||
476 | " PM1_EVT_LEN (%u)\n", | ||
477 | acpi_gbl_FADT.xpm1b_event_block.bit_width, | ||
478 | acpi_gbl_FADT.pm1_event_length); | ||
479 | acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable, | ||
480 | acpi_gbl_FADT.xpm1b_event_block.space_id, | ||
481 | pm1_register_byte_width, | ||
482 | (acpi_gbl_FADT.xpm1b_event_block. | ||
483 | address + pm1_register_byte_width)); | ||
484 | /* Don't forget to copy space_id of the GAS */ | ||
485 | acpi_gbl_xpm1b_enable.space_id = | ||
486 | acpi_gbl_FADT.xpm1b_event_block.space_id; | ||
487 | |||
488 | } | ||
489 | } | 447 | } |
490 | 448 | ||
491 | /****************************************************************************** | 449 | /******************************************************************************* |
492 | * | 450 | * |
493 | * FUNCTION: acpi_tb_validate_fadt | 451 | * FUNCTION: acpi_tb_validate_fadt |
494 | * | 452 | * |
@@ -525,18 +483,22 @@ static void acpi_tb_validate_fadt(void) | |||
525 | (acpi_gbl_FADT.Xfacs != (u64) acpi_gbl_FADT.facs)) { | 483 | (acpi_gbl_FADT.Xfacs != (u64) acpi_gbl_FADT.facs)) { |
526 | ACPI_WARNING((AE_INFO, | 484 | ACPI_WARNING((AE_INFO, |
527 | "32/64X FACS address mismatch in FADT - " | 485 | "32/64X FACS address mismatch in FADT - " |
528 | "two FACS tables! %8.8X/%8.8X%8.8X", | 486 | "%8.8X/%8.8X%8.8X, using 32", |
529 | acpi_gbl_FADT.facs, | 487 | acpi_gbl_FADT.facs, |
530 | ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xfacs))); | 488 | ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xfacs))); |
489 | |||
490 | acpi_gbl_FADT.Xfacs = (u64) acpi_gbl_FADT.facs; | ||
531 | } | 491 | } |
532 | 492 | ||
533 | if (acpi_gbl_FADT.dsdt && | 493 | if (acpi_gbl_FADT.dsdt && |
534 | (acpi_gbl_FADT.Xdsdt != (u64) acpi_gbl_FADT.dsdt)) { | 494 | (acpi_gbl_FADT.Xdsdt != (u64) acpi_gbl_FADT.dsdt)) { |
535 | ACPI_WARNING((AE_INFO, | 495 | ACPI_WARNING((AE_INFO, |
536 | "32/64X DSDT address mismatch in FADT - " | 496 | "32/64X DSDT address mismatch in FADT - " |
537 | "two DSDT tables! %8.8X/%8.8X%8.8X", | 497 | "%8.8X/%8.8X%8.8X, using 32", |
538 | acpi_gbl_FADT.dsdt, | 498 | acpi_gbl_FADT.dsdt, |
539 | ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xdsdt))); | 499 | ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xdsdt))); |
500 | |||
501 | acpi_gbl_FADT.Xdsdt = (u64) acpi_gbl_FADT.dsdt; | ||
540 | } | 502 | } |
541 | 503 | ||
542 | /* Examine all of the 64-bit extended address fields (X fields) */ | 504 | /* Examine all of the 64-bit extended address fields (X fields) */ |
@@ -561,7 +523,8 @@ static void acpi_tb_validate_fadt(void) | |||
561 | * For each extended field, check for length mismatch between the | 523 | * For each extended field, check for length mismatch between the |
562 | * legacy length field and the corresponding 64-bit X length field. | 524 | * legacy length field and the corresponding 64-bit X length field. |
563 | */ | 525 | */ |
564 | if (address64 && (address64->bit_width != ACPI_MUL_8(length))) { | 526 | if (address64->address && |
527 | (address64->bit_width != ACPI_MUL_8(length))) { | ||
565 | ACPI_WARNING((AE_INFO, | 528 | ACPI_WARNING((AE_INFO, |
566 | "32/64X length mismatch in %s: %d/%d", | 529 | "32/64X length mismatch in %s: %d/%d", |
567 | name, ACPI_MUL_8(length), | 530 | name, ACPI_MUL_8(length), |
@@ -575,7 +538,8 @@ static void acpi_tb_validate_fadt(void) | |||
575 | */ | 538 | */ |
576 | if (!address64->address || !length) { | 539 | if (!address64->address || !length) { |
577 | ACPI_ERROR((AE_INFO, | 540 | ACPI_ERROR((AE_INFO, |
578 | "Required field %s has zero address and/or length: %8.8X%8.8X/%X", | 541 | "Required field %s has zero address and/or length:" |
542 | " %8.8X%8.8X/%X", | ||
579 | name, | 543 | name, |
580 | ACPI_FORMAT_UINT64(address64-> | 544 | ACPI_FORMAT_UINT64(address64-> |
581 | address), | 545 | address), |
@@ -584,27 +548,112 @@ static void acpi_tb_validate_fadt(void) | |||
584 | } else if (fadt_info_table[i].type & ACPI_FADT_SEPARATE_LENGTH) { | 548 | } else if (fadt_info_table[i].type & ACPI_FADT_SEPARATE_LENGTH) { |
585 | /* | 549 | /* |
586 | * Field is optional (PM2Control, GPE0, GPE1) AND has its own | 550 | * Field is optional (PM2Control, GPE0, GPE1) AND has its own |
587 | * length field. If present, both the address and length must be valid. | 551 | * length field. If present, both the address and length must |
552 | * be valid. | ||
588 | */ | 553 | */ |
589 | if ((address64->address && !length) | 554 | if ((address64->address && !length) || |
590 | || (!address64->address && length)) { | 555 | (!address64->address && length)) { |
591 | ACPI_WARNING((AE_INFO, | 556 | ACPI_WARNING((AE_INFO, |
592 | "Optional field %s has zero address or length: %8.8X%8.8X/%X", | 557 | "Optional field %s has zero address or length: " |
558 | "%8.8X%8.8X/%X", | ||
593 | name, | 559 | name, |
594 | ACPI_FORMAT_UINT64(address64-> | 560 | ACPI_FORMAT_UINT64(address64-> |
595 | address), | 561 | address), |
596 | length)); | 562 | length)); |
597 | } | 563 | } |
598 | } | 564 | } |
565 | } | ||
566 | } | ||
599 | 567 | ||
600 | /* If both 32- and 64-bit addresses are valid (non-zero), they must match */ | 568 | /******************************************************************************* |
569 | * | ||
570 | * FUNCTION: acpi_tb_setup_fadt_registers | ||
571 | * | ||
572 | * PARAMETERS: None, uses acpi_gbl_FADT. | ||
573 | * | ||
574 | * RETURN: None | ||
575 | * | ||
576 | * DESCRIPTION: Initialize global ACPI PM1 register definitions. Optionally, | ||
577 | * force FADT register definitions to their default lengths. | ||
578 | * | ||
579 | ******************************************************************************/ | ||
601 | 580 | ||
602 | if (address64->address && *address32 && | 581 | static void acpi_tb_setup_fadt_registers(void) |
603 | (address64->address != (u64) * address32)) { | 582 | { |
604 | ACPI_ERROR((AE_INFO, | 583 | struct acpi_generic_address *target64; |
605 | "32/64X address mismatch in %s: %8.8X/%8.8X%8.8X, using 64X", | 584 | struct acpi_generic_address *source64; |
606 | name, *address32, | 585 | u8 pm1_register_byte_width; |
607 | ACPI_FORMAT_UINT64(address64->address))); | 586 | u32 i; |
587 | |||
588 | /* | ||
589 | * Optionally check all register lengths against the default values and | ||
590 | * update them if they are incorrect. | ||
591 | */ | ||
592 | if (acpi_gbl_use_default_register_widths) { | ||
593 | for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { | ||
594 | target64 = | ||
595 | ACPI_ADD_PTR(struct acpi_generic_address, | ||
596 | &acpi_gbl_FADT, | ||
597 | fadt_info_table[i].address64); | ||
598 | |||
599 | /* | ||
600 | * If a valid register (Address != 0) and the (default_length > 0) | ||
601 | * (Not a GPE register), then check the width against the default. | ||
602 | */ | ||
603 | if ((target64->address) && | ||
604 | (fadt_info_table[i].default_length > 0) && | ||
605 | (fadt_info_table[i].default_length != | ||
606 | target64->bit_width)) { | ||
607 | ACPI_WARNING((AE_INFO, | ||
608 | "Invalid length for %s: %d, using default %d", | ||
609 | fadt_info_table[i].name, | ||
610 | target64->bit_width, | ||
611 | fadt_info_table[i]. | ||
612 | default_length)); | ||
613 | |||
614 | /* Incorrect size, set width to the default */ | ||
615 | |||
616 | target64->bit_width = | ||
617 | fadt_info_table[i].default_length; | ||
618 | } | ||
619 | } | ||
620 | } | ||
621 | |||
622 | /* | ||
623 | * Get the length of the individual PM1 registers (enable and status). | ||
624 | * Each register is defined to be (event block length / 2). Extra divide | ||
625 | * by 8 converts bits to bytes. | ||
626 | */ | ||
627 | pm1_register_byte_width = (u8) | ||
628 | ACPI_DIV_16(acpi_gbl_FADT.xpm1a_event_block.bit_width); | ||
629 | |||
630 | /* | ||
631 | * Calculate separate GAS structs for the PM1x (A/B) Status and Enable | ||
632 | * registers. These addresses do not appear (directly) in the FADT, so it | ||
633 | * is useful to pre-calculate them from the PM1 Event Block definitions. | ||
634 | * | ||
635 | * The PM event blocks are split into two register blocks, first is the | ||
636 | * PM Status Register block, followed immediately by the PM Enable | ||
637 | * Register block. Each is of length (pm1_event_length/2) | ||
638 | * | ||
639 | * Note: The PM1A event block is required by the ACPI specification. | ||
640 | * However, the PM1B event block is optional and is rarely, if ever, | ||
641 | * used. | ||
642 | */ | ||
643 | |||
644 | for (i = 0; i < ACPI_FADT_PM_INFO_ENTRIES; i++) { | ||
645 | source64 = | ||
646 | ACPI_ADD_PTR(struct acpi_generic_address, &acpi_gbl_FADT, | ||
647 | fadt_pm_info_table[i].source); | ||
648 | |||
649 | if (source64->address) { | ||
650 | acpi_tb_init_generic_address(fadt_pm_info_table[i]. | ||
651 | target, source64->space_id, | ||
652 | pm1_register_byte_width, | ||
653 | source64->address + | ||
654 | (fadt_pm_info_table[i]. | ||
655 | register_num * | ||
656 | pm1_register_byte_width)); | ||
608 | } | 657 | } |
609 | } | 658 | } |
610 | } | 659 | } |