summaryrefslogtreecommitdiff
path: root/arch/arm/mach-exynos/asv.c
blob: d0a33d3cecf0a20971df4873804fc32a506cc5d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* linux/arch/arm/mach-exynos/asv.c
 *
 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
 *		http://www.samsung.com/
 *
 * EXYNOS4 - ASV(Adaptive Support Voltage) driver
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
*/

#include <linux/init.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/err.h>
#include <linux/io.h>
#include <linux/slab.h>

#include <plat/cpu.h>

#include <mach/map.h>
#include <mach/asv.h>

static struct samsung_asv *exynos_asv;

static int __init exynos_asv_init(void)
{
	exynos_asv = kzalloc(sizeof(struct samsung_asv), GFP_KERNEL);
	if (!exynos_asv)
		goto out;

	if (soc_is_exynos4210())
		exynos4210_asv_init(exynos_asv);
	else
		goto out;

	if (exynos_asv->check_vdd_arm) {
		if (exynos_asv->check_vdd_arm())
			goto out;
	}

	/* Get HPM Delay value */
	if (exynos_asv->get_hpm) {
		if (exynos_asv->get_hpm(exynos_asv))
			goto out;
	} else
		goto out;

	/* Get IDS ARM Value */
	if (exynos_asv->get_ids) {
		if (exynos_asv->get_ids(exynos_asv))
			goto out;
	} else
		goto out;

	if (exynos_asv->store_result) {
		if (exynos_asv->store_result(exynos_asv))
			goto out;
	} else
		goto out;

	return 0;
out:
	pr_err("EXYNOS : Fail to initialize ASV\n");

	kfree(exynos_asv);

	return -EINVAL;
}
device_initcall_sync(exynos_asv_init);