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

[media] mt9v032: Add reset and standby gpios

Add optional reset and standby gpios. The reset gpio is used to reset
the chip in power_on().

The standby gpio is not used currently. It is just unset, so the chip is
not in standby.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

Markus Pargmann and committed by
Mauro Carvalho Chehab
28d5bdbe c1ae8f3a

+30
+2
Documentation/devicetree/bindings/media/i2c/mt9v032.txt
··· 20 20 21 21 - link-frequencies: List of allowed link frequencies in Hz. Each frequency is 22 22 expressed as a 64-bit big-endian integer. 23 + - reset-gpios: GPIO handle which is connected to the reset pin of the chip. 24 + - standby-gpios: GPIO handle which is connected to the standby pin of the chip. 23 25 24 26 For further reading on port node refer to 25 27 Documentation/devicetree/bindings/media/video-interfaces.txt.
+28
drivers/media/i2c/mt9v032.c
··· 14 14 15 15 #include <linux/clk.h> 16 16 #include <linux/delay.h> 17 + #include <linux/gpio/consumer.h> 17 18 #include <linux/i2c.h> 18 19 #include <linux/log2.h> 19 20 #include <linux/mutex.h> ··· 252 251 253 252 struct regmap *regmap; 254 253 struct clk *clk; 254 + struct gpio_desc *reset_gpio; 255 + struct gpio_desc *standby_gpio; 255 256 256 257 struct mt9v032_platform_data *pdata; 257 258 const struct mt9v032_model_info *model; ··· 315 312 struct regmap *map = mt9v032->regmap; 316 313 int ret; 317 314 315 + if (mt9v032->reset_gpio) 316 + gpiod_set_value_cansleep(mt9v032->reset_gpio, 1); 317 + 318 318 ret = clk_set_rate(mt9v032->clk, mt9v032->sysclk); 319 319 if (ret < 0) 320 320 return ret; 321 321 322 + /* System clock has to be enabled before releasing the reset */ 322 323 ret = clk_prepare_enable(mt9v032->clk); 323 324 if (ret) 324 325 return ret; 325 326 326 327 udelay(1); 328 + 329 + if (mt9v032->reset_gpio) { 330 + gpiod_set_value_cansleep(mt9v032->reset_gpio, 0); 331 + 332 + /* After releasing reset we need to wait 10 clock cycles 333 + * before accessing the sensor over I2C. As the minimum SYSCLK 334 + * frequency is 13MHz, waiting 1µs will be enough in the worst 335 + * case. 336 + */ 337 + udelay(1); 338 + } 327 339 328 340 /* Reset the chip and stop data read out */ 329 341 ret = regmap_write(map, MT9V032_RESET, 1); ··· 971 953 mt9v032->clk = devm_clk_get(&client->dev, NULL); 972 954 if (IS_ERR(mt9v032->clk)) 973 955 return PTR_ERR(mt9v032->clk); 956 + 957 + mt9v032->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", 958 + GPIOD_OUT_HIGH); 959 + if (IS_ERR(mt9v032->reset_gpio)) 960 + return PTR_ERR(mt9v032->reset_gpio); 961 + 962 + mt9v032->standby_gpio = devm_gpiod_get_optional(&client->dev, "standby", 963 + GPIOD_OUT_LOW); 964 + if (IS_ERR(mt9v032->standby_gpio)) 965 + return PTR_ERR(mt9v032->standby_gpio); 974 966 975 967 mutex_init(&mt9v032->power_lock); 976 968 mt9v032->pdata = pdata;