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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
/* linux/arch/arm/mach-exynos/setup-jpeg.c
*
* Copyright (c) 2009-2011 Samsung Electronics Co., Ltd.
* http://www.samsung.com
*
* Base Exynos4 JPEG 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 <linux/platform_device.h>
#include <plat/gpio-cfg.h>
#include <plat/clock.h>
#include <mach/regs-clock.h>
#include <mach/map.h>
int __init exynos4_jpeg_setup_clock(struct device *dev,
unsigned long clk_rate)
{
struct clk *sclk = NULL;
struct clk *mout_jpeg = NULL;
struct clk *mout_mpll = NULL;
int ret;
sclk = clk_get(dev, "aclk_clk_jpeg");
if (IS_ERR(sclk)) {
dev_err(dev, "failed to get aclk for jpeg\n");
goto err_clk1;
}
mout_jpeg = clk_get(dev, "mout_jpeg0");
if (IS_ERR(mout_jpeg)) {
dev_err(dev, "failed to get mout_jpeg0 for jpeg\n");
goto err_clk2;
}
ret = clk_set_parent(sclk, mout_jpeg);
if (ret < 0) {
dev_err(dev, "failed to clk_set_parent for jpeg\n");
goto err_clk2;
}
mout_mpll = clk_get(dev, "mout_mpll_user");
if (IS_ERR(mout_mpll)) {
dev_err(dev, "failed to get mout_mpll for jpeg\n");
goto err_clk2;
}
ret = clk_set_parent(mout_jpeg, mout_mpll);
if (ret < 0) {
dev_err(dev, "failed to clk_set_parent for jpeg\n");
goto err_clk2;
}
ret = clk_set_rate(sclk, clk_rate);
if (ret < 0) {
dev_err(dev, "failed to clk_set_rate of sclk for jpeg\n");
goto err_clk2;
}
dev_dbg(dev, "set jpeg aclk rate\n");
clk_put(mout_jpeg);
clk_put(mout_mpll);
ret = clk_enable(sclk);
if (ret < 0) {
dev_err(dev, "failed to clk_enable of aclk for jpeg\n");
goto err_clk2;
}
return 0;
err_clk2:
clk_put(mout_mpll);
err_clk1:
clk_put(sclk);
return -EINVAL;
}
int __init exynos5_jpeg_setup_clock(struct device *dev,
unsigned long clk_rate)
{
struct clk *sclk;
sclk = clk_get(dev, "sclk_jpeg");
if (IS_ERR(sclk))
return PTR_ERR(sclk);
if (!clk_rate)
clk_rate = 150000000UL;
if (clk_set_rate(sclk, clk_rate)) {
pr_err("%s rate change failed: %lu\n", sclk->name, clk_rate);
clk_put(sclk);
return PTR_ERR(sclk);
}
clk_put(sclk);
return 0;
}
|