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

Commit 0ca42f16 authored by Vikash Garodia's avatar Vikash Garodia Committed by Deva Ramasubramanian
Browse files

msm: vidc: Reduce clock frequency before disabling



The change ensures that the clock frequency is reduced to min
before we disable it. With just clk_disable, rpm still votes
for high voltage on CX as venus vote is not removed. To unvote,
the frequency is set to min.

CRs-Fixed: 574365
Change-Id: I8e0515b9816f8c451d545443573afaba611aafe7
Signed-off-by: default avatarVikash Garodia <vgarodia@codeaurora.org>
parent 06c8b750
Loading
Loading
Loading
Loading
+42 −29
Original line number Diff line number Diff line
@@ -869,6 +869,35 @@ static inline int venus_hfi_reset_core(struct venus_hfi_device *device)
	return rc;
}

static struct venus_clock *venus_hfi_get_clock(struct venus_hfi_device *device,
		char *name)
{
	struct venus_clock *vc;

	venus_hfi_for_each_clock(device, vc, {
		if (!strcmp(vc->name, name))
			return vc;
	});

	return NULL;
}

static unsigned long venus_hfi_get_clock_rate(struct venus_clock *clock,
	int num_mbs_per_sec)
{
	int num_rows = clock->count;
	struct load_freq_table *table = clock->load_freq_tbl;
	unsigned long ret = table[0].freq;
	int i;
	for (i = 0; i < num_rows; i++) {
		if (num_mbs_per_sec > table[i].load)
			break;
		ret = table[i].freq;
	}
	dprintk(VIDC_PROF, "Required clock rate = %lu\n", ret);
	return ret;
}

/*Calling function is responsible to acquire device->clk_pwr_lock*/
static inline int venus_hfi_clk_enable(struct venus_hfi_device *device)
{
@@ -929,6 +958,19 @@ static inline void venus_hfi_clk_disable(struct venus_hfi_device *device)
		return;
	}

	/* We get better power savings if we lower the venus core clock to the
	 * lowest level before disabling it. */
	cl = venus_hfi_get_clock(device, "core_clk");
	if (cl && cl->has_sw_power_collapse) {
		int rc = clk_set_rate(cl->clk,
				venus_hfi_get_clock_rate(cl, 0));
		if (rc) {
			dprintk(VIDC_WARN,
					"Failed to lower core_clk before disabling: %d\n",
					rc);
		}
	}

	venus_hfi_for_each_clock(device, cl, {
		if (cl->has_sw_power_collapse) {
			clk_disable(cl->clk);
@@ -1156,22 +1198,6 @@ fail_clk_power_on:
	return rc;
}

static unsigned long venus_hfi_get_clock_rate(struct venus_clock *clock,
	int num_mbs_per_sec)
{
	int num_rows = clock->count;
	struct load_freq_table *table = clock->load_freq_tbl;
	unsigned long ret = table[0].freq;
	int i;
	for (i = 0; i < num_rows; i++) {
		if (num_mbs_per_sec > table[i].load)
			break;
		ret = table[i].freq;
	}
	dprintk(VIDC_PROF, "Required clock rate = %lu\n", ret);
	return ret;
}

static int venus_hfi_scale_clocks(void *dev, int load)
{
	int rc = 0;
@@ -2705,19 +2731,6 @@ err_core_init:

}

/*static*/ struct clk *venus_hfi_get_clock(struct venus_hfi_device *device,
		char *name)
{
	struct venus_clock *vc;

	venus_hfi_for_each_clock(device, vc, {
		if (!strcmp(vc->name, name))
			return vc->clk;
	});

	return NULL;
}

static inline int venus_hfi_init_clocks(struct msm_vidc_platform_resources *res,
		struct venus_hfi_device *device)
{