diff options
author | Ting Shen <phoenixshen@google.com> | 2019-04-16 15:14:06 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-06-05 10:22:11 +0000 |
commit | 2b057f9c06e24f2a904c77ba03740701978e2290 (patch) | |
tree | 55175090df15e1ff3cf35e7c02e76048ae03f82b /include | |
parent | 03fdd40624e42fd9e156f76693f72d64bc509518 (diff) | |
download | chrome-ec-2b057f9c06e24f2a904c77ba03740701978e2290.tar.gz |
charge_manager: customize dedicated port properties
Kukui's pogo charger breaks the basic assumption of a dedicated charger.
Add board specific functions to customize them.
Also add a check to make sure the value of DEDICATED_CHARGE_PORT is good.
BUG=b:128386458
TEST=combine with CL:1535087, verify that `ectool usbpdpower 1`
correctly reports its status.
BRANCH=None
Change-Id: I6c698ea6a6fb4ab765f87c6fea0b35d5a757295a
Signed-off-by: Ting Shen <phoenixshen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1569090
Reviewed-by: Yilun Lin <yllin@chromium.org>
Tested-by: Ting Shen <phoenixshen@chromium.org>
Commit-Queue: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/charge_manager.h | 51 | ||||
-rw-r--r-- | include/config.h | 9 |
2 files changed, 57 insertions, 3 deletions
diff --git a/include/charge_manager.h b/include/charge_manager.h index 938d323fbd..a45b6d55d7 100644 --- a/include/charge_manager.h +++ b/include/charge_manager.h @@ -7,6 +7,7 @@ #define __CROS_EC_CHARGE_MANAGER_H #include "common.h" +#include "ec_commands.h" /* Charge port that indicates no active port */ #define CHARGE_PORT_NONE -1 @@ -114,10 +115,29 @@ enum ceil_requestor { #define CHARGE_PORT_COUNT \ (CONFIG_USB_PD_PORT_COUNT + CONFIG_DEDICATED_CHARGE_PORT_COUNT) -#if (CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0) && !defined(DEDICATED_CHARGE_PORT) +#if (CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0) + +/** + * By default, dedicated port has following properties: + * + * - dedicated port is sink only. + * - dedicated port is always connected. + * - dedicated port is given highest priority (supplier type is always + * CHARGE_SUPPLIER_DEDICATED). + * - dualrole capability of dedicated port is always CAP_DEDICATED. + * - there's only one dedicated port, its number is larger than PD port number. + * + * Sink property can be customized by implementing board_charge_port_is_sink() + * and board_fill_source_power_info(). + * Connected can be customized by implementing board_charge_port_is_connected(). + */ +#if !defined(DEDICATED_CHARGE_PORT) #error "DEDICATED_CHARGE_PORT must be defined" -#endif +#elif DEDICATED_CHARGE_PORT < CONFIG_USB_PD_PORT_COUNT +#error "DEDICATED_CHARGE_PORT must larger than pd port numbers" +#endif /* !defined(DEDICATED_CHARGE_PORT) */ +#endif /* CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0 */ /** * Update charge ceiling for a given port. The ceiling can be set independently @@ -250,4 +270,31 @@ int board_vbus_source_enabled(int port); enum adc_channel board_get_vbus_adc(int port); #endif /* CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT */ +/** + * Board specific callback to check if the given port is sink. + * + * @param port Dedicated charge port. + * @return 1 if the port is sink. + */ +int board_charge_port_is_sink(int port); + +/** + * Board specific callback to check if the given port is connected. + * + * @param port Dedicated charge port. + * @return 1 if the port is connected. + */ +int board_charge_port_is_connected(int port); + +/** + * Board specific callback to fill passed power_info structure with current info + * about the passed dedicate port. + * This function is responsible for filling r->meas.* and r->max_power. + * + * @param port Dedicated charge port. + * @param r USB PD power info to be updated. + */ +void board_fill_source_power_info(int port, + struct ec_response_usb_pd_power_info *r); + #endif /* __CROS_EC_CHARGE_MANAGER_H */ diff --git a/include/config.h b/include/config.h index 9745444353..ce38ee658b 100644 --- a/include/config.h +++ b/include/config.h @@ -672,7 +672,14 @@ /* Compile charge manager */ #undef CONFIG_CHARGE_MANAGER -/* Number of charge ports excluding type-c ports */ +/* + * Number of charge ports excluding type-c ports + * + * If defined, the board must define a macro DEDICATED_CHARGE_PORT indicates + * the dedicated port number. + * + * See include/charger_manager.h for more details about dedicated port. + */ #define CONFIG_DEDICATED_CHARGE_PORT_COUNT 0 /* Allow charge manager to default to charging from dual-role partners */ |