Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Laurent Pinchart and committed by
Mauro Carvalho Chehab
15693b57 1c542ba8

+33 -9
+23 -6
drivers/media/video/mt9p031.c
··· 14 14 15 15 #include <linux/delay.h> 16 16 #include <linux/device.h> 17 + #include <linux/gpio.h> 17 18 #include <linux/module.h> 18 19 #include <linux/i2c.h> 19 20 #include <linux/log2.h> ··· 117 116 118 117 enum mt9p031_model model; 119 118 struct aptina_pll pll; 119 + int reset; 120 120 121 121 /* Registers cache */ 122 122 u16 output_control; ··· 249 247 static int mt9p031_power_on(struct mt9p031 *mt9p031) 250 248 { 251 249 /* Ensure RESET_BAR is low */ 252 - if (mt9p031->pdata->reset) { 253 - mt9p031->pdata->reset(&mt9p031->subdev, 1); 250 + if (mt9p031->reset != -1) { 251 + gpio_set_value(mt9p031->reset, 0); 254 252 usleep_range(1000, 2000); 255 253 } 256 254 ··· 260 258 mt9p031->pdata->ext_freq); 261 259 262 260 /* Now RESET_BAR must be high */ 263 - if (mt9p031->pdata->reset) { 264 - mt9p031->pdata->reset(&mt9p031->subdev, 0); 261 + if (mt9p031->reset != -1) { 262 + gpio_set_value(mt9p031->reset, 1); 265 263 usleep_range(1000, 2000); 266 264 } 267 265 ··· 270 268 271 269 static void mt9p031_power_off(struct mt9p031 *mt9p031) 272 270 { 273 - if (mt9p031->pdata->reset) { 274 - mt9p031->pdata->reset(&mt9p031->subdev, 1); 271 + if (mt9p031->reset != -1) { 272 + gpio_set_value(mt9p031->reset, 0); 275 273 usleep_range(1000, 2000); 276 274 } 277 275 ··· 851 849 mt9p031->output_control = MT9P031_OUTPUT_CONTROL_DEF; 852 850 mt9p031->mode2 = MT9P031_READ_MODE_2_ROW_BLC; 853 851 mt9p031->model = did->driver_data; 852 + mt9p031->reset = -1; 854 853 855 854 v4l2_ctrl_handler_init(&mt9p031->ctrls, ARRAY_SIZE(mt9p031_ctrls) + 4); 856 855 ··· 902 899 mt9p031->format.field = V4L2_FIELD_NONE; 903 900 mt9p031->format.colorspace = V4L2_COLORSPACE_SRGB; 904 901 902 + if (pdata->reset != -1) { 903 + ret = gpio_request_one(pdata->reset, GPIOF_OUT_INIT_LOW, 904 + "mt9p031_rst"); 905 + if (ret < 0) 906 + goto done; 907 + 908 + mt9p031->reset = pdata->reset; 909 + } 910 + 905 911 ret = mt9p031_pll_setup(mt9p031); 906 912 907 913 done: 908 914 if (ret < 0) { 915 + if (mt9p031->reset != -1) 916 + gpio_free(mt9p031->reset); 917 + 909 918 v4l2_ctrl_handler_free(&mt9p031->ctrls); 910 919 media_entity_cleanup(&mt9p031->subdev.entity); 911 920 kfree(mt9p031); ··· 934 919 v4l2_ctrl_handler_free(&mt9p031->ctrls); 935 920 v4l2_device_unregister_subdev(subdev); 936 921 media_entity_cleanup(&subdev->entity); 922 + if (mt9p031->reset != -1) 923 + gpio_free(mt9p031->reset); 937 924 kfree(mt9p031); 938 925 939 926 return 0;
+10 -3
include/media/mt9p031.h
··· 3 3 4 4 struct v4l2_subdev; 5 5 6 + /* 7 + * struct mt9p031_platform_data - MT9P031 platform data 8 + * @set_xclk: Clock frequency set callback 9 + * @reset: Chip reset GPIO (set to -1 if not used) 10 + * @ext_freq: Input clock frequency 11 + * @target_freq: Pixel clock frequency 12 + */ 6 13 struct mt9p031_platform_data { 7 14 int (*set_xclk)(struct v4l2_subdev *subdev, int hz); 8 - int (*reset)(struct v4l2_subdev *subdev, int active); 9 - int ext_freq; /* input frequency to the mt9p031 for PLL dividers */ 10 - int target_freq; /* frequency target for the PLL */ 15 + int reset; 16 + int ext_freq; 17 + int target_freq; 11 18 }; 12 19 13 20 #endif