Commit ecfbbc7b authored by Bob Moore's avatar Bob Moore Committed by Len Brown

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: default avatarLin Ming <ming.m.lin@intel.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent 385c4d98
......@@ -422,10 +422,8 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
/* Read the Status Register */
status =
acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH,
&status_reg,
&gpe_register_info->
status_address);
acpi_read(&status_reg,
&gpe_register_info->status_address);
if (ACPI_FAILURE(status)) {
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 */
status =
acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH,
&enable_reg,
&gpe_register_info->
enable_address);
acpi_read(&enable_reg,
&gpe_register_info->enable_address);
if (ACPI_FAILURE(status)) {
goto unlock_and_exit;
}
......
......@@ -830,10 +830,8 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
ACPI_GPE_REGISTER_WIDTH;
this_register->enable_address.bit_width =
ACPI_GPE_REGISTER_WIDTH;
this_register->status_address.bit_offset =
ACPI_GPE_REGISTER_WIDTH;
this_register->enable_address.bit_offset =
ACPI_GPE_REGISTER_WIDTH;
this_register->status_address.bit_offset = 0;
this_register->enable_address.bit_offset = 0;
/* 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 */
status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0x00,
&this_register->
enable_address);
status = acpi_write(0x00, &this_register->enable_address);
if (ACPI_FAILURE(status)) {
goto error_exit;
}
/* Clear any pending GPE events within this register */
status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0xFF,
&this_register->
status_address);
status = acpi_write(0xFF, &this_register->status_address);
if (ACPI_FAILURE(status)) {
goto error_exit;
}
......
......@@ -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 */
status = acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH, &enable_mask,
&gpe_register_info->enable_address);
status = acpi_read(&enable_mask, &gpe_register_info->enable_address);
if (ACPI_FAILURE(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 */
status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, enable_mask,
&gpe_register_info->enable_address);
status = acpi_write(enable_mask, &gpe_register_info->enable_address);
return (status);
}
......@@ -133,7 +130,7 @@ acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info * gpe_event_info)
/* 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);
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
* clear this GPE.
*/
status = acpi_hw_low_level_write(8, register_bit,
&gpe_event_info->register_info->
status_address);
status = acpi_write(register_bit,
&gpe_event_info->register_info->status_address);
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)? */
status =
acpi_hw_low_level_read(8, &in_byte,
&gpe_register_info->status_address);
status = acpi_read(&in_byte, &gpe_register_info->status_address);
if (ACPI_FAILURE(status)) {
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 */
status = acpi_hw_low_level_write(8, 0x00,
&gpe_block->register_info[i].
enable_address);
status =
acpi_write(0x00,
&gpe_block->register_info[i].enable_address);
if (ACPI_FAILURE(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 */
status = acpi_hw_low_level_write(8, 0xFF,
&gpe_block->register_info[i].
status_address);
status =
acpi_write(0xFF,
&gpe_block->register_info[i].status_address);
if (ACPI_FAILURE(status)) {
return (status);
}
......@@ -353,10 +347,7 @@ acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
/* Enable all "runtime" GPEs in this register */
status =
acpi_hw_low_level_write(8,
gpe_block->register_info[i].
enable_for_run,
status = acpi_write(gpe_block->register_info[i].enable_for_run,
&gpe_block->register_info[i].
enable_address);
if (ACPI_FAILURE(status)) {
......@@ -398,9 +389,7 @@ acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
/* Enable all "wake" GPEs in this register */
status = acpi_hw_low_level_write(8,
gpe_block->register_info[i].
enable_for_wake,
status = acpi_write(gpe_block->register_info[i].enable_for_wake,
&gpe_block->register_info[i].
enable_address);
if (ACPI_FAILURE(status)) {
......
......@@ -84,8 +84,7 @@ acpi_status acpi_hw_clear_acpi_status(void)
/* Clear the fixed events */
if (acpi_gbl_FADT.xpm1b_event_block.address) {
status =
acpi_hw_low_level_write(16, ACPI_BITMASK_ALL_FIXED_STATUS,
status = acpi_write(ACPI_BITMASK_ALL_FIXED_STATUS,
&acpi_gbl_FADT.xpm1b_event_block);
if (ACPI_FAILURE(status)) {
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]);
}
ACPI_EXPORT_SYMBOL(acpi_get_register_unlocked)
/*******************************************************************************
*
* FUNCTION: acpi_get_register
......@@ -483,63 +484,49 @@ acpi_hw_register_read(u32 register_id, u32 * return_value)
switch (register_id) {
case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
status =
acpi_hw_low_level_read(16, &value1,
&acpi_gbl_FADT.xpm1a_event_block);
status = acpi_read(&value1, &acpi_gbl_FADT.xpm1a_event_block);
if (ACPI_FAILURE(status)) {
goto exit;
}
/* PM1B is optional */
status =
acpi_hw_low_level_read(16, &value2,
&acpi_gbl_FADT.xpm1b_event_block);
status = acpi_read(&value2, &acpi_gbl_FADT.xpm1b_event_block);
value1 |= value2;
break;
case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */
status =
acpi_hw_low_level_read(16, &value1, &acpi_gbl_xpm1a_enable);
status = acpi_read(&value1, &acpi_gbl_xpm1a_enable);
if (ACPI_FAILURE(status)) {
goto exit;
}
/* PM1B is optional */
status =
acpi_hw_low_level_read(16, &value2, &acpi_gbl_xpm1b_enable);
status = acpi_read(&value2, &acpi_gbl_xpm1b_enable);
value1 |= value2;
break;
case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
status =
acpi_hw_low_level_read(16, &value1,
&acpi_gbl_FADT.xpm1a_control_block);
status = acpi_read(&value1, &acpi_gbl_FADT.xpm1a_control_block);
if (ACPI_FAILURE(status)) {
goto exit;
}
status =
acpi_hw_low_level_read(16, &value2,
&acpi_gbl_FADT.xpm1b_control_block);
status = acpi_read(&value2, &acpi_gbl_FADT.xpm1b_control_block);
value1 |= value2;
break;
case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
status =
acpi_hw_low_level_read(8, &value1,
&acpi_gbl_FADT.xpm2_control_block);
status = acpi_read(&value1, &acpi_gbl_FADT.xpm2_control_block);
break;
case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
status =
acpi_hw_low_level_read(32, &value1,
&acpi_gbl_FADT.xpm_timer_block);
status = acpi_read(&value1, &acpi_gbl_FADT.xpm_timer_block);
break;
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 */
status =
acpi_hw_low_level_write(16, value,
&acpi_gbl_FADT.xpm1a_event_block);
status = acpi_write(value, &acpi_gbl_FADT.xpm1a_event_block);
if (ACPI_FAILURE(status)) {
goto exit;
}
/* PM1B is optional */
status =
acpi_hw_low_level_write(16, value,
&acpi_gbl_FADT.xpm1b_event_block);
status = acpi_write(value, &acpi_gbl_FADT.xpm1b_event_block);
break;
case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */
status =
acpi_hw_low_level_write(16, value, &acpi_gbl_xpm1a_enable);
status = acpi_write(value, &acpi_gbl_xpm1a_enable);
if (ACPI_FAILURE(status)) {
goto exit;
}
/* PM1B is optional */
status =
acpi_hw_low_level_write(16, value, &acpi_gbl_xpm1b_enable);
status = acpi_write(value, &acpi_gbl_xpm1b_enable);
break;
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 */
status =
acpi_hw_low_level_write(16, value,
&acpi_gbl_FADT.xpm1a_control_block);
status = acpi_write(value, &acpi_gbl_FADT.xpm1a_control_block);
if (ACPI_FAILURE(status)) {
goto exit;
}
status =
acpi_hw_low_level_write(16, value,
&acpi_gbl_FADT.xpm1b_control_block);
status = acpi_write(value, &acpi_gbl_FADT.xpm1b_control_block);
break;
case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */
status =
acpi_hw_low_level_write(16, value,
&acpi_gbl_FADT.xpm1a_control_block);
status = acpi_write(value, &acpi_gbl_FADT.xpm1a_control_block);
break;
case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */
status =
acpi_hw_low_level_write(16, value,
&acpi_gbl_FADT.xpm1b_control_block);
status = acpi_write(value, &acpi_gbl_FADT.xpm1b_control_block);
break;
case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
status =
acpi_hw_low_level_write(8, value,
&acpi_gbl_FADT.xpm2_control_block);
status = acpi_write(value, &acpi_gbl_FADT.xpm2_control_block);
break;
case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
status =
acpi_hw_low_level_write(32, value,
&acpi_gbl_FADT.xpm_timer_block);
status = acpi_write(value, &acpi_gbl_FADT.xpm_timer_block);
break;
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
* Value - Where the value is returned
* PARAMETERS: Value - Where the value is returned
* Reg - GAS register structure
*
* RETURN: Status
......@@ -731,13 +699,13 @@ 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_read(u32 *value, struct acpi_generic_address *reg)
{
u32 width;
u64 address;
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
......@@ -754,6 +722,16 @@ acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg)
if (!address) {
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;
/*
......@@ -787,12 +765,13 @@ acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg)
return (status);
}
ACPI_EXPORT_SYMBOL(acpi_read)
/******************************************************************************
*
* FUNCTION: acpi_hw_low_level_write
* FUNCTION: acpi_write
*
* PARAMETERS: Width - 8, 16, or 32
* Value - To be written
* PARAMETERS: Value - To be written
* Reg - GAS register structure
*
* RETURN: Status
......@@ -802,12 +781,13 @@ 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_write(u32 value, struct acpi_generic_address *reg)
{
u32 width;
u64 address;
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
......@@ -825,6 +805,13 @@ acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address * reg)
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.
* 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);
}
ACPI_EXPORT_SYMBOL(acpi_write)
......@@ -42,7 +42,7 @@ void acpi_reboot(void)
case ACPI_ADR_SPACE_SYSTEM_MEMORY:
case ACPI_ADR_SPACE_SYSTEM_IO:
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;
}
/* Wait ten seconds */
......
......@@ -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_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);
/*
......
......@@ -81,11 +81,6 @@ const char *acpi_format_exception(acpi_status exception);
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
*/
......@@ -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);
/*
* Event handler interfaces
* Handler interfaces
*/
acpi_status
acpi_install_initialization_handler(acpi_init_handler handler, u32 function);
acpi_status
acpi_install_fixed_event_handler(u32 acpi_event,
acpi_event_handler handler, void *context);
......@@ -336,6 +334,10 @@ acpi_set_firmware_waking_vector(u32 physical_address);
acpi_status
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_get_sleep_type_data(u8 sleep_state, u8 * slp_typ_a, u8 * slp_typ_b);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment