diff options
author | Jan Dabros <jsd@semihalf.com> | 2020-12-15 13:55:12 +0100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-01-14 14:40:19 +0000 |
commit | 4f8c2db072fb4a8a99ccdc9fa557f122582f8173 (patch) | |
tree | bfcae95e7f847a03281f696217f8c707e6afddc3 /board/servo_v4p1/board.c | |
parent | 4ccfbe2d22b5c7f65a182dfb5bb35fe033799a2f (diff) | |
download | chrome-ec-4f8c2db072fb4a8a99ccdc9fa557f122582f8173.tar.gz |
servo_v4p1: Add driver for power management
Depending on the power source and loads, the servo_v4p1 may have
insufficient wattage available. New driver gathers information about
available inputs, monitors power consumed and sets alert when a
threshold is crossed.
For servo_v4p1 there are two main power sources - host USBC port and
servo charger port. Host connection operates on 5V and may allow up to
500mA(USB2.0), 900mA(USB3.0), 1500mA(BC1.2 or USB-C) or 3000mA(USB-C).
Servo charger port currently offers only standard USB-C wattage -
1500mA/5V or 3000mA/5V. There is a possibility that in future PD will be
enabled on this port, thus enabling higher wattages.
Algorithm queries host connection capabilities (including BC1.2) and
servo charger port connection settings, with charger port being always a
primary selection. INAXX chip is used to monitor level of consumed power
and notification is send to the user, when threshold is reached. In
future servod should be used as a channel for alerts notification.
BUG=b:144776402
BRANCH=master
TEST=Test various connections for input power to servo_v4p1 - USB2.0
host/cable, USB3.0, BC1.2 enabled/disabled, servo charger with different
Rp/Rd settings, also hot plugging servo charger. Provide different loads
to servo - pendrives, DUT connection and DisplayPort. Monitor power used
by servo and loads (either by external power meter or compile-in
INA_CMD). When threshold is reached, one should see "System full power
threshold exceeded" on the servo console. Default threshold is set to
90% of power.
For example on USB2.0 connection (500mA at max) and assuming 5V is
provided to VCC rail, warning should appear when drawing
500mA * 9/10 = 450m. Keep in mind though that actual alert is configured
on power over limit mode (not current), thus there may be some
differences when there is no ideal 5V on a tested connection.
Signed-off-by: Jan Dabros <jsd@semihalf.com>
Change-Id: I1099192fa7475b51922e9dcb272f812d1547f311
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2592495
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'board/servo_v4p1/board.c')
-rw-r--r-- | board/servo_v4p1/board.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/board/servo_v4p1/board.c b/board/servo_v4p1/board.c index 2d8725f206..6ffbfbad97 100644 --- a/board/servo_v4p1/board.c +++ b/board/servo_v4p1/board.c @@ -21,6 +21,7 @@ #include "ioexpanders.h" #include "pathsel.h" #include "pi3usb9201.h" +#include "power_mgmt.h" #include "queue_policies.h" #include "registers.h" #include "spi.h" @@ -387,6 +388,14 @@ int board_get_version(void) return board_id_det(); } +#ifdef SECTION_IS_RO +static void evaluate_input_power_def(void) +{ + evaluate_input_power(); +} +DECLARE_DEFERRED(evaluate_input_power_def); +#endif + static void board_init(void) { /* USB to serial queues */ @@ -420,6 +429,16 @@ static void board_init(void) init_ina231s(); init_fusb302b(1); + /* + * Get data about available input power. Add additional check after a + * delay, since we need to wait for USB2/USB3 enumeration on host hub + * as well as I2C interface of this hub needs to be initialized. + * 3 seconds is experimentally selected value, by this time hub should + * be up and running. + */ + evaluate_input_power(); + hook_call_deferred(&evaluate_input_power_def_data, 3 * SECOND); + /* Enable DUT USB2.0 pair. */ gpio_set_level(GPIO_FASTBOOT_DUTHUB_MUX_EN_L, 0); |