coresight: register to cpu_pm notifiers for cti save / restore

coresight_cti_ctx_save() and coresight_cti_ctx_restore() are
called directly from lpm-levels driver. These functions will no
longer be called from lpm-levels driver when we move to PSCI
framework.  Add support in coresight-cti driver to rely on cpu_pm
callback for save and restore functionality of CPU CTI configuration.

Change-Id: I715dcc2297709b7d903d9bd7752a68864477fd6c
Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
This commit is contained in:
Sarangdhar Joshi 2015-10-01 11:29:46 -07:00 committed by Gerrit - the friendly Code Review server
parent 7c5e0dd8b9
commit d2f8e5d2f9
1 changed files with 42 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -20,6 +20,7 @@
#include <linux/slab.h>
#include <linux/mutex.h>
#include <linux/clk.h>
#include <linux/cpu_pm.h>
#include <linux/topology.h>
#include <linux/of.h>
#include <linux/of_coresight.h>
@ -66,6 +67,7 @@ do { \
#define CTI_MAX_TRIGGERS (8)
#define CTI_MAX_CHANNELS (4)
#define AFFINITY_LEVEL_L2 1
#define to_cti_drvdata(c) container_of(c, struct cti_drvdata, cti)
@ -100,6 +102,9 @@ struct cti_drvdata {
struct cti_pctrl *gpio_trigout;
};
static struct notifier_block cti_cpu_pm_notifier;
static int registered;
static LIST_HEAD(cti_list);
static DEFINE_MUTEX(cti_lock);
#ifdef CONFIG_CORESIGHT_CTI_SAVE_DISABLE
@ -1360,6 +1365,30 @@ static const struct attribute_group *cti_attr_grps[] = {
NULL,
};
static int cti_cpu_pm_callback(struct notifier_block *self,
unsigned long cmd, void *v)
{
unsigned long aff_level = (unsigned long) v;
switch (cmd) {
case CPU_CLUSTER_PM_ENTER:
if (aff_level == AFFINITY_LEVEL_L2)
coresight_cti_ctx_save();
break;
case CPU_CLUSTER_PM_ENTER_FAILED:
case CPU_CLUSTER_PM_EXIT:
if (aff_level == AFFINITY_LEVEL_L2)
coresight_cti_ctx_restore();
break;
}
return NOTIFY_OK;
}
static struct notifier_block cti_cpu_pm_notifier = {
.notifier_call = cti_cpu_pm_callback,
};
static int cti_probe(struct platform_device *pdev)
{
int ret, cpu;
@ -1501,7 +1530,13 @@ static int cti_probe(struct platform_device *pdev)
goto err;
}
dev_info(dev, "CTI initialized\n");
if (drvdata->cti_save) {
if (!registered)
cpu_pm_register_notifier(&cti_cpu_pm_notifier);
registered++;
}
dev_dbg(dev, "CTI initialized\n");
return 0;
err:
if (drvdata->cti_save && !drvdata->cti_hwclk)
@ -1513,6 +1548,11 @@ static int cti_remove(struct platform_device *pdev)
{
struct cti_drvdata *drvdata = platform_get_drvdata(pdev);
if (drvdata->cti_save) {
registered--;
if (!registered)
cpu_pm_unregister_notifier(&cti_cpu_pm_notifier);
}
coresight_unregister(drvdata->csdev);
if (drvdata->cti_save && !drvdata->cti_hwclk)
clk_disable_unprepare(drvdata->clk);