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/ina231s.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/ina231s.c')
-rw-r--r-- | board/servo_v4p1/ina231s.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/board/servo_v4p1/ina231s.c b/board/servo_v4p1/ina231s.c index 3382686f3f..bd5355b052 100644 --- a/board/servo_v4p1/ina231s.c +++ b/board/servo_v4p1/ina231s.c @@ -67,3 +67,19 @@ int sr_chg_power(void) { return ina2xx_get_power(SR_CHG_IDX); } + +int set_sr_chg_power_limit(int limit) +{ + int enable; + int rv; + + /* Configure PowerOverLimit alert */ + enable = ina2xx_get_mask(SR_CHG_IDX); + enable |= 0x800; + + rv = ina2xx_set_alert(SR_CHG_IDX, limit / 25); + if (rv) + return rv; + + return ina2xx_set_mask(SR_CHG_IDX, enable); +} |