acpi_device: Replace polarity with active_low in acpi_gpio for GpioIo
As per ACPI spec, GpioIo does not have any polarity associated with it. Linux kernel uses `active_low` argument within GPIO _DSD property to allow BIOS to indicate if the corresponding GPIO should be treated as active low. Thus, if GPIO has active high polarity or if it does not have any polarity associated with it, then the `active_low` argument is supposed to be set to 0. Having a `polarity` field in acpi_gpio seems confusing because GPIOs might not always have polarity associated with them. Example, in case of DMIC-select GPIO where 0 means select DMIC0 and 1 means select DMIC1, there is no polarity associated with the GPIO. Thus, it would be clearer for mainboard to use macros without having to specify a particular polarity. In order to enable mainboards to provide GPIO information without polarity for GpioIo usage, this change also adds `ACPI_GPIO_OUTPUT` and `ACPI_GPIO_INPUT` macros. BUG=b:157603026 Change-Id: I39d2a6ac8f149a74afeb915812fece86c9b9ad93 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/42968 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
parent
7245100cdd
commit
d2d5e44a67
|
@ -1800,15 +1800,15 @@ int __weak acpigen_soc_clear_tx_gpio(unsigned int gpio_num)
|
|||
*/
|
||||
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
|
||||
if (gpio->active_low)
|
||||
return acpigen_soc_clear_tx_gpio(gpio->pins[0]);
|
||||
else
|
||||
return acpigen_soc_set_tx_gpio(gpio->pins[0]);
|
||||
}
|
||||
|
||||
int acpigen_disable_tx_gpio(struct acpi_gpio *gpio)
|
||||
{
|
||||
if (gpio->polarity == ACPI_GPIO_ACTIVE_LOW)
|
||||
if (gpio->active_low)
|
||||
return acpigen_soc_set_tx_gpio(gpio->pins[0]);
|
||||
else
|
||||
return acpigen_soc_clear_tx_gpio(gpio->pins[0]);
|
||||
|
@ -1818,7 +1818,7 @@ void acpigen_get_rx_gpio(struct acpi_gpio *gpio)
|
|||
{
|
||||
acpigen_soc_read_rx_gpio(gpio->pins[0]);
|
||||
|
||||
if (gpio->polarity == ACPI_GPIO_ACTIVE_LOW)
|
||||
if (gpio->active_low)
|
||||
acpigen_write_xor(LOCAL0_OP, 1, LOCAL0_OP);
|
||||
}
|
||||
|
||||
|
@ -1826,7 +1826,7 @@ void acpigen_get_tx_gpio(struct acpi_gpio *gpio)
|
|||
{
|
||||
acpigen_soc_get_tx_gpio(gpio->pins[0]);
|
||||
|
||||
if (gpio->polarity == ACPI_GPIO_ACTIVE_LOW)
|
||||
if (gpio->active_low)
|
||||
acpigen_write_xor(LOCAL0_OP, 1, LOCAL0_OP);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ static struct acpi_dp *gpio_keys_add_child_node(
|
|||
acpi_dp_add_integer(dsd, "debounce-interval",
|
||||
key->debounce_interval);
|
||||
acpi_dp_add_gpio(dsd, "gpios", parent_path, 0, 0,
|
||||
config->gpio.polarity);
|
||||
config->gpio.active_low);
|
||||
|
||||
return dsd;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ static void max98357a_fill_ssdt(const struct device *dev)
|
|||
path = acpi_device_path(dev);
|
||||
dp = acpi_dp_new_table("_DSD");
|
||||
acpi_dp_add_gpio(dp, "sdmode-gpio", path, 0, 0,
|
||||
config->sdmode_gpio.polarity);
|
||||
config->sdmode_gpio.active_low);
|
||||
acpi_dp_add_integer(dp, "sdmode-delay", config->sdmode_delay);
|
||||
acpi_dp_write(dp);
|
||||
|
||||
|
|
|
@ -114,16 +114,15 @@ void i2c_generic_fill_ssdt(const struct device *dev,
|
|||
if (irq_gpio_index != -1)
|
||||
acpi_dp_add_gpio(dsd, "irq-gpios", path,
|
||||
irq_gpio_index, 0,
|
||||
config->irq_gpio.polarity ==
|
||||
ACPI_GPIO_ACTIVE_LOW);
|
||||
config->irq_gpio.active_low);
|
||||
if (reset_gpio_index != -1)
|
||||
acpi_dp_add_gpio(dsd, "reset-gpios", path,
|
||||
reset_gpio_index, 0,
|
||||
config->reset_gpio.polarity);
|
||||
config->reset_gpio.active_low);
|
||||
if (enable_gpio_index != -1)
|
||||
acpi_dp_add_gpio(dsd, "enable-gpios", path,
|
||||
enable_gpio_index, 0,
|
||||
config->enable_gpio.polarity);
|
||||
config->enable_gpio.active_low);
|
||||
/* Add generic property list */
|
||||
acpi_dp_add_property_list(dsd, config->property_list,
|
||||
config->property_count);
|
||||
|
|
|
@ -53,7 +53,7 @@ static void rt5663_fill_ssdt(const struct device *dev)
|
|||
dp = acpi_dp_new_table("_DSD");
|
||||
if (config->irq_gpio.pin_count)
|
||||
acpi_dp_add_gpio(dp, "irq-gpios", acpi_device_path(dev), 0, 0,
|
||||
config->irq_gpio.polarity == ACPI_GPIO_ACTIVE_LOW);
|
||||
config->irq_gpio.active_low);
|
||||
RT5663_DP_INT("dc_offset_l_manual", config->dc_offset_l_manual);
|
||||
RT5663_DP_INT("dc_offset_r_manual", config->dc_offset_r_manual);
|
||||
RT5663_DP_INT("dc_offset_l_manual_mic", config->dc_offset_l_manual_mic);
|
||||
|
|
|
@ -139,15 +139,15 @@ static void spi_acpi_fill_ssdt_generator(const struct device *dev)
|
|||
if (irq_gpio_index >= 0)
|
||||
acpi_dp_add_gpio(dsd, "irq-gpios", path,
|
||||
irq_gpio_index, 0,
|
||||
config->irq_gpio.polarity);
|
||||
config->irq_gpio.active_low);
|
||||
if (reset_gpio_index >= 0)
|
||||
acpi_dp_add_gpio(dsd, "reset-gpios", path,
|
||||
reset_gpio_index, 0,
|
||||
config->reset_gpio.polarity);
|
||||
config->reset_gpio.active_low);
|
||||
if (enable_gpio_index >= 0)
|
||||
acpi_dp_add_gpio(dsd, "enable-gpios", path,
|
||||
enable_gpio_index, 0,
|
||||
config->enable_gpio.polarity);
|
||||
config->enable_gpio.active_low);
|
||||
acpi_dp_write(dsd);
|
||||
}
|
||||
|
||||
|
|
|
@ -103,15 +103,15 @@ static void uart_acpi_fill_ssdt(const struct device *dev)
|
|||
if (irq_gpio_index >= 0)
|
||||
acpi_dp_add_gpio(dsd, "irq-gpios", path,
|
||||
irq_gpio_index, 0,
|
||||
config->irq_gpio.polarity);
|
||||
config->irq_gpio.active_low);
|
||||
if (reset_gpio_index >= 0)
|
||||
acpi_dp_add_gpio(dsd, "reset-gpios", path,
|
||||
reset_gpio_index, 0,
|
||||
config->reset_gpio.polarity);
|
||||
config->reset_gpio.active_low);
|
||||
if (enable_gpio_index >= 0)
|
||||
acpi_dp_add_gpio(dsd, "enable-gpios", path,
|
||||
enable_gpio_index, 0,
|
||||
config->enable_gpio.polarity);
|
||||
config->enable_gpio.active_low);
|
||||
acpi_dp_write(dsd);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ static void usb_acpi_fill_ssdt_generator(const struct device *dev)
|
|||
|
||||
dsd = acpi_dp_new_table("_DSD");
|
||||
acpi_dp_add_gpio(dsd, "reset-gpio", path, 0, 0,
|
||||
config->reset_gpio.polarity);
|
||||
config->reset_gpio.active_low);
|
||||
acpi_dp_write(dsd);
|
||||
}
|
||||
|
||||
|
|
|
@ -158,11 +158,6 @@ enum acpi_gpio_io_restrict {
|
|||
ACPI_GPIO_IO_RESTRICT_PRESERVE
|
||||
};
|
||||
|
||||
enum acpi_gpio_polarity {
|
||||
ACPI_GPIO_ACTIVE_HIGH = 0,
|
||||
ACPI_GPIO_ACTIVE_LOW = 1,
|
||||
};
|
||||
|
||||
#define ACPI_GPIO_REVISION_ID 1
|
||||
#define ACPI_GPIO_MAX_PINS 8
|
||||
|
||||
|
@ -182,37 +177,43 @@ struct acpi_gpio {
|
|||
uint16_t output_drive_strength; /* 1/100 mA */
|
||||
int io_shared;
|
||||
enum acpi_gpio_io_restrict io_restrict;
|
||||
enum acpi_gpio_polarity polarity;
|
||||
/*
|
||||
* As per ACPI spec, GpioIo does not have any polarity associated with it. Linux kernel
|
||||
* uses `active_low` argument within GPIO _DSD property to allow BIOS to indicate if the
|
||||
* corresponding GPIO should be treated as active low. Thus, if the GPIO has active high
|
||||
* polarity or if it does not have any polarity, then the `active_low` argument is
|
||||
* supposed to be set to 0.
|
||||
*
|
||||
* Reference:
|
||||
* https://www.kernel.org/doc/html/latest/firmware-guide/acpi/gpio-properties.html
|
||||
*/
|
||||
bool active_low;
|
||||
};
|
||||
|
||||
/* GpioIo-related macros */
|
||||
#define ACPI_GPIO_CFG(_gpio, _io_restrict, _polarity) { \
|
||||
#define ACPI_GPIO_CFG(_gpio, _io_restrict, _active_low) { \
|
||||
.type = ACPI_GPIO_TYPE_IO, \
|
||||
.pull = ACPI_GPIO_PULL_DEFAULT, \
|
||||
.io_restrict = _io_restrict, \
|
||||
.polarity = _polarity, \
|
||||
.active_low = _active_low, \
|
||||
.pin_count = 1, \
|
||||
.pins = { (_gpio) } }
|
||||
|
||||
/* Basic output GPIO with default pull settings */
|
||||
#define ACPI_GPIO_OUTPUT_CFG(gpio, polarity) \
|
||||
ACPI_GPIO_CFG(gpio, ACPI_GPIO_IO_RESTRICT_OUTPUT, polarity)
|
||||
#define ACPI_GPIO_OUTPUT_CFG(gpio, active_low) \
|
||||
ACPI_GPIO_CFG(gpio, ACPI_GPIO_IO_RESTRICT_OUTPUT, active_low)
|
||||
|
||||
#define ACPI_GPIO_OUTPUT_ACTIVE_HIGH(gpio) \
|
||||
ACPI_GPIO_OUTPUT_CFG(gpio, ACPI_GPIO_ACTIVE_HIGH)
|
||||
|
||||
#define ACPI_GPIO_OUTPUT_ACTIVE_LOW(gpio) \
|
||||
ACPI_GPIO_OUTPUT_CFG(gpio, ACPI_GPIO_ACTIVE_LOW)
|
||||
#define ACPI_GPIO_OUTPUT(gpio) ACPI_GPIO_OUTPUT_CFG(gpio, 0)
|
||||
#define ACPI_GPIO_OUTPUT_ACTIVE_HIGH(gpio) ACPI_GPIO_OUTPUT_CFG(gpio, 0)
|
||||
#define ACPI_GPIO_OUTPUT_ACTIVE_LOW(gpio) ACPI_GPIO_OUTPUT_CFG(gpio, 1)
|
||||
|
||||
/* Basic input GPIO with default pull settings */
|
||||
#define ACPI_GPIO_INPUT_CFG(gpio, polarity) \
|
||||
ACPI_GPIO_CFG(gpio, ACPI_GPIO_IO_RESTRICT_INPUT, polarity)
|
||||
|
||||
#define ACPI_GPIO_INPUT_ACTIVE_HIGH(gpio) \
|
||||
ACPI_GPIO_INPUT_CFG(gpio, ACPI_GPIO_ACTIVE_HIGH)
|
||||
|
||||
#define ACPI_GPIO_INPUT_ACTIVE_LOW(gpio) \
|
||||
ACPI_GPIO_INPUT_CFG(gpio, ACPI_GPIO_ACTIVE_LOW)
|
||||
#define ACPI_GPIO_INPUT(gpio) ACPI_GPIO_INPUT_CFG(gpio, 0)
|
||||
#define ACPI_GPIO_INPUT_ACTIVE_HIGH(gpio) ACPI_GPIO_INPUT_CFG(gpio, 0)
|
||||
#define ACPI_GPIO_INPUT_ACTIVE_LOW(gpio) ACPI_GPIO_INPUT_CFG(gpio, 1)
|
||||
|
||||
/* GpioInt-related macros */
|
||||
#define ACPI_GPIO_IRQ_CFG(_gpio, _mode, _polarity, _wake) { \
|
||||
|
|
Loading…
Reference in New Issue