Skip to content

Commit bc1e051

Browse files
Ibrahim AbdalkaderChromeos LUCI
authored andcommitted
drivers: video: gc2145: Add support for a PWDN pin.
Add support for power-down pin. Some modules require this pin to enable the power supply. (cherry picked from commit 2a6e590) Original-Signed-off-by: Ibrahim Abdalkader <[email protected]> GitOrigin-RevId: 2a6e590 Cr-Build-Id: 8725452993329915921 Cr-Build-Url: https://cr-buildbucket.appspot.com/build/8725452993329915921 Copybot-Job-Name: zephyr-main-copybot-downstream Change-Id: Ib075384e89ce3a04f013bf691cf7bf9b0eb9e6ad Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/6183333 Commit-Queue: Jonathon Murphy <[email protected]> Reviewed-by: Jonathon Murphy <[email protected]> Tested-by: ChromeOS Prod (Robot) <[email protected]>
1 parent 2ac59a7 commit bc1e051

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

drivers/video/gc2145.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,9 @@ static const struct gc2145_reg default_regs[] = {
681681

682682
struct gc2145_config {
683683
struct i2c_dt_spec i2c;
684+
#if DT_INST_NODE_HAS_PROP(0, pwdn_gpios)
685+
struct gpio_dt_spec pwdn_gpio;
686+
#endif
684687
#if DT_INST_NODE_HAS_PROP(0, reset_gpios)
685688
struct gpio_dt_spec reset_gpio;
686689
#endif
@@ -1126,10 +1129,18 @@ static int gc2145_init(const struct device *dev)
11261129
{
11271130
struct video_format fmt;
11281131
int ret;
1129-
1130-
#if DT_INST_NODE_HAS_PROP(0, reset_gpios)
11311132
const struct gc2145_config *cfg = dev->config;
1133+
(void) cfg;
1134+
1135+
#if DT_INST_NODE_HAS_PROP(0, pwdn_gpios)
1136+
ret = gpio_pin_configure_dt(&cfg->pwdn_gpio, GPIO_OUTPUT_INACTIVE);
1137+
if (ret) {
1138+
return ret;
1139+
}
11321140

1141+
k_sleep(K_MSEC(10));
1142+
#endif
1143+
#if DT_INST_NODE_HAS_PROP(0, reset_gpios)
11331144
ret = gpio_pin_configure_dt(&cfg->reset_gpio, GPIO_OUTPUT_ACTIVE);
11341145
if (ret) {
11351146
return ret;
@@ -1166,6 +1177,9 @@ static int gc2145_init(const struct device *dev)
11661177
/* Unique Instance */
11671178
static const struct gc2145_config gc2145_cfg_0 = {
11681179
.i2c = I2C_DT_SPEC_INST_GET(0),
1180+
#if DT_INST_NODE_HAS_PROP(0, pwdn_gpios)
1181+
.pwdn_gpio = GPIO_DT_SPEC_INST_GET(0, pwdn_gpios),
1182+
#endif
11691183
#if DT_INST_NODE_HAS_PROP(0, reset_gpios)
11701184
.reset_gpio = GPIO_DT_SPEC_INST_GET(0, reset_gpios),
11711185
#endif
@@ -1181,6 +1195,12 @@ static int gc2145_init_0(const struct device *dev)
11811195
return -ENODEV;
11821196
}
11831197

1198+
#if DT_INST_NODE_HAS_PROP(0, pwdn_gpios)
1199+
if (!gpio_is_ready_dt(&cfg->pwdn_gpio)) {
1200+
LOG_ERR("%s: device %s is not ready", dev->name, cfg->pwdn_gpio.port->name);
1201+
return -ENODEV;
1202+
}
1203+
#endif
11841204
#if DT_INST_NODE_HAS_PROP(0, reset_gpios)
11851205
if (!gpio_is_ready_dt(&cfg->reset_gpio)) {
11861206
LOG_ERR("%s: device %s is not ready", dev->name, cfg->reset_gpio.port->name);

dts/bindings/video/galaxycore,gc2145.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ properties:
1313
description: |
1414
The RESETn pin is asserted to disable the sensor causing a hard
1515
reset. The sensor receives this as an active-low signal.
16+
pwdn-gpios:
17+
type: phandle-array
18+
description: |
19+
The PWDN pin is asserted to power down the sensor. The sensor
20+
receives this as an active high signal

0 commit comments

Comments
 (0)