aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-exynos/setup-gsc.c
blob: 493d75680de88273a2cc6fd93c1e7a6581a7bde4 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* linux/arch/arm/mach-exynos/setup-gsc.c
 *
 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
 *             http://www.samsung.com
 *
 * Base Exynos5 G-Scaler clock configuration
 *
 * 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/kernel.h>
#include <linux/types.h>
#include <linux/clk.h>
#include <linux/err.h>
#include <plat/clock.h>
#include <plat/devs.h>
#include <mach/regs-clock.h>
#include <mach/map.h>
#include <media/exynos_gscaler.h>

void __init exynos5_gsc_set_pdev_name(int id, char *name)
{
	switch (id) {
	case 0:
		exynos5_device_gsc0.name = name;
		break;
	case 1:
		exynos5_device_gsc1.name = name;
		break;
	case 2:
		exynos5_device_gsc2.name = name;
		break;
	case 3:
		exynos5_device_gsc3.name = name;
		break;
	}
}

int __init exynos5_gsc_set_parent_clock(const char *child, const char *parent)
{
	struct clk *clk_parent;
	struct clk *clk_child;

	clk_child = clk_get(NULL, child);
	if (IS_ERR(clk_child)) {
		pr_err("failed to get %s clock.\n", child);
		return PTR_ERR(clk_child);
	}

	clk_parent = clk_get(NULL, parent);
	if (IS_ERR(clk_parent)) {
		clk_put(clk_child);
		pr_err("failed to get %s clock.\n", parent);
		return PTR_ERR(clk_parent);
	}

	if (clk_set_parent(clk_child, clk_parent)) {
		pr_err("Unable to set parent %s of clock %s.\n",
				clk_parent->name, clk_child->name);
		clk_put(clk_child);
		clk_put(clk_parent);
		return PTR_ERR(clk_child);
	}

	clk_put(clk_child);
	clk_put(clk_parent);

	return 0;
}

int __init exynos5_gsc_set_clock_rate(const char *clk, unsigned long clk_rate)
{
	struct clk *gsc_clk;

	gsc_clk = clk_get(NULL, clk);
	if (IS_ERR(gsc_clk)) {
		pr_err("failed to get %s clock.\n", clk);
		return PTR_ERR(gsc_clk);
	}

	if (!clk_rate)
		clk_rate = 310000000UL;

	if (clk_set_rate(gsc_clk, clk_rate)) {
		pr_err("%s rate change failed: %lu\n", gsc_clk->name, clk_rate);
		clk_put(gsc_clk);
		return PTR_ERR(gsc_clk);
	}

	clk_put(gsc_clk);

	return 0;
}