summaryrefslogtreecommitdiff
path: root/zephyr/projects/nissa/src/charger.c
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/projects/nissa/src/charger.c')
-rw-r--r--zephyr/projects/nissa/src/charger.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/zephyr/projects/nissa/src/charger.c b/zephyr/projects/nissa/src/charger.c
new file mode 100644
index 0000000000..32dff4c403
--- /dev/null
+++ b/zephyr/projects/nissa/src/charger.c
@@ -0,0 +1,37 @@
+/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "battery.h"
+#include "charger.h"
+#include "charger/isl923x_public.h"
+#include "usb_pd.h"
+
+const struct charger_config_t chg_chips[] = {
+ {
+ .i2c_port = I2C_PORT_USB_C0_TCPC,
+ .i2c_addr_flags = ISL923X_ADDR_FLAGS,
+ .drv = &isl923x_drv,
+ },
+ /*
+ * TODO(b:212490923) port 1 is present on sub-boards 1 and 2 with same
+ * configuration as port 0 but on I2C_PORT_USB_C1_TCPC.
+ */
+};
+const unsigned int chg_cnt = ARRAY_SIZE(chg_chips);
+
+int extpower_is_present(void)
+{
+ int port;
+ int rv;
+ bool acok;
+
+ for (port = 0; port < board_get_usb_pd_port_count(); port++) {
+ rv = raa489000_is_acok(port, &acok);
+ if ((rv == EC_SUCCESS) && acok)
+ return 1;
+ }
+
+ return 0;
+}