acpi_device: Move power resource function to generic code
Move the function that adds a power resource block from i2c/generic to the acpi device code at src/arch/x86/acpi_device.c so it can be used by more drivers. BUG=chrome-os-partner:61233 TEST=verify SSDT table generation is unchanged Change-Id: I0ffb61a4f46028cbe912e85c0124d9f5200b9c76 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://review.coreboot.org/18391 Tested-by: build bot (Jenkins) Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
parent
f9d5308690
commit
bd73dbbc38
|
@ -490,6 +490,52 @@ void acpi_device_write_spi(const struct acpi_spi *spi)
|
|||
acpi_device_fill_len(desc_length);
|
||||
}
|
||||
|
||||
/* PowerResource() with Enable and/or Reset control */
|
||||
void acpi_device_add_power_res(
|
||||
struct acpi_gpio *reset, unsigned reset_delay_ms,
|
||||
struct acpi_gpio *enable, unsigned enable_delay_ms)
|
||||
{
|
||||
const char *power_res_dev_states[] = { "_PR0", "_PR3" };
|
||||
unsigned reset_gpio = reset->pins[0];
|
||||
unsigned enable_gpio = enable->pins[0];
|
||||
|
||||
if (!reset_gpio && !enable_gpio)
|
||||
return;
|
||||
|
||||
/* PowerResource (PRIC, 0, 0) */
|
||||
acpigen_write_power_res("PRIC", 0, 0, power_res_dev_states,
|
||||
ARRAY_SIZE(power_res_dev_states));
|
||||
|
||||
/* Method (_STA, 0, NotSerialized) { Return (0x1) } */
|
||||
acpigen_write_STA(0x1);
|
||||
|
||||
/* Method (_ON, 0, Serialized) */
|
||||
acpigen_write_method_serialized("_ON", 0);
|
||||
if (reset_gpio)
|
||||
acpigen_soc_set_tx_gpio(reset_gpio);
|
||||
if (enable_gpio) {
|
||||
acpigen_soc_set_tx_gpio(enable_gpio);
|
||||
if (enable_delay_ms)
|
||||
acpigen_write_sleep(enable_delay_ms);
|
||||
}
|
||||
if (reset_gpio) {
|
||||
acpigen_soc_clear_tx_gpio(reset_gpio);
|
||||
if (reset_delay_ms)
|
||||
acpigen_write_sleep(reset_delay_ms);
|
||||
}
|
||||
acpigen_pop_len(); /* _ON method */
|
||||
|
||||
/* Method (_OFF, 0, Serialized) */
|
||||
acpigen_write_method_serialized("_OFF", 0);
|
||||
if (reset_gpio)
|
||||
acpigen_soc_set_tx_gpio(reset_gpio);
|
||||
if (enable_gpio)
|
||||
acpigen_soc_clear_tx_gpio(enable_gpio);
|
||||
acpigen_pop_len(); /* _OFF method */
|
||||
|
||||
acpigen_pop_len(); /* PowerResource PRIC */
|
||||
}
|
||||
|
||||
static void acpi_dp_write_array(const struct acpi_dp *array);
|
||||
static void acpi_dp_write_value(const struct acpi_dp *prop)
|
||||
{
|
||||
|
|
|
@ -239,6 +239,15 @@ struct acpi_spi {
|
|||
/* Write SPI Bus descriptor to SSDT AML output */
|
||||
void acpi_device_write_spi(const struct acpi_spi *spi);
|
||||
|
||||
/*
|
||||
* Add a basic PowerResource block for a device that includes
|
||||
* GPIOs for enable and/or reset control of the device. Each
|
||||
* GPIO is optional, but at least one must be provided.
|
||||
*/
|
||||
void acpi_device_add_power_res(
|
||||
struct acpi_gpio *reset, unsigned reset_delay_ms,
|
||||
struct acpi_gpio *enable, unsigned enable_delay_ms);
|
||||
|
||||
/*
|
||||
* Writing Device Properties objects via _DSD
|
||||
*
|
||||
|
|
|
@ -26,50 +26,6 @@
|
|||
|
||||
#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
|
||||
|
||||
static void i2c_generic_add_power_res(struct drivers_i2c_generic_config *config)
|
||||
{
|
||||
const char *power_res_dev_states[] = { "_PR0", "_PR3" };
|
||||
unsigned reset_gpio = config->reset_gpio.pins[0];
|
||||
unsigned enable_gpio = config->enable_gpio.pins[0];
|
||||
|
||||
if (!config->has_power_resource)
|
||||
return;
|
||||
|
||||
if (!reset_gpio && !enable_gpio)
|
||||
return;
|
||||
|
||||
/* PowerResource (PRIC, 0, 0) */
|
||||
acpigen_write_power_res("PRIC", 0, 0, power_res_dev_states,
|
||||
ARRAY_SIZE(power_res_dev_states));
|
||||
|
||||
/* Method (_STA, 0, NotSerialized) { Return (0x1) } */
|
||||
acpigen_write_STA(0x1);
|
||||
|
||||
/* Method (_ON, 0, Serialized) */
|
||||
acpigen_write_method_serialized("_ON", 0);
|
||||
if (reset_gpio)
|
||||
acpigen_soc_set_tx_gpio(reset_gpio);
|
||||
if (enable_gpio) {
|
||||
acpigen_soc_set_tx_gpio(enable_gpio);
|
||||
acpigen_write_sleep(config->enable_delay_ms);
|
||||
}
|
||||
if (reset_gpio) {
|
||||
acpigen_soc_clear_tx_gpio(reset_gpio);
|
||||
acpigen_write_sleep(config->reset_delay_ms);
|
||||
}
|
||||
acpigen_pop_len(); /* _ON method */
|
||||
|
||||
/* Method (_OFF, 0, Serialized) */
|
||||
acpigen_write_method_serialized("_OFF", 0);
|
||||
if (reset_gpio)
|
||||
acpigen_soc_set_tx_gpio(reset_gpio);
|
||||
if (enable_gpio)
|
||||
acpigen_soc_clear_tx_gpio(enable_gpio);
|
||||
acpigen_pop_len(); /* _OFF method */
|
||||
|
||||
acpigen_pop_len(); /* PowerResource PRIC */
|
||||
}
|
||||
|
||||
static bool i2c_generic_add_gpios_to_crs(struct drivers_i2c_generic_config *cfg)
|
||||
{
|
||||
/*
|
||||
|
@ -170,7 +126,10 @@ void i2c_generic_fill_ssdt(struct device *dev,
|
|||
}
|
||||
|
||||
/* Power Resource */
|
||||
i2c_generic_add_power_res(config);
|
||||
if (config->has_power_resource)
|
||||
acpi_device_add_power_res(
|
||||
&config->reset_gpio, config->reset_delay_ms,
|
||||
&config->enable_gpio, config->enable_delay_ms);
|
||||
|
||||
/* Callback if any. */
|
||||
if (callback)
|
||||
|
|
Loading…
Reference in New Issue