@@ -708,3 +708,24 @@ Description:
Access: Read
Valid values: 1-31
+
+What: /sys/class/power_supply/<supply_name>/quick_charge_type
+Date: Jul 2020
+Contact: Fei Jiang <jiangfei1@xiaomi.com>
+ Description:
+ Reports the kind of quick charge type based on different adapter power.
+ Different quick charge type represent different charging power.
+ QUICK_CHARGE_NORMAL : Charging Power <= 10W
+ QUICK_CHARGE_FAST : 10W < Charging Power <= 20W
+ QUICK_CHARGE_FLASH : 20W < Charging Power <= 30W
+ QUICK_CHARGE_TURBE : 30W < Charging Power <= 50W
+ QUICK_CHARGE_SUPER : Charging Power > 50W
+
+ Access: Read-Only
+ Valid values:
+ 0: QUICK_CHARGE_NORMAL,
+ 1: QUICK_CHARGE_FAST,
+ 2: QUICK_CHARGE_FLASH,
+ 3: QUICK_CHARGE_TURBE,
+ 4: QUICK_CHARGE_SUPER.
+
@@ -206,6 +206,7 @@ static struct power_supply_attr power_supply_attrs[] = {
POWER_SUPPLY_ATTR(MODEL_NAME),
POWER_SUPPLY_ATTR(MANUFACTURER),
POWER_SUPPLY_ATTR(SERIAL_NUMBER),
+ POWER_SUPPLY_ATTR(QUICK_CHARGE_TYPE),
};
static struct attribute *
@@ -485,6 +485,53 @@ static const struct smbb_irq {
{ "dc-valid", smbb_dc_valid_handler },
};
+struct quick_charge {
+ enum power_supply_type adap_type;
+ enum power_supply_quick_charge_type adap_cap;
+};
+
+static struct quick_charge adapter_cap[10] = {
+ { POWER_SUPPLY_TYPE_USB, QUICK_CHARGE_NORMAL },
+ { POWER_SUPPLY_TYPE_USB_DCP, QUICK_CHARGE_NORMAL },
+ { POWER_SUPPLY_TYPE_USB_CDP, QUICK_CHARGE_NORMAL },
+ { POWER_SUPPLY_TYPE_USB_ACA, QUICK_CHARGE_NORMAL },
+ { POWER_SUPPLY_TYPE_USB_FLOAT, QUICK_CHARGE_NORMAL },
+ { POWER_SUPPLY_TYPE_USB_PD, QUICK_CHARGE_FAST },
+ { POWER_SUPPLY_TYPE_USB_HVDCP, QUICK_CHARGE_FAST },
+ { POWER_SUPPLY_TYPE_USB_HVDCP_3, QUICK_CHARGE_FAST },
+ { POWER_SUPPLY_TYPE_USB_HVDCP_3P5, QUICK_CHARGE_FAST },
+ {0, 0},
+};
+
+static int get_quick_charge_type(struct smbb_charger *chg)
+{
+ union power_supply_propval prop = {0, };
+ int charger_type, rc;
+ int i = 0;
+
+ rc = power_supply_get_property(chg->bat_psy,
+ POWER_SUPPLY_PROP_STATUS, &prop);
+ if (rc < 0)
+ return rc;
+ if (prop.intval == POWER_SUPPLY_STATUS_DISCHARGING)
+ return 0;
+
+ rc = power_supply_get_property(chg->usb_psy,
+ POWER_SUPPLY_PROP_USB_TYPE, &prop);
+ if (rc < 0)
+ return rc;
+ charger_type = prop.intval;
+
+ while (adapter_cap[i].adap_type != 0) {
+ if (charger_type == adapter_cap[i].adap_type) {
+ return adapter_cap[i].adap_cap;
+ }
+ i++;
+ }
+
+ return 0;
+}
+
static int smbb_usbin_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
@@ -505,6 +552,9 @@ static int smbb_usbin_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX:
val->intval = 2500000;
break;
+ case POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE:
+ val->intval = get_quick_charge_type(chg);
+ break;
default:
rc = -EINVAL;
break;
@@ -695,6 +745,7 @@ static enum power_supply_property smbb_charger_properties[] = {
POWER_SUPPLY_PROP_ONLINE,
POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT,
POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX,
+ POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE,
};
static enum power_supply_property smbb_battery_properties[] = {
@@ -167,6 +167,7 @@ enum power_supply_property {
POWER_SUPPLY_PROP_MODEL_NAME,
POWER_SUPPLY_PROP_MANUFACTURER,
POWER_SUPPLY_PROP_SERIAL_NUMBER,
+ POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE,
};
enum power_supply_type {
@@ -182,6 +183,10 @@ enum power_supply_type {
POWER_SUPPLY_TYPE_USB_PD, /* Power Delivery Port */
POWER_SUPPLY_TYPE_USB_PD_DRP, /* PD Dual Role Port */
POWER_SUPPLY_TYPE_APPLE_BRICK_ID, /* Apple Charging Method */
+ POWER_SUPPLY_TYPE_USB_HVDCP, /* High Voltage DCP */
+ POWER_SUPPLY_TYPE_USB_HVDCP_3, /* Efficient High Voltage DCP */
+ POWER_SUPPLY_TYPE_USB_HVDCP_3P5, /* Efficient High Voltage DCP */
+ POWER_SUPPLY_TYPE_USB_FLOAT, /* Floating charger */
};
enum power_supply_usb_type {
@@ -197,6 +202,15 @@ enum power_supply_usb_type {
POWER_SUPPLY_USB_TYPE_APPLE_BRICK_ID, /* Apple Charging Method */
};
+enum power_supply_quick_charge_type {
+ QUICK_CHARGE_NORMAL = 0, /* Charging Power <= 10W */
+ QUICK_CHARGE_FAST, /* 10W < Charging Power <= 20W */
+ QUICK_CHARGE_FLASH, /* 20W < Charging Power <= 30W */
+ QUICK_CHARGE_TURBE, /* 30W < Charging Power <= 50W */
+ QUICK_CHARGE_SUPER, /* Charging Power > 50W */
+ QUICK_CHARGE_MAX,
+};
+
enum power_supply_notifier_events {
PSY_EVENT_PROP_CHANGED,
};