diff options
| author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2013-07-05 06:16:02 -0400 |
|---|---|---|
| committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2013-08-22 10:37:46 -0400 |
| commit | 3300a8fd48976e7126cf078de95f52d59e413bb0 (patch) | |
| tree | fbe1385dbd543e3450685231ae37ebad848f579f | |
| parent | 4ab0620bdc6fe3ca2365c014552dee64402670a4 (diff) | |
[media] mt9v032: Use the common clock framework
Configure the device external clock using the common clock framework
instead of a board code callback function.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
| -rw-r--r-- | drivers/media/i2c/mt9v032.c | 17 | ||||
| -rw-r--r-- | include/media/mt9v032.h | 4 |
2 files changed, 11 insertions, 10 deletions
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c index 60c6f6739560..2c50effaa334 100644 --- a/drivers/media/i2c/mt9v032.c +++ b/drivers/media/i2c/mt9v032.c | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | * published by the Free Software Foundation. | 12 | * published by the Free Software Foundation. |
| 13 | */ | 13 | */ |
| 14 | 14 | ||
| 15 | #include <linux/clk.h> | ||
| 15 | #include <linux/delay.h> | 16 | #include <linux/delay.h> |
| 16 | #include <linux/i2c.h> | 17 | #include <linux/i2c.h> |
| 17 | #include <linux/log2.h> | 18 | #include <linux/log2.h> |
| @@ -135,6 +136,8 @@ struct mt9v032 { | |||
| 135 | struct mutex power_lock; | 136 | struct mutex power_lock; |
| 136 | int power_count; | 137 | int power_count; |
| 137 | 138 | ||
| 139 | struct clk *clk; | ||
| 140 | |||
| 138 | struct mt9v032_platform_data *pdata; | 141 | struct mt9v032_platform_data *pdata; |
| 139 | 142 | ||
| 140 | u32 sysclk; | 143 | u32 sysclk; |
| @@ -219,10 +222,9 @@ static int mt9v032_power_on(struct mt9v032 *mt9v032) | |||
| 219 | struct i2c_client *client = v4l2_get_subdevdata(&mt9v032->subdev); | 222 | struct i2c_client *client = v4l2_get_subdevdata(&mt9v032->subdev); |
| 220 | int ret; | 223 | int ret; |
| 221 | 224 | ||
| 222 | if (mt9v032->pdata->set_clock) { | 225 | clk_set_rate(mt9v032->clk, mt9v032->sysclk); |
| 223 | mt9v032->pdata->set_clock(&mt9v032->subdev, mt9v032->sysclk); | 226 | clk_prepare_enable(mt9v032->clk); |
| 224 | udelay(1); | 227 | udelay(1); |
| 225 | } | ||
| 226 | 228 | ||
| 227 | /* Reset the chip and stop data read out */ | 229 | /* Reset the chip and stop data read out */ |
| 228 | ret = mt9v032_write(client, MT9V032_RESET, 1); | 230 | ret = mt9v032_write(client, MT9V032_RESET, 1); |
| @@ -238,8 +240,7 @@ static int mt9v032_power_on(struct mt9v032 *mt9v032) | |||
| 238 | 240 | ||
| 239 | static void mt9v032_power_off(struct mt9v032 *mt9v032) | 241 | static void mt9v032_power_off(struct mt9v032 *mt9v032) |
| 240 | { | 242 | { |
| 241 | if (mt9v032->pdata->set_clock) | 243 | clk_disable_unprepare(mt9v032->clk); |
| 242 | mt9v032->pdata->set_clock(&mt9v032->subdev, 0); | ||
| 243 | } | 244 | } |
| 244 | 245 | ||
| 245 | static int __mt9v032_set_power(struct mt9v032 *mt9v032, bool on) | 246 | static int __mt9v032_set_power(struct mt9v032 *mt9v032, bool on) |
| @@ -748,6 +749,10 @@ static int mt9v032_probe(struct i2c_client *client, | |||
| 748 | if (!mt9v032) | 749 | if (!mt9v032) |
| 749 | return -ENOMEM; | 750 | return -ENOMEM; |
| 750 | 751 | ||
| 752 | mt9v032->clk = devm_clk_get(&client->dev, NULL); | ||
| 753 | if (IS_ERR(mt9v032->clk)) | ||
| 754 | return PTR_ERR(mt9v032->clk); | ||
| 755 | |||
| 751 | mutex_init(&mt9v032->power_lock); | 756 | mutex_init(&mt9v032->power_lock); |
| 752 | mt9v032->pdata = pdata; | 757 | mt9v032->pdata = pdata; |
| 753 | 758 | ||
diff --git a/include/media/mt9v032.h b/include/media/mt9v032.h index 78fd39eac219..12175a63c5b2 100644 --- a/include/media/mt9v032.h +++ b/include/media/mt9v032.h | |||
| @@ -1,13 +1,9 @@ | |||
| 1 | #ifndef _MEDIA_MT9V032_H | 1 | #ifndef _MEDIA_MT9V032_H |
| 2 | #define _MEDIA_MT9V032_H | 2 | #define _MEDIA_MT9V032_H |
| 3 | 3 | ||
| 4 | struct v4l2_subdev; | ||
| 5 | |||
| 6 | struct mt9v032_platform_data { | 4 | struct mt9v032_platform_data { |
| 7 | unsigned int clk_pol:1; | 5 | unsigned int clk_pol:1; |
| 8 | 6 | ||
| 9 | void (*set_clock)(struct v4l2_subdev *subdev, unsigned int rate); | ||
| 10 | |||
| 11 | const s64 *link_freqs; | 7 | const s64 *link_freqs; |
| 12 | s64 link_def_freq; | 8 | s64 link_def_freq; |
| 13 | }; | 9 | }; |
