diff options
author | ben chen <ben.chen2@quanta.corp-partner.google.com> | 2023-02-04 10:58:38 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-02-15 03:15:20 +0000 |
commit | 50e534a5c04e92405b07fb12d333415ab7785228 (patch) | |
tree | 95a286c2b0d6a908fdf5c069ec0ade2825da82a8 | |
parent | beee9887df7bcbe30d4558644f89c8946e897f32 (diff) | |
download | chrome-ec-50e534a5c04e92405b07fb12d333415ab7785228.tar.gz |
peripheral_charger: Add board_get_pchg_count(void) declaration
Some hardware skus may not have peripheral charger but share the
same EC firmware, add board_get_pchg_count(void), and in each board
implement the int board_get_pchg_count(void) to allow charger count
to be determined at runtime.
BUG=b:267700817
BRANCH=None
TEST=make BOARD PASS
Cq-Depend:chromium:4248459
Cq-Depend:chromium:4248823
Change-Id: I62f37a9e39da7b8949ba59c314987e9d80835710
Signed-off-by: Ben Chen <ben.chen2@quanta.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4218552
Commit-Queue: Derek Huang <derekhuang@google.com>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: caveh jalali <caveh@chromium.org>
-rw-r--r-- | common/peripheral_charger.c | 4 | ||||
-rw-r--r-- | include/peripheral_charger.h | 6 |
2 files changed, 9 insertions, 1 deletions
diff --git a/common/peripheral_charger.c b/common/peripheral_charger.c index bf139c1688..9e73100db1 100644 --- a/common/peripheral_charger.c +++ b/common/peripheral_charger.c @@ -26,6 +26,8 @@ static struct queue const host_events = QUEUE_NULL(PCHG_EVENT_QUEUE_SIZE, uint32_t); struct mutex host_event_mtx; +static int pchg_count; + /* * Events and errors to be reported to the host in each chipset state. * @@ -778,6 +780,8 @@ static void pchg_startup(void) CPRINTS("%s", __func__); queue_init(&host_events); + pchg_count = board_get_pchg_count(); + for (p = 0; p < pchg_count; p++) { rv = EC_SUCCESS; ctx = &pchgs[p]; diff --git a/include/peripheral_charger.h b/include/peripheral_charger.h index e4b4993d47..bb27a1207d 100644 --- a/include/peripheral_charger.h +++ b/include/peripheral_charger.h @@ -343,7 +343,6 @@ struct pchg_drv { * Should be defined in board.c. */ extern struct pchg pchgs[]; -extern const int pchg_count; /* Utility macro converting port config to port number. */ #define PCHG_CTX_TO_PORT(ctx) ((ctx) - &pchgs[0]) @@ -368,4 +367,9 @@ void pchg_task(void *u); */ __override_proto void board_pchg_power_on(int port, bool on); +/** + * Return counts for PCHG charger. + */ +int board_get_pchg_count(void); + #endif /* __CROS_EC_PERIPHERAL_CHARGER_H */ |