summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2017-10-11 13:59:10 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-10-17 11:07:44 -0700
commit33ec4ae3bc4a6c08e78fa6039b8f424627560bdc (patch)
tree236e714ac88b4c9e8c7065f337c3d8ef681b000c
parentebcbc5d5f284aacae3a09c12d426bc5187db4f27 (diff)
downloadchrome-ec-33ec4ae3bc4a6c08e78fa6039b8f424627560bdc.tar.gz
charge_manager: Support no-battery / no-host boards
Boards without batteries and/or without host command support may wish to use charge_manager. BUG=chromium:769895 BRANCH=None TEST=`make buildall -j` Change-Id: I2455528de3300a0651791752a05409c888b5f2a3 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/713943 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--common/charge_manager.c8
-rw-r--r--include/usb_pd.h4
-rw-r--r--test/test_config.h22
3 files changed, 22 insertions, 12 deletions
diff --git a/common/charge_manager.c b/common/charge_manager.c
index 50d7d3b8e0..9f4c776159 100644
--- a/common/charge_manager.c
+++ b/common/charge_manager.c
@@ -124,6 +124,7 @@ static int is_connected(int port)
* @return 1 when we need to override the a non-dedicated charger
* to be a dedicated one, 0 otherwise.
*/
+#ifdef CONFIG_BATTERY
static int charge_manager_spoof_dualrole_capability(void)
{
int spoof_dualrole = (system_get_image_copy() == SYSTEM_IMAGE_RO &&
@@ -135,6 +136,13 @@ static int charge_manager_spoof_dualrole_capability(void)
#endif
return spoof_dualrole;
}
+#else /* CONFIG_BATTERY */
+/* No battery, so always charge from input port. */
+static inline int charge_manager_spoof_dualrole_capability(void)
+{
+ return 1;
+}
+#endif /* CONFIG_BATTERY */
/**
* Initialize available charge. Run before board init, so board init can
diff --git a/include/usb_pd.h b/include/usb_pd.h
index 9deed54b88..816fe15517 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -1271,7 +1271,11 @@ extern const int pd_snk_pdo_cnt;
*
* @param mask host event mask.
*/
+#if defined(HAS_TASK_HOSTCMD) && !defined(TEST_BUILD)
void pd_send_host_event(int mask);
+#else
+static inline void pd_send_host_event(int mask) { }
+#endif
/**
* Determine if in alternate mode or not.
diff --git a/test/test_config.h b/test/test_config.h
index 61d04c0658..a912e08a0d 100644
--- a/test/test_config.h
+++ b/test/test_config.h
@@ -181,19 +181,22 @@ int ncp15wb_calculate_temp(uint16_t adc);
#endif
#endif /* TEST_USB_PD || TEST_USB_PD_GIVEBACK */
-#ifdef TEST_CHARGE_MANAGER
+#if defined(TEST_CHARGE_MANAGER) || defined(TEST_CHARGE_MANAGER_DRP_CHARGING)
#define CONFIG_CHARGE_MANAGER
-#undef CONFIG_CHARGE_MANAGER_DRP_CHARGING
#define CONFIG_USB_PD_DUAL_ROLE
#define CONFIG_USB_PD_PORT_COUNT 2
-#endif
+#define CONFIG_BATTERY
+#define CONFIG_BATTERY_SMART
+#define CONFIG_I2C
+#define CONFIG_I2C_MASTER
+#define I2C_PORT_BATTERY 0
+#endif /* TEST_CHARGE_MANAGER_* */
#ifdef TEST_CHARGE_MANAGER_DRP_CHARGING
-#define CONFIG_CHARGE_MANAGER
#define CONFIG_CHARGE_MANAGER_DRP_CHARGING
-#define CONFIG_USB_PD_DUAL_ROLE
-#define CONFIG_USB_PD_PORT_COUNT 2
-#endif
+#else
+#undef CONFIG_CHARGE_MANAGER_DRP_CHARGING
+#endif /* TEST_CHARGE_MANAGER_DRP_CHARGING */
#ifdef TEST_CHARGE_RAMP
#define CONFIG_CHARGE_RAMP_SW
@@ -275,10 +278,5 @@ enum nvmem_vars {
#define CONFIG_CURVE25519
#endif /* TEST_X25519 */
-#ifndef __ASSEMBLER__
-/* Callback function from charge_manager to send host event */
-static inline void pd_send_host_event(int mask) { }
-#endif
-
#endif /* TEST_BUILD */
#endif /* __TEST_TEST_CONFIG_H */