diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2014-09-20 17:38:56 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-04-02 20:29:56 -0400 |
commit | 7c3be9f812be6c2466ecb705200fc13cc34caa9c (patch) | |
tree | 8a9511b18f1844e598fc55dd208e9d642bb4d1ab /drivers/media/i2c | |
parent | 9012d0888c8fc473d5760f2367b002dfddee80f9 (diff) |
[media] v4l: mt9p031: Convert to the gpiod API
This simplifies platform data and DT integration.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/i2c')
-rw-r--r-- | drivers/media/i2c/mt9p031.c | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c index 9258d048a1e3..0db15f528ac1 100644 --- a/drivers/media/i2c/mt9p031.c +++ b/drivers/media/i2c/mt9p031.c | |||
@@ -15,12 +15,11 @@ | |||
15 | #include <linux/clk.h> | 15 | #include <linux/clk.h> |
16 | #include <linux/delay.h> | 16 | #include <linux/delay.h> |
17 | #include <linux/device.h> | 17 | #include <linux/device.h> |
18 | #include <linux/gpio.h> | 18 | #include <linux/gpio/consumer.h> |
19 | #include <linux/i2c.h> | 19 | #include <linux/i2c.h> |
20 | #include <linux/log2.h> | 20 | #include <linux/log2.h> |
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | #include <linux/of.h> | 22 | #include <linux/of.h> |
23 | #include <linux/of_gpio.h> | ||
24 | #include <linux/of_graph.h> | 23 | #include <linux/of_graph.h> |
25 | #include <linux/pm.h> | 24 | #include <linux/pm.h> |
26 | #include <linux/regulator/consumer.h> | 25 | #include <linux/regulator/consumer.h> |
@@ -136,7 +135,7 @@ struct mt9p031 { | |||
136 | struct aptina_pll pll; | 135 | struct aptina_pll pll; |
137 | unsigned int clk_div; | 136 | unsigned int clk_div; |
138 | bool use_pll; | 137 | bool use_pll; |
139 | int reset; | 138 | struct gpio_desc *reset; |
140 | 139 | ||
141 | struct v4l2_ctrl_handler ctrls; | 140 | struct v4l2_ctrl_handler ctrls; |
142 | struct v4l2_ctrl *blc_auto; | 141 | struct v4l2_ctrl *blc_auto; |
@@ -309,9 +308,9 @@ static int mt9p031_power_on(struct mt9p031 *mt9p031) | |||
309 | { | 308 | { |
310 | int ret; | 309 | int ret; |
311 | 310 | ||
312 | /* Ensure RESET_BAR is low */ | 311 | /* Ensure RESET_BAR is active */ |
313 | if (gpio_is_valid(mt9p031->reset)) { | 312 | if (mt9p031->reset) { |
314 | gpio_set_value(mt9p031->reset, 0); | 313 | gpiod_set_value(mt9p031->reset, 1); |
315 | usleep_range(1000, 2000); | 314 | usleep_range(1000, 2000); |
316 | } | 315 | } |
317 | 316 | ||
@@ -332,8 +331,8 @@ static int mt9p031_power_on(struct mt9p031 *mt9p031) | |||
332 | } | 331 | } |
333 | 332 | ||
334 | /* Now RESET_BAR must be high */ | 333 | /* Now RESET_BAR must be high */ |
335 | if (gpio_is_valid(mt9p031->reset)) { | 334 | if (mt9p031->reset) { |
336 | gpio_set_value(mt9p031->reset, 1); | 335 | gpiod_set_value(mt9p031->reset, 0); |
337 | usleep_range(1000, 2000); | 336 | usleep_range(1000, 2000); |
338 | } | 337 | } |
339 | 338 | ||
@@ -342,8 +341,8 @@ static int mt9p031_power_on(struct mt9p031 *mt9p031) | |||
342 | 341 | ||
343 | static void mt9p031_power_off(struct mt9p031 *mt9p031) | 342 | static void mt9p031_power_off(struct mt9p031 *mt9p031) |
344 | { | 343 | { |
345 | if (gpio_is_valid(mt9p031->reset)) { | 344 | if (mt9p031->reset) { |
346 | gpio_set_value(mt9p031->reset, 0); | 345 | gpiod_set_value(mt9p031->reset, 1); |
347 | usleep_range(1000, 2000); | 346 | usleep_range(1000, 2000); |
348 | } | 347 | } |
349 | 348 | ||
@@ -1023,7 +1022,6 @@ mt9p031_get_pdata(struct i2c_client *client) | |||
1023 | if (!pdata) | 1022 | if (!pdata) |
1024 | goto done; | 1023 | goto done; |
1025 | 1024 | ||
1026 | pdata->reset = of_get_named_gpio(client->dev.of_node, "reset-gpios", 0); | ||
1027 | of_property_read_u32(np, "input-clock-frequency", &pdata->ext_freq); | 1025 | of_property_read_u32(np, "input-clock-frequency", &pdata->ext_freq); |
1028 | of_property_read_u32(np, "pixel-clock-frequency", &pdata->target_freq); | 1026 | of_property_read_u32(np, "pixel-clock-frequency", &pdata->target_freq); |
1029 | 1027 | ||
@@ -1060,7 +1058,6 @@ static int mt9p031_probe(struct i2c_client *client, | |||
1060 | mt9p031->output_control = MT9P031_OUTPUT_CONTROL_DEF; | 1058 | mt9p031->output_control = MT9P031_OUTPUT_CONTROL_DEF; |
1061 | mt9p031->mode2 = MT9P031_READ_MODE_2_ROW_BLC; | 1059 | mt9p031->mode2 = MT9P031_READ_MODE_2_ROW_BLC; |
1062 | mt9p031->model = did->driver_data; | 1060 | mt9p031->model = did->driver_data; |
1063 | mt9p031->reset = -1; | ||
1064 | 1061 | ||
1065 | mt9p031->regulators[0].supply = "vdd"; | 1062 | mt9p031->regulators[0].supply = "vdd"; |
1066 | mt9p031->regulators[1].supply = "vdd_io"; | 1063 | mt9p031->regulators[1].supply = "vdd_io"; |
@@ -1136,14 +1133,8 @@ static int mt9p031_probe(struct i2c_client *client, | |||
1136 | mt9p031->format.field = V4L2_FIELD_NONE; | 1133 | mt9p031->format.field = V4L2_FIELD_NONE; |
1137 | mt9p031->format.colorspace = V4L2_COLORSPACE_SRGB; | 1134 | mt9p031->format.colorspace = V4L2_COLORSPACE_SRGB; |
1138 | 1135 | ||
1139 | if (gpio_is_valid(pdata->reset)) { | 1136 | mt9p031->reset = devm_gpiod_get_optional(&client->dev, "reset", |
1140 | ret = devm_gpio_request_one(&client->dev, pdata->reset, | 1137 | GPIOD_OUT_HIGH); |
1141 | GPIOF_OUT_INIT_LOW, "mt9p031_rst"); | ||
1142 | if (ret < 0) | ||
1143 | goto done; | ||
1144 | |||
1145 | mt9p031->reset = pdata->reset; | ||
1146 | } | ||
1147 | 1138 | ||
1148 | ret = mt9p031_clk_setup(mt9p031); | 1139 | ret = mt9p031_clk_setup(mt9p031); |
1149 | if (ret) | 1140 | if (ret) |