Commit d0fbdcbe authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

media: ccs: Request for "reset" GPIO

The DT bindings documented "reset-gpios" property but the driver never
made use of it. Instead it used a GPIO called "xshutdown", with apprently
wrong polarity.

Fix this by requesting "reset" GPIO with the right polarity first, and if
that fails, then request "xshutdown" GPIO with the old polarity. This way
it works for new users as expected while if someone, somewhere, depended
on "xshutdown" GPIO, that continues to work as well.
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent aab402ea
...@@ -1295,6 +1295,7 @@ static int ccs_power_on(struct device *dev) ...@@ -1295,6 +1295,7 @@ static int ccs_power_on(struct device *dev)
} }
usleep_range(1000, 1000); usleep_range(1000, 1000);
gpiod_set_value(sensor->reset, 0);
gpiod_set_value(sensor->xshutdown, 1); gpiod_set_value(sensor->xshutdown, 1);
sleep = SMIAPP_RESET_DELAY(sensor->hwcfg->ext_clk); sleep = SMIAPP_RESET_DELAY(sensor->hwcfg->ext_clk);
...@@ -1381,6 +1382,7 @@ static int ccs_power_on(struct device *dev) ...@@ -1381,6 +1382,7 @@ static int ccs_power_on(struct device *dev)
return 0; return 0;
out_cci_addr_fail: out_cci_addr_fail:
gpiod_set_value(sensor->reset, 1);
gpiod_set_value(sensor->xshutdown, 0); gpiod_set_value(sensor->xshutdown, 0);
clk_disable_unprepare(sensor->ext_clk); clk_disable_unprepare(sensor->ext_clk);
...@@ -1407,6 +1409,7 @@ static int ccs_power_off(struct device *dev) ...@@ -1407,6 +1409,7 @@ static int ccs_power_off(struct device *dev)
if (sensor->hwcfg->i2c_addr_alt) if (sensor->hwcfg->i2c_addr_alt)
ccs_write(sensor, SOFTWARE_RESET, CCS_SOFTWARE_RESET_ON); ccs_write(sensor, SOFTWARE_RESET, CCS_SOFTWARE_RESET_ON);
gpiod_set_value(sensor->reset, 1);
gpiod_set_value(sensor->xshutdown, 0); gpiod_set_value(sensor->xshutdown, 0);
clk_disable_unprepare(sensor->ext_clk); clk_disable_unprepare(sensor->ext_clk);
usleep_range(5000, 5000); usleep_range(5000, 5000);
...@@ -3008,8 +3011,15 @@ static int ccs_probe(struct i2c_client *client) ...@@ -3008,8 +3011,15 @@ static int ccs_probe(struct i2c_client *client)
return -EINVAL; return -EINVAL;
} }
sensor->xshutdown = devm_gpiod_get_optional(&client->dev, "xshutdown", sensor->reset = devm_gpiod_get_optional(&client->dev, "reset",
GPIOD_OUT_LOW); GPIOD_OUT_HIGH);
if (IS_ERR(sensor->reset))
return PTR_ERR(sensor->reset);
/* Support old users that may have used "xshutdown" property. */
if (!sensor->reset)
sensor->xshutdown = devm_gpiod_get_optional(&client->dev,
"xshutdown",
GPIOD_OUT_LOW);
if (IS_ERR(sensor->xshutdown)) if (IS_ERR(sensor->xshutdown))
return PTR_ERR(sensor->xshutdown); return PTR_ERR(sensor->xshutdown);
......
...@@ -219,6 +219,7 @@ struct ccs_sensor { ...@@ -219,6 +219,7 @@ struct ccs_sensor {
struct regulator *vana; struct regulator *vana;
struct clk *ext_clk; struct clk *ext_clk;
struct gpio_desc *xshutdown; struct gpio_desc *xshutdown;
struct gpio_desc *reset;
void *ccs_limits; void *ccs_limits;
u8 nbinning_subtypes; u8 nbinning_subtypes;
struct ccs_binning_subtype binning_subtypes[CCS_LIM_BINNING_SUB_TYPE_MAX_N + 1]; struct ccs_binning_subtype binning_subtypes[CCS_LIM_BINNING_SUB_TYPE_MAX_N + 1];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment