mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 10:14:57 +00:00
pi3usb9281: Add function for translating registers to current limit
Decode Pericom registers to current limits. BUG=chrome-os-partner:32003 TEST=Manual on samus_pd. Insert 1A Apple charger, verify current limit is correctly detected as 1A. BRANCH=samus Change-Id: I310d9f22cef80e97c1734e6a56f0034ebe01df31 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/222638 Reviewed-by: Alec Berg <alecaberg@chromium.org>
This commit is contained in:
committed by
chrome-internal-fetch
parent
358aeb2877
commit
ac2b30d1e7
@@ -74,6 +74,9 @@ int pi3usb9281_get_device_type(uint8_t chip_idx);
|
||||
/* Get attached charger status. */
|
||||
int pi3usb9281_get_charger_status(uint8_t chip_idx);
|
||||
|
||||
/* Get charger current limit based on device type and charger status. */
|
||||
int pi3usb9281_get_ilim(int device_type, int charger_status);
|
||||
|
||||
/* Set switch configuration to manual. */
|
||||
int pi3usb9281_set_switch_manual(uint8_t chip_idx, int val);
|
||||
|
||||
|
||||
@@ -119,6 +119,28 @@ int pi3usb9281_get_charger_status(uint8_t chip_idx)
|
||||
return pi3usb9281_read(chip_idx, PI3USB9281_REG_CHG_STATUS) & 0x1f;
|
||||
}
|
||||
|
||||
int pi3usb9281_get_ilim(int device_type, int charger_status)
|
||||
{
|
||||
/* Limit USB port current. 500mA for not listed types. */
|
||||
int current_limit_ma = 500;
|
||||
|
||||
if (charger_status & PI3USB9281_CHG_CAR_TYPE1 ||
|
||||
charger_status & PI3USB9281_CHG_CAR_TYPE2)
|
||||
current_limit_ma = 3000;
|
||||
else if (charger_status & PI3USB9281_CHG_APPLE_1A)
|
||||
current_limit_ma = 1000;
|
||||
else if (charger_status & PI3USB9281_CHG_APPLE_2A)
|
||||
current_limit_ma = 2000;
|
||||
else if (charger_status & PI3USB9281_CHG_APPLE_2_4A)
|
||||
current_limit_ma = 2400;
|
||||
else if (device_type & PI3USB9281_TYPE_CDP)
|
||||
current_limit_ma = 1500;
|
||||
else if (device_type & PI3USB9281_TYPE_DCP)
|
||||
current_limit_ma = 1500;
|
||||
|
||||
return current_limit_ma;
|
||||
}
|
||||
|
||||
int pi3usb9281_get_vbus(uint8_t chip_idx)
|
||||
{
|
||||
int vbus = pi3usb9281_read(chip_idx, PI3USB9281_REG_VBUS);
|
||||
|
||||
Reference in New Issue
Block a user