summaryrefslogtreecommitdiff
path: root/include/usb_pd_flags.h
diff options
context:
space:
mode:
authorParth Malkan <parthmalkan@google.com>2021-08-10 21:54:59 +0000
committerCommit Bot <commit-bot@chromium.org>2021-09-24 22:54:51 +0000
commit06d89b033065d9c96f4a6e53129b22b912fae224 (patch)
tree34c7038c6fe35b915db34d42aa7112be5a5e095f /include/usb_pd_flags.h
parentd4938b281fede972db577180efb791a47c47140b (diff)
downloadchrome-ec-06d89b033065d9c96f4a6e53129b22b912fae224.tar.gz
SSFC: Framework to support two charger sources
Many platforms have requirements to support more than one charge source (eg. pirika). It can't be supported by just enabling two different CONFIGS as that can lead to conflicts. Eg.USD_PD_VBUS_DETECT_TCPC vs USB_PD_VBUS_DETECT_DISCHARGE. This change provides a framework that supports two different charger sources in the same build. Please see the CL for relevant logs. BRANCH=None BUG=b:194375840 TEST=make -j buildall Signed-off-by: Parth Malkan <parthmalkan@google.com> Change-Id: I309cc5930233983e615d90a4290fc749abf7aa2d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3088232 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'include/usb_pd_flags.h')
-rw-r--r--include/usb_pd_flags.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/include/usb_pd_flags.h b/include/usb_pd_flags.h
new file mode 100644
index 0000000000..71932de885
--- /dev/null
+++ b/include/usb_pd_flags.h
@@ -0,0 +1,88 @@
+/* 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.
+ */
+
+/*
+ * Contains USB PD flags definition and accessors
+ */
+#ifndef __CROS_EC_USB_PD_FLAGS_H
+#define __CROS_EC_USB_PD_FLAGS_H
+
+#include "stdint.h"
+
+/*
+ * USB PD VBUS detect (0-2)
+ */
+enum usb_pd_vbus_detect {
+ USB_PD_VBUS_DETECT_NONE = 0,
+ USB_PD_VBUS_DETECT_TCPC = 1,
+ USB_PD_VBUS_DETECT_GPIO = 2,
+ USB_PD_VBUS_DETECT_PPC = 3,
+ USB_PD_VBUS_DETECT_CHARGER = 4
+};
+
+/*
+ * USB PD DISCHARGE (Bits 3-4)
+ */
+enum usb_pd_discharge {
+ USB_PD_DISCHARGE_NONE = 0,
+ USB_PD_DISCHARGE_TCPC = 1,
+ USB_PD_DISCHARGE_GPIO = 2,
+ USB_PD_DISCHARGE_PPC = 3
+};
+
+/*
+ * USB PD Charger OTG (Bit 5)
+ */
+enum usb_pd_charger_otg {
+ USB_PD_CHARGER_OTG_DISABLED = 0,
+ USB_PD_CHARGER_OTG_ENABLED = 1
+};
+
+union usb_pd_runtime_flags {
+ struct {
+ enum usb_pd_vbus_detect vbus_detect : 3;
+ enum usb_pd_discharge discharge : 2;
+ enum usb_pd_charger_otg charger_otg : 1;
+ uint32_t reserved : 26;
+ };
+ uint32_t raw_value;
+};
+
+/**
+ * Set VBUS detect type from USB_PD_FLAGS.
+ */
+void set_usb_pd_vbus_detect(enum usb_pd_vbus_detect vbus_detect);
+
+/**
+ * Get VBUS detect type from USB_PD_FLAGS.
+ *
+ * @return the VBUS detect type.
+ */
+enum usb_pd_vbus_detect get_usb_pd_vbus_detect(void);
+
+/**
+ * Set USB PD discharge type from USB_PD_FLAGS.
+ */
+void set_usb_pd_discharge(enum usb_pd_discharge discharge);
+
+/**
+ * Get USB PD discharge type from USB_PD_FLAGS.
+ *
+ * @return the USB PD discharge type.
+ */
+enum usb_pd_discharge get_usb_pd_discharge(void);
+
+/**
+ * Set USB PD charger OTG from USB_PD_FLAGS.
+ */
+void set_usb_pd_charger_otg(enum usb_pd_charger_otg charger_otg);
+
+/**
+ * Get USB PD charger OTG from USB_PD_FLAGS.
+ *
+ * @return the USB PD charger OTG.
+ */
+enum usb_pd_charger_otg get_usb_pd_charger_otg(void);
+#endif /* __CROS_EC_USB_PD_FLAGS_H */