Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/811763/?format=api
{ "id": 811763, "url": "http://patchwork.ozlabs.org/api/patches/811763/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-i2c/patch/20170908175448.3367-2-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": "<20170908175448.3367-2-fcooper@ti.com>", "list_archive_url": null, "date": "2017-09-08T17:54:47", "name": "[v3,1/2] i2c: davinci: Add PM Runtime Support", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "088b40755e2e29bde3be297f5b64b8d0b06038d3", "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/20170908175448.3367-2-fcooper@ti.com/mbox/", "series": [ { "id": 2266, "url": "http://patchwork.ozlabs.org/api/series/2266/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-i2c/list/?series=2266", "date": "2017-09-08T17:54:48", "name": "ARM: dts: keystone-k2g: Add I2C support for 66AK2G", "version": 3, "mbox": "http://patchwork.ozlabs.org/series/2266/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/811763/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/811763/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=\"iLzIWkf8\";\n\tdkim-atps=neutral" ], "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xplNx3k4Xz9sBZ\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat, 9 Sep 2017 03:56:01 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S932643AbdIHRzp (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tFri, 8 Sep 2017 13:55:45 -0400", "from fllnx210.ext.ti.com ([198.47.19.17]:51750 \"EHLO\n\tfllnx210.ext.ti.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1756593AbdIHRzk (ORCPT\n\t<rfc822;linux-i2c@vger.kernel.org>); Fri, 8 Sep 2017 13:55:40 -0400", "from dflxv15.itg.ti.com ([128.247.5.124])\n\tby fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id v88Ht2ZO028555; \n\tFri, 8 Sep 2017 12:55:02 -0500", "from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24])\n\tby dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v88Ht1bf021499;\n\tFri, 8 Sep 2017 12:55:02 -0500", "from DFLE106.ent.ti.com (10.64.6.27) by DFLE103.ent.ti.com\n\t(10.64.6.24) with Microsoft SMTP Server (version=TLS1_2,\n\tcipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34;\n\tFri, 8 Sep 2017 12:55:01 -0500", "from dflp32.itg.ti.com (10.64.6.15) by DFLE106.ent.ti.com\n\t(10.64.6.27) 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; Fri, 8 Sep 2017 12:55:01 -0500", "from dbdmail01.india.ti.com (dbdmail01.india.ti.com\n\t[172.24.162.206])\n\tby dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v88HsxIp015319;\n\tFri, 8 Sep 2017 12:55:00 -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 v88HspF5007984; Fri, 8 Sep 2017 23:24:56 +0530" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com;\n\ts=ti-com-17Q1; t=1504893302;\n\tbh=jxxG+Iajwfcvrkn3yVPLdLPX9sOloH6u57Iick8QNyw=;\n\th=From:To:CC:Subject:Date:In-Reply-To:References;\n\tb=iLzIWkf8FBefCTnHBsXxESaB6rt+PM6esO60nfXnAxItXCnHnGk4cwjbAnj08vfMY\n\t0vaiD13NpSzqeHGzTbiY6wrPd+nBsiTlBh2+cTYjkBCTQ42GSg6QPu/xPWiOmkH0kw\n\t46jtt0+FAMs1grAQD6FnLvp5uEG5tsMJbFyBl2ek=", "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 v3 1/2] i2c: davinci: Add PM Runtime Support", "Date": "Fri, 8 Sep 2017 12:54:47 -0500", "Message-ID": "<20170908175448.3367-2-fcooper@ti.com>", "X-Mailer": "git-send-email 2.9.4.dirty", "In-Reply-To": "<20170908175448.3367-1-fcooper@ti.com>", "References": "<20170908175448.3367-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 3 changes:\nRemove several statements that set clk to NULL\nFix error path\n\n drivers/i2c/busses/i2c-davinci.c | 64 +++++++++++++++++++++++++++++++++-------\n 1 file changed, 53 insertions(+), 11 deletions(-)", "diff": "diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c\nindex b8c4353..57612cb 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,12 +821,22 @@ 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 \tif (IS_ERR(dev->base)) {\n-\t\tr = PTR_ERR(dev->base);\n+\t\treturn PTR_ERR(dev->base);\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@@ -849,27 +878,40 @@ 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-\tdev->clk = NULL;\n+\tpm_runtime_dont_use_autosuspend(dev->dev);\n+\tpm_runtime_put_sync(dev->dev);\n+\tpm_runtime_disable(dev->dev);\n+\n \treturn r;\n }\n \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-\tdev->clk = NULL;\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 \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 +922,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 +930,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 +939,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": [ "v3", "1/2" ] }