]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/patches/kernel/omap/3isp/0005-mt9p031-Add-support-for-regulators.patch
Merge remote-tracking branch 'alfh/feature_firewalllog_first_last' into next
[people/teissler/ipfire-2.x.git] / src / patches / kernel / omap / 3isp / 0005-mt9p031-Add-support-for-regulators.patch
1 From 9ff2bc0c9458f0eecde6d9b52a899fd2bb1dd3a3 Mon Sep 17 00:00:00 2001
2 From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
3 Date: Tue, 8 May 2012 15:10:36 +0200
4 Subject: [PATCH 5/6] mt9p031: Add support for regulators
5
6 Enable the regulators when powering the sensor up, and disable them when
7 powering it down.
8
9 The regulators are mandatory. Boards that don't allow controlling the
10 sensor power lines must provide fixed voltage regulators.
11
12 Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
13 ---
14 drivers/media/i2c/mt9p031.c | 24 ++++++++++++++++++++++++
15 1 file changed, 24 insertions(+)
16
17 diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
18 index e0bad59..ecf4492 100644
19 --- a/drivers/media/i2c/mt9p031.c
20 +++ b/drivers/media/i2c/mt9p031.c
21 @@ -19,6 +19,7 @@
22 #include <linux/i2c.h>
23 #include <linux/log2.h>
24 #include <linux/pm.h>
25 +#include <linux/regulator/consumer.h>
26 #include <linux/slab.h>
27 #include <linux/videodev2.h>
28
29 @@ -121,6 +122,10 @@ struct mt9p031 {
30 struct mutex power_lock; /* lock to protect power_count */
31 int power_count;
32
33 + struct regulator *vaa;
34 + struct regulator *vdd;
35 + struct regulator *vdd_io;
36 +
37 enum mt9p031_model model;
38 struct aptina_pll pll;
39 int reset;
40 @@ -264,6 +269,11 @@ static int mt9p031_power_on(struct mt9p031 *mt9p031)
41 usleep_range(1000, 2000);
42 }
43
44 + /* Bring up the supplies */
45 + regulator_enable(mt9p031->vdd);
46 + regulator_enable(mt9p031->vdd_io);
47 + regulator_enable(mt9p031->vaa);
48 +
49 /* Emable clock */
50 if (mt9p031->pdata->set_xclk)
51 mt9p031->pdata->set_xclk(&mt9p031->subdev,
52 @@ -285,6 +295,10 @@ static void mt9p031_power_off(struct mt9p031 *mt9p031)
53 usleep_range(1000, 2000);
54 }
55
56 + regulator_disable(mt9p031->vaa);
57 + regulator_disable(mt9p031->vdd_io);
58 + regulator_disable(mt9p031->vdd);
59 +
60 if (mt9p031->pdata->set_xclk)
61 mt9p031->pdata->set_xclk(&mt9p031->subdev, 0);
62 }
63 @@ -937,6 +951,16 @@ static int mt9p031_probe(struct i2c_client *client,
64 mt9p031->model = did->driver_data;
65 mt9p031->reset = -1;
66
67 + mt9p031->vaa = devm_regulator_get(&client->dev, "vaa");
68 + mt9p031->vdd = devm_regulator_get(&client->dev, "vdd");
69 + mt9p031->vdd_io = devm_regulator_get(&client->dev, "vdd_io");
70 +
71 + if (IS_ERR(mt9p031->vaa) || IS_ERR(mt9p031->vdd) ||
72 + IS_ERR(mt9p031->vdd_io)) {
73 + dev_err(&client->dev, "Unable to get regulators\n");
74 + return -ENODEV;
75 + }
76 +
77 v4l2_ctrl_handler_init(&mt9p031->ctrls, ARRAY_SIZE(mt9p031_ctrls) + 6);
78
79 v4l2_ctrl_new_std(&mt9p031->ctrls, &mt9p031_ctrl_ops,
80 --
81 1.7.10.4
82