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

Commit 9d283135 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "soc: qcom: Implement hibernation callbacks for jtag-etm"

parents fa13309b 3bc1b425
Loading
Loading
Loading
Loading
+54 −2
Original line number Diff line number Diff line
@@ -245,6 +245,7 @@ struct etm_ctx {

static struct etm_ctx *etm[NR_CPUS];
static int cnt;
static bool hibernation_freeze;

static struct clk *clock[NR_CPUS];

@@ -1437,7 +1438,8 @@ void msm_jtag_etm_save_state(void)

	cpu = raw_smp_processor_id();

	if (!etm[cpu] || etm[cpu]->save_restore_disabled)
	if (!etm[cpu] || etm[cpu]->save_restore_disabled
				|| hibernation_freeze)
		return;

	if (etm[cpu]->save_restore_enabled) {
@@ -1455,7 +1457,8 @@ void msm_jtag_etm_restore_state(void)

	cpu = raw_smp_processor_id();

	if (!etm[cpu] || etm[cpu]->save_restore_disabled)
	if (!etm[cpu] || etm[cpu]->save_restore_disabled
				|| hibernation_freeze)
		return;

	/*
@@ -1723,6 +1726,54 @@ static int jtag_mm_remove(struct platform_device *pdev)
	return 0;
}

static void msm_jtag_etm_save_state_hib(void *unused_info)
{
	msm_jtag_etm_save_state();
}

static void msm_jtag_etm_restore_state_hib(void *unused_info)
{
	msm_jtag_etm_restore_state();
}

static int jtag_mm_freeze(struct device *dev)
{
	int cpu;

	if (hibernation_freeze)
		return 0;
	get_online_cpus();
	on_each_cpu(msm_jtag_etm_save_state_hib,
				NULL, true);
	for_each_online_cpu(cpu)
		clk_disable_unprepare(clock[cpu]);
	put_online_cpus();
	hibernation_freeze = true;
	return 0;
}

static int jtag_mm_restore(struct device *dev)
{
	int cpu;

	if (!hibernation_freeze)
		return 0;
	get_online_cpus();
	for_each_online_cpu(cpu)
		clk_prepare_enable(clock[cpu]);
	on_each_cpu(msm_jtag_etm_restore_state_hib,
					NULL, true);
	put_online_cpus();
	hibernation_freeze = false;
	return 0;
}

static const struct dev_pm_ops jtag_mm_pm_ops = {
	.freeze = jtag_mm_freeze,
	.restore = jtag_mm_restore,
	.thaw = jtag_mm_restore,
};

static const struct of_device_id msm_qdss_mm_match[] = {
	{ .compatible = "qcom,jtagv8-mm"},
	{}
@@ -1735,6 +1786,7 @@ static struct platform_driver jtag_mm_driver = {
		.name   = "msm-jtagv8-mm",
		.owner	= THIS_MODULE,
		.of_match_table	= msm_qdss_mm_match,
		.pm = &jtag_mm_pm_ops,
		},
};