]>
Commit | Line | Data |
---|---|---|
d006af40 AF |
1 | From 6cd62f5ae305142c0490e80caa04f99f00029b68 Mon Sep 17 00:00:00 2001 |
2 | From: Laurent Pinchart <laurent.pinchart@ideasonboard.com> | |
3 | Date: Fri, 21 Dec 2012 20:11:55 +0100 | |
4 | Subject: [PATCH 6/6] mt9p031: Use the common clock framework | |
5 | ||
6 | Configure the device external clock using the common clock framework | |
7 | instead of a board code callback function. | |
8 | ||
9 | Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> | |
10 | Acked-by: Sakari Ailus <sakari.ailus@iki.fi> | |
11 | --- | |
12 | drivers/media/i2c/mt9p031.c | 21 ++++++++++++++------- | |
13 | include/media/mt9p031.h | 2 -- | |
14 | 2 files changed, 14 insertions(+), 9 deletions(-) | |
15 | ||
16 | diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c | |
17 | index ecf4492..28cf95b 100644 | |
18 | --- a/drivers/media/i2c/mt9p031.c | |
19 | +++ b/drivers/media/i2c/mt9p031.c | |
20 | @@ -12,6 +12,7 @@ | |
21 | * published by the Free Software Foundation. | |
22 | */ | |
23 | ||
24 | +#include <linux/clk.h> | |
25 | #include <linux/delay.h> | |
26 | #include <linux/device.h> | |
27 | #include <linux/gpio.h> | |
28 | @@ -122,6 +123,7 @@ struct mt9p031 { | |
29 | struct mutex power_lock; /* lock to protect power_count */ | |
30 | int power_count; | |
31 | ||
32 | + struct clk *clk; | |
33 | struct regulator *vaa; | |
34 | struct regulator *vdd; | |
35 | struct regulator *vdd_io; | |
36 | @@ -200,7 +202,7 @@ static int mt9p031_reset(struct mt9p031 *mt9p031) | |
37 | 0); | |
38 | } | |
39 | ||
40 | -static int mt9p031_pll_setup(struct mt9p031 *mt9p031) | |
41 | +static int mt9p031_clk_setup(struct mt9p031 *mt9p031) | |
42 | { | |
43 | static const struct aptina_pll_limits limits = { | |
44 | .ext_clock_min = 6000000, | |
45 | @@ -221,6 +223,12 @@ static int mt9p031_pll_setup(struct mt9p031 *mt9p031) | |
46 | struct i2c_client *client = v4l2_get_subdevdata(&mt9p031->subdev); | |
47 | struct mt9p031_platform_data *pdata = mt9p031->pdata; | |
48 | ||
49 | + mt9p031->clk = devm_clk_get(&client->dev, NULL); | |
50 | + if (IS_ERR(mt9p031->clk)) | |
51 | + return PTR_ERR(mt9p031->clk); | |
52 | + | |
53 | + clk_set_rate(mt9p031->clk, pdata->ext_freq); | |
54 | + | |
55 | mt9p031->pll.ext_clock = pdata->ext_freq; | |
56 | mt9p031->pll.pix_clock = pdata->target_freq; | |
57 | ||
58 | @@ -275,9 +283,8 @@ static int mt9p031_power_on(struct mt9p031 *mt9p031) | |
59 | regulator_enable(mt9p031->vaa); | |
60 | ||
61 | /* Emable clock */ | |
62 | - if (mt9p031->pdata->set_xclk) | |
63 | - mt9p031->pdata->set_xclk(&mt9p031->subdev, | |
64 | - mt9p031->pdata->ext_freq); | |
65 | + if (mt9p031->clk) | |
66 | + clk_prepare_enable(mt9p031->clk); | |
67 | ||
68 | /* Now RESET_BAR must be high */ | |
69 | if (mt9p031->reset != -1) { | |
70 | @@ -299,8 +306,8 @@ static void mt9p031_power_off(struct mt9p031 *mt9p031) | |
71 | regulator_disable(mt9p031->vdd_io); | |
72 | regulator_disable(mt9p031->vdd); | |
73 | ||
74 | - if (mt9p031->pdata->set_xclk) | |
75 | - mt9p031->pdata->set_xclk(&mt9p031->subdev, 0); | |
76 | + if (mt9p031->clk) | |
77 | + clk_disable_unprepare(mt9p031->clk); | |
78 | } | |
79 | ||
80 | static int __mt9p031_set_power(struct mt9p031 *mt9p031, bool on) | |
81 | @@ -1033,7 +1040,7 @@ static int mt9p031_probe(struct i2c_client *client, | |
82 | mt9p031->reset = pdata->reset; | |
83 | } | |
84 | ||
85 | - ret = mt9p031_pll_setup(mt9p031); | |
86 | + ret = mt9p031_clk_setup(mt9p031); | |
87 | ||
88 | done: | |
89 | if (ret < 0) { | |
90 | diff --git a/include/media/mt9p031.h b/include/media/mt9p031.h | |
91 | index 0c97b19..b1e63f2 100644 | |
92 | --- a/include/media/mt9p031.h | |
93 | +++ b/include/media/mt9p031.h | |
94 | @@ -5,13 +5,11 @@ struct v4l2_subdev; | |
95 | ||
96 | /* | |
97 | * struct mt9p031_platform_data - MT9P031 platform data | |
98 | - * @set_xclk: Clock frequency set callback | |
99 | * @reset: Chip reset GPIO (set to -1 if not used) | |
100 | * @ext_freq: Input clock frequency | |
101 | * @target_freq: Pixel clock frequency | |
102 | */ | |
103 | struct mt9p031_platform_data { | |
104 | - int (*set_xclk)(struct v4l2_subdev *subdev, int hz); | |
105 | int reset; | |
106 | int ext_freq; | |
107 | int target_freq; | |
108 | -- | |
109 | 1.7.10.4 | |
110 |