ACPICA: ACPI 4.0: Interpreter support for IPMI.
authorLin Ming <ming.m.lin@intel.com>
Wed, 24 Jun 2009 03:32:04 +0000 (11:32 +0800)
committerLen Brown <len.brown@intel.com>
Thu, 27 Aug 2009 14:17:18 +0000 (10:17 -0400)
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=773

Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
drivers/acpi/acpica/acconfig.h
drivers/acpi/acpica/exfield.c
drivers/acpi/acpica/exfldio.c
include/acpi/actypes.h

index 9123d5a11627bc74405f2b9cf5abb0f9aab3aa34..8e679ef5b23153600523c856f6d046ea26977615 100644 (file)
 #define ACPI_RSDP_CHECKSUM_LENGTH       20
 #define ACPI_RSDP_XCHECKSUM_LENGTH      36
 
-/* SMBus bidirectional buffer size */
+/* SMBus and IPMI bidirectional buffer size */
 
 #define ACPI_SMBUS_BUFFER_SIZE          34
+#define ACPI_IPMI_BUFFER_SIZE           66
 
 /* _sx_d and _sx_w control methods */
 
index 546dcdd8678562b3795c31eb3e0248caa5c828ab..0b33d6c887b91a3600e9b26bdee1b2e1d825f112 100644 (file)
@@ -72,6 +72,7 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
        union acpi_operand_object *buffer_desc;
        acpi_size length;
        void *buffer;
+       u32 function;
 
        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,
                }
        } else if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
                   (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
-                * and directly access the region handler.
+                * This is an SMBus or IPMI read. We must create a buffer to hold
+                * the data and then directly access the region handler.
+                *
+                * Note: Smbus protocol value is passed in upper 16-bits of Function
                 */
-               buffer_desc =
-                   acpi_ut_create_buffer_object(ACPI_SMBUS_BUFFER_SIZE);
+               if (obj_desc->field.region_obj->region.space_id ==
+                   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) {
                        return_ACPI_STATUS(AE_NO_MEMORY);
                }
@@ -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);
 
-               /*
-                * Perform the read.
-                * Note: Smbus protocol value is passed in upper 16-bits of Function
-                */
+               /* Call the region handler for the read */
+
                status = acpi_ex_access_region(obj_desc, 0,
                                               ACPI_CAST_PTR(acpi_integer,
                                                             buffer_desc->
                                                             buffer.pointer),
-                                              ACPI_READ | (obj_desc->field.
-                                                           attribute << 16));
+                                              function);
                acpi_ex_release_global_lock(obj_desc->common_field.field_flags);
                goto exit;
        }
@@ -212,6 +224,7 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
        u32 length;
        void *buffer;
        union acpi_operand_object *buffer_desc;
+       u32 function;
 
        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,
                }
        } else if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
                   (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
-                * and handoff the buffer directly to the handler.
+                * This is an SMBus or IPMI write. We will bypass the entire field
+                * 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) {
                        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)));
 
                        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,
-                                   "SMBus write requires Buffer of length %X, found length %X",
-                                   ACPI_SMBUS_BUFFER_SIZE,
-                                   source_desc->buffer.length));
+                                   "SMBus or IPMI write requires Buffer of length %X, found length %X",
+                                   length, source_desc->buffer.length));
 
                        return_ACPI_STATUS(AE_AML_BUFFER_LIMIT);
                }
 
-               buffer_desc =
-                   acpi_ut_create_buffer_object(ACPI_SMBUS_BUFFER_SIZE);
+               /* Create the bi-directional buffer */
+
+               buffer_desc = acpi_ut_create_buffer_object(length);
                if (!buffer_desc) {
                        return_ACPI_STATUS(AE_NO_MEMORY);
                }
 
                buffer = buffer_desc->buffer.pointer;
-               ACPI_MEMCPY(buffer, source_desc->buffer.pointer,
-                           ACPI_SMBUS_BUFFER_SIZE);
+               ACPI_MEMCPY(buffer, source_desc->buffer.pointer, length);
 
                /* Lock entire transaction if requested */
 
@@ -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
                 * same buffer)
-                * Note: SMBus protocol type is passed in upper 16-bits of Function.
                 */
                status = acpi_ex_access_region(obj_desc, 0,
                                               (acpi_integer *) buffer,
-                                              ACPI_WRITE | (obj_desc->field.
-                                                            attribute << 16));
+                                              function);
                acpi_ex_release_global_lock(obj_desc->common_field.field_flags);
 
                *result_desc = buffer_desc;
index 6687be167f5f67c6d6b30c5c6b24d3cfd19a7346..d7b3b418fb45739e82efdc20a6a2477270511842 100644 (file)
@@ -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
         */
-       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);
        }
index 7a4ff79e238c4186ede1f07fc4b28536d26414b6..4371805d2def4ec21d6b1bb56934fb6dfc4aa1cf 100644 (file)
@@ -732,7 +732,8 @@ typedef u8 acpi_adr_space_type;
 #define ACPI_ADR_SPACE_SMBUS            (acpi_adr_space_type) 4
 #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_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
 
 /*