ACPICA: New: acpi_read and acpi_write public interfaces

Changed the acpi_hw_low_level_read and acpi_hw_low_level_write functions to
the public acpi_read and acpi_write to allow direct access to
ACPI registers.  Removed the "width" parameter since the width
can be obtained from the input GAS structure. Updated the FADT
initialization to setup the GAS structures with the proper
widths. Some widths are still hardcoded because many FADTs have
incorrect register lengths.

Signed-off-by: Bob Moore <robert.moore@intel.com
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
Bob Moore 2008-12-31 02:55:32 +08:00 committed by Len Brown
parent 385c4d98d8
commit ecfbbc7b46
7 changed files with 89 additions and 126 deletions

View File

@ -422,10 +422,8 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
/* Read the Status Register */ /* Read the Status Register */
status = status =
acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH, acpi_read(&status_reg,
&status_reg, &gpe_register_info->status_address);
&gpe_register_info->
status_address);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
goto unlock_and_exit; goto unlock_and_exit;
} }
@ -433,10 +431,8 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
/* Read the Enable Register */ /* Read the Enable Register */
status = status =
acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH, acpi_read(&enable_reg,
&enable_reg, &gpe_register_info->enable_address);
&gpe_register_info->
enable_address);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
goto unlock_and_exit; goto unlock_and_exit;
} }

View File

@ -830,10 +830,8 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
ACPI_GPE_REGISTER_WIDTH; ACPI_GPE_REGISTER_WIDTH;
this_register->enable_address.bit_width = this_register->enable_address.bit_width =
ACPI_GPE_REGISTER_WIDTH; ACPI_GPE_REGISTER_WIDTH;
this_register->status_address.bit_offset = this_register->status_address.bit_offset = 0;
ACPI_GPE_REGISTER_WIDTH; this_register->enable_address.bit_offset = 0;
this_register->enable_address.bit_offset =
ACPI_GPE_REGISTER_WIDTH;
/* Init the event_info for each GPE within this register */ /* Init the event_info for each GPE within this register */
@ -846,18 +844,14 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
/* Disable all GPEs within this register */ /* Disable all GPEs within this register */
status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0x00, status = acpi_write(0x00, &this_register->enable_address);
&this_register->
enable_address);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
goto error_exit; goto error_exit;
} }
/* Clear any pending GPE events within this register */ /* Clear any pending GPE events within this register */
status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0xFF, status = acpi_write(0xFF, &this_register->status_address);
&this_register->
status_address);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
goto error_exit; goto error_exit;
} }

View File

@ -81,8 +81,7 @@ acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info)
/* Get current value of the enable register that contains this GPE */ /* Get current value of the enable register that contains this GPE */
status = acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH, &enable_mask, status = acpi_read(&enable_mask, &gpe_register_info->enable_address);
&gpe_register_info->enable_address);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return (status); return (status);
} }
@ -96,9 +95,7 @@ acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info)
/* Write the updated enable mask */ /* Write the updated enable mask */
status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, enable_mask, status = acpi_write(enable_mask, &gpe_register_info->enable_address);
&gpe_register_info->enable_address);
return (status); return (status);
} }
@ -133,8 +130,8 @@ acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info * gpe_event_info)
/* Write the entire GPE (runtime) enable register */ /* Write the entire GPE (runtime) enable register */
status = acpi_hw_low_level_write(8, gpe_register_info->enable_for_run, status = acpi_write(gpe_register_info->enable_for_run,
&gpe_register_info->enable_address); &gpe_register_info->enable_address);
return (status); return (status);
} }
@ -167,9 +164,8 @@ acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info)
* Write a one to the appropriate bit in the status register to * Write a one to the appropriate bit in the status register to
* clear this GPE. * clear this GPE.
*/ */
status = acpi_hw_low_level_write(8, register_bit, status = acpi_write(register_bit,
&gpe_event_info->register_info-> &gpe_event_info->register_info->status_address);
status_address);
return (status); return (status);
} }
@ -228,9 +224,7 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
/* GPE currently active (status bit == 1)? */ /* GPE currently active (status bit == 1)? */
status = status = acpi_read(&in_byte, &gpe_register_info->status_address);
acpi_hw_low_level_read(8, &in_byte,
&gpe_register_info->status_address);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
goto unlock_and_exit; goto unlock_and_exit;
} }
@ -273,9 +267,9 @@ acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
/* Disable all GPEs in this register */ /* Disable all GPEs in this register */
status = acpi_hw_low_level_write(8, 0x00, status =
&gpe_block->register_info[i]. acpi_write(0x00,
enable_address); &gpe_block->register_info[i].enable_address);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return (status); return (status);
} }
@ -310,9 +304,9 @@ acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
/* Clear status on all GPEs in this register */ /* Clear status on all GPEs in this register */
status = acpi_hw_low_level_write(8, 0xFF, status =
&gpe_block->register_info[i]. acpi_write(0xFF,
status_address); &gpe_block->register_info[i].status_address);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return (status); return (status);
} }
@ -353,12 +347,9 @@ acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
/* Enable all "runtime" GPEs in this register */ /* Enable all "runtime" GPEs in this register */
status = status = acpi_write(gpe_block->register_info[i].enable_for_run,
acpi_hw_low_level_write(8, &gpe_block->register_info[i].
gpe_block->register_info[i]. enable_address);
enable_for_run,
&gpe_block->register_info[i].
enable_address);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return (status); return (status);
} }
@ -398,11 +389,9 @@ acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
/* Enable all "wake" GPEs in this register */ /* Enable all "wake" GPEs in this register */
status = acpi_hw_low_level_write(8, status = acpi_write(gpe_block->register_info[i].enable_for_wake,
gpe_block->register_info[i]. &gpe_block->register_info[i].
enable_for_wake, enable_address);
&gpe_block->register_info[i].
enable_address);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return (status); return (status);
} }

View File

@ -84,9 +84,8 @@ acpi_status acpi_hw_clear_acpi_status(void)
/* Clear the fixed events */ /* Clear the fixed events */
if (acpi_gbl_FADT.xpm1b_event_block.address) { if (acpi_gbl_FADT.xpm1b_event_block.address) {
status = status = acpi_write(ACPI_BITMASK_ALL_FIXED_STATUS,
acpi_hw_low_level_write(16, ACPI_BITMASK_ALL_FIXED_STATUS, &acpi_gbl_FADT.xpm1b_event_block);
&acpi_gbl_FADT.xpm1b_event_block);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
goto unlock_and_exit; goto unlock_and_exit;
} }
@ -244,6 +243,8 @@ struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id)
return (&acpi_gbl_bit_register_info[register_id]); return (&acpi_gbl_bit_register_info[register_id]);
} }
ACPI_EXPORT_SYMBOL(acpi_get_register_unlocked)
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_get_register * FUNCTION: acpi_get_register
@ -483,63 +484,49 @@ acpi_hw_register_read(u32 register_id, u32 * return_value)
switch (register_id) { switch (register_id) {
case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
status = status = acpi_read(&value1, &acpi_gbl_FADT.xpm1a_event_block);
acpi_hw_low_level_read(16, &value1,
&acpi_gbl_FADT.xpm1a_event_block);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
goto exit; goto exit;
} }
/* PM1B is optional */ /* PM1B is optional */
status = status = acpi_read(&value2, &acpi_gbl_FADT.xpm1b_event_block);
acpi_hw_low_level_read(16, &value2,
&acpi_gbl_FADT.xpm1b_event_block);
value1 |= value2; value1 |= value2;
break; break;
case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */
status = status = acpi_read(&value1, &acpi_gbl_xpm1a_enable);
acpi_hw_low_level_read(16, &value1, &acpi_gbl_xpm1a_enable);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
goto exit; goto exit;
} }
/* PM1B is optional */ /* PM1B is optional */
status = status = acpi_read(&value2, &acpi_gbl_xpm1b_enable);
acpi_hw_low_level_read(16, &value2, &acpi_gbl_xpm1b_enable);
value1 |= value2; value1 |= value2;
break; break;
case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
status = status = acpi_read(&value1, &acpi_gbl_FADT.xpm1a_control_block);
acpi_hw_low_level_read(16, &value1,
&acpi_gbl_FADT.xpm1a_control_block);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
goto exit; goto exit;
} }
status = status = acpi_read(&value2, &acpi_gbl_FADT.xpm1b_control_block);
acpi_hw_low_level_read(16, &value2,
&acpi_gbl_FADT.xpm1b_control_block);
value1 |= value2; value1 |= value2;
break; break;
case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
status = status = acpi_read(&value1, &acpi_gbl_FADT.xpm2_control_block);
acpi_hw_low_level_read(8, &value1,
&acpi_gbl_FADT.xpm2_control_block);
break; break;
case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
status = status = acpi_read(&value1, &acpi_gbl_FADT.xpm_timer_block);
acpi_hw_low_level_read(32, &value1,
&acpi_gbl_FADT.xpm_timer_block);
break; break;
case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
@ -614,32 +601,26 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value)
/* Now we can write the data */ /* Now we can write the data */
status = status = acpi_write(value, &acpi_gbl_FADT.xpm1a_event_block);
acpi_hw_low_level_write(16, value,
&acpi_gbl_FADT.xpm1a_event_block);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
goto exit; goto exit;
} }
/* PM1B is optional */ /* PM1B is optional */
status = status = acpi_write(value, &acpi_gbl_FADT.xpm1b_event_block);
acpi_hw_low_level_write(16, value,
&acpi_gbl_FADT.xpm1b_event_block);
break; break;
case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */
status = status = acpi_write(value, &acpi_gbl_xpm1a_enable);
acpi_hw_low_level_write(16, value, &acpi_gbl_xpm1a_enable);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
goto exit; goto exit;
} }
/* PM1B is optional */ /* PM1B is optional */
status = status = acpi_write(value, &acpi_gbl_xpm1b_enable);
acpi_hw_low_level_write(16, value, &acpi_gbl_xpm1b_enable);
break; break;
case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
@ -660,44 +641,32 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value)
/* Now we can write the data */ /* Now we can write the data */
status = status = acpi_write(value, &acpi_gbl_FADT.xpm1a_control_block);
acpi_hw_low_level_write(16, value,
&acpi_gbl_FADT.xpm1a_control_block);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
goto exit; goto exit;
} }
status = status = acpi_write(value, &acpi_gbl_FADT.xpm1b_control_block);
acpi_hw_low_level_write(16, value,
&acpi_gbl_FADT.xpm1b_control_block);
break; break;
case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */ case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */
status = status = acpi_write(value, &acpi_gbl_FADT.xpm1a_control_block);
acpi_hw_low_level_write(16, value,
&acpi_gbl_FADT.xpm1a_control_block);
break; break;
case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */ case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */
status = status = acpi_write(value, &acpi_gbl_FADT.xpm1b_control_block);
acpi_hw_low_level_write(16, value,
&acpi_gbl_FADT.xpm1b_control_block);
break; break;
case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
status = status = acpi_write(value, &acpi_gbl_FADT.xpm2_control_block);
acpi_hw_low_level_write(8, value,
&acpi_gbl_FADT.xpm2_control_block);
break; break;
case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
status = status = acpi_write(value, &acpi_gbl_FADT.xpm_timer_block);
acpi_hw_low_level_write(32, value,
&acpi_gbl_FADT.xpm_timer_block);
break; break;
case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
@ -719,10 +688,9 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value)
/****************************************************************************** /******************************************************************************
* *
* FUNCTION: acpi_hw_low_level_read * FUNCTION: acpi_read
* *
* PARAMETERS: Width - 8, 16, or 32 * PARAMETERS: Value - Where the value is returned
* Value - Where the value is returned
* Reg - GAS register structure * Reg - GAS register structure
* *
* RETURN: Status * RETURN: Status
@ -731,13 +699,13 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value)
* *
******************************************************************************/ ******************************************************************************/
acpi_status acpi_status acpi_read(u32 *value, struct acpi_generic_address *reg)
acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg)
{ {
u32 width;
u64 address; u64 address;
acpi_status status; acpi_status status;
ACPI_FUNCTION_NAME(hw_low_level_read); ACPI_FUNCTION_NAME(acpi_read);
/* /*
* Must have a valid pointer to a GAS structure, and * Must have a valid pointer to a GAS structure, and
@ -754,6 +722,16 @@ acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg)
if (!address) { if (!address) {
return (AE_OK); return (AE_OK);
} }
/* Supported widths are 8/16/32 */
width = reg->bit_width;
if ((width != 8) && (width != 16) && (width != 32)) {
return (AE_SUPPORT);
}
/* Initialize entire 32-bit return value to zero */
*value = 0; *value = 0;
/* /*
@ -787,12 +765,13 @@ acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg)
return (status); return (status);
} }
ACPI_EXPORT_SYMBOL(acpi_read)
/****************************************************************************** /******************************************************************************
* *
* FUNCTION: acpi_hw_low_level_write * FUNCTION: acpi_write
* *
* PARAMETERS: Width - 8, 16, or 32 * PARAMETERS: Value - To be written
* Value - To be written
* Reg - GAS register structure * Reg - GAS register structure
* *
* RETURN: Status * RETURN: Status
@ -802,12 +781,13 @@ acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg)
******************************************************************************/ ******************************************************************************/
acpi_status acpi_status
acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address * reg) acpi_write(u32 value, struct acpi_generic_address *reg)
{ {
u32 width;
u64 address; u64 address;
acpi_status status; acpi_status status;
ACPI_FUNCTION_NAME(hw_low_level_write); ACPI_FUNCTION_NAME(acpi_write);
/* /*
* Must have a valid pointer to a GAS structure, and * Must have a valid pointer to a GAS structure, and
@ -825,6 +805,13 @@ acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address * reg)
return (AE_OK); return (AE_OK);
} }
/* Supported widths are 8/16/32 */
width = reg->bit_width;
if ((width != 8) && (width != 16) && (width != 32)) {
return (AE_SUPPORT);
}
/* /*
* Two address spaces supported: Memory or IO. * Two address spaces supported: Memory or IO.
* PCI_Config is not supported here because the GAS struct is insufficient * PCI_Config is not supported here because the GAS struct is insufficient
@ -855,3 +842,5 @@ acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address * reg)
return (status); return (status);
} }
ACPI_EXPORT_SYMBOL(acpi_write)

View File

@ -42,7 +42,7 @@ void acpi_reboot(void)
case ACPI_ADR_SPACE_SYSTEM_MEMORY: case ACPI_ADR_SPACE_SYSTEM_MEMORY:
case ACPI_ADR_SPACE_SYSTEM_IO: case ACPI_ADR_SPACE_SYSTEM_IO:
printk(KERN_DEBUG "ACPI MEMORY or I/O RESET_REG.\n"); printk(KERN_DEBUG "ACPI MEMORY or I/O RESET_REG.\n");
acpi_hw_low_level_write(8, reset_value, rr); acpi_write(reset_value, rr);
break; break;
} }
/* Wait ten seconds */ /* Wait ten seconds */

View File

@ -75,13 +75,6 @@ acpi_hw_register_read(u32 register_id, u32 * return_value);
acpi_status acpi_hw_register_write(u32 register_id, u32 value); acpi_status acpi_hw_register_write(u32 register_id, u32 value);
acpi_status
acpi_hw_low_level_read(u32 width,
u32 * value, struct acpi_generic_address *reg);
acpi_status
acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address *reg);
acpi_status acpi_hw_clear_acpi_status(void); acpi_status acpi_hw_clear_acpi_status(void);
/* /*

View File

@ -81,11 +81,6 @@ const char *acpi_format_exception(acpi_status exception);
acpi_status acpi_purge_cached_objects(void); acpi_status acpi_purge_cached_objects(void);
#ifdef ACPI_FUTURE_USAGE
acpi_status
acpi_install_initialization_handler(acpi_init_handler handler, u32 function);
#endif
/* /*
* ACPI Memory management * ACPI Memory management
*/ */
@ -195,8 +190,11 @@ acpi_status acpi_get_id(acpi_handle object, acpi_owner_id * out_type);
acpi_status acpi_get_parent(acpi_handle object, acpi_handle * out_handle); acpi_status acpi_get_parent(acpi_handle object, acpi_handle * out_handle);
/* /*
* Event handler interfaces * Handler interfaces
*/ */
acpi_status
acpi_install_initialization_handler(acpi_init_handler handler, u32 function);
acpi_status acpi_status
acpi_install_fixed_event_handler(u32 acpi_event, acpi_install_fixed_event_handler(u32 acpi_event,
acpi_event_handler handler, void *context); acpi_event_handler handler, void *context);
@ -336,6 +334,10 @@ acpi_set_firmware_waking_vector(u32 physical_address);
acpi_status acpi_status
acpi_set_firmware_waking_vector64(u64 physical_address); acpi_set_firmware_waking_vector64(u64 physical_address);
acpi_status acpi_read(u32 *value, struct acpi_generic_address *reg);
acpi_status acpi_write(u32 value, struct acpi_generic_address *reg);
acpi_status acpi_status
acpi_get_sleep_type_data(u8 sleep_state, u8 * slp_typ_a, u8 * slp_typ_b); acpi_get_sleep_type_data(u8 sleep_state, u8 * slp_typ_a, u8 * slp_typ_b);