Skip to content

Commit

Permalink
drivers: video: gc2145: Add support for a PWDN pin.
Browse files Browse the repository at this point in the history
Add support for power-down pin. Some modules require this pin
to enable the power supply.

Signed-off-by: Ibrahim Abdalkader <[email protected]>
  • Loading branch information
iabdalkader authored and kartben committed Jan 17, 2025
1 parent 8f83267 commit 2a6e590
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
24 changes: 22 additions & 2 deletions drivers/video/gc2145.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,9 @@ static const struct gc2145_reg default_regs[] = {

struct gc2145_config {
struct i2c_dt_spec i2c;
#if DT_INST_NODE_HAS_PROP(0, pwdn_gpios)
struct gpio_dt_spec pwdn_gpio;
#endif
#if DT_INST_NODE_HAS_PROP(0, reset_gpios)
struct gpio_dt_spec reset_gpio;
#endif
Expand Down Expand Up @@ -1126,10 +1129,18 @@ static int gc2145_init(const struct device *dev)
{
struct video_format fmt;
int ret;

#if DT_INST_NODE_HAS_PROP(0, reset_gpios)
const struct gc2145_config *cfg = dev->config;
(void) cfg;

#if DT_INST_NODE_HAS_PROP(0, pwdn_gpios)
ret = gpio_pin_configure_dt(&cfg->pwdn_gpio, GPIO_OUTPUT_INACTIVE);
if (ret) {
return ret;
}

k_sleep(K_MSEC(10));
#endif
#if DT_INST_NODE_HAS_PROP(0, reset_gpios)
ret = gpio_pin_configure_dt(&cfg->reset_gpio, GPIO_OUTPUT_ACTIVE);
if (ret) {
return ret;
Expand Down Expand Up @@ -1166,6 +1177,9 @@ static int gc2145_init(const struct device *dev)
/* Unique Instance */
static const struct gc2145_config gc2145_cfg_0 = {
.i2c = I2C_DT_SPEC_INST_GET(0),
#if DT_INST_NODE_HAS_PROP(0, pwdn_gpios)
.pwdn_gpio = GPIO_DT_SPEC_INST_GET(0, pwdn_gpios),
#endif
#if DT_INST_NODE_HAS_PROP(0, reset_gpios)
.reset_gpio = GPIO_DT_SPEC_INST_GET(0, reset_gpios),
#endif
Expand All @@ -1181,6 +1195,12 @@ static int gc2145_init_0(const struct device *dev)
return -ENODEV;
}

#if DT_INST_NODE_HAS_PROP(0, pwdn_gpios)
if (!gpio_is_ready_dt(&cfg->pwdn_gpio)) {
LOG_ERR("%s: device %s is not ready", dev->name, cfg->pwdn_gpio.port->name);
return -ENODEV;
}
#endif
#if DT_INST_NODE_HAS_PROP(0, reset_gpios)
if (!gpio_is_ready_dt(&cfg->reset_gpio)) {
LOG_ERR("%s: device %s is not ready", dev->name, cfg->reset_gpio.port->name);
Expand Down
5 changes: 5 additions & 0 deletions dts/bindings/video/galaxycore,gc2145.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ properties:
description: |
The RESETn pin is asserted to disable the sensor causing a hard
reset. The sensor receives this as an active-low signal.
pwdn-gpios:
type: phandle-array
description: |
The PWDN pin is asserted to power down the sensor. The sensor
receives this as an active high signal

0 comments on commit 2a6e590

Please sign in to comment.