|
@@ -12,6 +12,7 @@
|
|
|
* published by the Free Software Foundation.
|
|
|
*/
|
|
|
|
|
|
+#include <linux/clk.h>
|
|
|
#include <linux/delay.h>
|
|
|
#include <linux/i2c.h>
|
|
|
#include <linux/log2.h>
|
|
@@ -135,6 +136,8 @@ struct mt9v032 {
|
|
|
struct mutex power_lock;
|
|
|
int power_count;
|
|
|
|
|
|
+ struct clk *clk;
|
|
|
+
|
|
|
struct mt9v032_platform_data *pdata;
|
|
|
|
|
|
u32 sysclk;
|
|
@@ -219,10 +222,9 @@ static int mt9v032_power_on(struct mt9v032 *mt9v032)
|
|
|
struct i2c_client *client = v4l2_get_subdevdata(&mt9v032->subdev);
|
|
|
int ret;
|
|
|
|
|
|
- if (mt9v032->pdata->set_clock) {
|
|
|
- mt9v032->pdata->set_clock(&mt9v032->subdev, mt9v032->sysclk);
|
|
|
- udelay(1);
|
|
|
- }
|
|
|
+ clk_set_rate(mt9v032->clk, mt9v032->sysclk);
|
|
|
+ clk_prepare_enable(mt9v032->clk);
|
|
|
+ udelay(1);
|
|
|
|
|
|
/* Reset the chip and stop data read out */
|
|
|
ret = mt9v032_write(client, MT9V032_RESET, 1);
|
|
@@ -238,8 +240,7 @@ static int mt9v032_power_on(struct mt9v032 *mt9v032)
|
|
|
|
|
|
static void mt9v032_power_off(struct mt9v032 *mt9v032)
|
|
|
{
|
|
|
- if (mt9v032->pdata->set_clock)
|
|
|
- mt9v032->pdata->set_clock(&mt9v032->subdev, 0);
|
|
|
+ clk_disable_unprepare(mt9v032->clk);
|
|
|
}
|
|
|
|
|
|
static int __mt9v032_set_power(struct mt9v032 *mt9v032, bool on)
|
|
@@ -748,6 +749,10 @@ static int mt9v032_probe(struct i2c_client *client,
|
|
|
if (!mt9v032)
|
|
|
return -ENOMEM;
|
|
|
|
|
|
+ mt9v032->clk = devm_clk_get(&client->dev, NULL);
|
|
|
+ if (IS_ERR(mt9v032->clk))
|
|
|
+ return PTR_ERR(mt9v032->clk);
|
|
|
+
|
|
|
mutex_init(&mt9v032->power_lock);
|
|
|
mt9v032->pdata = pdata;
|
|
|
|