summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2016-08-13 12:46:50 -0300
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-09-05 15:52:33 -0300
commit567716c5817cbcc482f70724d7f98aa6702c6e4c (patch)
tree8596e85b67bd2c5a9fc9b76af69b8c2fddc8df0f
parent7374300191c862a785dbf4c5f3d7b52ee00c7b45 (diff)
[media] smiapp: Switch to gpiod API for GPIO control
Switch from the old gpio API to the new descriptor based gpiod API. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Sebastian Reichel <sre@kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r--drivers/media/i2c/smiapp/smiapp-core.c36
-rw-r--r--drivers/media/i2c/smiapp/smiapp.h1
-rw-r--r--include/media/i2c/smiapp.h3
3 files changed, 12 insertions, 28 deletions
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index 103e33583f68..061f44a611c1 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -24,8 +24,8 @@
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/module.h>
-#include <linux/of_gpio.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#include <linux/smiapp.h>
@@ -1212,8 +1212,7 @@ static int smiapp_power_on(struct smiapp_sensor *sensor)
}
usleep_range(1000, 1000);
- if (gpio_is_valid(sensor->hwcfg->xshutdown))
- gpio_set_value(sensor->hwcfg->xshutdown, 1);
+ gpiod_set_value(sensor->xshutdown, 1);
sleep = SMIAPP_RESET_DELAY(sensor->hwcfg->ext_clk);
usleep_range(sleep, sleep);
@@ -1322,8 +1321,7 @@ static int smiapp_power_on(struct smiapp_sensor *sensor)
return 0;
out_cci_addr_fail:
- if (gpio_is_valid(sensor->hwcfg->xshutdown))
- gpio_set_value(sensor->hwcfg->xshutdown, 0);
+ gpiod_set_value(sensor->xshutdown, 0);
if (sensor->hwcfg->set_xclk)
sensor->hwcfg->set_xclk(&sensor->src->sd, 0);
else
@@ -1348,8 +1346,7 @@ static void smiapp_power_off(struct smiapp_sensor *sensor)
SMIAPP_REG_U8_SOFTWARE_RESET,
SMIAPP_SOFTWARE_RESET);
- if (gpio_is_valid(sensor->hwcfg->xshutdown))
- gpio_set_value(sensor->hwcfg->xshutdown, 0);
+ gpiod_set_value(sensor->xshutdown, 0);
if (sensor->hwcfg->set_xclk)
sensor->hwcfg->set_xclk(&sensor->src->sd, 0);
else
@@ -2572,17 +2569,10 @@ static int smiapp_init(struct smiapp_sensor *sensor)
}
}
- if (gpio_is_valid(sensor->hwcfg->xshutdown)) {
- rval = devm_gpio_request_one(
- &client->dev, sensor->hwcfg->xshutdown, 0,
- "SMIA++ xshutdown");
- if (rval < 0) {
- dev_err(&client->dev,
- "unable to acquire reset gpio %d\n",
- sensor->hwcfg->xshutdown);
- return rval;
- }
- }
+ sensor->xshutdown = devm_gpiod_get_optional(&client->dev, "xshutdown",
+ GPIOD_OUT_LOW);
+ if (IS_ERR(sensor->xshutdown))
+ return PTR_ERR(sensor->xshutdown);
rval = smiapp_power_on(sensor);
if (rval)
@@ -3020,9 +3010,6 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)
hwcfg->lanes = bus_cfg->bus.mipi_csi2.num_data_lanes;
dev_dbg(dev, "lanes %u\n", hwcfg->lanes);
- /* xshutdown GPIO is optional */
- hwcfg->xshutdown = of_get_named_gpio(dev->of_node, "reset-gpios", 0);
-
/* NVM size is not mandatory */
of_property_read_u32(dev->of_node, "nokia,nvm-size",
&hwcfg->nvm_size);
@@ -3034,8 +3021,8 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)
goto out_err;
}
- dev_dbg(dev, "reset %d, nvm %d, clk %d, csi %d\n", hwcfg->xshutdown,
- hwcfg->nvm_size, hwcfg->ext_clk, hwcfg->csi_signalling_mode);
+ dev_dbg(dev, "nvm %d, clk %d, csi %d\n", hwcfg->nvm_size,
+ hwcfg->ext_clk, hwcfg->csi_signalling_mode);
if (!bus_cfg->nr_of_link_frequencies) {
dev_warn(dev, "no link frequencies defined\n");
@@ -3120,8 +3107,7 @@ static int smiapp_remove(struct i2c_client *client)
v4l2_async_unregister_subdev(subdev);
if (sensor->power_count) {
- if (gpio_is_valid(sensor->hwcfg->xshutdown))
- gpio_set_value(sensor->hwcfg->xshutdown, 0);
+ gpiod_set_value(sensor->xshutdown, 0);
if (sensor->hwcfg->set_xclk)
sensor->hwcfg->set_xclk(&sensor->src->sd, 0);
else
diff --git a/drivers/media/i2c/smiapp/smiapp.h b/drivers/media/i2c/smiapp/smiapp.h
index 6ff095ae5faf..c504bd8f36b8 100644
--- a/drivers/media/i2c/smiapp/smiapp.h
+++ b/drivers/media/i2c/smiapp/smiapp.h
@@ -200,6 +200,7 @@ struct smiapp_sensor {
struct smiapp_hwconfig *hwcfg;
struct regulator *vana;
struct clk *ext_clk;
+ struct gpio_desc *xshutdown;
u32 limits[SMIAPP_LIMIT_LAST];
u8 nbinning_subtypes;
struct smiapp_binning_subtype binning_subtypes[SMIAPP_BINNING_SUBTYPES];
diff --git a/include/media/i2c/smiapp.h b/include/media/i2c/smiapp.h
index a4a1b510c9d3..eacc3f4e3deb 100644
--- a/include/media/i2c/smiapp.h
+++ b/include/media/i2c/smiapp.h
@@ -36,8 +36,6 @@
#define SMIAPP_CSI_SIGNALLING_MODE_CCP2_DATA_STROBE 1
#define SMIAPP_CSI_SIGNALLING_MODE_CSI2 2
-#define SMIAPP_NO_XSHUTDOWN -1
-
/*
* Sometimes due to board layout considerations the camera module can be
* mounted rotated. The typical rotation used is 180 degrees which can be
@@ -77,7 +75,6 @@ struct smiapp_hwconfig {
struct smiapp_flash_strobe_parms *strobe_setup;
int (*set_xclk)(struct v4l2_subdev *sd, int hz);
- int32_t xshutdown; /* gpio or SMIAPP_NO_XSHUTDOWN */
};
#endif /* __SMIAPP_H_ */