Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/812599/?format=api
{ "id": 812599, "url": "http://patchwork.ozlabs.org/api/patches/812599/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-i2c/patch/20170911201145.31257-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": "<20170911201145.31257-2-fcooper@ti.com>", "list_archive_url": null, "date": "2017-09-11T20:11:44", "name": "[v4,1/2] i2c: davinci: Add PM Runtime Support", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "01af3e673b28de138f6b85cb636bedfb71ffb490", "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/20170911201145.31257-2-fcooper@ti.com/mbox/", "series": [ { "id": 2561, "url": "http://patchwork.ozlabs.org/api/series/2561/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-i2c/list/?series=2561", "date": "2017-09-11T20:11:43", "name": "i2c: davinci: Add PM Runtime Support needed by 66AK2G", "version": 4, "mbox": "http://patchwork.ozlabs.org/series/2561/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/812599/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/812599/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=\"mb8DZZzd\";\n\tdkim-atps=neutral" ], "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xrfJS3jBwz9s8J\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 06:13:44 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751047AbdIKUNm (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tMon, 11 Sep 2017 16:13:42 -0400", "from fllnx209.ext.ti.com ([198.47.19.16]:31658 \"EHLO\n\tfllnx209.ext.ti.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1750987AbdIKUNl (ORCPT\n\t<rfc822; linux-i2c@vger.kernel.org>); Mon, 11 Sep 2017 16:13:41 -0400", "from dlelxv90.itg.ti.com ([172.17.2.17])\n\tby fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id v8BKCCT0014519; \n\tMon, 11 Sep 2017 15:12:12 -0500", "from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38])\n\tby dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8BKC7Z9003605; \n\tMon, 11 Sep 2017 15:12:07 -0500", "from DLEE104.ent.ti.com (157.170.170.34) by DLEE108.ent.ti.com\n\t(157.170.170.38) with Microsoft SMTP Server (version=TLS1_2,\n\tcipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34;\n\tMon, 11 Sep 2017 15:12:07 -0500", "from dlep32.itg.ti.com (157.170.170.100) by DLEE104.ent.ti.com\n\t(157.170.170.34) 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; Mon, 11 Sep 2017 15:12:07 -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 v8BKC6Va017622;\n\tMon, 11 Sep 2017 15:12:06 -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 v8BKBvrf005179; Tue, 12 Sep 2017 01:42:02 +0530" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com;\n\ts=ti-com-17Q1; t=1505160732;\n\tbh=Toph8fY1i1cD47RQg5U3xfaWAveHIEfu+Ca0+19wQ7o=;\n\th=From:To:CC:Subject:Date:In-Reply-To:References;\n\tb=mb8DZZzdFSZQCEXubBZmp+Lia/iBaUggTcd3tY4T09DAJnny4tmm2ETtF7oTR+A2j\n\tXcArEULuxQ1GN/ITKTVfg/Hu4AakU6VyKhybHf1p82Yf0rDWx3AfNJhaIKMwnX3Ab/\n\tGgofK0Hcw7iqMTve76KpR10RTusZLUmL+WIeJRFk=", "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 v4 1/2] i2c: davinci: Add PM Runtime Support", "Date": "Mon, 11 Sep 2017 15:11:44 -0500", "Message-ID": "<20170911201145.31257-2-fcooper@ti.com>", "X-Mailer": "git-send-email 2.9.4.dirty", "In-Reply-To": "<20170911201145.31257-1-fcooper@ti.com>", "References": "<20170911201145.31257-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\nunlike 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 4 changes:\nFix wording on error message\nFix additional error path\n\nVersion 3 changes:\nRemove several statements that set clk to NULL\nFix error path\n\n drivers/i2c/busses/i2c-davinci.c | 67 +++++++++++++++++++++++++++++++++-------\n 1 file changed, 55 insertions(+), 12 deletions(-)", "diff": "diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c\nindex b8c4353..a2d9f7c 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,13 +821,24 @@ 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\tgoto err_unuse_clocks;\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\tpm_runtime_put_noidle(dev->dev);\n+\t\treturn r;\n \t}\n \n \ti2c_davinci_init(dev);\n@@ -849,27 +879,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 +923,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 +931,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 +940,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": [ "v4", "1/2" ] }