hwregs.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. /*******************************************************************************
  2. *
  3. * Module Name: hwregs - Read/write access functions for the various ACPI
  4. * control and status registers.
  5. *
  6. ******************************************************************************/
  7. /*
  8. * Copyright (C) 2000 - 2015, Intel Corp.
  9. * All rights reserved.
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  14. * 1. Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions, and the following disclaimer,
  16. * without modification.
  17. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18. * substantially similar to the "NO WARRANTY" disclaimer below
  19. * ("Disclaimer") and any redistribution must be conditioned upon
  20. * including a substantially similar Disclaimer requirement for further
  21. * binary redistribution.
  22. * 3. Neither the names of the above-listed copyright holders nor the names
  23. * of any contributors may be used to endorse or promote products derived
  24. * from this software without specific prior written permission.
  25. *
  26. * Alternatively, this software may be distributed under the terms of the
  27. * GNU General Public License ("GPL") version 2 as published by the Free
  28. * Software Foundation.
  29. *
  30. * NO WARRANTY
  31. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  32. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  33. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  34. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  35. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  36. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  37. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  38. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  39. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  40. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  41. * POSSIBILITY OF SUCH DAMAGES.
  42. */
  43. #include <acpi/acpi.h>
  44. #include "accommon.h"
  45. #include "acevents.h"
  46. #define _COMPONENT ACPI_HARDWARE
  47. ACPI_MODULE_NAME("hwregs")
  48. #if (!ACPI_REDUCED_HARDWARE)
  49. /* Local Prototypes */
  50. static acpi_status
  51. acpi_hw_read_multiple(u32 *value,
  52. struct acpi_generic_address *register_a,
  53. struct acpi_generic_address *register_b);
  54. static acpi_status
  55. acpi_hw_write_multiple(u32 value,
  56. struct acpi_generic_address *register_a,
  57. struct acpi_generic_address *register_b);
  58. #endif /* !ACPI_REDUCED_HARDWARE */
  59. /******************************************************************************
  60. *
  61. * FUNCTION: acpi_hw_validate_register
  62. *
  63. * PARAMETERS: reg - GAS register structure
  64. * max_bit_width - Max bit_width supported (32 or 64)
  65. * address - Pointer to where the gas->address
  66. * is returned
  67. *
  68. * RETURN: Status
  69. *
  70. * DESCRIPTION: Validate the contents of a GAS register. Checks the GAS
  71. * pointer, Address, space_id, bit_width, and bit_offset.
  72. *
  73. ******************************************************************************/
  74. acpi_status
  75. acpi_hw_validate_register(struct acpi_generic_address *reg,
  76. u8 max_bit_width, u64 *address)
  77. {
  78. /* Must have a valid pointer to a GAS structure */
  79. if (!reg) {
  80. return (AE_BAD_PARAMETER);
  81. }
  82. /*
  83. * Copy the target address. This handles possible alignment issues.
  84. * Address must not be null. A null address also indicates an optional
  85. * ACPI register that is not supported, so no error message.
  86. */
  87. ACPI_MOVE_64_TO_64(address, &reg->address);
  88. if (!(*address)) {
  89. return (AE_BAD_ADDRESS);
  90. }
  91. /* Validate the space_ID */
  92. if ((reg->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
  93. (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO)) {
  94. ACPI_ERROR((AE_INFO,
  95. "Unsupported address space: 0x%X", reg->space_id));
  96. return (AE_SUPPORT);
  97. }
  98. /* Validate the bit_width */
  99. if ((reg->bit_width != 8) &&
  100. (reg->bit_width != 16) &&
  101. (reg->bit_width != 32) && (reg->bit_width != max_bit_width)) {
  102. ACPI_ERROR((AE_INFO,
  103. "Unsupported register bit width: 0x%X",
  104. reg->bit_width));
  105. return (AE_SUPPORT);
  106. }
  107. /* Validate the bit_offset. Just a warning for now. */
  108. if (reg->bit_offset != 0) {
  109. ACPI_WARNING((AE_INFO,
  110. "Unsupported register bit offset: 0x%X",
  111. reg->bit_offset));
  112. }
  113. return (AE_OK);
  114. }
  115. /******************************************************************************
  116. *
  117. * FUNCTION: acpi_hw_read
  118. *
  119. * PARAMETERS: value - Where the value is returned
  120. * reg - GAS register structure
  121. *
  122. * RETURN: Status
  123. *
  124. * DESCRIPTION: Read from either memory or IO space. This is a 32-bit max
  125. * version of acpi_read, used internally since the overhead of
  126. * 64-bit values is not needed.
  127. *
  128. * LIMITATIONS: <These limitations also apply to acpi_hw_write>
  129. * bit_width must be exactly 8, 16, or 32.
  130. * space_ID must be system_memory or system_IO.
  131. * bit_offset and access_width are currently ignored, as there has
  132. * not been a need to implement these.
  133. *
  134. ******************************************************************************/
  135. acpi_status acpi_hw_read(u32 *value, struct acpi_generic_address *reg)
  136. {
  137. u64 address;
  138. u64 value64;
  139. acpi_status status;
  140. ACPI_FUNCTION_NAME(hw_read);
  141. /* Validate contents of the GAS register */
  142. status = acpi_hw_validate_register(reg, 32, &address);
  143. if (ACPI_FAILURE(status)) {
  144. return (status);
  145. }
  146. /* Initialize entire 32-bit return value to zero */
  147. *value = 0;
  148. /*
  149. * Two address spaces supported: Memory or IO. PCI_Config is
  150. * not supported here because the GAS structure is insufficient
  151. */
  152. if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
  153. status = acpi_os_read_memory((acpi_physical_address)
  154. address, &value64, reg->bit_width);
  155. *value = (u32)value64;
  156. } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
  157. status = acpi_hw_read_port((acpi_io_address)
  158. address, value, reg->bit_width);
  159. }
  160. ACPI_DEBUG_PRINT((ACPI_DB_IO,
  161. "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n",
  162. *value, reg->bit_width, ACPI_FORMAT_UINT64(address),
  163. acpi_ut_get_region_name(reg->space_id)));
  164. return (status);
  165. }
  166. /******************************************************************************
  167. *
  168. * FUNCTION: acpi_hw_write
  169. *
  170. * PARAMETERS: value - Value to be written
  171. * reg - GAS register structure
  172. *
  173. * RETURN: Status
  174. *
  175. * DESCRIPTION: Write to either memory or IO space. This is a 32-bit max
  176. * version of acpi_write, used internally since the overhead of
  177. * 64-bit values is not needed.
  178. *
  179. ******************************************************************************/
  180. acpi_status acpi_hw_write(u32 value, struct acpi_generic_address *reg)
  181. {
  182. u64 address;
  183. acpi_status status;
  184. ACPI_FUNCTION_NAME(hw_write);
  185. /* Validate contents of the GAS register */
  186. status = acpi_hw_validate_register(reg, 32, &address);
  187. if (ACPI_FAILURE(status)) {
  188. return (status);
  189. }
  190. /*
  191. * Two address spaces supported: Memory or IO. PCI_Config is
  192. * not supported here because the GAS structure is insufficient
  193. */
  194. if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
  195. status = acpi_os_write_memory((acpi_physical_address)
  196. address, (u64)value,
  197. reg->bit_width);
  198. } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
  199. status = acpi_hw_write_port((acpi_io_address)
  200. address, value, reg->bit_width);
  201. }
  202. ACPI_DEBUG_PRINT((ACPI_DB_IO,
  203. "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n",
  204. value, reg->bit_width, ACPI_FORMAT_UINT64(address),
  205. acpi_ut_get_region_name(reg->space_id)));
  206. return (status);
  207. }
  208. #if (!ACPI_REDUCED_HARDWARE)
  209. /*******************************************************************************
  210. *
  211. * FUNCTION: acpi_hw_clear_acpi_status
  212. *
  213. * PARAMETERS: None
  214. *
  215. * RETURN: Status
  216. *
  217. * DESCRIPTION: Clears all fixed and general purpose status bits
  218. *
  219. ******************************************************************************/
  220. acpi_status acpi_hw_clear_acpi_status(void)
  221. {
  222. acpi_status status;
  223. acpi_cpu_flags lock_flags = 0;
  224. ACPI_FUNCTION_TRACE(hw_clear_acpi_status);
  225. ACPI_DEBUG_PRINT((ACPI_DB_IO, "About to write %04X to %8.8X%8.8X\n",
  226. ACPI_BITMASK_ALL_FIXED_STATUS,
  227. ACPI_FORMAT_UINT64(acpi_gbl_xpm1a_status.address)));
  228. lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
  229. /* Clear the fixed events in PM1 A/B */
  230. status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS,
  231. ACPI_BITMASK_ALL_FIXED_STATUS);
  232. acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags);
  233. if (ACPI_FAILURE(status)) {
  234. goto exit;
  235. }
  236. /* Clear the GPE Bits in all GPE registers in all GPE blocks */
  237. status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL);
  238. exit:
  239. return_ACPI_STATUS(status);
  240. }
  241. /*******************************************************************************
  242. *
  243. * FUNCTION: acpi_hw_get_bit_register_info
  244. *
  245. * PARAMETERS: register_id - Index of ACPI Register to access
  246. *
  247. * RETURN: The bitmask to be used when accessing the register
  248. *
  249. * DESCRIPTION: Map register_id into a register bitmask.
  250. *
  251. ******************************************************************************/
  252. struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id)
  253. {
  254. ACPI_FUNCTION_ENTRY();
  255. if (register_id > ACPI_BITREG_MAX) {
  256. ACPI_ERROR((AE_INFO, "Invalid BitRegister ID: 0x%X",
  257. register_id));
  258. return (NULL);
  259. }
  260. return (&acpi_gbl_bit_register_info[register_id]);
  261. }
  262. /******************************************************************************
  263. *
  264. * FUNCTION: acpi_hw_write_pm1_control
  265. *
  266. * PARAMETERS: pm1a_control - Value to be written to PM1A control
  267. * pm1b_control - Value to be written to PM1B control
  268. *
  269. * RETURN: Status
  270. *
  271. * DESCRIPTION: Write the PM1 A/B control registers. These registers are
  272. * different than than the PM1 A/B status and enable registers
  273. * in that different values can be written to the A/B registers.
  274. * Most notably, the SLP_TYP bits can be different, as per the
  275. * values returned from the _Sx predefined methods.
  276. *
  277. ******************************************************************************/
  278. acpi_status acpi_hw_write_pm1_control(u32 pm1a_control, u32 pm1b_control)
  279. {
  280. acpi_status status;
  281. ACPI_FUNCTION_TRACE(hw_write_pm1_control);
  282. status =
  283. acpi_hw_write(pm1a_control, &acpi_gbl_FADT.xpm1a_control_block);
  284. if (ACPI_FAILURE(status)) {
  285. return_ACPI_STATUS(status);
  286. }
  287. if (acpi_gbl_FADT.xpm1b_control_block.address) {
  288. status =
  289. acpi_hw_write(pm1b_control,
  290. &acpi_gbl_FADT.xpm1b_control_block);
  291. }
  292. return_ACPI_STATUS(status);
  293. }
  294. /******************************************************************************
  295. *
  296. * FUNCTION: acpi_hw_register_read
  297. *
  298. * PARAMETERS: register_id - ACPI Register ID
  299. * return_value - Where the register value is returned
  300. *
  301. * RETURN: Status and the value read.
  302. *
  303. * DESCRIPTION: Read from the specified ACPI register
  304. *
  305. ******************************************************************************/
  306. acpi_status acpi_hw_register_read(u32 register_id, u32 *return_value)
  307. {
  308. u32 value = 0;
  309. acpi_status status;
  310. ACPI_FUNCTION_TRACE(hw_register_read);
  311. switch (register_id) {
  312. case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */
  313. status = acpi_hw_read_multiple(&value,
  314. &acpi_gbl_xpm1a_status,
  315. &acpi_gbl_xpm1b_status);
  316. break;
  317. case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */
  318. status = acpi_hw_read_multiple(&value,
  319. &acpi_gbl_xpm1a_enable,
  320. &acpi_gbl_xpm1b_enable);
  321. break;
  322. case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */
  323. status = acpi_hw_read_multiple(&value,
  324. &acpi_gbl_FADT.
  325. xpm1a_control_block,
  326. &acpi_gbl_FADT.
  327. xpm1b_control_block);
  328. /*
  329. * Zero the write-only bits. From the ACPI specification, "Hardware
  330. * Write-Only Bits": "Upon reads to registers with write-only bits,
  331. * software masks out all write-only bits."
  332. */
  333. value &= ~ACPI_PM1_CONTROL_WRITEONLY_BITS;
  334. break;
  335. case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
  336. status =
  337. acpi_hw_read(&value, &acpi_gbl_FADT.xpm2_control_block);
  338. break;
  339. case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
  340. status = acpi_hw_read(&value, &acpi_gbl_FADT.xpm_timer_block);
  341. break;
  342. case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
  343. status =
  344. acpi_hw_read_port(acpi_gbl_FADT.smi_command, &value, 8);
  345. break;
  346. default:
  347. ACPI_ERROR((AE_INFO, "Unknown Register ID: 0x%X", register_id));
  348. status = AE_BAD_PARAMETER;
  349. break;
  350. }
  351. if (ACPI_SUCCESS(status)) {
  352. *return_value = value;
  353. }
  354. return_ACPI_STATUS(status);
  355. }
  356. /******************************************************************************
  357. *
  358. * FUNCTION: acpi_hw_register_write
  359. *
  360. * PARAMETERS: register_id - ACPI Register ID
  361. * value - The value to write
  362. *
  363. * RETURN: Status
  364. *
  365. * DESCRIPTION: Write to the specified ACPI register
  366. *
  367. * NOTE: In accordance with the ACPI specification, this function automatically
  368. * preserves the value of the following bits, meaning that these bits cannot be
  369. * changed via this interface:
  370. *
  371. * PM1_CONTROL[0] = SCI_EN
  372. * PM1_CONTROL[9]
  373. * PM1_STATUS[11]
  374. *
  375. * ACPI References:
  376. * 1) Hardware Ignored Bits: When software writes to a register with ignored
  377. * bit fields, it preserves the ignored bit fields
  378. * 2) SCI_EN: OSPM always preserves this bit position
  379. *
  380. ******************************************************************************/
  381. acpi_status acpi_hw_register_write(u32 register_id, u32 value)
  382. {
  383. acpi_status status;
  384. u32 read_value;
  385. ACPI_FUNCTION_TRACE(hw_register_write);
  386. switch (register_id) {
  387. case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */
  388. /*
  389. * Handle the "ignored" bit in PM1 Status. According to the ACPI
  390. * specification, ignored bits are to be preserved when writing.
  391. * Normally, this would mean a read/modify/write sequence. However,
  392. * preserving a bit in the status register is different. Writing a
  393. * one clears the status, and writing a zero preserves the status.
  394. * Therefore, we must always write zero to the ignored bit.
  395. *
  396. * This behavior is clarified in the ACPI 4.0 specification.
  397. */
  398. value &= ~ACPI_PM1_STATUS_PRESERVED_BITS;
  399. status = acpi_hw_write_multiple(value,
  400. &acpi_gbl_xpm1a_status,
  401. &acpi_gbl_xpm1b_status);
  402. break;
  403. case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */
  404. status = acpi_hw_write_multiple(value,
  405. &acpi_gbl_xpm1a_enable,
  406. &acpi_gbl_xpm1b_enable);
  407. break;
  408. case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */
  409. /*
  410. * Perform a read first to preserve certain bits (per ACPI spec)
  411. * Note: This includes SCI_EN, we never want to change this bit
  412. */
  413. status = acpi_hw_read_multiple(&read_value,
  414. &acpi_gbl_FADT.
  415. xpm1a_control_block,
  416. &acpi_gbl_FADT.
  417. xpm1b_control_block);
  418. if (ACPI_FAILURE(status)) {
  419. goto exit;
  420. }
  421. /* Insert the bits to be preserved */
  422. ACPI_INSERT_BITS(value, ACPI_PM1_CONTROL_PRESERVED_BITS,
  423. read_value);
  424. /* Now we can write the data */
  425. status = acpi_hw_write_multiple(value,
  426. &acpi_gbl_FADT.
  427. xpm1a_control_block,
  428. &acpi_gbl_FADT.
  429. xpm1b_control_block);
  430. break;
  431. case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
  432. /*
  433. * For control registers, all reserved bits must be preserved,
  434. * as per the ACPI spec.
  435. */
  436. status =
  437. acpi_hw_read(&read_value,
  438. &acpi_gbl_FADT.xpm2_control_block);
  439. if (ACPI_FAILURE(status)) {
  440. goto exit;
  441. }
  442. /* Insert the bits to be preserved */
  443. ACPI_INSERT_BITS(value, ACPI_PM2_CONTROL_PRESERVED_BITS,
  444. read_value);
  445. status =
  446. acpi_hw_write(value, &acpi_gbl_FADT.xpm2_control_block);
  447. break;
  448. case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
  449. status = acpi_hw_write(value, &acpi_gbl_FADT.xpm_timer_block);
  450. break;
  451. case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
  452. /* SMI_CMD is currently always in IO space */
  453. status =
  454. acpi_hw_write_port(acpi_gbl_FADT.smi_command, value, 8);
  455. break;
  456. default:
  457. ACPI_ERROR((AE_INFO, "Unknown Register ID: 0x%X", register_id));
  458. status = AE_BAD_PARAMETER;
  459. break;
  460. }
  461. exit:
  462. return_ACPI_STATUS(status);
  463. }
  464. /******************************************************************************
  465. *
  466. * FUNCTION: acpi_hw_read_multiple
  467. *
  468. * PARAMETERS: value - Where the register value is returned
  469. * register_a - First ACPI register (required)
  470. * register_b - Second ACPI register (optional)
  471. *
  472. * RETURN: Status
  473. *
  474. * DESCRIPTION: Read from the specified two-part ACPI register (such as PM1 A/B)
  475. *
  476. ******************************************************************************/
  477. static acpi_status
  478. acpi_hw_read_multiple(u32 *value,
  479. struct acpi_generic_address *register_a,
  480. struct acpi_generic_address *register_b)
  481. {
  482. u32 value_a = 0;
  483. u32 value_b = 0;
  484. acpi_status status;
  485. /* The first register is always required */
  486. status = acpi_hw_read(&value_a, register_a);
  487. if (ACPI_FAILURE(status)) {
  488. return (status);
  489. }
  490. /* Second register is optional */
  491. if (register_b->address) {
  492. status = acpi_hw_read(&value_b, register_b);
  493. if (ACPI_FAILURE(status)) {
  494. return (status);
  495. }
  496. }
  497. /*
  498. * OR the two return values together. No shifting or masking is necessary,
  499. * because of how the PM1 registers are defined in the ACPI specification:
  500. *
  501. * "Although the bits can be split between the two register blocks (each
  502. * register block has a unique pointer within the FADT), the bit positions
  503. * are maintained. The register block with unimplemented bits (that is,
  504. * those implemented in the other register block) always returns zeros,
  505. * and writes have no side effects"
  506. */
  507. *value = (value_a | value_b);
  508. return (AE_OK);
  509. }
  510. /******************************************************************************
  511. *
  512. * FUNCTION: acpi_hw_write_multiple
  513. *
  514. * PARAMETERS: value - The value to write
  515. * register_a - First ACPI register (required)
  516. * register_b - Second ACPI register (optional)
  517. *
  518. * RETURN: Status
  519. *
  520. * DESCRIPTION: Write to the specified two-part ACPI register (such as PM1 A/B)
  521. *
  522. ******************************************************************************/
  523. static acpi_status
  524. acpi_hw_write_multiple(u32 value,
  525. struct acpi_generic_address *register_a,
  526. struct acpi_generic_address *register_b)
  527. {
  528. acpi_status status;
  529. /* The first register is always required */
  530. status = acpi_hw_write(value, register_a);
  531. if (ACPI_FAILURE(status)) {
  532. return (status);
  533. }
  534. /*
  535. * Second register is optional
  536. *
  537. * No bit shifting or clearing is necessary, because of how the PM1
  538. * registers are defined in the ACPI specification:
  539. *
  540. * "Although the bits can be split between the two register blocks (each
  541. * register block has a unique pointer within the FADT), the bit positions
  542. * are maintained. The register block with unimplemented bits (that is,
  543. * those implemented in the other register block) always returns zeros,
  544. * and writes have no side effects"
  545. */
  546. if (register_b->address) {
  547. status = acpi_hw_write(value, register_b);
  548. }
  549. return (status);
  550. }
  551. #endif /* !ACPI_REDUCED_HARDWARE */