media: mt9m111: add regulator support
In the soc_camera removal, the board specific power callback was dropped. This at least will remove the power optimization from ezx and em-x270 pxa based boards. As to recreate the same level of functionality, make the mt9m111 have a regulator providing it its power, so that board designers can plug in a gpio based or ldo regulator, mimicking their former soc_camera power hook. [sakari.ailus@linux.intel.com: fix a build warning] Fixes: 5c10113cc668 ("media: mt9m111: make a standalone v4l2 subdevice") Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Tested-by: Akinobu Mita <akinobu.mita@gmail.com> Tested-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
parent
e14b77c3db
commit
3a959dcd11
|
@ -13,6 +13,7 @@
|
||||||
#include <linux/log2.h>
|
#include <linux/log2.h>
|
||||||
#include <linux/gpio.h>
|
#include <linux/gpio.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
|
#include <linux/regulator/consumer.h>
|
||||||
#include <linux/v4l2-mediabus.h>
|
#include <linux/v4l2-mediabus.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/property.h>
|
#include <linux/property.h>
|
||||||
|
@ -243,6 +244,7 @@ struct mt9m111 {
|
||||||
int power_count;
|
int power_count;
|
||||||
const struct mt9m111_datafmt *fmt;
|
const struct mt9m111_datafmt *fmt;
|
||||||
int lastpage; /* PageMap cache value */
|
int lastpage; /* PageMap cache value */
|
||||||
|
struct regulator *regulator;
|
||||||
bool is_streaming;
|
bool is_streaming;
|
||||||
/* user point of view - 0: falling 1: rising edge */
|
/* user point of view - 0: falling 1: rising edge */
|
||||||
unsigned int pclk_sample:1;
|
unsigned int pclk_sample:1;
|
||||||
|
@ -982,6 +984,12 @@ static int mt9m111_power_on(struct mt9m111 *mt9m111)
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
if (mt9m111->regulator) {
|
||||||
|
ret = regulator_enable(mt9m111->regulator);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
ret = mt9m111_resume(mt9m111);
|
ret = mt9m111_resume(mt9m111);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&client->dev, "Failed to resume the sensor: %d\n", ret);
|
dev_err(&client->dev, "Failed to resume the sensor: %d\n", ret);
|
||||||
|
@ -994,6 +1002,8 @@ static int mt9m111_power_on(struct mt9m111 *mt9m111)
|
||||||
static void mt9m111_power_off(struct mt9m111 *mt9m111)
|
static void mt9m111_power_off(struct mt9m111 *mt9m111)
|
||||||
{
|
{
|
||||||
mt9m111_suspend(mt9m111);
|
mt9m111_suspend(mt9m111);
|
||||||
|
if (mt9m111->regulator)
|
||||||
|
regulator_disable(mt9m111->regulator);
|
||||||
v4l2_clk_disable(mt9m111->clk);
|
v4l2_clk_disable(mt9m111->clk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1256,6 +1266,13 @@ static int mt9m111_probe(struct i2c_client *client,
|
||||||
if (IS_ERR(mt9m111->clk))
|
if (IS_ERR(mt9m111->clk))
|
||||||
return PTR_ERR(mt9m111->clk);
|
return PTR_ERR(mt9m111->clk);
|
||||||
|
|
||||||
|
mt9m111->regulator = devm_regulator_get(&client->dev, "vdd");
|
||||||
|
if (IS_ERR(mt9m111->regulator)) {
|
||||||
|
dev_err(&client->dev, "regulator not found: %ld\n",
|
||||||
|
PTR_ERR(mt9m111->regulator));
|
||||||
|
return PTR_ERR(mt9m111->regulator);
|
||||||
|
}
|
||||||
|
|
||||||
/* Default HIGHPOWER context */
|
/* Default HIGHPOWER context */
|
||||||
mt9m111->ctx = &context_b;
|
mt9m111->ctx = &context_b;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue