From patchwork Mon Oct 20 03:42:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenyou Yang X-Patchwork-Id: 5102251 Return-Path: X-Original-To: patchwork-linux-arm@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 492F99F30B for ; Mon, 20 Oct 2014 03:52:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 685BB201F2 for ; Mon, 20 Oct 2014 03:52:15 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8FF9320149 for ; Mon, 20 Oct 2014 03:52:14 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xg3zC-0006Tc-KY; Mon, 20 Oct 2014 03:50:22 +0000 Received: from eusmtp01.atmel.com ([212.144.249.243]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xg3z6-0005Hb-M2 for linux-arm-kernel@lists.infradead.org; Mon, 20 Oct 2014 03:50:18 +0000 Received: from apsmtp01.atmel.com (10.168.254.31) by eusmtp01.atmel.com (10.161.101.31) with Microsoft SMTP Server id 14.2.347.0; Mon, 20 Oct 2014 05:49:52 +0200 Received: from shaarm01.corp.atmel.com (10.168.254.13) by apsmtp01.atmel.com (10.168.254.31) with Microsoft SMTP Server id 14.2.347.0; Mon, 20 Oct 2014 11:47:35 +0800 From: Wenyou Yang To: , Subject: [PATCH 3/3] i2c/at91: adopt pinctrl support Date: Mon, 20 Oct 2014 11:42:14 +0800 Message-ID: <1413776535-10123-4-git-send-email-wenyou.yang@atmel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1413776535-10123-1-git-send-email-wenyou.yang@atmel.com> References: <1413776535-10123-1-git-send-email-wenyou.yang@atmel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141019_205017_061763_1EC246F7 X-CRM114-Status: GOOD ( 11.92 ) X-Spam-Score: -1.4 (-) Cc: wenyou.yang@atmel.com, nicolas.ferre@atmel.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Amend the i2c at91 pin controller to optionally take a pin control handle and set the state of the pins to: - "default" on boot, resume and before performing an transfer - "sleep" on suspend() This should make it possible to optimize energy usage for the pins both for the suspend/resume cycle Signed-off-by: Wenyou Yang --- drivers/i2c/busses/i2c-at91.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c index 8f408f8..ed2c382 100644 --- a/drivers/i2c/busses/i2c-at91.c +++ b/drivers/i2c/busses/i2c-at91.c @@ -32,6 +32,7 @@ #include #include #include +#include #define DEFAULT_TWI_CLK_HZ 100000 /* max 400 Kbits/s */ #define AT91_I2C_TIMEOUT msecs_to_jiffies(100) /* transfer timeout */ @@ -748,6 +749,8 @@ static int at91_twi_probe(struct platform_device *pdev) u32 phy_addr; u32 bus_clk_rate; + pinctrl_pm_select_default_state(&pdev->dev); + dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); if (!dev) return -ENOMEM; @@ -850,8 +853,10 @@ static int at91_twi_suspend(struct device *dev) { struct at91_twi_dev *twi_dev = dev_get_drvdata(dev); - if (!pm_runtime_suspended(dev)) + if (!pm_runtime_suspended(dev)) { clk_disable_unprepare(twi_dev->clk); + pinctrl_pm_select_sleep_state(dev); + } return 0; } @@ -862,6 +867,7 @@ static int at91_twi_resume(struct device *dev) int ret; if (!pm_runtime_suspended(dev)) { + pinctrl_pm_select_default_state(dev); ret = clk_prepare_enable(twi_dev->clk); if (ret) return ret; @@ -881,6 +887,8 @@ static int at91_twi_runtime_suspend(struct device *dev) clk_disable_unprepare(twi_dev->clk); + pinctrl_pm_select_sleep_state(dev); + return 0; } @@ -888,6 +896,8 @@ static int at91_twi_runtime_resume(struct device *dev) { struct at91_twi_dev *twi_dev = dev_get_drvdata(dev); + pinctrl_pm_select_default_state(dev); + return clk_prepare_enable(twi_dev->clk); } #endif