diff options
| author | Doug Anderson <dianders@chromium.org> | 2014-09-18 11:18:54 -0400 |
|---|---|---|
| committer | Lee Jones <lee.jones@linaro.org> | 2014-10-06 16:28:48 -0400 |
| commit | 659e142be09482cfd8b9017f616afebc7cf48fa3 (patch) | |
| tree | c26148959a3cbe749c7084dcf1579573ccb047d9 | |
| parent | 48b490d23ef5aaf65e16e194e0fd2578a9b6497f (diff) | |
mfd: cros_ec: Delay for 50ms when we see EC_CMD_REBOOT_EC
If someone sends a EC_CMD_REBOOT_EC to the EC, the EC will likely be
unresponsive for quite a while. Add a delay to the end of the command
to prevent random failures of future commands.
NOTES:
* This could be optimized a bit by simply delaying the next command
sent, but EC_CMD_REBOOT_EC is such a rare command that the extra
complexity doesn't seem worth it.
* This is a bit of an "ugly hack" since the SPI driver is effectively
snooping on the communication and making a lot of assumptions. It
would be nice to architect in some better solution long term.
* This same logic probably needs to be applied to the i2c driver.
Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
| -rw-r--r-- | drivers/mfd/cros_ec_spi.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/mfd/cros_ec_spi.c b/drivers/mfd/cros_ec_spi.c index 588c700af39c..b396705203fc 100644 --- a/drivers/mfd/cros_ec_spi.c +++ b/drivers/mfd/cros_ec_spi.c | |||
| @@ -65,6 +65,12 @@ | |||
| 65 | */ | 65 | */ |
| 66 | #define EC_SPI_RECOVERY_TIME_NS (200 * 1000) | 66 | #define EC_SPI_RECOVERY_TIME_NS (200 * 1000) |
| 67 | 67 | ||
| 68 | /* | ||
| 69 | * The EC is unresponsive for a time after a reboot command. Add a | ||
| 70 | * simple delay to make sure that the bus stays locked. | ||
| 71 | */ | ||
| 72 | #define EC_REBOOT_DELAY_MS 50 | ||
| 73 | |||
| 68 | /** | 74 | /** |
| 69 | * struct cros_ec_spi - information about a SPI-connected EC | 75 | * struct cros_ec_spi - information about a SPI-connected EC |
| 70 | * | 76 | * |
| @@ -318,6 +324,9 @@ static int cros_ec_cmd_xfer_spi(struct cros_ec_device *ec_dev, | |||
| 318 | 324 | ||
| 319 | ret = len; | 325 | ret = len; |
| 320 | exit: | 326 | exit: |
| 327 | if (ec_msg->command == EC_CMD_REBOOT_EC) | ||
| 328 | msleep(EC_REBOOT_DELAY_MS); | ||
| 329 | |||
| 321 | mutex_unlock(&ec_spi->lock); | 330 | mutex_unlock(&ec_spi->lock); |
| 322 | return ret; | 331 | return ret; |
| 323 | } | 332 | } |
