Source
x
// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
/******************************************************************************
*
* Module Name: exserial - field_unit support for serial address spaces
*
* Copyright (C) 2000 - 2019, Intel Corp.
*
*****************************************************************************/
ACPI_MODULE_NAME("exserial")
/*******************************************************************************
*
* FUNCTION: acpi_ex_read_gpio
*
* PARAMETERS: obj_desc - The named field to read
* buffer - Where the return data is returned
*
* RETURN: Status
*
* DESCRIPTION: Read from a named field that references a Generic Serial Bus
* field
*
******************************************************************************/
acpi_status acpi_ex_read_gpio(union acpi_operand_object *obj_desc, void *buffer)
{
acpi_status status;
ACPI_FUNCTION_TRACE_PTR(ex_read_gpio, obj_desc);
/*
* For GPIO (general_purpose_io), the Address will be the bit offset
* from the previous Connection() operator, making it effectively a
* pin number index. The bit_length is the length of the field, which
* is thus the number of pins.
*/
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
"GPIO FieldRead [FROM]: Pin %u Bits %u\n",
obj_desc->field.pin_number_index,
obj_desc->field.bit_length));
/* Lock entire transaction if requested */
acpi_ex_acquire_global_lock(obj_desc->common_field.field_flags);
/* Perform the read */
status = acpi_ex_access_region(obj_desc, 0, (u64 *)buffer, ACPI_READ);
acpi_ex_release_global_lock(obj_desc->common_field.field_flags);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_write_gpio
*
* PARAMETERS: source_desc - Contains data to write. Expect to be
* an Integer object.
* obj_desc - The named field
* result_desc - Where the return value is returned, if any
*
* RETURN: Status
*
* DESCRIPTION: Write to a named field that references a General Purpose I/O
* field.
*
******************************************************************************/
acpi_status
acpi_ex_write_gpio(union acpi_operand_object *source_desc,
union acpi_operand_object *obj_desc,
union acpi_operand_object **return_buffer)
{
acpi_status status;
void *buffer;
ACPI_FUNCTION_TRACE_PTR(ex_write_gpio, obj_desc);
/*
* For GPIO (general_purpose_io), we will bypass the entire field
* mechanism and handoff the bit address and bit width directly to
* the handler. The Address will be the bit offset
* from the previous Connection() operator, making it effectively a
* pin number index. The bit_length is the length of the field, which