Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd7ca17b authored by Pratik Patel's avatar Pratik Patel Committed by Stephen Boyd
Browse files

cs: let each driver manage the clk for its device



Each device driver manages its own clk by using the clk apis that
now support CoreSight clock. Remove qdss clock wrapper functions
and their usage.

Change-Id: If73198f273f69e5525a6444e7a7c277c20c96111
Signed-off-by: default avatarPratik Patel <pratikp@codeaurora.org>
parent c622c592
Loading
Loading
Loading
Loading
+18 −6
Original line number Diff line number Diff line
@@ -5069,8 +5069,12 @@ static struct clk_lookup msm_clocks_8064[] = {
	CLK_LOOKUP("mem_a_clk",		ebi1_msmbus_a_clk.c,	"msm_bus"),
	CLK_LOOKUP("dfab_clk",		dfab_msmbus_clk.c,	"msm_bus"),
	CLK_LOOKUP("dfab_a_clk",	dfab_msmbus_a_clk.c,	"msm_bus"),
	CLK_LOOKUP("core_clk",		qdss_clk.c,		"msm_qdss"),
	CLK_LOOKUP("core_a_clk",	qdss_a_clk.c,		"msm_qdss"),
	CLK_LOOKUP("core_a_clk",	qdss_a_clk.c,		""),
	CLK_LOOKUP("core_clk",		qdss_clk.c,		"msm_etb.0"),
	CLK_LOOKUP("core_clk",		qdss_clk.c,		"msm_tpiu.0"),
	CLK_LOOKUP("core_clk",		qdss_clk.c,		"msm_funnel.0"),
	CLK_LOOKUP("core_clk",		qdss_clk.c,		"msm_stm.0"),
	CLK_LOOKUP("core_clk",		qdss_clk.c,		"msm_etm.0"),

	CLK_LOOKUP("ebi1_clk",		ebi1_clk.c,		""),
	CLK_LOOKUP("mmfpb_clk",		mmfpb_clk.c,		""),
@@ -5395,8 +5399,12 @@ static struct clk_lookup msm_clocks_8960[] = {
	CLK_LOOKUP("mem_a_clk",		ebi1_msmbus_a_clk.c,	"msm_bus"),
	CLK_LOOKUP("dfab_clk",		dfab_msmbus_clk.c,	"msm_bus"),
	CLK_LOOKUP("dfab_a_clk",	dfab_msmbus_a_clk.c,	"msm_bus"),
	CLK_LOOKUP("core_clk",		qdss_clk.c,		"msm_qdss"),
	CLK_LOOKUP("core_a_clk",	qdss_a_clk.c,		"msm_qdss"),
	CLK_LOOKUP("core_a_clk",	qdss_a_clk.c,		""),
	CLK_LOOKUP("core_clk",		qdss_clk.c,		"msm_etb.0"),
	CLK_LOOKUP("core_clk",		qdss_clk.c,		"msm_tpiu.0"),
	CLK_LOOKUP("core_clk",		qdss_clk.c,		"msm_funnel.0"),
	CLK_LOOKUP("core_clk",		qdss_clk.c,		"msm_stm.0"),
	CLK_LOOKUP("core_clk",		qdss_clk.c,		"msm_etm.0"),

	CLK_LOOKUP("ebi1_clk",		ebi1_clk.c,		NULL),
	CLK_LOOKUP("mmfpb_clk",		mmfpb_clk.c,		NULL),
@@ -5713,8 +5721,12 @@ static struct clk_lookup msm_clocks_8930[] = {
	CLK_LOOKUP("mem_a_clk",		ebi1_msmbus_a_clk.c,	"msm_bus"),
	CLK_LOOKUP("dfab_clk",		dfab_msmbus_clk.c,	"msm_bus"),
	CLK_LOOKUP("dfab_a_clk",	dfab_msmbus_a_clk.c,	"msm_bus"),
	CLK_LOOKUP("core_clk",		qdss_clk.c,		"msm_qdss"),
	CLK_LOOKUP("core_a_clk",	qdss_a_clk.c,		"msm_qdss"),
	CLK_LOOKUP("core_a_clk",	qdss_a_clk.c,		""),
	CLK_LOOKUP("core_clk",		qdss_clk.c,		"msm_etb.0"),
	CLK_LOOKUP("core_clk",		qdss_clk.c,		"msm_tpiu.0"),
	CLK_LOOKUP("core_clk",		qdss_clk.c,		"msm_funnel.0"),
	CLK_LOOKUP("core_clk",		qdss_clk.c,		"msm_stm.0"),
	CLK_LOOKUP("core_clk",		qdss_clk.c,		"msm_etm.0"),

	CLK_LOOKUP("ebi1_clk",		ebi1_clk.c,		NULL),
	CLK_LOOKUP("mmfpb_clk",		mmfpb_clk.c,		NULL),
+26 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/mutex.h>
#include <linux/clk.h>
#include <linux/cs.h>

#include "cs-priv.h"
@@ -74,6 +75,7 @@ struct etb_ctx {
	atomic_t	in_use;
	struct device	*dev;
	struct kobject	*kobj;
	struct clk	*clk;
	uint32_t	trigger_cntr;
};

@@ -99,15 +101,22 @@ static void __etb_enable(void)
	ETB_LOCK();
}

void etb_enable(void)
int etb_enable(void)
{
	int ret;
	unsigned long flags;

	ret = clk_prepare_enable(etb.clk);
	if (ret)
		return ret;

	spin_lock_irqsave(&etb.spinlock, flags);
	__etb_enable();
	etb.enabled = true;
	dev_info(etb.dev, "ETB enabled\n");
	spin_unlock_irqrestore(&etb.spinlock, flags);

	return 0;
}

static void __etb_disable(void)
@@ -147,6 +156,8 @@ void etb_disable(void)
	etb.enabled = false;
	dev_info(etb.dev, "ETB disabled\n");
	spin_unlock_irqrestore(&etb.spinlock, flags);

	clk_disable_unprepare(etb.clk);
}

static void __etb_dump(void)
@@ -352,6 +363,16 @@ static int etb_probe(struct platform_device *pdev)

	spin_lock_init(&etb.spinlock);

	etb.clk = clk_get(etb.dev, "core_clk");
	if (IS_ERR(etb.clk)) {
		ret = PTR_ERR(etb.clk);
		goto err_clk_get;
	}

	ret = clk_set_rate(etb.clk, CS_CLK_RATE_TRACE);
	if (ret)
		goto err_clk_rate;

	ret = misc_register(&etb_misc);
	if (ret)
		goto err_misc;
@@ -370,6 +391,9 @@ static int etb_probe(struct platform_device *pdev)
err_alloc:
	misc_deregister(&etb_misc);
err_misc:
err_clk_rate:
	clk_put(etb.clk);
err_clk_get:
	iounmap(etb.base);
err_ioremap:
err_res:
@@ -384,6 +408,7 @@ static int etb_remove(struct platform_device *pdev)
	etb_sysfs_exit();
	kfree(etb.buf);
	misc_deregister(&etb_misc);
	clk_put(etb.clk);
	iounmap(etb.base);

	return 0;
+30 −6
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include <linux/pm_qos.h>
#include <linux/sysfs.h>
#include <linux/stat.h>
#include <linux/clk.h>
#include <linux/cs.h>
#include <asm/sections.h>
#include <mach/socinfo.h>
@@ -161,6 +162,7 @@ struct etm_ctx {
	struct mutex			mutex;
	struct device			*dev;
	struct kobject			*kobj;
	struct clk			*clk;
	uint8_t				arch;
	uint8_t				nr_addr_cmp;
	uint8_t				nr_cntr;
@@ -351,6 +353,10 @@ static int etm_enable(void)
	 */
	pm_qos_update_request(&etm.qos_req, 0);

	ret = clk_prepare_enable(etm.clk);
	if (ret)
		goto err_clk;

	ret = qdss_enable(etm.src);
	if (ret)
		goto err_qdss;
@@ -367,6 +373,8 @@ static int etm_enable(void)
	return 0;

err_qdss:
	clk_disable_unprepare(etm.clk);
err_clk:
	pm_qos_update_request(&etm.qos_req, PM_QOS_DEFAULT_VALUE);
	wake_unlock(&etm.wake_lock);
err:
@@ -409,9 +417,11 @@ static int etm_disable(void)
	for_each_online_cpu(cpu)
		__etm_disable(cpu);

	etm.enabled = false;

	qdss_disable(etm.src);

	etm.enabled = false;
	clk_disable_unprepare(etm.clk);

	pm_qos_update_request(&etm.qos_req, PM_QOS_DEFAULT_VALUE);
	wake_unlock(&etm.wake_lock);
@@ -1253,9 +1263,19 @@ static int etm_probe(struct platform_device *pdev)
		goto err_qdssget;
	}

	ret = qdss_clk_enable();
	etm.clk = clk_get(etm.dev, "core_clk");
	if (IS_ERR(etm.clk)) {
		ret = PTR_ERR(etm.clk);
		goto err_clk_get;
	}

	ret = clk_set_rate(etm.clk, CS_CLK_RATE_TRACE);
	if (ret)
		goto err_clk;
		goto err_clk_rate;

	ret = clk_prepare_enable(etm.clk);
	if (ret)
		goto err_clk_enable;

	ret = etm_arch_init();
	if (ret)
@@ -1267,7 +1287,7 @@ static int etm_probe(struct platform_device *pdev)

	etm.enabled = false;

	qdss_clk_disable();
	clk_disable_unprepare(etm.clk);

	dev_info(etm.dev, "ETM initialized\n");

@@ -1278,8 +1298,11 @@ static int etm_probe(struct platform_device *pdev)

err_sysfs:
err_arch:
	qdss_clk_disable();
err_clk:
	clk_disable_unprepare(etm.clk);
err_clk_enable:
err_clk_rate:
	clk_put(etm.clk);
err_clk_get:
	qdss_put(etm.src);
err_qdssget:
	pm_qos_remove_request(&etm.qos_req);
@@ -1297,6 +1320,7 @@ static int etm_remove(struct platform_device *pdev)
	if (etm.enabled)
		etm_disable();
	etm_sysfs_exit();
	clk_put(etm.clk);
	qdss_put(etm.src);
	pm_qos_remove_request(&etm.qos_req);
	wake_lock_destroy(&etm.wake_lock);
+29 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/err.h>
#include <linux/clk.h>
#include <linux/cs.h>

#include "cs-priv.h"
@@ -56,6 +57,7 @@ struct funnel_ctx {
	struct mutex	mutex;
	struct device	*dev;
	struct kobject	*kobj;
	struct clk	*clk;
	uint32_t	priority;
};

@@ -77,14 +79,22 @@ static void __funnel_enable(uint8_t id, uint32_t port_mask)
	FUNNEL_LOCK(id);
}

void funnel_enable(uint8_t id, uint32_t port_mask)
int funnel_enable(uint8_t id, uint32_t port_mask)
{
	int ret;

	ret = clk_prepare_enable(funnel.clk);
	if (ret)
		return ret;

	mutex_lock(&funnel.mutex);
	__funnel_enable(id, port_mask);
	funnel.enabled = true;
	dev_info(funnel.dev, "FUNNEL port mask 0x%lx enabled\n",
					(unsigned long) port_mask);
	mutex_unlock(&funnel.mutex);

	return 0;
}

static void __funnel_disable(uint8_t id, uint32_t port_mask)
@@ -108,6 +118,8 @@ void funnel_disable(uint8_t id, uint32_t port_mask)
	dev_info(funnel.dev, "FUNNEL port mask 0x%lx disabled\n",
					(unsigned long) port_mask);
	mutex_unlock(&funnel.mutex);

	clk_disable_unprepare(funnel.clk);
}

#define FUNNEL_ATTR(__name)						\
@@ -187,11 +199,26 @@ static int funnel_probe(struct platform_device *pdev)

	mutex_init(&funnel.mutex);

	funnel.clk = clk_get(funnel.dev, "core_clk");
	if (IS_ERR(funnel.clk)) {
		ret = PTR_ERR(funnel.clk);
		goto err_clk_get;
	}

	ret = clk_set_rate(funnel.clk, CS_CLK_RATE_TRACE);
	if (ret)
		goto err_clk_rate;

	funnel_sysfs_init();

	dev_info(funnel.dev, "FUNNEL initialized\n");
	return 0;

err_clk_rate:
	clk_put(funnel.clk);
err_clk_get:
	mutex_destroy(&funnel.mutex);
	iounmap(funnel.base);
err_ioremap:
err_res:
	dev_err(funnel.dev, "FUNNEL init failed\n");
@@ -203,6 +230,7 @@ static int funnel_remove(struct platform_device *pdev)
	if (funnel.enabled)
		funnel_disable(0x0, 0xFF);
	funnel_sysfs_exit();
	clk_put(funnel.clk);
	mutex_destroy(&funnel.mutex);
	iounmap(funnel.base);

+2 −2
Original line number Diff line number Diff line
@@ -36,11 +36,11 @@
#define BMVAL(val, lsb, msb)	((val & BM(lsb, msb)) >> lsb)
#define BVAL(val, n)		((val & BIT(n)) >> n)

void etb_enable(void);
int etb_enable(void);
void etb_disable(void);
void etb_dump(void);
void tpiu_disable(void);
void funnel_enable(uint8_t id, uint32_t port_mask);
int funnel_enable(uint8_t id, uint32_t port_mask);
void funnel_disable(uint8_t id, uint32_t port_mask);

struct kobject *qdss_get_modulekobj(void);
Loading