coresight-stm: let runtime PM handle core clock
Use runtime PM to manage the PCLK ("amba_pclk") instead of handling clk directly. The AMBA bus core will unprepare and disable the clock when device is unused. Change-Id: Id03ea9d622905393f81a9d4cafc111029ef6852d Signed-off-by: Shashank Mittal <mittals@codeaurora.org>
This commit is contained in:
parent
c605e110ab
commit
1bf0c2d8b3
1 changed files with 9 additions and 14 deletions
|
@ -22,6 +22,7 @@
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
|
#include <linux/pm_runtime.h>
|
||||||
#include <linux/clk.h>
|
#include <linux/clk.h>
|
||||||
#include <linux/bitmap.h>
|
#include <linux/bitmap.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
|
@ -135,7 +136,6 @@ struct stm_drvdata {
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
struct coresight_device *csdev;
|
struct coresight_device *csdev;
|
||||||
struct miscdevice miscdev;
|
struct miscdevice miscdev;
|
||||||
struct clk *clk;
|
|
||||||
spinlock_t spinlock;
|
spinlock_t spinlock;
|
||||||
struct channel_space chs;
|
struct channel_space chs;
|
||||||
bool enable;
|
bool enable;
|
||||||
|
@ -270,8 +270,8 @@ static int stm_enable(struct coresight_device *csdev)
|
||||||
int ret;
|
int ret;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
ret = clk_prepare_enable(drvdata->clk);
|
ret = pm_runtime_get_sync(drvdata->dev);
|
||||||
if (ret)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
spin_lock_irqsave(&drvdata->spinlock, flags);
|
spin_lock_irqsave(&drvdata->spinlock, flags);
|
||||||
|
@ -349,7 +349,7 @@ static void stm_disable(struct coresight_device *csdev)
|
||||||
/* Wait for 100ms so that pending data has been written to HW */
|
/* Wait for 100ms so that pending data has been written to HW */
|
||||||
msleep(100);
|
msleep(100);
|
||||||
|
|
||||||
clk_disable_unprepare(drvdata->clk);
|
pm_runtime_put(drvdata->dev);
|
||||||
|
|
||||||
dev_info(drvdata->dev, "STM tracing disabled\n");
|
dev_info(drvdata->dev, "STM tracing disabled\n");
|
||||||
}
|
}
|
||||||
|
@ -360,7 +360,7 @@ static int stm_trace_id(struct coresight_device *csdev)
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int trace_id = -1;
|
int trace_id = -1;
|
||||||
|
|
||||||
if (clk_prepare_enable(drvdata->clk))
|
if (pm_runtime_get_sync(drvdata->dev) < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
spin_lock_irqsave(&drvdata->spinlock, flags);
|
spin_lock_irqsave(&drvdata->spinlock, flags);
|
||||||
|
@ -370,7 +370,7 @@ static int stm_trace_id(struct coresight_device *csdev)
|
||||||
CS_LOCK(drvdata->base);
|
CS_LOCK(drvdata->base);
|
||||||
|
|
||||||
spin_unlock_irqrestore(&drvdata->spinlock, flags);
|
spin_unlock_irqrestore(&drvdata->spinlock, flags);
|
||||||
clk_disable_unprepare(drvdata->clk);
|
pm_runtime_put(drvdata->dev);
|
||||||
out:
|
out:
|
||||||
return trace_id;
|
return trace_id;
|
||||||
}
|
}
|
||||||
|
@ -806,19 +806,14 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
|
|
||||||
spin_lock_init(&drvdata->spinlock);
|
spin_lock_init(&drvdata->spinlock);
|
||||||
|
|
||||||
drvdata->clk = adev->pclk;
|
ret = clk_set_rate(adev->pclk, CORESIGHT_CLK_RATE_TRACE);
|
||||||
ret = clk_set_rate(drvdata->clk, CORESIGHT_CLK_RATE_TRACE);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = clk_prepare_enable(drvdata->clk);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (!coresight_authstatus_enabled(drvdata->base))
|
if (!coresight_authstatus_enabled(drvdata->base))
|
||||||
goto err1;
|
goto err1;
|
||||||
|
|
||||||
clk_disable_unprepare(drvdata->clk);
|
pm_runtime_put(&adev->dev);
|
||||||
|
|
||||||
bitmap_fill(drvdata->entities, OST_ENTITY_MAX);
|
bitmap_fill(drvdata->entities, OST_ENTITY_MAX);
|
||||||
|
|
||||||
|
@ -856,7 +851,7 @@ err:
|
||||||
coresight_unregister(drvdata->csdev);
|
coresight_unregister(drvdata->csdev);
|
||||||
return ret;
|
return ret;
|
||||||
err1:
|
err1:
|
||||||
clk_disable_unprepare(drvdata->clk);
|
pm_runtime_put(&adev->dev);
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue