Commit 6557a49a authored by Lin Ming's avatar Lin Ming Committed by Len Brown

ACPICA: ACPI 4.0: Interpreter support for IPMI.

Adds support for IPMI which is similar to SMBus and uses a bi-directional data buffer.
ACPICA BZ 773.

http://acpica.org/bugzilla/show_bug.cgi?id=773Signed-off-by: default avatarLin Ming <ming.m.lin@intel.com>
Signed-off-by: default avatarBob Moore <robert.moore@intel.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent 3db20bed
...@@ -199,9 +199,10 @@ ...@@ -199,9 +199,10 @@
#define ACPI_RSDP_CHECKSUM_LENGTH 20 #define ACPI_RSDP_CHECKSUM_LENGTH 20
#define ACPI_RSDP_XCHECKSUM_LENGTH 36 #define ACPI_RSDP_XCHECKSUM_LENGTH 36
/* SMBus bidirectional buffer size */ /* SMBus and IPMI bidirectional buffer size */
#define ACPI_SMBUS_BUFFER_SIZE 34 #define ACPI_SMBUS_BUFFER_SIZE 34
#define ACPI_IPMI_BUFFER_SIZE 66
/* _sx_d and _sx_w control methods */ /* _sx_d and _sx_w control methods */
......
...@@ -72,6 +72,7 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state, ...@@ -72,6 +72,7 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
union acpi_operand_object *buffer_desc; union acpi_operand_object *buffer_desc;
acpi_size length; acpi_size length;
void *buffer; void *buffer;
u32 function;
ACPI_FUNCTION_TRACE_PTR(ex_read_data_from_field, obj_desc); ACPI_FUNCTION_TRACE_PTR(ex_read_data_from_field, obj_desc);
...@@ -97,13 +98,27 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state, ...@@ -97,13 +98,27 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
} }
} else if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) && } else if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
(obj_desc->field.region_obj->region.space_id == (obj_desc->field.region_obj->region.space_id ==
ACPI_ADR_SPACE_SMBUS)) { ACPI_ADR_SPACE_SMBUS
|| obj_desc->field.region_obj->region.space_id ==
ACPI_ADR_SPACE_IPMI)) {
/* /*
* This is an SMBus read. We must create a buffer to hold the data * This is an SMBus or IPMI read. We must create a buffer to hold
* and directly access the region handler. * the data and then directly access the region handler.
*
* Note: Smbus protocol value is passed in upper 16-bits of Function
*/ */
buffer_desc = if (obj_desc->field.region_obj->region.space_id ==
acpi_ut_create_buffer_object(ACPI_SMBUS_BUFFER_SIZE); ACPI_ADR_SPACE_SMBUS) {
length = ACPI_SMBUS_BUFFER_SIZE;
function =
ACPI_READ | (obj_desc->field.attribute << 16);
} else { /* IPMI */
length = ACPI_IPMI_BUFFER_SIZE;
function = ACPI_READ;
}
buffer_desc = acpi_ut_create_buffer_object(length);
if (!buffer_desc) { if (!buffer_desc) {
return_ACPI_STATUS(AE_NO_MEMORY); return_ACPI_STATUS(AE_NO_MEMORY);
} }
...@@ -112,16 +127,13 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state, ...@@ -112,16 +127,13 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
acpi_ex_acquire_global_lock(obj_desc->common_field.field_flags); acpi_ex_acquire_global_lock(obj_desc->common_field.field_flags);
/* /* Call the region handler for the read */
* Perform the read.
* Note: Smbus protocol value is passed in upper 16-bits of Function
*/
status = acpi_ex_access_region(obj_desc, 0, status = acpi_ex_access_region(obj_desc, 0,
ACPI_CAST_PTR(acpi_integer, ACPI_CAST_PTR(acpi_integer,
buffer_desc-> buffer_desc->
buffer.pointer), buffer.pointer),
ACPI_READ | (obj_desc->field. function);
attribute << 16));
acpi_ex_release_global_lock(obj_desc->common_field.field_flags); acpi_ex_release_global_lock(obj_desc->common_field.field_flags);
goto exit; goto exit;
} }
...@@ -212,6 +224,7 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc, ...@@ -212,6 +224,7 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
u32 length; u32 length;
void *buffer; void *buffer;
union acpi_operand_object *buffer_desc; union acpi_operand_object *buffer_desc;
u32 function;
ACPI_FUNCTION_TRACE_PTR(ex_write_data_to_field, obj_desc); ACPI_FUNCTION_TRACE_PTR(ex_write_data_to_field, obj_desc);
...@@ -234,39 +247,56 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc, ...@@ -234,39 +247,56 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
} }
} else if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) && } else if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
(obj_desc->field.region_obj->region.space_id == (obj_desc->field.region_obj->region.space_id ==
ACPI_ADR_SPACE_SMBUS)) { ACPI_ADR_SPACE_SMBUS
|| obj_desc->field.region_obj->region.space_id ==
ACPI_ADR_SPACE_IPMI)) {
/* /*
* This is an SMBus write. We will bypass the entire field mechanism * This is an SMBus or IPMI write. We will bypass the entire field
* and handoff the buffer directly to the handler. * mechanism and handoff the buffer directly to the handler. For
* these address spaces, the buffer is bi-directional; on a write,
* return data is returned in the same buffer.
*
* Source must be a buffer of sufficient size:
* ACPI_SMBUS_BUFFER_SIZE or ACPI_IPMI_BUFFER_SIZE.
* *
* Source must be a buffer of sufficient size (ACPI_SMBUS_BUFFER_SIZE). * Note: SMBus protocol type is passed in upper 16-bits of Function
*/ */
if (source_desc->common.type != ACPI_TYPE_BUFFER) { if (source_desc->common.type != ACPI_TYPE_BUFFER) {
ACPI_ERROR((AE_INFO, ACPI_ERROR((AE_INFO,
"SMBus write requires Buffer, found type %s", "SMBus or IPMI write requires Buffer, found type %s",
acpi_ut_get_object_type_name(source_desc))); acpi_ut_get_object_type_name(source_desc)));
return_ACPI_STATUS(AE_AML_OPERAND_TYPE); return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
} }
if (source_desc->buffer.length < ACPI_SMBUS_BUFFER_SIZE) { if (obj_desc->field.region_obj->region.space_id ==
ACPI_ADR_SPACE_SMBUS) {
length = ACPI_SMBUS_BUFFER_SIZE;
function =
ACPI_WRITE | (obj_desc->field.attribute << 16);
} else { /* IPMI */
length = ACPI_IPMI_BUFFER_SIZE;
function = ACPI_WRITE;
}
if (source_desc->buffer.length < length) {
ACPI_ERROR((AE_INFO, ACPI_ERROR((AE_INFO,
"SMBus write requires Buffer of length %X, found length %X", "SMBus or IPMI write requires Buffer of length %X, found length %X",
ACPI_SMBUS_BUFFER_SIZE, length, source_desc->buffer.length));
source_desc->buffer.length));
return_ACPI_STATUS(AE_AML_BUFFER_LIMIT); return_ACPI_STATUS(AE_AML_BUFFER_LIMIT);
} }
buffer_desc = /* Create the bi-directional buffer */
acpi_ut_create_buffer_object(ACPI_SMBUS_BUFFER_SIZE);
buffer_desc = acpi_ut_create_buffer_object(length);
if (!buffer_desc) { if (!buffer_desc) {
return_ACPI_STATUS(AE_NO_MEMORY); return_ACPI_STATUS(AE_NO_MEMORY);
} }
buffer = buffer_desc->buffer.pointer; buffer = buffer_desc->buffer.pointer;
ACPI_MEMCPY(buffer, source_desc->buffer.pointer, ACPI_MEMCPY(buffer, source_desc->buffer.pointer, length);
ACPI_SMBUS_BUFFER_SIZE);
/* Lock entire transaction if requested */ /* Lock entire transaction if requested */
...@@ -275,12 +305,10 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc, ...@@ -275,12 +305,10 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
/* /*
* Perform the write (returns status and perhaps data in the * Perform the write (returns status and perhaps data in the
* same buffer) * same buffer)
* Note: SMBus protocol type is passed in upper 16-bits of Function.
*/ */
status = acpi_ex_access_region(obj_desc, 0, status = acpi_ex_access_region(obj_desc, 0,
(acpi_integer *) buffer, (acpi_integer *) buffer,
ACPI_WRITE | (obj_desc->field. function);
attribute << 16));
acpi_ex_release_global_lock(obj_desc->common_field.field_flags); acpi_ex_release_global_lock(obj_desc->common_field.field_flags);
*result_desc = buffer_desc; *result_desc = buffer_desc;
......
...@@ -120,12 +120,13 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc, ...@@ -120,12 +120,13 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc,
} }
/* /*
* Exit now for SMBus address space, it has a non-linear address space * Exit now for SMBus or IPMI address space, it has a non-linear address space
* and the request cannot be directly validated * and the request cannot be directly validated
*/ */
if (rgn_desc->region.space_id == ACPI_ADR_SPACE_SMBUS) { if (rgn_desc->region.space_id == ACPI_ADR_SPACE_SMBUS ||
rgn_desc->region.space_id == ACPI_ADR_SPACE_IPMI) {
/* SMBus has a non-linear address space */ /* SMBus or IPMI has a non-linear address space */
return_ACPI_STATUS(AE_OK); return_ACPI_STATUS(AE_OK);
} }
......
...@@ -732,7 +732,8 @@ typedef u8 acpi_adr_space_type; ...@@ -732,7 +732,8 @@ typedef u8 acpi_adr_space_type;
#define ACPI_ADR_SPACE_SMBUS (acpi_adr_space_type) 4 #define ACPI_ADR_SPACE_SMBUS (acpi_adr_space_type) 4
#define ACPI_ADR_SPACE_CMOS (acpi_adr_space_type) 5 #define ACPI_ADR_SPACE_CMOS (acpi_adr_space_type) 5
#define ACPI_ADR_SPACE_PCI_BAR_TARGET (acpi_adr_space_type) 6 #define ACPI_ADR_SPACE_PCI_BAR_TARGET (acpi_adr_space_type) 6
#define ACPI_ADR_SPACE_DATA_TABLE (acpi_adr_space_type) 7 #define ACPI_ADR_SPACE_IPMI (acpi_adr_space_type) 7
#define ACPI_ADR_SPACE_DATA_TABLE (acpi_adr_space_type) 8
#define ACPI_ADR_SPACE_FIXED_HARDWARE (acpi_adr_space_type) 127 #define ACPI_ADR_SPACE_FIXED_HARDWARE (acpi_adr_space_type) 127
/* /*
......
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