Ejemplo n.º 1
0
Archivo: pm.c Proyecto: wosigh/kernel
void memory_logic_res_setting(struct system_power_state *trg_st)
{
	int res1_level = resource_get_level(memret1);
	int res2_level = resource_get_level(memret2);
	int res3_level = resource_get_level(logret1);

	if (res3_level == LOGIC_RET) {
		if ((res1_level == MEMORY_RET) && (res2_level == MEMORY_RET))
			trg_st->core_state = PRCM_CORE_CSWR_MEMRET;
		else if (res1_level == MEMORY_OFF && res2_level == MEMORY_RET)
			trg_st->core_state = PRCM_CORE_CSWR_MEM1OFF;
		else if (res1_level == MEMORY_RET && res2_level == MEMORY_OFF)
			trg_st->core_state = PRCM_CORE_CSWR_MEM2OFF;
		else
			trg_st->core_state = PRCM_CORE_CSWR_MEMOFF;
	} else if (res3_level == LOGIC_OFF) {
		if ((res1_level && res2_level) == MEMORY_RET)
			trg_st->core_state = PRCM_CORE_OSWR_MEMRET;
		else if (res1_level == MEMORY_OFF && res2_level == MEMORY_RET)
			trg_st->core_state = PRCM_CORE_OSWR_MEM1OFF;
		else if (res1_level == MEMORY_RET && res2_level == MEMORY_OFF)
			trg_st->core_state = PRCM_CORE_OSWR_MEM2OFF;
		else
			trg_st->core_state = PRCM_CORE_OSWR_MEMOFF;
	} else
		DPRINTK("Current State not supported in Retention");
}
Ejemplo n.º 2
0
static ssize_t vdd_opp_show(struct kobject *kobj, struct kobj_attribute *attr,
			 char *buf)
{
	if (attr == &vdd1_opp_attr)
		return sprintf(buf, "%hu\n", resource_get_level("vdd1_opp"));
	else if (attr == &vdd2_opp_attr)
		return sprintf(buf, "%hu\n", resource_get_level("vdd2_opp"));
	else if (attr == &vdd1_lock_attr)
		return sprintf(buf, "%hu\n", resource_get_opp_lock(PRCM_VDD1));
	else if (attr == &vdd2_lock_attr)
		return sprintf(buf, "%hu\n", resource_get_opp_lock(PRCM_VDD2));
	else
		return -EINVAL;
}
Ejemplo n.º 3
0
/**
 * resource_test_2 - Tests resource framework APIs when two devices requests
 *                   the same "opp/freq" resource for same or different levels
 * @res_name: Name of the resource requested
 * @req_lvl1: Device 1 level requested for the resource
 * @req_lvl2: Device 2 level requested for the resource
 *
 * Two devices requests the "opp/freq" resource for the specified levels,
 * verifies if the resource's current level is same as the maximum of
 * requested levels and releases the resource
 *
 * Returns 0 on success, -1 on failure
 */
static int resource_test_2(const char *res_name, unsigned long req_lvl1,
			unsigned long req_lvl2)
{
	int ret, result = TEST_PASS;
	int cur_lvl, req_lvl;
	struct device dev1, dev2;

	printk(KERN_INFO "Entry resource_test_2 \n");

	if (!strcmp(res_name, "vdd2_opp"))
		ret = request_vdd2_opp(&dev1, req_lvl1);
	else
		ret = resource_request(res_name, &dev1, req_lvl1);

	if (ret) {
		printk(KERN_ERR "FAILED!!!! dev1 resource request for %s failed"
			" with value %d\n", res_name, ret);
		return TEST_FAIL;
	}

	if (!strcmp(res_name, "vdd2_opp"))
		ret = request_vdd2_opp(&dev2, req_lvl2);
	else
		ret = resource_request(res_name, &dev2, req_lvl2);

	if (ret) {
		printk(KERN_ERR "FAILED!!!! dev2 resource request for %s failed"
			" with value %d\n", res_name, ret);
		resource_release(res_name, &dev1);
		return TEST_FAIL;
	}

	cur_lvl = resource_get_level(res_name);
	req_lvl = (int) max_level(req_lvl1, req_lvl2);
	if (cur_lvl != req_lvl) {
		printk(KERN_ERR "FAILED!!!! resource %s current level:%d"
			" req lvl:%d\n", res_name, cur_lvl, req_lvl);
		result = TEST_FAIL;
	}

	ret = resource_release(res_name, &dev1);
	if (ret) {
		printk(KERN_ERR "FAILED!!!! dev1 resource release for %s failed"
			" with value %d\n", res_name, ret);
		result = TEST_FAIL;
	}
	ret = resource_release(res_name, &dev2);
	if (ret) {
		printk(KERN_ERR "FAILED!!!! dev2 resource release for %s failed"
			" with value %d\n", res_name, ret);
		result = TEST_FAIL;
	}

	if (!result)
		printk(KERN_INFO "resource_test_2 PASSED for %s\n", res_name);
	return result;
}
Ejemplo n.º 4
0
/**
 * resource_test_4 - Tests the resource framework basic APIs for
 *                   "latency" resources
 * @res_name: Name of the resource requested
 * @req_lat: Requested lat for the resource
 * @ref_table: Pointer to the reference latency table for the given resource
 *
 * Requests the "latency" resource for the given level,
 * verifies if the resource's current level is same as the
 * closest lower reference level and releases the resource
 *
 * Returns 0 on success, -1 on failure
 */
static int resource_test_4(const char *res_name, unsigned long req_lat,
			unsigned long *ref_table)
{
	int ret, i, result = TEST_PASS;
	int cur_lvl;
	struct device dev;

	printk(KERN_INFO "Entry resource_test_4 \n");

	ret = resource_request(res_name, &dev, req_lat);
	if (ret) {
		printk(KERN_ERR "FAILED!!!! resource request for %s failed"
			" with value %d\n", res_name, ret);
		return TEST_FAIL;
	}

	cur_lvl = resource_get_level(res_name);

	/* using the ref table to find the appropriate PD state */
	for (i = 0; i < 3; i++) {
		if (ref_table[i] < req_lat)
			break;
	}
	if (!enable_off_mode && i == PD_LATENCY_OFF)
		i = PD_LATENCY_RET;
	/* Inactive state is not being tested */
	else if (i == 2)
		i = PD_LATENCY_ON;

	if (cur_lvl != i) {
		printk(KERN_ERR "FAILED!!!! resource %s current level:%d"
			" req lvl:%d\n", res_name, cur_lvl, i);
		result = TEST_FAIL;
	}

	ret = resource_release(res_name, &dev);
	if (ret) {
		printk(KERN_ERR "FAILED!!!! resource release for %s failed"
			" with value %d\n", res_name, ret);
		result = TEST_FAIL;
	}

	if (!result)
		printk(KERN_INFO "resource_test_4 PASSED for %s\n", res_name);
	return result;
}
Ejemplo n.º 5
0
unsigned long omap_pm_cpu_get_freq(void)
{
	pr_debug("OMAP PM: CPUFreq requests current CPU frequency\n");
	return resource_get_level("mpu_freq");
}
Ejemplo n.º 6
0
u8 omap_pm_vdd2_get_opp(void)
{
	pr_debug("OMAP PM: User requests current VDD2 OPP\n");
	return resource_get_level("vdd2_opp");
}
Ejemplo n.º 7
0
u8 omap_pm_dsp_get_opp(void)
{
	pr_debug("OMAP PM: DSP requests current DSP OPP ID\n");
	return resource_get_level("vdd1_opp");
}
Ejemplo n.º 8
0
/**
 * resource_test_7 - Tests the resource_refresh API
 * @res_name: Name of the resource requested ("vdd1_opp"/"vdd2_opp")
 * @req_lvl1: Requested lower level for the resource
 * @req_lvl2: Requested higher level for the resource
 *
 * Device 1 requests the resource for the given lower level,
 * locks the resource. Meanwhile device 2 requests the reource for a
 * higher level.
 * Verifies if the resource's current level is same as the requested
 * higher level after device 1 unlocks the resource
 *
 * Returns 0 on success, -1 on failure
 */
static int resource_test_7(const char *res_name, unsigned long req_lvl1,
			unsigned long req_lvl2)
{
	int ret, cur_lvl, result = TEST_PASS;
	int lock_val;
	struct device dev1, dev2;

	printk(KERN_INFO "Entry resource_test_7 \n");

	if (!strcmp(res_name, "vdd1_opp"))
		lock_val = VDD1_OPP;
	else if (!strcmp(res_name, "vdd2_opp"))
		lock_val = VDD2_OPP;
	else {
		printk(KERN_ERR "FAILED!!!! invalid resource name\n");
		return TEST_FAIL;
	}

	ret = resource_request(res_name, &dev1, req_lvl1);
	if (ret) {
		printk(KERN_ERR "FAILED!!!! resource1 request for %s failed"
			" with value %d\n", res_name, ret);
		return TEST_FAIL;
	}

	cur_lvl = resource_get_level(res_name);
	if (cur_lvl != req_lvl1) {
		printk(KERN_ERR "FAILED!!!! resource %s current level:%d"
			" req lvl:%d\n", res_name, cur_lvl, (int)req_lvl1);
		result = TEST_FAIL;
	}

	if (result == TEST_PASS) {
		ret = resource_access_opp_lock(lock_val, 1);
		if (ret < 0) {
			printk(KERN_ERR "FAILED!!!! resource %s lock failed"
				" with value %d\n", res_name, ret);
			result = TEST_FAIL;
		}
	}

	if (result == TEST_PASS) {
		ret = resource_request(res_name, &dev2, req_lvl2);
		if (ret) {
			printk(KERN_ERR "FAILED!!!! resource2 request %s failed"
				" with value %d\n", res_name, ret);
			ret = resource_access_opp_lock(lock_val, -1);
			if (ret < 0)
				printk(KERN_ERR "FAILED!!!! resource unlock"
					"for %s failed\n", res_name);
			result = TEST_FAIL;
		}
	}

	if (result == TEST_PASS) {
		cur_lvl = resource_get_level(res_name);
		if (cur_lvl != req_lvl1) {
			printk(KERN_ERR "FAILED!!!! %s current level:%d"
				" req lvl:%d\n", res_name, cur_lvl,
				(int)req_lvl1);
			result = TEST_FAIL;
		}

		ret = resource_access_opp_lock(lock_val, -1);
		if (ret < 0) {
			printk(KERN_ERR "FAILED!!!! resource unlock %s failed"
				" with value %d\n", res_name, ret);
			result = TEST_FAIL;
		}

		ret = resource_refresh();
		if (ret) {
			printk(KERN_ERR "FAILED!!!! resource refresh failed"
				" with value %d\n", ret);
			result = TEST_FAIL;
		}

		cur_lvl = resource_get_level(res_name);
		if (cur_lvl != req_lvl2) {
			printk(KERN_ERR "FAILED!!!! %s current level:%d"
				" req lvl:%d\n", res_name, cur_lvl,
				(int)req_lvl2);
			result = TEST_FAIL;
		}
	}

	ret = resource_release(res_name, &dev1);
	if (ret) {
		printk(KERN_ERR "FAILED!!!! resource1 release for %s failed"
			" with value %d\n", res_name, ret);
		result = TEST_FAIL;
	}
	ret = resource_release(res_name, &dev2);
	if (ret) {
		printk(KERN_ERR "FAILED!!!! resource2 release for %s failed"
			" with value %d\n", res_name, ret);
		result = TEST_FAIL;
	}

	if (!result)
		printk(KERN_INFO "resource_test_7 PASSED for %s\n", res_name);
	return result;
}