Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/802268/?format=api
{ "id": 802268, "url": "http://patchwork.ozlabs.org/api/patches/802268/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-i2c/patch/20170816221715.15027-3-fcooper@ti.com/", "project": { "id": 35, "url": "http://patchwork.ozlabs.org/api/projects/35/?format=api", "name": "Linux I2C development", "link_name": "linux-i2c", "list_id": "linux-i2c.vger.kernel.org", "list_email": "linux-i2c@vger.kernel.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170816221715.15027-3-fcooper@ti.com>", "list_archive_url": null, "date": "2017-08-16T22:17:14", "name": "[v2,2/3] i2c: davinci: Add PM Runtime Support", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": false, "hash": "d74f3fc379ebc9887bed1319be8cb3ef1daac350", "submitter": { "id": 64326, "url": "http://patchwork.ozlabs.org/api/people/64326/?format=api", "name": "Franklin S Cooper Jr", "email": "fcooper@ti.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-i2c/patch/20170816221715.15027-3-fcooper@ti.com/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/802268/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/802268/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<linux-i2c-owner@vger.kernel.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=linux-i2c-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=ti.com header.i=@ti.com header.b=\"s4A2uQyR\";\n\tdkim-atps=neutral" ], "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xXkMl0kkRz9t3C\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 17 Aug 2017 08:21:23 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752465AbdHPWVU (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tWed, 16 Aug 2017 18:21:20 -0400", "from fllnx209.ext.ti.com ([198.47.19.16]:49306 \"EHLO\n\tfllnx209.ext.ti.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1752352AbdHPWVT (ORCPT\n\t<rfc822; linux-i2c@vger.kernel.org>); Wed, 16 Aug 2017 18:21:19 -0400", "from dflxv15.itg.ti.com ([128.247.5.124])\n\tby fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id v7GMHdQS017344; \n\tWed, 16 Aug 2017 17:17:39 -0500", "from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26])\n\tby dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v7GMHYE9026041;\n\tWed, 16 Aug 2017 17:17:34 -0500", "from DFLE102.ent.ti.com (10.64.6.23) by DFLE105.ent.ti.com\n\t(10.64.6.26) with Microsoft SMTP Server (version=TLS1_2,\n\tcipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34;\n\tWed, 16 Aug 2017 17:17:33 -0500", "from dlep32.itg.ti.com (157.170.170.100) by DFLE102.ent.ti.com\n\t(10.64.6.23) with Microsoft SMTP Server (version=TLS1_0,\n\tcipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend\n\tTransport; Wed, 16 Aug 2017 17:17:33 -0500", "from dbdmail01.india.ti.com (dbdmail01.india.ti.com\n\t[172.24.162.206])\n\tby dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v7GMHWLQ003850;\n\tWed, 16 Aug 2017 17:17:33 -0500", "from uda0273011.dhcp.ti.com (uda0273011.dhcp.ti.com\n\t[128.247.59.135])\n\tby dbdmail01.india.ti.com (8.14.3/8.14.3/SuSE Linux 0.8) with ESMTP\n\tid v7GMHKkN028296; Thu, 17 Aug 2017 03:47:28 +0530" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com;\n\ts=ti-com-17Q1; t=1502921859;\n\tbh=vHMuVlUjTfOUt52NhHStPRv0uN5pSz5qF7fq8ZBi/yA=;\n\th=From:To:CC:Subject:Date:In-Reply-To:References;\n\tb=s4A2uQyRguknF0pyJT06fwFUYkcHfLUB0j68ZBksxTCdJAYv5FaPKZwLEtC5a+IDk\n\tJhN6UhqbSqPyl4T/p3dGkh1wrSsVIfAVSakkE31qnOB5ZtFki+Ta+2pW/9TnOAYEyl\n\tucz8BVlV/JQJ1dgpsS6tQYSzhPWLDb6TrEpu1T4k=", "From": "Franklin S Cooper Jr <fcooper@ti.com>", "To": "<wsa@the-dreams.de>, <robh+dt@kernel.org>, <linux@armlinux.org.uk>,\n\t<nsekhar@ti.com>, <linux-i2c@vger.kernel.org>,\n\t<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,\n\t<linux-arm-kernel@lists.infradead.org>, <grygorii.strashko@ti.com>,\n\t<vigneshr@ti.com>", "CC": "Franklin S Cooper Jr <fcooper@ti.com>", "Subject": "[PATCH v2 2/3] i2c: davinci: Add PM Runtime Support", "Date": "Wed, 16 Aug 2017 17:17:14 -0500", "Message-ID": "<20170816221715.15027-3-fcooper@ti.com>", "X-Mailer": "git-send-email 2.9.4.dirty", "In-Reply-To": "<20170816221715.15027-1-fcooper@ti.com>", "References": "<20170816221715.15027-1-fcooper@ti.com>", "MIME-Version": "1.0", "Content-Type": "text/plain", "X-EXCLAIMER-MD-CONFIG": "e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180", "Sender": "linux-i2c-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<linux-i2c.vger.kernel.org>", "X-Mailing-List": "linux-i2c@vger.kernel.org" }, "content": "66AK2G has I2C instances that are not apart of the ALWAYS_ON power domain\nlike other Keystone 2 SoCs and OMAPL138. Therefore, pm_runtime\nis required to insure the power domain used by the specific I2C instance is\nproperly turned on along with its functional clock.\n\nSigned-off-by: Franklin S Cooper Jr <fcooper@ti.com>\n---\nVersion 2 changes:\nMove initial calls to pm runtime autosuspend before pm_runtime_enable\n\n drivers/i2c/busses/i2c-davinci.c | 62 ++++++++++++++++++++++++++++++++++------\n 1 file changed, 54 insertions(+), 8 deletions(-)", "diff": "diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c\nindex b8c4353..6b1930d 100644\n--- a/drivers/i2c/busses/i2c-davinci.c\n+++ b/drivers/i2c/busses/i2c-davinci.c\n@@ -36,6 +36,7 @@\n #include <linux/gpio.h>\n #include <linux/of_device.h>\n #include <linux/platform_data/i2c-davinci.h>\n+#include <linux/pm_runtime.h>\n \n /* ----- global defines ----------------------------------------------- */\n \n@@ -122,6 +123,9 @@\n /* set the SDA GPIO low */\n #define DAVINCI_I2C_DCLR_PDCLR1\tBIT(1)\n \n+/* timeout for pm runtime autosuspend */\n+#define DAVINCI_I2C_PM_TIMEOUT\t1000\t/* ms */\n+\n struct davinci_i2c_dev {\n \tstruct device *dev;\n \tvoid __iomem\t\t*base;\n@@ -541,10 +545,17 @@ i2c_davinci_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)\n \n \tdev_dbg(dev->dev, \"%s: msgs: %d\\n\", __func__, num);\n \n+\tret = pm_runtime_get_sync(dev->dev);\n+\tif (ret < 0) {\n+\t\tdev_err(dev->dev, \"Failed to runtime_get device: %d\\n\", ret);\n+\t\tpm_runtime_put_noidle(dev->dev);\n+\t\treturn ret;\n+\t}\n+\n \tret = i2c_davinci_wait_bus_not_busy(dev);\n \tif (ret < 0) {\n \t\tdev_warn(dev->dev, \"timeout waiting for bus ready\\n\");\n-\t\treturn ret;\n+\t\tgoto out;\n \t}\n \n \tfor (i = 0; i < num; i++) {\n@@ -552,14 +563,19 @@ i2c_davinci_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)\n \t\tdev_dbg(dev->dev, \"%s [%d/%d] ret: %d\\n\", __func__, i + 1, num,\n \t\t\tret);\n \t\tif (ret < 0)\n-\t\t\treturn ret;\n+\t\t\tgoto out;\n \t}\n \n+\tret = num;\n #ifdef CONFIG_CPU_FREQ\n \tcomplete(&dev->xfr_complete);\n #endif\n \n-\treturn num;\n+out:\n+\tpm_runtime_mark_last_busy(dev->dev);\n+\tpm_runtime_put_autosuspend(dev->dev);\n+\n+\treturn ret;\n }\n \n static u32 i2c_davinci_func(struct i2c_adapter *adap)\n@@ -599,6 +615,9 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void *dev_id)\n \tint count = 0;\n \tu16 w;\n \n+\tif (pm_runtime_suspended(dev->dev))\n+\t\treturn IRQ_NONE;\n+\n \twhile ((stat = davinci_i2c_read_reg(dev, DAVINCI_I2C_IVR_REG))) {\n \t\tdev_dbg(dev->dev, \"%s: stat=0x%x\\n\", __func__, stat);\n \t\tif (count++ == 100) {\n@@ -802,7 +821,6 @@ static int davinci_i2c_probe(struct platform_device *pdev)\n \tdev->clk = devm_clk_get(&pdev->dev, NULL);\n \tif (IS_ERR(dev->clk))\n \t\treturn PTR_ERR(dev->clk);\n-\tclk_prepare_enable(dev->clk);\n \n \tmem = platform_get_resource(pdev, IORESOURCE_MEM, 0);\n \tdev->base = devm_ioremap_resource(&pdev->dev, mem);\n@@ -811,6 +829,18 @@ static int davinci_i2c_probe(struct platform_device *pdev)\n \t\tgoto err_unuse_clocks;\n \t}\n \n+\tpm_runtime_set_autosuspend_delay(dev->dev,\n+\t\t\t\t\t DAVINCI_I2C_PM_TIMEOUT);\n+\tpm_runtime_use_autosuspend(dev->dev);\n+\n+\tpm_runtime_enable(dev->dev);\n+\n+\tr = pm_runtime_get_sync(dev->dev);\n+\tif (r < 0) {\n+\t\tdev_err(dev->dev, \"failed to runtime_get device: %d\\n\", r);\n+\t\tgoto err_unuse_clocks;\n+\t}\n+\n \ti2c_davinci_init(dev);\n \n \tr = devm_request_irq(&pdev->dev, dev->irq, i2c_davinci_isr, 0,\n@@ -849,10 +879,16 @@ static int davinci_i2c_probe(struct platform_device *pdev)\n \tif (r)\n \t\tgoto err_unuse_clocks;\n \n+\tpm_runtime_mark_last_busy(dev->dev);\n+\tpm_runtime_put_autosuspend(dev->dev);\n+\n \treturn 0;\n \n err_unuse_clocks:\n-\tclk_disable_unprepare(dev->clk);\n+\tpm_runtime_dont_use_autosuspend(dev->dev);\n+\tpm_runtime_put_sync(dev->dev);\n+\tpm_runtime_disable(dev->dev);\n+\n \tdev->clk = NULL;\n \treturn r;\n }\n@@ -860,16 +896,26 @@ static int davinci_i2c_probe(struct platform_device *pdev)\n static int davinci_i2c_remove(struct platform_device *pdev)\n {\n \tstruct davinci_i2c_dev *dev = platform_get_drvdata(pdev);\n+\tint ret;\n \n \ti2c_davinci_cpufreq_deregister(dev);\n \n \ti2c_del_adapter(&dev->adapter);\n \n-\tclk_disable_unprepare(dev->clk);\n+\tret = pm_runtime_get_sync(&pdev->dev);\n+\tif (ret < 0) {\n+\t\tpm_runtime_put_noidle(&pdev->dev);\n+\t\treturn ret;\n+\t}\n+\n \tdev->clk = NULL;\n \n \tdavinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, 0);\n \n+\tpm_runtime_dont_use_autosuspend(dev->dev);\n+\tpm_runtime_put_sync(dev->dev);\n+\tpm_runtime_disable(dev->dev);\n+\n \treturn 0;\n }\n \n@@ -880,7 +926,6 @@ static int davinci_i2c_suspend(struct device *dev)\n \n \t/* put I2C into reset */\n \tdavinci_i2c_reset_ctrl(i2c_dev, 0);\n-\tclk_disable_unprepare(i2c_dev->clk);\n \n \treturn 0;\n }\n@@ -889,7 +934,6 @@ static int davinci_i2c_resume(struct device *dev)\n {\n \tstruct davinci_i2c_dev *i2c_dev = dev_get_drvdata(dev);\n \n-\tclk_prepare_enable(i2c_dev->clk);\n \t/* take I2C out of reset */\n \tdavinci_i2c_reset_ctrl(i2c_dev, 1);\n \n@@ -899,6 +943,8 @@ static int davinci_i2c_resume(struct device *dev)\n static const struct dev_pm_ops davinci_i2c_pm = {\n \t.suspend = davinci_i2c_suspend,\n \t.resume = davinci_i2c_resume,\n+\tSET_NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,\n+\t\t\t\t pm_runtime_force_resume)\n };\n \n #define davinci_i2c_pm_ops (&davinci_i2c_pm)\n", "prefixes": [ "v2", "2/3" ] }