From patchwork Tue Mar 1 06:32:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhrajyoti Datta X-Patchwork-Id: 590353 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 681761402C9 for ; Tue, 1 Mar 2016 17:48:18 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750912AbcCAGsR (ORCPT ); Tue, 1 Mar 2016 01:48:17 -0500 Received: from mail-cys01nam02on0046.outbound.protection.outlook.com ([104.47.37.46]:1354 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750820AbcCAGsR (ORCPT ); Tue, 1 Mar 2016 01:48:17 -0500 X-Greylist: delayed 908 seconds by postgrey-1.27 at vger.kernel.org; Tue, 01 Mar 2016 01:48:16 EST Received: from CY1NAM02FT024.eop-nam02.prod.protection.outlook.com (10.152.74.52) by CY1NAM02HT157.eop-nam02.prod.protection.outlook.com (10.152.75.61) with Microsoft SMTP Server (TLS) id 15.1.422.5; Tue, 1 Mar 2016 06:33:06 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by CY1NAM02FT024.mail.protection.outlook.com (10.152.74.210) with Microsoft SMTP Server (TLS) id 15.1.427.7 via Frontend Transport; Tue, 1 Mar 2016 06:33:06 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1aadrl-0006da-Jn; Mon, 29 Feb 2016 22:33:05 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1aadrl-0001MZ-0Z; Mon, 29 Feb 2016 22:33:05 -0800 Received: from xsj-pvapsmtp01 (xsj-pvapsmtp01.xilinx.com [149.199.38.66]) by xsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id u216Wuib025287; Mon, 29 Feb 2016 22:32:56 -0800 Received: from [172.23.146.171] (helo=xhdl3763.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1aadrb-0001Ht-Fg; Mon, 29 Feb 2016 22:32:55 -0800 Received: by xhdl3763.xilinx.com (Postfix, from userid 9049) id 24CF52CE04EA; Tue, 1 Mar 2016 12:02:55 +0530 (IST) From: Shubhrajyoti Datta To: CC: , , , Shubhrajyoti Datta Subject: [PATCH 2/2] i2c: cadence: Implement save restore Date: Tue, 1 Mar 2016 12:02:39 +0530 Message-ID: <1456813959-20398-2-git-send-email-shubhraj@xilinx.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1456813959-20398-1-git-send-email-shubhraj@xilinx.com> References: <1456813959-20398-1-git-send-email-shubhraj@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-22160.006 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:149.199.60.83; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(189002)(199003)(45336002)(86362001)(110136002)(107886002)(46386002)(33646002)(19580395003)(19580405001)(1220700001)(92566002)(36756003)(36386004)(11100500001)(48376002)(47776003)(103686003)(229853001)(5001960100003)(586003)(1096002)(106466001)(2351001)(50986999)(76176999)(52956003)(87936001)(2950100001)(4001430100002)(50226001)(6806005)(189998001)(90966002)(5003940100001)(5008740100001)(4326007)(551934003)(2906002)(50466002)(63266004)(42186005)(81156008)(107986001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1NAM02HT157; H:xsj-pvapsmtpgw01; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: e4299288-a4ea-4044-c643-08d3419b5944 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:CY1NAM02HT157; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13018025)(13024025)(5005006)(8121501046)(13017025)(13023025)(13015025)(10201501046)(3002001); SRVR:CY1NAM02HT157; BCL:0; PCL:0; RULEID:; SRVR:CY1NAM02HT157; X-Forefront-PRVS: 086831DFB4 X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2016 06:33:06.1068 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.83]; Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1NAM02HT157 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Implement save restore for i2c module. Since we have only a couple of registers an unconditional restore is done. Signed-off-by: Shubhrajyoti Datta --- zynq-mp has the capability of going off. the current kernel does not hit off however some day it will. since the overhead of having the support is not much may be it is better to have it in the kernel. drivers/i2c/busses/i2c-cadence.c | 32 ++++++++++++++++++-------------- 1 files changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c index a761520..3d50914 100644 --- a/drivers/i2c/busses/i2c-cadence.c +++ b/drivers/i2c/busses/i2c-cadence.c @@ -161,6 +161,7 @@ struct cdns_i2c { struct clk *clk; struct notifier_block clk_rate_change_nb; u32 quirks; + u32 ctrl_reg; }; struct cdns_platform_data { @@ -743,12 +744,11 @@ static int cdns_i2c_setclk(unsigned long clk_in, struct cdns_i2c *id) if (ret) return ret; - ctrl_reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET); + ctrl_reg = id->ctrl_reg; ctrl_reg &= ~(CDNS_I2C_CR_DIVA_MASK | CDNS_I2C_CR_DIVB_MASK); ctrl_reg |= ((div_a << CDNS_I2C_CR_DIVA_SHIFT) | (div_b << CDNS_I2C_CR_DIVB_SHIFT)); - cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET); - + id->ctrl_reg = ctrl_reg; return 0; } @@ -831,6 +831,18 @@ static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev) return 0; } +static void cdns_i2c_init(struct cdns_i2c *id) +{ + cdns_i2c_writereg(id->ctrl_reg, CDNS_I2C_CR_OFFSET); + /* + * Cadence I2C controller has a bug wherein it generates + * invalid read transaction after HW timeout in master receiver mode. + * HW timeout is not used by this driver and the interrupt is disabled. + * But the feature itself cannot be disabled. Hence maximum value + * is written to this register to reduce the chances of error. + */ + cdns_i2c_writereg(CDNS_I2C_TIMEOUT_MAX, CDNS_I2C_TIME_OUT_OFFSET); +} /** * cdns_i2c_runtime_resume - Runtime resume @@ -851,6 +863,7 @@ static int __maybe_unused cdns_i2c_runtime_resume(struct device *dev) dev_err(dev, "Cannot enable clock.\n"); return ret; } + cdns_i2c_init(xi2c); return 0; } @@ -943,8 +956,7 @@ static int cdns_i2c_probe(struct platform_device *pdev) if (ret || (id->i2c_clk > CDNS_I2C_SPEED_MAX)) id->i2c_clk = CDNS_I2C_SPEED_DEFAULT; - cdns_i2c_writereg(CDNS_I2C_CR_ACK_EN | CDNS_I2C_CR_NEA | CDNS_I2C_CR_MS, - CDNS_I2C_CR_OFFSET); + id->ctrl_reg = CDNS_I2C_CR_ACK_EN | CDNS_I2C_CR_NEA | CDNS_I2C_CR_MS; ret = cdns_i2c_setclk(id->input_clk, id); if (ret) { @@ -965,15 +977,7 @@ static int cdns_i2c_probe(struct platform_device *pdev) dev_err(&pdev->dev, "reg adap failed: %d\n", ret); goto err_clk_dis; } - - /* - * Cadence I2C controller has a bug wherein it generates - * invalid read transaction after HW timeout in master receiver mode. - * HW timeout is not used by this driver and the interrupt is disabled. - * But the feature itself cannot be disabled. Hence maximum value - * is written to this register to reduce the chances of error. - */ - cdns_i2c_writereg(CDNS_I2C_TIMEOUT_MAX, CDNS_I2C_TIME_OUT_OFFSET); + cdns_i2c_init(id); dev_info(&pdev->dev, "%u kHz mmio %08lx irq %d\n", id->i2c_clk / 1000, (unsigned long)r_mem->start, id->irq);