summaryrefslogtreecommitdiff
path: root/common/peripheral_charger.c
diff options
context:
space:
mode:
authorDerek Huang <derekhuang@google.com>2022-08-22 08:58:47 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-09-21 02:45:21 +0000
commitcbf2ab787e86524eed964923e54c833b584a814f (patch)
treed9a7a946c9d010af9bdea50c77a5516b62d7bd8d /common/peripheral_charger.c
parent242a8ecb5c720f6e008f3c1af9ab5703f15b6f13 (diff)
downloadchrome-ec-cbf2ab787e86524eed964923e54c833b584a814f.tar.gz
common/peripheral_charger.c: Refactor pchg_startup() function
pchg_startup() should do: 1. Disable irq. 2. Call reset(). 3. Call get_chip_info(). 4. Enable irq. BUG=b:239783274 BRANCH=None TEST=Check CPS8100 and CPS8200 wireless charger work on Brask. Signed-off-by: Derek Huang <derekhuang@google.com> Change-Id: Idf9ab7899ecd42e786c59bc5a153328b9e040b80 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3845339 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'common/peripheral_charger.c')
-rw-r--r--common/peripheral_charger.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/common/peripheral_charger.c b/common/peripheral_charger.c
index ad7e069e69..5767315a78 100644
--- a/common/peripheral_charger.c
+++ b/common/peripheral_charger.c
@@ -543,20 +543,33 @@ static void pchg_startup(void)
{
struct pchg *ctx;
int p;
+ int active_pchg_count = 0;
+ int rv;
CPRINTS("%s", __func__);
queue_init(&host_events);
for (p = 0; p < pchg_count; p++) {
+ rv = EC_SUCCESS;
ctx = &pchgs[p];
_clear_port(ctx);
ctx->mode = PCHG_MODE_NORMAL;
+ gpio_disable_interrupt(ctx->cfg->irq_pin);
board_pchg_power_on(p, 1);
ctx->cfg->drv->reset(ctx);
- gpio_enable_interrupt(ctx->cfg->irq_pin);
+ if (ctx->cfg->drv->get_chip_info)
+ rv = ctx->cfg->drv->get_chip_info(ctx);
+ if (rv == EC_SUCCESS) {
+ gpio_enable_interrupt(ctx->cfg->irq_pin);
+ active_pchg_count++;
+ } else {
+ CPRINTS("ERR: Failed to probe P%d", p);
+ board_pchg_power_on(p, 0);
+ }
}
- task_wake(TASK_ID_PCHG);
+ if (active_pchg_count)
+ task_wake(TASK_ID_PCHG);
}
DECLARE_HOOK(HOOK_CHIPSET_STARTUP, pchg_startup, HOOK_PRIO_DEFAULT);