src/drivers: Add reset/enable/stop_off_ms variables to ACPI devices

Some touchscreens need to adhere to certain timings during the power
off sequence as well as during the power on sequence.  Adding
reset_off_delay_ms, enable_off_delay_ms, and stop_off_delay_ms to
accommodate these devices.

BUG=b:78311818
BRANCH=None
TEST=./util/abuild/abuild -p none -t google/poppy -x -a

Change-Id: Idb4a5dbe56eee4749d2f2b514e92c28fb2c6078f
Signed-off-by: Shelley Chen <shchen@google.com>
Reviewed-on: https://review.coreboot.org/25882
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
Shelley Chen 2018-04-26 13:52:30 -07:00
parent 77034fa7d4
commit a060339774
6 changed files with 110 additions and 43 deletions

View File

@ -469,15 +469,12 @@ void acpi_device_write_spi(const struct acpi_spi *spi)
} }
/* PowerResource() with Enable and/or Reset control */ /* PowerResource() with Enable and/or Reset control */
void acpi_device_add_power_res( void acpi_device_add_power_res(const struct acpi_power_res_params *params)
struct acpi_gpio *reset, unsigned int reset_delay_ms,
struct acpi_gpio *enable, unsigned int enable_delay_ms,
struct acpi_gpio *stop, unsigned int stop_delay_ms)
{ {
static const char *power_res_dev_states[] = { "_PR0", "_PR3" }; static const char *power_res_dev_states[] = { "_PR0", "_PR3" };
unsigned int reset_gpio = reset->pins[0]; unsigned int reset_gpio = params->reset_gpio->pins[0];
unsigned int enable_gpio = enable->pins[0]; unsigned int enable_gpio = params->enable_gpio->pins[0];
unsigned int stop_gpio = stop->pins[0]; unsigned int stop_gpio = params->stop_gpio->pins[0];
if (!reset_gpio && !enable_gpio && !stop_gpio) if (!reset_gpio && !enable_gpio && !stop_gpio)
return; return;
@ -492,32 +489,41 @@ 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_enable_tx_gpio(reset); acpigen_enable_tx_gpio(params->reset_gpio);
if (enable_gpio) { if (enable_gpio) {
acpigen_enable_tx_gpio(enable); acpigen_enable_tx_gpio(params->enable_gpio);
if (enable_delay_ms) if (params->enable_delay_ms)
acpigen_write_sleep(enable_delay_ms); acpigen_write_sleep(params->enable_delay_ms);
} }
if (reset_gpio) { if (reset_gpio) {
acpigen_disable_tx_gpio(reset); acpigen_disable_tx_gpio(params->reset_gpio);
if (reset_delay_ms) if (params->reset_delay_ms)
acpigen_write_sleep(reset_delay_ms); acpigen_write_sleep(params->reset_delay_ms);
} }
if (stop_gpio) { if (stop_gpio) {
acpigen_disable_tx_gpio(stop); acpigen_disable_tx_gpio(params->stop_gpio);
if (stop_delay_ms) if (params->stop_delay_ms)
acpigen_write_sleep(stop_delay_ms); acpigen_write_sleep(params->stop_delay_ms);
} }
acpigen_pop_len(); /* _ON method */ acpigen_pop_len(); /* _ON method */
/* Method (_OFF, 0, Serialized) */ /* Method (_OFF, 0, Serialized) */
acpigen_write_method_serialized("_OFF", 0); acpigen_write_method_serialized("_OFF", 0);
if (stop_gpio) if (stop_gpio) {
acpigen_enable_tx_gpio(stop); acpigen_enable_tx_gpio(params->stop_gpio);
if (reset_gpio) if (params->stop_off_delay_ms)
acpigen_enable_tx_gpio(reset); acpigen_write_sleep(params->stop_off_delay_ms);
if (enable_gpio) }
acpigen_disable_tx_gpio(enable); if (reset_gpio) {
acpigen_enable_tx_gpio(params->reset_gpio);
if (params->reset_off_delay_ms)
acpigen_write_sleep(params->reset_off_delay_ms);
}
if (enable_gpio) {
acpigen_disable_tx_gpio(params->enable_gpio);
if (params->enable_off_delay_ms)
acpigen_write_sleep(params->enable_off_delay_ms);
}
acpigen_pop_len(); /* _OFF method */ acpigen_pop_len(); /* _OFF method */
acpigen_pop_len(); /* PowerResource PRIC */ acpigen_pop_len(); /* PowerResource PRIC */

View File

@ -315,6 +315,40 @@ struct acpi_spi {
/* Write SPI Bus descriptor to SSDT AML output */ /* Write SPI Bus descriptor to SSDT AML output */
void acpi_device_write_spi(const struct acpi_spi *spi); void acpi_device_write_spi(const struct acpi_spi *spi);
/* GPIO/timing information for the power on/off sequences */
struct acpi_power_res_params {
/* GPIO used to take device out of reset or to put it into reset. */
struct acpi_gpio *reset_gpio;
/* Delay to be inserted after device is taken out of reset.
* (_ON method delay)
*/
unsigned int reset_delay_ms;
/* Delay to be inserted after device is put into reset.
* (_OFF method delay)
*/
unsigned int reset_off_delay_ms;
/* GPIO used to enable device. */
struct acpi_gpio *enable_gpio;
/* Delay to be inserted after device is enabled.
* (_ON method delay)
*/
unsigned int enable_delay_ms;
/* Delay to be inserted after device is disabled.
* (_OFF method delay)
*/
unsigned int enable_off_delay_ms;
/* GPIO used to stop operation of device. */
struct acpi_gpio *stop_gpio;
/* Delay to be inserted after disabling stop.
* (_ON method delay)
*/
unsigned int stop_delay_ms;
/* Delay to be inserted after enabling stop.
* (_OFF method delay)
*/
unsigned int stop_off_delay_ms;
};
/* /*
* Add a basic PowerResource block for a device that includes * Add a basic PowerResource block for a device that includes
* GPIOs to control enable, reset and stop operation of the device. Each * GPIOs to control enable, reset and stop operation of the device. Each
@ -324,10 +358,7 @@ void acpi_device_write_spi(const struct acpi_spi *spi);
* Enable - Enable / disable power to device. * Enable - Enable / disable power to device.
* Stop - Stop / start operation of device. * Stop - Stop / start operation of device.
*/ */
void acpi_device_add_power_res( void acpi_device_add_power_res(const struct acpi_power_res_params *params);
struct acpi_gpio *reset, unsigned int reset_delay_ms,
struct acpi_gpio *enable, unsigned int enable_delay_ms,
struct acpi_gpio *stop, unsigned int stop_delay_ms);
/* /*
* Writing Device Properties objects via _DSD * Writing Device Properties objects via _DSD

View File

@ -56,15 +56,21 @@ struct drivers_i2c_generic_config {
/* GPIO used to take device out of reset or to put it into reset. */ /* GPIO used to take device out of reset or to put it into reset. */
struct acpi_gpio reset_gpio; struct acpi_gpio reset_gpio;
/* Delay to be inserted after device is taken out of reset. */ /* Delay to be inserted after device is taken out of reset. */
unsigned reset_delay_ms; unsigned int reset_delay_ms;
/* Delay to be inserted after device is put into reset. */
unsigned int reset_off_delay_ms;
/* GPIO used to enable device. */ /* GPIO used to enable device. */
struct acpi_gpio enable_gpio; struct acpi_gpio enable_gpio;
/* Delay to be inserted after device is enabled. */ /* Delay to be inserted after device is enabled. */
unsigned enable_delay_ms; unsigned int enable_delay_ms;
/* Delay to be inserted after device is disabled. */
unsigned int enable_off_delay_ms;
/* GPIO used to stop operation of device. */ /* GPIO used to stop operation of device. */
struct acpi_gpio stop_gpio; struct acpi_gpio stop_gpio;
/* Delay to be inserted after disabling stop. */ /* Delay to be inserted after disabling stop. */
unsigned stop_delay_ms; unsigned int stop_delay_ms;
/* Delay to be inserted after enabling stop. */
unsigned int stop_off_delay_ms;
/* Generic properties for exporting device-specific data to the OS */ /* Generic properties for exporting device-specific data to the OS */
struct acpi_dp property_list[MAX_GENERIC_PROPERTY_LIST]; struct acpi_dp property_list[MAX_GENERIC_PROPERTY_LIST];

View File

@ -142,11 +142,20 @@ void i2c_generic_fill_ssdt(struct device *dev,
} }
/* Power Resource */ /* Power Resource */
if (config->has_power_resource) if (config->has_power_resource) {
acpi_device_add_power_res( const struct acpi_power_res_params power_res_params = {
&config->reset_gpio, config->reset_delay_ms, &config->reset_gpio,
&config->enable_gpio, config->enable_delay_ms, config->reset_delay_ms,
&config->stop_gpio, config->stop_delay_ms); config->reset_off_delay_ms,
&config->enable_gpio,
config->enable_delay_ms,
config->enable_off_delay_ms,
&config->stop_gpio,
config->stop_delay_ms,
config->stop_off_delay_ms
};
acpi_device_add_power_res(&power_res_params);
}
/* Callback if any. */ /* Callback if any. */
if (callback) if (callback)

View File

@ -165,11 +165,20 @@ static void spi_acpi_fill_ssdt_generator(struct device *dev)
} }
/* Power Resource */ /* Power Resource */
if (config->has_power_resource) if (config->has_power_resource) {
acpi_device_add_power_res( const struct acpi_power_res_params power_res_params = {
&config->reset_gpio, config->reset_delay_ms, &config->reset_gpio,
&config->enable_gpio, config->enable_delay_ms, config->reset_delay_ms,
&config->stop_gpio, config->stop_delay_ms); config->reset_off_delay_ms,
&config->enable_gpio,
config->enable_delay_ms,
config->enable_off_delay_ms,
&config->stop_gpio,
config->stop_delay_ms,
config->stop_off_delay_ms
};
acpi_device_add_power_res(&power_res_params);
}
acpigen_pop_len(); /* Device */ acpigen_pop_len(); /* Device */
acpigen_pop_len(); /* Scope */ acpigen_pop_len(); /* Scope */

View File

@ -41,17 +41,23 @@ struct drivers_spi_acpi_config {
/* GPIO used to take device out of reset or to put it into reset. */ /* GPIO used to take device out of reset or to put it into reset. */
struct acpi_gpio reset_gpio; struct acpi_gpio reset_gpio;
/* Delay to be inserted after device is taken out of reset. */ /* Delay to be inserted after device is taken out of reset. */
unsigned reset_delay_ms; unsigned int reset_delay_ms;
/* Delay to be inserted after device is put into reset. */
unsigned int reset_off_delay_ms;
/* GPIO used to enable device. */ /* GPIO used to enable device. */
struct acpi_gpio enable_gpio; struct acpi_gpio enable_gpio;
/* Delay to be inserted after device is enabled. */ /* Delay to be inserted after device is enabled. */
unsigned enable_delay_ms; unsigned int enable_delay_ms;
/* Delay to be inserted after device is disabled. */
unsigned int enable_off_delay_ms;
/* GPIO used to stop operation of device. */ /* GPIO used to stop operation of device. */
struct acpi_gpio stop_gpio; struct acpi_gpio stop_gpio;
/* Delay to be inserted after disabling stop. */ /* Delay to be inserted after disabling stop. */
unsigned stop_delay_ms; unsigned int stop_delay_ms;
/* Delay to be inserted after enabling stop. */
unsigned int stop_off_delay_ms;
}; };
#endif /* __SPI_ACPI_CHIP_H__ */ #endif /* __SPI_ACPI_CHIP_H__ */