fuel gauge: rk817: set different input current when different charger is detected

The four power source types that are detected are:
Standard downstream port (SDP)
– This is a computer USB port capable of 500mA.
Charging downstream port (CDP)
- This is typically a powered USB hub capable of 1500mA.
Dedicated charging port (DCP)
- This is a standard wall charger capable of at least 1500mA.
DCP without shorting D+/D-(FLOATING)
- This is a non-standard wall charger capable of at least 1500mA.

Change-Id: Icb3d3c02d9ef5dfbcabf0232743ad057c578dcf4
Signed-off-by: shengfei Xu <xsf@rock-chips.com>
This commit is contained in:
shengfei Xu 2018-07-25 09:42:06 +08:00 committed by Jianhong Chen
parent de440615aa
commit 8a7ae883f7
1 changed files with 13 additions and 4 deletions

View File

@ -198,6 +198,14 @@ enum charger_type {
UNDEF_CHARGER,
};
enum power_supply_type {
POWER_SUPPLY_TYPE_UNKNOWN = 0,
POWER_SUPPLY_TYPE_USB, /* Standard Downstream Port */
POWER_SUPPLY_TYPE_USB_DCP, /* Dedicated Charging Port */
POWER_SUPPLY_TYPE_USB_CDP, /* Charging Downstream Port */
POWER_SUPPLY_TYPE_USB_FLOATING, /* DCP without shorting D+/D- */
};
struct rk817_battery_device {
struct udevice *dev;
int res_div;
@ -924,17 +932,18 @@ static int rk817_bat_get_usb_state(struct rk817_battery_device *battery)
int charger_type;
switch (rk817_bat_dwc_otg_check_dpdm()) {
case 0:
case POWER_SUPPLY_TYPE_UNKNOWN:
if ((rk817_bat_read(battery, PMIC_SYS_STS) & PLUG_IN_STS) != 0)
charger_type = DC_CHARGER;
else
charger_type = NO_CHARGER;
break;
case 1:
case 3:
case POWER_SUPPLY_TYPE_USB:
charger_type = USB_CHARGER;
break;
case 2:
case POWER_SUPPLY_TYPE_USB_DCP:
case POWER_SUPPLY_TYPE_USB_CDP:
case POWER_SUPPLY_TYPE_USB_FLOATING:
charger_type = AC_CHARGER;
break;
default: