Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp351970ybi; Wed, 29 May 2019 22:56:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqyV51ijvN7g5pfNXcsmtbNOWDFLegCy7PmI2kA1lrEG3eJ2hEOWRzXfNc6QhN1a2URIPOT4 X-Received: by 2002:a63:c508:: with SMTP id f8mr2248292pgd.48.1559195804076; Wed, 29 May 2019 22:56:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559195804; cv=none; d=google.com; s=arc-20160816; b=qVEoQfwQj60Xm1PamqHI9No4qfA8AHc2TRStcufBwr6xEFOQDzsxEO3I6VtKZgxBR3 zcQ+O64gNunty2JqEaZ+txmt1nx/I9PWsmH5a6nY9N2sRFi4HsGUfWaD0epYRWqk/mwc 8O07tslVMiPWJyFcHMq+Fs5c5uaI9agyD1X7YnxZgoKrIA8s+BX++N5Ji8BD1OhAYNq6 E3pMKw8/6ovrnxOM726vh4MVQDwUcI2zu0wmJAoGTbK9qGtCrrn0P6+CLlgmBdPPkTmU f15y62WVIPKIvamal4dNj2c2d8mghLy6U/qiG5M0eRxZDGopAKe00pTyNCRu2ls+nT8B 9E5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:mime-version:message-id :date:subject:cc:to:from; bh=EPpj67COYGBhlkWdKr0QIR/atWxow2EbLdfTiuxH0u4=; b=i500HPQrbjgZqVkwLGcfAKCW+ItT1AmXZSUk2ToN2pF4KawykDYbYiCEcJj5dMNbZL VrVo4CuTTXlNW/OhAC6n0G7Mv5eRDnnVrr+UNLRv6weu1RWBdPNGCz8qQFUaOhwu7cHy eakCXtGZM8uhpmquwSXZxpp3npqrlCHPFIDAZctkg4umZJbXTTblSKLsunqLPtBkp3JA 1pjJLbIfGq4jz/e1+UWfFuAL4bRp7WHqK9FAkZWeGoKeVphSisY0WLMeAmiMNl5euWMC uDIip7L2VG3yJFBNHxC2WC3iElYag/uCOn1k8Y37rpwrZQl2Xbomr7C2Lxqb4+wNDldE varA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b="dtfcl42/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p5si2158677pls.431.2019.05.29.22.56.27; Wed, 29 May 2019 22:56:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b="dtfcl42/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727005AbfE3Fz0 (ORCPT + 99 others); Thu, 30 May 2019 01:55:26 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:15712 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725961AbfE3Fz0 (ORCPT ); Thu, 30 May 2019 01:55:26 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 29 May 2019 22:55:24 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Wed, 29 May 2019 22:55:25 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Wed, 29 May 2019 22:55:25 -0700 Received: from HQMAIL102.nvidia.com (172.18.146.10) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 30 May 2019 05:55:25 +0000 Received: from HQMAIL103.nvidia.com (172.20.187.11) by HQMAIL102.nvidia.com (172.18.146.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 30 May 2019 05:55:24 +0000 Received: from hqnvemgw02.nvidia.com (172.16.227.111) by HQMAIL103.nvidia.com (172.20.187.11) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Thu, 30 May 2019 05:55:24 +0000 Received: from dhcp-10-19-65-14.client.nvidia.com (Not Verified[10.19.65.14]) by hqnvemgw02.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Wed, 29 May 2019 22:55:24 -0700 From: Bitan Biswas To: Laxman Dewangan , Thierry Reding , Jonathan Hunter , , , CC: Shardar Mohammed , Sowjanya Komatineni , Mantravadi Karthik , "Bitan Biswas" Subject: [PATCH V1] i2c: busses: tegra: Add suspend-resume support Date: Wed, 29 May 2019 22:55:18 -0700 Message-ID: <1559195718-6693-1-git-send-email-bbiswas@nvidia.com> X-Mailer: git-send-email 2.7.4 X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1559195725; bh=EPpj67COYGBhlkWdKr0QIR/atWxow2EbLdfTiuxH0u4=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: X-NVConfidentiality:MIME-Version:Content-Type; b=dtfcl42/jEs/OXvHlq4hBtfPuB3IDVKkqtZfI4Ftr9JxH50H7V46TkhmITkqasE+E pMufthNmo6PssZsCRY5rvx/8QcH9rcpJ/epYtgsDMj0doWmg6AAsCUBsRlBCDFmplG 5fXvPLY9I/+cBh6tIp3EGJk58ZXMJExWnnrLKL6uEcCQaeCWmF7jA6PJCJHvjIywTA QIrbwOzpguAeDvEWbnCXvZp2oPjrCwUytpZPHkQ5bJgSO1pCMGZ70vLOm7E3ZR7bHr mu96qnxP/IP0iVYnk4iS2DC9WhpnEQJuHydfF+SAWOPMDbLk2O2tJYe5GdMYBZcvwn w6xC3/2wOx7hw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Post suspend I2C registers have power on reset values. Before any transfer initialize I2C registers to prevent I2C transfer timeout and implement suspend and resume callbacks needed. Fix below errors post suspend: 1) Tegra I2C transfer timeout during jetson tx2 resume: [ 27.520613] pca953x 1-0074: calling pca953x_resume+0x0/0x1b0 @ 2939, parent: i2c-1 [ 27.633623] tegra-i2c 3160000.i2c: i2c transfer timed out [ 27.639162] pca953x 1-0074: Unable to sync registers 0x3-0x5. -110 [ 27.645336] pca953x 1-0074: Failed to sync GPIO dir registers: -110 [ 27.651596] PM: dpm_run_callback(): pca953x_resume+0x0/0x1b0 returns -110 [ 27.658375] pca953x 1-0074: pca953x_resume+0x0/0x1b0 returned -110 after 127152 usecs [ 27.666194] PM: Device 1-0074 failed to resume: error -110 2) Tegra I2C transfer timeout error on jetson Xavier post resume. Signed-off-by: Bitan Biswas --- drivers/i2c/busses/i2c-tegra.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index ebaa78d..f6a377f 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -1687,9 +1687,33 @@ static int tegra_i2c_remove(struct platform_device *pdev) } #ifdef CONFIG_PM_SLEEP +static int tegra_i2c_suspend(struct device *dev) +{ + struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev); + + i2c_mark_adapter_suspended(&i2c_dev->adapter); + + return 0; +} + +static int tegra_i2c_resume(struct device *dev) +{ + struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev); + int ret; + + i2c_lock_bus(&i2c_dev->adapter, I2C_LOCK_ROOT_ADAPTER); + ret = tegra_i2c_init(i2c_dev, false); + i2c_unlock_bus(&i2c_dev->adapter, I2C_LOCK_ROOT_ADAPTER); + if (!ret) + i2c_mark_adapter_resumed(&i2c_dev->adapter); + + return ret; +} + static const struct dev_pm_ops tegra_i2c_pm = { SET_RUNTIME_PM_OPS(tegra_i2c_runtime_suspend, tegra_i2c_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(tegra_i2c_suspend, tegra_i2c_resume) }; #define TEGRA_I2C_PM (&tegra_i2c_pm) #else -- 2.7.4