diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2012-12-21 16:11:55 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-04-14 16:03:22 -0300 |
commit | d67492585d8308a22a841956f1e629ef3b7d0315 (patch) | |
tree | e161fdd698d376b46084db6497458cca1f16d704 /drivers/media/i2c/mt9p031.c | |
parent | 97f212767a4d0fbddbf4786ccedacb47fc210548 (diff) | |
download | talos-obmc-linux-d67492585d8308a22a841956f1e629ef3b7d0315.tar.gz talos-obmc-linux-d67492585d8308a22a841956f1e629ef3b7d0315.zip |
[media] mt9p031: 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: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/i2c/mt9p031.c')
-rw-r--r-- | drivers/media/i2c/mt9p031.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c index ecf4492c6b8e..28cf95b37285 100644 --- a/drivers/media/i2c/mt9p031.c +++ b/drivers/media/i2c/mt9p031.c @@ -12,6 +12,7 @@ * published by the Free Software Foundation. */ +#include <linux/clk.h> #include <linux/delay.h> #include <linux/device.h> #include <linux/gpio.h> @@ -122,6 +123,7 @@ struct mt9p031 { struct mutex power_lock; /* lock to protect power_count */ int power_count; + struct clk *clk; struct regulator *vaa; struct regulator *vdd; struct regulator *vdd_io; @@ -200,7 +202,7 @@ static int mt9p031_reset(struct mt9p031 *mt9p031) 0); } -static int mt9p031_pll_setup(struct mt9p031 *mt9p031) +static int mt9p031_clk_setup(struct mt9p031 *mt9p031) { static const struct aptina_pll_limits limits = { .ext_clock_min = 6000000, @@ -221,6 +223,12 @@ static int mt9p031_pll_setup(struct mt9p031 *mt9p031) struct i2c_client *client = v4l2_get_subdevdata(&mt9p031->subdev); struct mt9p031_platform_data *pdata = mt9p031->pdata; + mt9p031->clk = devm_clk_get(&client->dev, NULL); + if (IS_ERR(mt9p031->clk)) + return PTR_ERR(mt9p031->clk); + + clk_set_rate(mt9p031->clk, pdata->ext_freq); + mt9p031->pll.ext_clock = pdata->ext_freq; mt9p031->pll.pix_clock = pdata->target_freq; @@ -275,9 +283,8 @@ static int mt9p031_power_on(struct mt9p031 *mt9p031) regulator_enable(mt9p031->vaa); /* Emable clock */ - if (mt9p031->pdata->set_xclk) - mt9p031->pdata->set_xclk(&mt9p031->subdev, - mt9p031->pdata->ext_freq); + if (mt9p031->clk) + clk_prepare_enable(mt9p031->clk); /* Now RESET_BAR must be high */ if (mt9p031->reset != -1) { @@ -299,8 +306,8 @@ static void mt9p031_power_off(struct mt9p031 *mt9p031) regulator_disable(mt9p031->vdd_io); regulator_disable(mt9p031->vdd); - if (mt9p031->pdata->set_xclk) - mt9p031->pdata->set_xclk(&mt9p031->subdev, 0); + if (mt9p031->clk) + clk_disable_unprepare(mt9p031->clk); } static int __mt9p031_set_power(struct mt9p031 *mt9p031, bool on) @@ -1033,7 +1040,7 @@ static int mt9p031_probe(struct i2c_client *client, mt9p031->reset = pdata->reset; } - ret = mt9p031_pll_setup(mt9p031); + ret = mt9p031_clk_setup(mt9p031); done: if (ret < 0) { |