From patchwork Mon Jun 17 13:16:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 251846 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 10EFF2C009D for ; Mon, 17 Jun 2013 23:17:00 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756234Ab3FQNQ7 (ORCPT ); Mon, 17 Jun 2013 09:16:59 -0400 Received: from mail-pd0-f174.google.com ([209.85.192.174]:46011 "EHLO mail-pd0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756150Ab3FQNQ6 (ORCPT ); Mon, 17 Jun 2013 09:16:58 -0400 Received: by mail-pd0-f174.google.com with SMTP id 10so2765962pdc.33 for ; Mon, 17 Jun 2013 06:16:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=SqmAn+UyXUUUqIgBUJ8ddPjRuzZAz7f0Ae5u6rr/J5I=; b=HlSgSmk3klFahuyFbYXYJ4b5OCyIbddGVCVVH3DRYLDLszKJomCz/FO1ABZAZ9osIH 1t3M35Ntr+8G6XGgf81Ps7HOJkqjAlDPBo/14gG/3Tu+DR3AJcxc1uIkBY3XdEan48mg gwDs/orBte5Swd4whQtXFsjY+kH/4EUUusjV3Mlv1f82KTybBCamBTDdtUIkl0zVBHrG 0KZWlXhfTauh1oYv8esjGLhjwxssG+JmLPuoDxdTMNpVw+9OXYa4fEsU2sKAnsAp+huf IRZs6zO7jlpXObM3YWvznrHrEMIHIG6Lxp8+lhYFlG8xcNkeGsV90Y3dSzJWkCGS/RLp El2g== X-Received: by 10.68.212.106 with SMTP id nj10mr12803645pbc.74.1371475018062; Mon, 17 Jun 2013 06:16:58 -0700 (PDT) Received: from localhost ([122.167.240.191]) by mx.google.com with ESMTPSA id 6sm13809554pbn.45.2013.06.17.06.16.54 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 17 Jun 2013 06:16:57 -0700 (PDT) From: Viresh Kumar To: wsa@the-dreams.de Cc: khali@linux-fr.org, linux-i2c@vger.kernel.org, spear-devel@list.st.com, u.kleine-koenig@pengutronix.de, Viresh Kumar , Vincenzo Frascino , Shiraz Hashim Subject: [PATCH V10 Resend] i2c/designware: Provide i2c bus recovery support Date: Mon, 17 Jun 2013 18:46:45 +0530 Message-Id: <70c7ee79478cc2b89ad876d814207c6433e26a59.1371474881.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e X-Gm-Message-State: ALoCoQm3TcvkxGxj1rfna3ZUMVBWYYWkxUOrNqafnJNFBwKz6cuzuwzZXcCZxyYsVlaGYoBuqjVq Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Add bus recovery support for designware_i2c controller. It uses generic gpio based i2c_gpio_recover_bus() routine. Platforms need to pass struct i2c_bus_recovery_info as platform data to designware I2C controller. Signed-off-by: Vincenzo Frascino Signed-off-by: Shiraz Hashim Signed-off-by: Viresh Kumar --- This patch isn't drawing attention since sometime, so sending it again. drivers/i2c/busses/i2c-designware-core.c | 5 ++++- drivers/i2c/busses/i2c-designware-platdrv.c | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c index c41ca63..5ecb2f0 100644 --- a/drivers/i2c/busses/i2c-designware-core.c +++ b/drivers/i2c/busses/i2c-designware-core.c @@ -583,7 +583,10 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) ret = wait_for_completion_interruptible_timeout(&dev->cmd_complete, HZ); if (ret == 0) { dev_err(dev->dev, "controller timed out\n"); - i2c_dw_init(dev); + + if (i2c_recover_bus(adap) < 0) + i2c_dw_init(dev); + ret = -ETIMEDOUT; goto done; } else if (ret < 0) diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index 35b70a1..c3ada3e 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -162,6 +162,12 @@ static int dw_i2c_probe(struct platform_device *pdev) adap->dev.parent = &pdev->dev; adap->dev.of_node = pdev->dev.of_node; + /* Bus recovery support */ + adap->bus_recovery_info = dev_get_platdata(&pdev->dev); + if (adap->bus_recovery_info) + adap->bus_recovery_info->recover_bus = + i2c_generic_gpio_recovery; + r = i2c_add_numbered_adapter(adap); if (r) { dev_err(&pdev->dev, "failure adding adapter\n");