Commit dadf28a1 authored by Alexey Starikovskiy's avatar Alexey Starikovskiy Committed by Len Brown

ACPI: EC: Allow multibyte access to EC

http://bugzilla.kernel.org/show_bug.cgi?id=14667Signed-off-by: default avatarAlexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent a3d3203e
...@@ -468,6 +468,18 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info) ...@@ -468,6 +468,18 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info)
acpi_ut_add_reference(obj_desc->field.region_obj); acpi_ut_add_reference(obj_desc->field.region_obj);
/* allow full data read from EC address space */
if (obj_desc->field.region_obj->region.space_id ==
ACPI_ADR_SPACE_EC) {
if (obj_desc->common_field.bit_length > 8)
obj_desc->common_field.access_bit_width =
ACPI_ROUND_UP(obj_desc->common_field.
bit_length, 8);
obj_desc->common_field.access_byte_width =
ACPI_DIV_8(obj_desc->common_field.
access_bit_width);
}
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
"RegionField: BitOff %X, Off %X, Gran %X, Region %p\n", "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n",
obj_desc->field.start_field_bit_offset, obj_desc->field.start_field_bit_offset,
......
...@@ -628,12 +628,12 @@ static u32 acpi_ec_gpe_handler(void *data) ...@@ -628,12 +628,12 @@ static u32 acpi_ec_gpe_handler(void *data)
static acpi_status static acpi_status
acpi_ec_space_handler(u32 function, acpi_physical_address address, acpi_ec_space_handler(u32 function, acpi_physical_address address,
u32 bits, u64 *value, u32 bits, u64 *value64,
void *handler_context, void *region_context) void *handler_context, void *region_context)
{ {
struct acpi_ec *ec = handler_context; struct acpi_ec *ec = handler_context;
int result = 0, i; int result = 0, i, bytes = bits / 8;
u8 temp = 0; u8 *value = (u8 *)value64;
if ((address > 0xFF) || !value || !handler_context) if ((address > 0xFF) || !value || !handler_context)
return AE_BAD_PARAMETER; return AE_BAD_PARAMETER;
...@@ -641,32 +641,15 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address, ...@@ -641,32 +641,15 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address,
if (function != ACPI_READ && function != ACPI_WRITE) if (function != ACPI_READ && function != ACPI_WRITE)
return AE_BAD_PARAMETER; return AE_BAD_PARAMETER;
if (bits != 8 && acpi_strict) if (EC_FLAGS_MSI || bits > 8)
return AE_BAD_PARAMETER;
if (EC_FLAGS_MSI)
acpi_ec_burst_enable(ec); acpi_ec_burst_enable(ec);
if (function == ACPI_READ) { for (i = 0; i < bytes; ++i, ++address, ++value)
result = acpi_ec_read(ec, address, &temp); result = (function == ACPI_READ) ?
*value = temp; acpi_ec_read(ec, address, value) :
} else { acpi_ec_write(ec, address, *value);
temp = 0xff & (*value);
result = acpi_ec_write(ec, address, temp);
}
for (i = 8; unlikely(bits - i > 0); i += 8) {
++address;
if (function == ACPI_READ) {
result = acpi_ec_read(ec, address, &temp);
(*value) |= ((u64)temp) << i;
} else {
temp = 0xff & ((*value) >> i);
result = acpi_ec_write(ec, address, temp);
}
}
if (EC_FLAGS_MSI) if (EC_FLAGS_MSI || bits > 8)
acpi_ec_burst_disable(ec); acpi_ec_burst_disable(ec);
switch (result) { switch (result) {
......
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