From: Franklin S Cooper Jr <fcooper@ti.com>
To: <linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>,
<netdev@vger.kernel.org>, <linux-can@vger.kernel.org>,
<wg@grandegger.com>, <mkl@pengutronix.de>, <robh+dt@kernel.org>,
<quentin.schulz@free-electrons.com>
Cc: Franklin S Cooper Jr <fcooper@ti.com>
Subject: [PATCH v2 3/3] can: m_can: Add PM Runtime
Date: Mon, 24 Jul 2017 17:51:42 -0500 [thread overview]
Message-ID: <20170724225142.19975-4-fcooper@ti.com> (raw)
In-Reply-To: <20170724225142.19975-1-fcooper@ti.com>
Add support for PM Runtime which is the new way to handle managing clocks.
However, to avoid breaking SoCs not using PM_RUNTIME leave the old clk
management approach in place.
PM_RUNTIME is required by OMAP based devices to handle clock management.
Therefore, this allows future Texas Instruments SoCs that have the MCAN IP
to work with this driver.
Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com>
---
drivers/net/can/m_can/m_can.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index ea48e59..93e23f5 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -23,6 +23,7 @@
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
#include <linux/iopoll.h>
#include <linux/can/dev.h>
@@ -633,11 +634,15 @@ static int m_can_clk_start(struct m_can_priv *priv)
if (err)
clk_disable_unprepare(priv->hclk);
+ pm_runtime_get_sync(priv->device);
+
return err;
}
static void m_can_clk_stop(struct m_can_priv *priv)
{
+ pm_runtime_put_sync(priv->device);
+
clk_disable_unprepare(priv->cclk);
clk_disable_unprepare(priv->hclk);
}
@@ -1582,6 +1587,8 @@ static int m_can_plat_probe(struct platform_device *pdev)
/* Enable clocks. Necessary to read Core Release in order to determine
* M_CAN version
*/
+ pm_runtime_enable(&pdev->dev);
+
ret = clk_prepare_enable(hclk);
if (ret)
goto disable_hclk_ret;
@@ -1626,6 +1633,8 @@ static int m_can_plat_probe(struct platform_device *pdev)
*/
tx_fifo_size = mram_config_vals[7];
+ pm_runtime_get_sync(&pdev->dev);
+
/* allocate the m_can device */
dev = alloc_m_can_dev(pdev, addr, tx_fifo_size);
if (!dev) {
@@ -1670,6 +1679,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
disable_hclk_ret:
clk_disable_unprepare(hclk);
failed_ret:
+ pm_runtime_put_sync(&pdev->dev);
return ret;
}
@@ -1726,6 +1736,9 @@ static int m_can_plat_remove(struct platform_device *pdev)
struct net_device *dev = platform_get_drvdata(pdev);
unregister_m_can_dev(dev);
+
+ pm_runtime_disable(&pdev->dev);
+
platform_set_drvdata(pdev, NULL);
free_m_can_dev(dev);
--
2.10.0
next prev parent reply other threads:[~2017-07-24 22:51 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-24 22:51 [PATCH v2 0/3] can: m_can: Add PM Runtime Support Franklin S Cooper Jr
[not found] ` <20170724225142.19975-1-fcooper-l0cyMroinI0@public.gmane.org>
2017-07-24 22:51 ` [PATCH v2 1/3] can: m_can: Make hclk optional Franklin S Cooper Jr
2017-08-24 8:00 ` [v2,1/3] " Sekhar Nori
[not found] ` <6f574628-51cd-0db8-e5aa-e7ae4a9cf79a-l0cyMroinI0@public.gmane.org>
2017-09-21 0:31 ` Franklin S Cooper Jr
2017-09-21 14:08 ` Sekhar Nori
2017-09-21 19:35 ` Franklin S Cooper Jr
2017-09-20 22:00 ` [PATCH v2 1/3] " Mario Hüttel
2017-09-20 23:29 ` Franklin S Cooper Jr
2017-07-24 22:51 ` [PATCH v2 2/3] can: m_can: Update documentation to indicate that hclk may be optional Franklin S Cooper Jr
2017-07-24 22:51 ` Franklin S Cooper Jr [this message]
2017-08-24 8:30 ` [v2,3/3] can: m_can: Add PM Runtime Sekhar Nori
[not found] ` <8037f5f9-d51f-99c3-f2e8-62c90e56a6fa-l0cyMroinI0@public.gmane.org>
2017-09-21 0:36 ` Franklin S Cooper Jr
2017-09-22 1:54 ` Yang, Wenyou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170724225142.19975-4-fcooper@ti.com \
--to=fcooper@ti.com \
--cc=devicetree@vger.kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=quentin.schulz@free-electrons.com \
--cc=robh+dt@kernel.org \
--cc=wg@grandegger.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox