From patchwork Wed Aug 20 12:13:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 4750691 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B9FA99F3B4 for ; Wed, 20 Aug 2014 12:15:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2AAE92018A for ; Wed, 20 Aug 2014 12:15:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 061B9201C8 for ; Wed, 20 Aug 2014 12:15:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754686AbaHTMOF (ORCPT ); Wed, 20 Aug 2014 08:14:05 -0400 Received: from bhuna.collabora.co.uk ([93.93.135.160]:43125 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752416AbaHTMOB (ORCPT ); Wed, 20 Aug 2014 08:14:01 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: javier) with ESMTPSA id DC3FE60332C From: Javier Martinez Canillas To: Lee Jones Cc: Wolfram Sang , Dmitry Torokhov , Doug Anderson , Simon Glass , Bill Richardson , Andrew Bresticker , Derek Basehore , Todd Broch , Olof Johansson , =?UTF-8?q?Andreas=20F=C3=A4rber?= , linux-i2c@vger.kernel.org, linux-input@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Javier Martinez Canillas Subject: [RESEND PATCH 1/7] mfd: cros_ec: Delay for 50ms when we see EC_CMD_REBOOT_EC Date: Wed, 20 Aug 2014 14:13:26 +0200 Message-Id: <1408536812-7836-2-git-send-email-javier.martinez@collabora.co.uk> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1408536812-7836-1-git-send-email-javier.martinez@collabora.co.uk> References: <1408536812-7836-1-git-send-email-javier.martinez@collabora.co.uk> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Doug Anderson 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 Reviewed-by: Randall Spangler Reviewed-by: Vadim Bendebury Signed-off-by: Javier Martinez Canillas Acked-by: Lee Jones --- drivers/mfd/cros_ec_spi.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/mfd/cros_ec_spi.c b/drivers/mfd/cros_ec_spi.c index 588c700..b396705 100644 --- a/drivers/mfd/cros_ec_spi.c +++ b/drivers/mfd/cros_ec_spi.c @@ -65,6 +65,12 @@ */ #define EC_SPI_RECOVERY_TIME_NS (200 * 1000) +/* + * The EC is unresponsive for a time after a reboot command. Add a + * simple delay to make sure that the bus stays locked. + */ +#define EC_REBOOT_DELAY_MS 50 + /** * struct cros_ec_spi - information about a SPI-connected EC * @@ -318,6 +324,9 @@ static int cros_ec_cmd_xfer_spi(struct cros_ec_device *ec_dev, ret = len; exit: + if (ec_msg->command == EC_CMD_REBOOT_EC) + msleep(EC_REBOOT_DELAY_MS); + mutex_unlock(&ec_spi->lock); return ret; }