aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/mt9p031.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-03-09 08:59:41 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-05-14 12:33:44 -0400
commit15693b57931b19f3bb4664cb4fa3f6f966058749 (patch)
treeb6ce52ec72ff1d0aa90653b630c3b106b939d833 /drivers/media/video/mt9p031.c
parent1c542ba85461f4f4f456eeee4fa7e90a3d138c6a (diff)
[media] mt9p031: Replace the reset board callback by a GPIO number
Use the GPIO from the sensor driver instead of calling back to board code. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/mt9p031.c')
-rw-r--r--drivers/media/video/mt9p031.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/drivers/media/video/mt9p031.c b/drivers/media/video/mt9p031.c
index 5b8a3968035d..3a9363118e83 100644
--- a/drivers/media/video/mt9p031.c
+++ b/drivers/media/video/mt9p031.c
@@ -14,6 +14,7 @@
14 14
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/device.h> 16#include <linux/device.h>
17#include <linux/gpio.h>
17#include <linux/module.h> 18#include <linux/module.h>
18#include <linux/i2c.h> 19#include <linux/i2c.h>
19#include <linux/log2.h> 20#include <linux/log2.h>
@@ -116,6 +117,7 @@ struct mt9p031 {
116 117
117 enum mt9p031_model model; 118 enum mt9p031_model model;
118 struct aptina_pll pll; 119 struct aptina_pll pll;
120 int reset;
119 121
120 /* Registers cache */ 122 /* Registers cache */
121 u16 output_control; 123 u16 output_control;
@@ -247,8 +249,8 @@ static inline int mt9p031_pll_disable(struct mt9p031 *mt9p031)
247static int mt9p031_power_on(struct mt9p031 *mt9p031) 249static int mt9p031_power_on(struct mt9p031 *mt9p031)
248{ 250{
249 /* Ensure RESET_BAR is low */ 251 /* Ensure RESET_BAR is low */
250 if (mt9p031->pdata->reset) { 252 if (mt9p031->reset != -1) {
251 mt9p031->pdata->reset(&mt9p031->subdev, 1); 253 gpio_set_value(mt9p031->reset, 0);
252 usleep_range(1000, 2000); 254 usleep_range(1000, 2000);
253 } 255 }
254 256
@@ -258,8 +260,8 @@ static int mt9p031_power_on(struct mt9p031 *mt9p031)
258 mt9p031->pdata->ext_freq); 260 mt9p031->pdata->ext_freq);
259 261
260 /* Now RESET_BAR must be high */ 262 /* Now RESET_BAR must be high */
261 if (mt9p031->pdata->reset) { 263 if (mt9p031->reset != -1) {
262 mt9p031->pdata->reset(&mt9p031->subdev, 0); 264 gpio_set_value(mt9p031->reset, 1);
263 usleep_range(1000, 2000); 265 usleep_range(1000, 2000);
264 } 266 }
265 267
@@ -268,8 +270,8 @@ static int mt9p031_power_on(struct mt9p031 *mt9p031)
268 270
269static void mt9p031_power_off(struct mt9p031 *mt9p031) 271static void mt9p031_power_off(struct mt9p031 *mt9p031)
270{ 272{
271 if (mt9p031->pdata->reset) { 273 if (mt9p031->reset != -1) {
272 mt9p031->pdata->reset(&mt9p031->subdev, 1); 274 gpio_set_value(mt9p031->reset, 0);
273 usleep_range(1000, 2000); 275 usleep_range(1000, 2000);
274 } 276 }
275 277
@@ -849,6 +851,7 @@ static int mt9p031_probe(struct i2c_client *client,
849 mt9p031->output_control = MT9P031_OUTPUT_CONTROL_DEF; 851 mt9p031->output_control = MT9P031_OUTPUT_CONTROL_DEF;
850 mt9p031->mode2 = MT9P031_READ_MODE_2_ROW_BLC; 852 mt9p031->mode2 = MT9P031_READ_MODE_2_ROW_BLC;
851 mt9p031->model = did->driver_data; 853 mt9p031->model = did->driver_data;
854 mt9p031->reset = -1;
852 855
853 v4l2_ctrl_handler_init(&mt9p031->ctrls, ARRAY_SIZE(mt9p031_ctrls) + 4); 856 v4l2_ctrl_handler_init(&mt9p031->ctrls, ARRAY_SIZE(mt9p031_ctrls) + 4);
854 857
@@ -899,10 +902,22 @@ static int mt9p031_probe(struct i2c_client *client,
899 mt9p031->format.field = V4L2_FIELD_NONE; 902 mt9p031->format.field = V4L2_FIELD_NONE;
900 mt9p031->format.colorspace = V4L2_COLORSPACE_SRGB; 903 mt9p031->format.colorspace = V4L2_COLORSPACE_SRGB;
901 904
905 if (pdata->reset != -1) {
906 ret = gpio_request_one(pdata->reset, GPIOF_OUT_INIT_LOW,
907 "mt9p031_rst");
908 if (ret < 0)
909 goto done;
910
911 mt9p031->reset = pdata->reset;
912 }
913
902 ret = mt9p031_pll_setup(mt9p031); 914 ret = mt9p031_pll_setup(mt9p031);
903 915
904done: 916done:
905 if (ret < 0) { 917 if (ret < 0) {
918 if (mt9p031->reset != -1)
919 gpio_free(mt9p031->reset);
920
906 v4l2_ctrl_handler_free(&mt9p031->ctrls); 921 v4l2_ctrl_handler_free(&mt9p031->ctrls);
907 media_entity_cleanup(&mt9p031->subdev.entity); 922 media_entity_cleanup(&mt9p031->subdev.entity);
908 kfree(mt9p031); 923 kfree(mt9p031);
@@ -919,6 +934,8 @@ static int mt9p031_remove(struct i2c_client *client)
919 v4l2_ctrl_handler_free(&mt9p031->ctrls); 934 v4l2_ctrl_handler_free(&mt9p031->ctrls);
920 v4l2_device_unregister_subdev(subdev); 935 v4l2_device_unregister_subdev(subdev);
921 media_entity_cleanup(&subdev->entity); 936 media_entity_cleanup(&subdev->entity);
937 if (mt9p031->reset != -1)
938 gpio_free(mt9p031->reset);
922 kfree(mt9p031); 939 kfree(mt9p031);
923 940
924 return 0; 941 return 0;