summaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2014-02-08 11:33:46 -0500
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-02-24 11:11:40 -0500
commitb16fdd53de8f46da425a87f7175276d1c8d92355 (patch)
treea4a6087ed6c9dab7425ee694f16ce800dc9b3f5b /drivers/media/i2c
parentb2b3593e331cce1718d7388f8a1182b5195be5fb (diff)
[media] mt9t001: Add clock support
The sensor needs a master clock, handle it explictly in the driver. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/i2c')
-rw-r--r--drivers/media/i2c/mt9t001.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/drivers/media/i2c/mt9t001.c b/drivers/media/i2c/mt9t001.c
index 9a0bb063aa9b..422e068f5f1b 100644
--- a/drivers/media/i2c/mt9t001.c
+++ b/drivers/media/i2c/mt9t001.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/i2c.h> 16#include <linux/i2c.h>
16#include <linux/log2.h> 17#include <linux/log2.h>
17#include <linux/module.h> 18#include <linux/module.h>
@@ -118,6 +119,7 @@ struct mt9t001 {
118 struct v4l2_subdev subdev; 119 struct v4l2_subdev subdev;
119 struct media_pad pad; 120 struct media_pad pad;
120 121
122 struct clk *clk;
121 struct regulator_bulk_data regulators[2]; 123 struct regulator_bulk_data regulators[2];
122 124
123 struct mutex power_lock; /* lock to protect power_count */ 125 struct mutex power_lock; /* lock to protect power_count */
@@ -189,9 +191,21 @@ static int mt9t001_reset(struct mt9t001 *mt9t001)
189 191
190static int mt9t001_power_on(struct mt9t001 *mt9t001) 192static int mt9t001_power_on(struct mt9t001 *mt9t001)
191{ 193{
194 int ret;
195
192 /* Bring up the supplies */ 196 /* Bring up the supplies */
193 return regulator_bulk_enable(ARRAY_SIZE(mt9t001->regulators), 197 ret = regulator_bulk_enable(ARRAY_SIZE(mt9t001->regulators),
194 mt9t001->regulators); 198 mt9t001->regulators);
199 if (ret < 0)
200 return ret;
201
202 /* Enable clock */
203 ret = clk_prepare_enable(mt9t001->clk);
204 if (ret < 0)
205 regulator_bulk_disable(ARRAY_SIZE(mt9t001->regulators),
206 mt9t001->regulators);
207
208 return ret;
195} 209}
196 210
197static void mt9t001_power_off(struct mt9t001 *mt9t001) 211static void mt9t001_power_off(struct mt9t001 *mt9t001)
@@ -199,6 +213,9 @@ static void mt9t001_power_off(struct mt9t001 *mt9t001)
199 regulator_bulk_disable(ARRAY_SIZE(mt9t001->regulators), 213 regulator_bulk_disable(ARRAY_SIZE(mt9t001->regulators),
200 mt9t001->regulators); 214 mt9t001->regulators);
201 215
216 clk_disable_unprepare(mt9t001->clk);
217}
218
202static int __mt9t001_set_power(struct mt9t001 *mt9t001, bool on) 219static int __mt9t001_set_power(struct mt9t001 *mt9t001, bool on)
203{ 220{
204 struct i2c_client *client = v4l2_get_subdevdata(&mt9t001->subdev); 221 struct i2c_client *client = v4l2_get_subdevdata(&mt9t001->subdev);
@@ -854,6 +871,12 @@ static int mt9t001_probe(struct i2c_client *client,
854 return ret; 871 return ret;
855 } 872 }
856 873
874 mt9t001->clk = devm_clk_get(&client->dev, NULL);
875 if (IS_ERR(mt9t001->clk)) {
876 dev_err(&client->dev, "Unable to get clock\n");
877 return PTR_ERR(mt9t001->clk);
878 }
879
857 v4l2_ctrl_handler_init(&mt9t001->ctrls, ARRAY_SIZE(mt9t001_ctrls) + 880 v4l2_ctrl_handler_init(&mt9t001->ctrls, ARRAY_SIZE(mt9t001_ctrls) +
858 ARRAY_SIZE(mt9t001_gains) + 4); 881 ARRAY_SIZE(mt9t001_gains) + 4);
859 882