"Unknown", "System", "Device"
};
+static const char * const power_supply_charge_rate_text[] = {
+ "None","Normal","Weak","Turbo"
+};
+
static ssize_t power_supply_show_property(struct device *dev,
struct device_attribute *attr,
char *buf) {
else if (off == POWER_SUPPLY_PROP_CHARGE_TYPE)
return sprintf(buf, "%s\n",
power_supply_charge_type_text[value.intval]);
+ else if (off == POWER_SUPPLY_PROP_CHARGE_RATE)
+ return sprintf(buf,"%s\n",
+ power_supply_charge_rate_text[value.intval]);
else if (off == POWER_SUPPLY_PROP_HEALTH)
return sprintf(buf, "%s\n",
power_supply_health_text[value.intval]);
POWER_SUPPLY_ATTR(rr_enable),
POWER_SUPPLY_ATTR(usbpd_reset),
POWER_SUPPLY_ATTR(usbpd_test_read),
+ POWER_SUPPLY_ATTR(charge_rate),
};
static struct attribute *
POWER_SUPPLY_PROP_TECHNOLOGY,
POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
+ POWER_SUPPLY_PROP_CHARGE_RATE,
};
static enum power_supply_property s2mu00x_power_props[] = {
#endif
}
+#define WEAK_CHRG_THRSH 450
+static void get_prop_charge_rate(struct s2mu00x_battery_info *battery)
+{
+ int prev_chg_rate = battery->charger_rate;
+ char *charge_rate[] = {
+ "None", "Normal", "Weak", "Turbo"
+ };
+
+ if (!is_usb_present(battery)) {
+ battery->charger_rate = POWER_SUPPLY_CHARGE_RATE_NONE;
+ return;
+ }
+
+ if(battery->cable_type == POWER_SUPPLY_TYPE_HV_MAINS)
+ battery->charger_rate = POWER_SUPPLY_CHARGE_RATE_TURBO;
+ else
+ battery->charger_rate = POWER_SUPPLY_CHARGE_RATE_NORMAL;
+
+ if(prev_chg_rate != battery->charger_rate)
+ printk(KERN_ERR "%s,charge_rate:%s\n",__func__,charge_rate[battery->charger_rate]);
+}
+
static int s2mu00x_battery_get_property(struct power_supply *psy,
enum power_supply_property psp, union power_supply_propval *val)
{
case POWER_SUPPLY_PROP_SOH:
val->intval = battery->soh;
break;
+ case POWER_SUPPLY_PROP_CHARGE_RATE:
+ get_prop_charge_rate(battery);
+ val->intval = battery->charger_rate;
+ break;
default:
ret = -ENODATA;
}
battery->stepchg_state = STEP_NONE;
battery->charging_limit_modes = CHARGING_LIMIT_OFF;
set_max_allowed_current_ma(battery,battery->stepchg_current_ma);
+ battery->charger_rate = POWER_SUPPLY_CHARGE_RATE_NONE;
} else {
+ battery->charger_rate = POWER_SUPPLY_CHARGE_RATE_NORMAL;
smbchg_stay_awake(battery);
cancel_delayed_work(&battery->heartbeat_work);
schedule_delayed_work(&battery->heartbeat_work, msecs_to_jiffies(0));
case POWER_SUPPLY_TYPE_HV_MAINS:
case POWER_SUPPLY_TYPE_PREPARE_TA:
case POWER_SUPPLY_TYPE_UNKNOWN:
+ case POWER_SUPPLY_TYPE_USB_ACA: /* Accessory Charger Adapters */
+ case POWER_SUPPLY_TYPE_USB_TYPE_C: /* Type C Port */
+ case POWER_SUPPLY_TYPE_USB_PD: /* Power Delivery Port */
+ case POWER_SUPPLY_TYPE_USB_PD_DRP: /* PD Dual Role Port */
+ case POWER_SUPPLY_TYPE_APPLE_BRICK_ID: /* Apple Charging Method */
present = true;
break;
default:
{
int type = chip->cable_type;
- if (type == POWER_SUPPLY_TYPE_USB_DCP || type == POWER_SUPPLY_TYPE_MAINS)
+ if (type == POWER_SUPPLY_TYPE_USB_DCP || type == POWER_SUPPLY_TYPE_MAINS || type == POWER_SUPPLY_TYPE_HV_MAINS)
return true;
else
return false;
battery->is_weak_charger = false;
battery->usb_online = -EINVAL;
battery->stepchg_state = STEP_NONE;
+ battery->charger_rate = POWER_SUPPLY_CHARGE_RATE_NONE;
rc = device_create_file(battery->dev,
&dev_attr_force_demo_mode);
if (rc) {
POWER_SUPPLY_SCOPE_DEVICE,
};
+enum {
+ POWER_SUPPLY_CHARGE_RATE_NONE = 0,
+ POWER_SUPPLY_CHARGE_RATE_NORMAL,
+ POWER_SUPPLY_CHARGE_RATE_WEAK,
+ POWER_SUPPLY_CHARGE_RATE_TURBO,
+};
+
enum power_supply_property {
/* Properties of type `int' */
POWER_SUPPLY_PROP_STATUS = 0,
POWER_SUPPLY_PROP_RR_ENABLE,
POWER_SUPPLY_PROP_USBPD_RESET,
POWER_SUPPLY_PROP_USBPD_TEST_READ,
+ POWER_SUPPLY_PROP_CHARGE_RATE,
};
enum power_supply_type {