arch/x86/acpigen: Provide helper functions for enabling/disabling GPIO
In order to allow GPIOs to be set/clear according to their polarity, provide helper functions that check for polarity and call set/clear SoC functions for generating ACPI code. BUG=None BRANCH=None TEST=Verified that the ACPI code generated remains the same as before for reef. Change-Id: Ie8bdb9dc18e61a4a658f1447d6f1db0b166d9c12 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://review.coreboot.org/18427 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Tested-by: build bot (Jenkins)
This commit is contained in:
parent
5b9b593f2f
commit
bf4845dd3a
|
@ -3,6 +3,7 @@
|
||||||
# Table of contents #
|
# Table of contents #
|
||||||
- Introduction
|
- Introduction
|
||||||
- Platform Interface
|
- Platform Interface
|
||||||
|
- Helper routines
|
||||||
- Implementation details
|
- Implementation details
|
||||||
- Arguments and Local Variables Management
|
- Arguments and Local Variables Management
|
||||||
|
|
||||||
|
@ -55,6 +56,23 @@ adding them as AML code callbacks for the following reasons:
|
||||||
3. Allows GPIO AML methods to be present under any device scope and
|
3. Allows GPIO AML methods to be present under any device scope and
|
||||||
gives SoC the flexibility to call them without any restrictions.
|
gives SoC the flexibility to call them without any restrictions.
|
||||||
|
|
||||||
|
# Helper routines #
|
||||||
|
|
||||||
|
In order to relieve drivers of the task of implementing the same code
|
||||||
|
for enabling/disabling Tx GPIOs based on the GPIO polarity, helper
|
||||||
|
routines are provided which implement this common code and can be used
|
||||||
|
directly in the driver routines:
|
||||||
|
1. Enable Tx GPIO
|
||||||
|
int acpigen_enable_tx_gpio(struct acpi_gpio gpio)
|
||||||
|
2. Disable Tx GPIO
|
||||||
|
int acpigen_disable_tx_gpio(struct acpi_gpio gpio)
|
||||||
|
|
||||||
|
Both the above functions take as input struct acpi_gpio type and
|
||||||
|
return -1 on error and 0 on success. These helper routines end up
|
||||||
|
calling the platform specific acpigen_soc_{set,clear}_tx_gpio
|
||||||
|
functions internally. Thus, all the ACPI AML calling conventions for
|
||||||
|
the platform functions apply to these helper functions as well.
|
||||||
|
|
||||||
# Implementation Details #
|
# Implementation Details #
|
||||||
|
|
||||||
ACPI library in coreboot will provide weak definitions for all the
|
ACPI library in coreboot will provide weak definitions for all the
|
||||||
|
@ -84,7 +102,6 @@ variables.
|
||||||
acpigen_soc_clear_tx_gpio Generate ACPI AML code to Error = -1
|
acpigen_soc_clear_tx_gpio Generate ACPI AML code to Error = -1
|
||||||
set Tx to 0. Success = 0
|
set Tx to 0. Success = 0
|
||||||
|
|
||||||
|
|
||||||
Ideally, the operation column in the above table should use one or
|
Ideally, the operation column in the above table should use one or
|
||||||
more functions implemented by the platform in AML code library (like
|
more functions implemented by the platform in AML code library (like
|
||||||
gpiolib.asl). In the example below SPC0 and GPC0 need to be
|
gpiolib.asl). In the example below SPC0 and GPC0 need to be
|
||||||
|
|
|
@ -512,14 +512,14 @@ void acpi_device_add_power_res(
|
||||||
/* Method (_ON, 0, Serialized) */
|
/* Method (_ON, 0, Serialized) */
|
||||||
acpigen_write_method_serialized("_ON", 0);
|
acpigen_write_method_serialized("_ON", 0);
|
||||||
if (reset_gpio)
|
if (reset_gpio)
|
||||||
acpigen_soc_set_tx_gpio(reset_gpio);
|
acpigen_enable_tx_gpio(reset);
|
||||||
if (enable_gpio) {
|
if (enable_gpio) {
|
||||||
acpigen_soc_set_tx_gpio(enable_gpio);
|
acpigen_enable_tx_gpio(enable);
|
||||||
if (enable_delay_ms)
|
if (enable_delay_ms)
|
||||||
acpigen_write_sleep(enable_delay_ms);
|
acpigen_write_sleep(enable_delay_ms);
|
||||||
}
|
}
|
||||||
if (reset_gpio) {
|
if (reset_gpio) {
|
||||||
acpigen_soc_clear_tx_gpio(reset_gpio);
|
acpigen_disable_tx_gpio(reset);
|
||||||
if (reset_delay_ms)
|
if (reset_delay_ms)
|
||||||
acpigen_write_sleep(reset_delay_ms);
|
acpigen_write_sleep(reset_delay_ms);
|
||||||
}
|
}
|
||||||
|
@ -528,9 +528,9 @@ void acpi_device_add_power_res(
|
||||||
/* Method (_OFF, 0, Serialized) */
|
/* Method (_OFF, 0, Serialized) */
|
||||||
acpigen_write_method_serialized("_OFF", 0);
|
acpigen_write_method_serialized("_OFF", 0);
|
||||||
if (reset_gpio)
|
if (reset_gpio)
|
||||||
acpigen_soc_set_tx_gpio(reset_gpio);
|
acpigen_enable_tx_gpio(reset);
|
||||||
if (enable_gpio)
|
if (enable_gpio)
|
||||||
acpigen_soc_clear_tx_gpio(enable_gpio);
|
acpigen_disable_tx_gpio(enable);
|
||||||
acpigen_pop_len(); /* _OFF method */
|
acpigen_pop_len(); /* _OFF method */
|
||||||
|
|
||||||
acpigen_pop_len(); /* PowerResource PRIC */
|
acpigen_pop_len(); /* PowerResource PRIC */
|
||||||
|
|
|
@ -1299,3 +1299,26 @@ int __attribute__((weak)) acpigen_soc_clear_tx_gpio(unsigned int gpio_num)
|
||||||
acpigen_write_debug_string("clear_tx_gpio not available");
|
acpigen_write_debug_string("clear_tx_gpio not available");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Helper functions for enabling/disabling Tx GPIOs based on the GPIO
|
||||||
|
* polarity. These functions end up calling acpigen_soc_{set,clear}_tx_gpio to
|
||||||
|
* make callbacks into SoC acpigen code.
|
||||||
|
*
|
||||||
|
* Returns 0 on success and -1 on error.
|
||||||
|
*/
|
||||||
|
int acpigen_enable_tx_gpio(struct acpi_gpio *gpio)
|
||||||
|
{
|
||||||
|
if (gpio->polarity == ACPI_GPIO_ACTIVE_HIGH)
|
||||||
|
return acpigen_soc_set_tx_gpio(gpio->pins[0]);
|
||||||
|
else
|
||||||
|
return acpigen_soc_clear_tx_gpio(gpio->pins[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
int acpigen_disable_tx_gpio(struct acpi_gpio *gpio)
|
||||||
|
{
|
||||||
|
if (gpio->polarity == ACPI_GPIO_ACTIVE_LOW)
|
||||||
|
return acpigen_soc_set_tx_gpio(gpio->pins[0]);
|
||||||
|
else
|
||||||
|
return acpigen_soc_clear_tx_gpio(gpio->pins[0]);
|
||||||
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <arch/acpi.h>
|
#include <arch/acpi.h>
|
||||||
|
#include <arch/acpi_device.h>
|
||||||
|
|
||||||
/* Values that can be returned for ACPI Device _STA method */
|
/* Values that can be returned for ACPI Device _STA method */
|
||||||
#define ACPI_STATUS_DEVICE_PRESENT (1 << 0)
|
#define ACPI_STATUS_DEVICE_PRESENT (1 << 0)
|
||||||
|
@ -289,4 +290,14 @@ int acpigen_soc_set_tx_gpio(unsigned int gpio_num);
|
||||||
/* Generate ACPI AML code to set Tx value of GPIO to 0. */
|
/* Generate ACPI AML code to set Tx value of GPIO to 0. */
|
||||||
int acpigen_soc_clear_tx_gpio(unsigned int gpio_num);
|
int acpigen_soc_clear_tx_gpio(unsigned int gpio_num);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Helper functions for enabling/disabling Tx GPIOs based on the GPIO
|
||||||
|
* polarity. These functions end up calling acpigen_soc_{set,clear}_tx_gpio to
|
||||||
|
* make callbacks into SoC acpigen code.
|
||||||
|
*
|
||||||
|
* Returns 0 on success and -1 on error.
|
||||||
|
*/
|
||||||
|
int acpigen_enable_tx_gpio(struct acpi_gpio *gpio);
|
||||||
|
int acpigen_disable_tx_gpio(struct acpi_gpio *gpio);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue