Lines Matching +full:address +full:- +full:bits

1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
4 * Module Name: hwregs - Read/write access functions for the various ACPI
19 acpi_hw_get_access_bit_width(u64 address,
39 * PARAMETERS: address - GAS register address
40 * reg - GAS register structure
41 * max_bit_width - Max bit_width supported (32 or 64)
50 acpi_hw_get_access_bit_width(u64 address, in acpi_hw_get_access_bit_width() argument
66 * Note: This algorithm assumes that the "Address" fields should always in acpi_hw_get_access_bit_width()
69 if (!reg->bit_offset && reg->bit_width && in acpi_hw_get_access_bit_width()
70 ACPI_IS_POWER_OF_TWO(reg->bit_width) && in acpi_hw_get_access_bit_width()
71 ACPI_IS_ALIGNED(reg->bit_width, 8)) { in acpi_hw_get_access_bit_width()
72 access_bit_width = reg->bit_width; in acpi_hw_get_access_bit_width()
73 } else if (reg->access_width) { in acpi_hw_get_access_bit_width()
74 access_bit_width = ACPI_ACCESS_BIT_WIDTH(reg->access_width); in acpi_hw_get_access_bit_width()
77 ACPI_ROUND_UP_POWER_OF_TWO_8(reg->bit_offset + in acpi_hw_get_access_bit_width()
78 reg->bit_width); in acpi_hw_get_access_bit_width()
82 while (!ACPI_IS_ALIGNED(address, access_bit_width >> 3)) { in acpi_hw_get_access_bit_width()
90 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) { in acpi_hw_get_access_bit_width()
97 * a 32-bit accesses. in acpi_hw_get_access_bit_width()
109 * PARAMETERS: reg - GAS register structure
110 * max_bit_width - Max bit_width supported (32 or 64)
111 * address - Pointer to where the gas->address
117 * pointer, Address, space_id, bit_width, and bit_offset.
123 u8 max_bit_width, u64 *address) in acpi_hw_validate_register() argument
135 * Copy the target address. This handles possible alignment issues. in acpi_hw_validate_register()
136 * Address must not be null. A null address also indicates an optional in acpi_hw_validate_register()
139 ACPI_MOVE_64_TO_64(address, &reg->address); in acpi_hw_validate_register()
140 if (!(*address)) { in acpi_hw_validate_register()
146 if ((reg->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) && in acpi_hw_validate_register()
147 (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO)) { in acpi_hw_validate_register()
149 "Unsupported address space: 0x%X", reg->space_id)); in acpi_hw_validate_register()
155 if (reg->access_width > 4) { in acpi_hw_validate_register()
158 reg->access_width)); in acpi_hw_validate_register()
162 /* Validate the bit_width, convert access_width into number of bits */ in acpi_hw_validate_register()
165 acpi_hw_get_access_bit_width(*address, reg, max_bit_width); in acpi_hw_validate_register()
167 ACPI_ROUND_UP(reg->bit_offset + reg->bit_width, access_width); in acpi_hw_validate_register()
182 * PARAMETERS: value - Where the value is returned
183 * reg - GAS register structure
187 * DESCRIPTION: Read from either memory or IO space. This is a 64-bit max
197 u64 address; in acpi_hw_read() local
210 status = acpi_hw_validate_register(reg, 64, &address); in acpi_hw_read()
216 * Initialize entire 64-bit return value to zero, convert access_width in acpi_hw_read()
217 * into number of bits based in acpi_hw_read()
220 access_width = acpi_hw_get_access_bit_width(address, reg, 64); in acpi_hw_read()
221 bit_width = reg->bit_offset + reg->bit_width; in acpi_hw_read()
222 bit_offset = reg->bit_offset; in acpi_hw_read()
225 * Two address spaces supported: Memory or IO. PCI_Config is in acpi_hw_read()
232 bit_offset -= access_width; in acpi_hw_read()
234 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { in acpi_hw_read()
237 address + in acpi_hw_read()
245 address + in acpi_hw_read()
257 * ensured to be less than 64-bits by acpi_hw_validate_register(). in acpi_hw_read()
262 bit_width -= in acpi_hw_read()
270 ACPI_FORMAT_UINT64(address), in acpi_hw_read()
271 acpi_ut_get_region_name(reg->space_id))); in acpi_hw_read()
280 * PARAMETERS: value - Value to be written
281 * reg - GAS register structure
285 * DESCRIPTION: Write to either memory or IO space. This is a 64-bit max
292 u64 address; in acpi_hw_write() local
304 status = acpi_hw_validate_register(reg, 64, &address); in acpi_hw_write()
309 /* Convert access_width into number of bits based */ in acpi_hw_write()
311 access_width = acpi_hw_get_access_bit_width(address, reg, 64); in acpi_hw_write()
312 bit_width = reg->bit_offset + reg->bit_width; in acpi_hw_write()
313 bit_offset = reg->bit_offset; in acpi_hw_write()
316 * Two address spaces supported: Memory or IO. PCI_Config is in acpi_hw_write()
323 * ensured to be less than 64-bits by acpi_hw_validate_register(). in acpi_hw_write()
329 bit_offset -= access_width; in acpi_hw_write()
331 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { in acpi_hw_write()
334 address + in acpi_hw_write()
342 address + in acpi_hw_write()
352 * Index * access_width is ensured to be less than 32-bits by in acpi_hw_write()
355 bit_width -= in acpi_hw_write()
363 ACPI_FORMAT_UINT64(address), in acpi_hw_write()
364 acpi_ut_get_region_name(reg->space_id))); in acpi_hw_write()
378 * DESCRIPTION: Clears all fixed and general purpose status bits
391 ACPI_FORMAT_UINT64(acpi_gbl_xpm1a_status.address))); in acpi_hw_clear_acpi_status()
406 /* Clear the GPE Bits in all GPE registers in all GPE blocks */ in acpi_hw_clear_acpi_status()
418 * PARAMETERS: register_id - Index of ACPI Register to access
443 * PARAMETERS: pm1a_control - Value to be written to PM1A control
444 * pm1b_control - Value to be written to PM1B control
451 * Most notably, the SLP_TYP bits can be different, as per the
468 if (acpi_gbl_FADT.xpm1b_control_block.address) { in acpi_hw_write_pm1_control()
480 * PARAMETERS: register_id - ACPI Register ID
481 * return_value - Where the register value is returned
497 case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */ in acpi_hw_register_read()
504 case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */ in acpi_hw_register_read()
511 case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */ in acpi_hw_register_read()
520 * Zero the write-only bits. From the ACPI specification, "Hardware in acpi_hw_register_read()
521 * Write-Only Bits": "Upon reads to registers with write-only bits, in acpi_hw_register_read()
522 * software masks out all write-only bits." in acpi_hw_register_read()
527 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ in acpi_hw_register_read()
536 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ in acpi_hw_register_read()
545 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ in acpi_hw_register_read()
569 * PARAMETERS: register_id - ACPI Register ID
570 * value - The value to write
577 * preserves the value of the following bits, meaning that these bits cannot be
585 * 1) Hardware Ignored Bits: When software writes to a register with ignored
600 case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */ in acpi_hw_register_write()
603 * specification, ignored bits are to be preserved when writing. in acpi_hw_register_write()
618 case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */ in acpi_hw_register_write()
625 case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */ in acpi_hw_register_write()
627 * Perform a read first to preserve certain bits (per ACPI spec) in acpi_hw_register_write()
639 /* Insert the bits to be preserved */ in acpi_hw_register_write()
653 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ in acpi_hw_register_write()
655 * For control registers, all reserved bits must be preserved, in acpi_hw_register_write()
666 /* Insert the bits to be preserved */ in acpi_hw_register_write()
675 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ in acpi_hw_register_write()
680 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ in acpi_hw_register_write()
703 * PARAMETERS: value - Where the register value is returned
704 * register_a - First ACPI register (required)
705 * register_b - Second ACPI register (optional)
709 * DESCRIPTION: Read from the specified two-part ACPI register (such as PM1 A/B)
733 if (register_b->address) { in acpi_hw_read_multiple()
745 * "Although the bits can be split between the two register blocks (each in acpi_hw_read_multiple()
747 * are maintained. The register block with unimplemented bits (that is, in acpi_hw_read_multiple()
759 * PARAMETERS: value - The value to write
760 * register_a - First ACPI register (required)
761 * register_b - Second ACPI register (optional)
765 * DESCRIPTION: Write to the specified two-part ACPI register (such as PM1 A/B)
789 * "Although the bits can be split between the two register blocks (each in acpi_hw_write_multiple()
791 * are maintained. The register block with unimplemented bits (that is, in acpi_hw_write_multiple()
795 if (register_b->address) { in acpi_hw_write_multiple()