Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7668953ybi; Wed, 5 Jun 2019 22:56:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzs7/WV54/BrdmIgVcA0Bhx5W6Sjj3uoS2l0Hy37B/xq8bP39ZnxaIsArKfoO8Ku00UxWi5 X-Received: by 2002:a17:902:ab90:: with SMTP id f16mr47688867plr.262.1559800573208; Wed, 05 Jun 2019 22:56:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559800573; cv=none; d=google.com; s=arc-20160816; b=YIW45mHVLEU/B86bD/prBystxgKDuzFw+uYF363gYcAqz+mLTIk8gB5qYkzL70i1Or juUQZoZt4s4itM7+JKfICcwevHh/xtxVTPNG2RuRebqaEo9JZkt/T5Au/o/z6Ij9dcpf bg2dVjrW03/AHKLiwqtoz1AndaXW8wZyK1ReEnO80j69P5Ouwcr5c3jtrt97b2gjZ8pf ynyG7VRgCa71cRu1Bs2hBaSXnfux0RPdIr7gKcU9OBkKsCc9EB/LGMq2i/0a8Q83NjYI HcnWo6qC5kg5m+1vdwcU3J44o64+V8AI7iapjrya3cfWSwV/Fl6yTgpLK5HiEanew9AS 0Qnw== 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=Ql18WqF5DlKTmuF9A6ySKjZp8fdZDrnvE3SqNnzlawE=; b=D274BJ6VVxk6tmbhvkES1ahd3JQkddk8DBJuTv/lYNLnfVrOco74AfTrAC3cUimnj2 h6BvZNFz5RqOFXcBdxjFZ0nuv4YmCk85NLbAWqoapGuXE7IcwWP4kBy99Zz1XA2lruR5 zJSvlLI157wgY6wwQzfUN/IGRMsTKzzvkM9hCH7A52wHK7XVtFjbmWOzZSDeijMPDGMz KnXkRnFwZKGcu4MgeB/CGMv6foHIaFT1k0Ixa85ON3UiCR4cYxRGJ2AVSzmqGFK+EjVO Kw6Dx7vO4zmhQ1yB34lwddQBBTpPoMqBGuDWXTs6eAg+4IUeXHgwwvaK2Djn1fro6obB 0btQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=HrlMr375; 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 g11si837350plt.35.2019.06.05.22.55.57; Wed, 05 Jun 2019 22:56:13 -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=HrlMr375; 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 S1726301AbfFFFyo (ORCPT + 99 others); Thu, 6 Jun 2019 01:54:44 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:13063 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbfFFFyn (ORCPT ); Thu, 6 Jun 2019 01:54:43 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 05 Jun 2019 22:54:28 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Wed, 05 Jun 2019 22:54:42 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 05 Jun 2019 22:54:42 -0700 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL106.nvidia.com (172.18.146.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 6 Jun 2019 05:54:41 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Thu, 6 Jun 2019 05:54:41 +0000 Received: from dhcp-10-19-65-14.client.nvidia.com (Not Verified[10.19.65.14]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Wed, 05 Jun 2019 22:54:41 -0700 From: Bitan Biswas To: Laxman Dewangan , Thierry Reding , Jonathan Hunter , , , CC: Shardar Mohammed , Sowjanya Komatineni , Mantravadi Karthik , Bitan Biswas Subject: [PATCH V2] i2c: busses: tegra: Add suspend-resume support Date: Wed, 5 Jun 2019 22:54:35 -0700 Message-ID: <1559800475-5446-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=1559800468; bh=Ql18WqF5DlKTmuF9A6ySKjZp8fdZDrnvE3SqNnzlawE=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: X-NVConfidentiality:MIME-Version:Content-Type; b=HrlMr375rplGGrTwZAMBPbEiWKXvAb6on7iK2T+rPQz2OO7AbLocC3HCdyFdgzXw+ Urc1zmcD/z27n703dwJepbKzj97ru1mcf/YvPubtz2PKRzCaCKQ9ojHu/D7SHcLtEF llhlan2uG0/xsmEEOzloW0pXsTpl4Cd0C1qSy8CzOnlC2yGgMYa2BPGnwURUH05RpF VOYuYD9Nid5mbrTig/Z2lurtoO0/kP8HBTIuuU6gddbzUm0JT80dOaQZqhIcfGboVq 3tKXxCJopWv5wnXy+H99CDKPpvLBSLwhCx3mqJczX8bY6AeJLl5DRxOzcuXP/hYWqD yTp9HVCc2yahQ== 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. Remove i2c bus lock-unlock calls in resume callback as i2c_mark_adapter_* (suspended-resumed) help ensure i2c core calls from client are not executed before i2c-tegra resume. Signed-off-by: Bitan Biswas --- drivers/i2c/busses/i2c-tegra.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index ebaa78d..76b7926 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -1687,7 +1687,30 @@ 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; + + ret = tegra_i2c_init(i2c_dev, false); + if (ret) + return ret; + + i2c_mark_adapter_resumed(&i2c_dev->adapter); + return 0; +} + static const struct dev_pm_ops tegra_i2c_pm = { + SET_SYSTEM_SLEEP_PM_OPS(tegra_i2c_suspend, tegra_i2c_resume) SET_RUNTIME_PM_OPS(tegra_i2c_runtime_suspend, tegra_i2c_runtime_resume, NULL) }; -- 2.7.4