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

[media] mt9t001: Add clock support

The sensor needs a master clock, handle it explictly in the driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

authored by

Laurent Pinchart and committed by
Mauro Carvalho Chehab
b16fdd53 b2b3593e

+25 -2
+25 -2
drivers/media/i2c/mt9t001.c
··· 12 12 * published by the Free Software Foundation. 13 13 */ 14 14 15 + #include <linux/clk.h> 15 16 #include <linux/i2c.h> 16 17 #include <linux/log2.h> 17 18 #include <linux/module.h> ··· 119 118 struct v4l2_subdev subdev; 120 119 struct media_pad pad; 121 120 121 + struct clk *clk; 122 122 struct regulator_bulk_data regulators[2]; 123 123 124 124 struct mutex power_lock; /* lock to protect power_count */ ··· 191 189 192 190 static int mt9t001_power_on(struct mt9t001 *mt9t001) 193 191 { 192 + int ret; 193 + 194 194 /* Bring up the supplies */ 195 - return regulator_bulk_enable(ARRAY_SIZE(mt9t001->regulators), 196 - mt9t001->regulators); 195 + ret = regulator_bulk_enable(ARRAY_SIZE(mt9t001->regulators), 196 + mt9t001->regulators); 197 + if (ret < 0) 198 + return ret; 199 + 200 + /* Enable clock */ 201 + ret = clk_prepare_enable(mt9t001->clk); 202 + if (ret < 0) 203 + regulator_bulk_disable(ARRAY_SIZE(mt9t001->regulators), 204 + mt9t001->regulators); 205 + 206 + return ret; 197 207 } 198 208 199 209 static void mt9t001_power_off(struct mt9t001 *mt9t001) 200 210 { 201 211 regulator_bulk_disable(ARRAY_SIZE(mt9t001->regulators), 202 212 mt9t001->regulators); 213 + 214 + clk_disable_unprepare(mt9t001->clk); 215 + } 203 216 204 217 static int __mt9t001_set_power(struct mt9t001 *mt9t001, bool on) 205 218 { ··· 869 852 if (ret < 0) { 870 853 dev_err(&client->dev, "Unable to get regulators\n"); 871 854 return ret; 855 + } 856 + 857 + mt9t001->clk = devm_clk_get(&client->dev, NULL); 858 + if (IS_ERR(mt9t001->clk)) { 859 + dev_err(&client->dev, "Unable to get clock\n"); 860 + return PTR_ERR(mt9t001->clk); 872 861 } 873 862 874 863 v4l2_ctrl_handler_init(&mt9t001->ctrls, ARRAY_SIZE(mt9t001_ctrls) +