Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4e72c08f authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: qpnp-linear-charger: expose a few power supply properties"

parents aa0c4c78 cea4901d
Loading
Loading
Loading
Loading
+45 −5
Original line number Diff line number Diff line
@@ -208,14 +208,18 @@ static enum power_supply_property msm_batt_power_props[] = {
	POWER_SUPPLY_PROP_PRESENT,
	POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
	POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
	POWER_SUPPLY_PROP_VOLTAGE_MAX,
	POWER_SUPPLY_PROP_VOLTAGE_NOW,
	POWER_SUPPLY_PROP_CAPACITY,
	POWER_SUPPLY_PROP_CURRENT_NOW,
	POWER_SUPPLY_PROP_CHARGE_COUNTER,
	POWER_SUPPLY_PROP_CYCLE_COUNT,
	POWER_SUPPLY_PROP_CHARGE_FULL,
	POWER_SUPPLY_PROP_TEMP,
	POWER_SUPPLY_PROP_COOL_TEMP,
	POWER_SUPPLY_PROP_WARM_TEMP,
	POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL,
	POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT,
	POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX,
};

static char *pm_batt_supplied_to[] = {
@@ -1351,6 +1355,23 @@ static int get_prop_capacity(struct qpnp_lbc_chip *chip)
	return DEFAULT_CAPACITY;
}

static int get_bms_property(struct qpnp_lbc_chip *chip,
				enum power_supply_property psy_prop)
{
	union power_supply_propval ret = {0,};

	if (!chip->bms_psy)
		chip->bms_psy = power_supply_get_by_name("bms");

	if (chip->bms_psy)  {
		power_supply_get_property(chip->bms_psy, psy_prop, &ret);
		return ret.intval;
	}
	pr_debug("No BMS supply registered\n");

	return -EINVAL;
}

static int get_prop_charge_count(struct qpnp_lbc_chip *chip)
{
	union power_supply_propval ret = {0,};
@@ -1536,7 +1557,7 @@ static int qpnp_batt_property_is_writeable(struct power_supply *psy,
	case POWER_SUPPLY_PROP_COOL_TEMP:
	case POWER_SUPPLY_PROP_VOLTAGE_MIN:
	case POWER_SUPPLY_PROP_WARM_TEMP:
	case POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL:
	case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT:
		return 1;
	default:
		break;
@@ -1640,7 +1661,7 @@ static int qpnp_batt_power_set_property(struct power_supply *psy,
	case POWER_SUPPLY_PROP_VOLTAGE_MIN:
		qpnp_lbc_vinmin_set(chip, val->intval / 1000);
		break;
	case POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL:
	case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT:
		qpnp_lbc_system_temp_level_set(chip, val->intval);
		break;
	default:
@@ -1676,6 +1697,9 @@ static int qpnp_batt_power_get_property(struct power_supply *psy,
	case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
		val->intval = chip->cfg_min_voltage_mv * 1000;
		break;
	case POWER_SUPPLY_PROP_VOLTAGE_MAX:
		val->intval = chip->cfg_max_voltage_mv * 1000;
		break;
	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
		val->intval = get_prop_battery_voltage_now(chip);
		break;
@@ -1697,12 +1721,21 @@ static int qpnp_batt_power_get_property(struct power_supply *psy,
	case POWER_SUPPLY_PROP_CHARGE_COUNTER:
		val->intval = get_prop_charge_count(chip);
		break;
	case POWER_SUPPLY_PROP_CYCLE_COUNT:
		val->intval = get_bms_property(chip, psp);
		break;
	case POWER_SUPPLY_PROP_CHARGE_FULL:
		val->intval = get_bms_property(chip, psp);
		break;
	case POWER_SUPPLY_PROP_CHARGING_ENABLED:
		val->intval = !(chip->cfg_charging_disabled);
		break;
	case POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL:
	case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT:
		val->intval = chip->therm_lvl_sel;
		break;
	case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX:
		val->intval = chip->cfg_thermal_levels;
		break;
	default:
		return -EINVAL;
	}
@@ -1793,8 +1826,9 @@ static enum power_supply_property qpnp_lbc_usb_properties[] = {
	POWER_SUPPLY_PROP_TYPE,
	POWER_SUPPLY_PROP_REAL_TYPE,
	POWER_SUPPLY_PROP_SDP_CURRENT_MAX,
	POWER_SUPPLY_PROP_VOLTAGE_MAX,
};

#define MICRO_5V        5000000
static int qpnp_lbc_usb_get_property(struct power_supply *psy,
				  enum power_supply_property psp,
				  union power_supply_propval *val)
@@ -1827,6 +1861,12 @@ static int qpnp_lbc_usb_get_property(struct power_supply *psy,
			(chip->usb_supply_type != POWER_SUPPLY_TYPE_UNKNOWN))
			val->intval = chip->usb_supply_type;
		break;
	case POWER_SUPPLY_PROP_VOLTAGE_MAX:
		if (chip->usb_present)
			val->intval = MICRO_5V;
		else
			val->intval = 0;
		break;
	default:
		return -EINVAL;
	}
+13 −0
Original line number Diff line number Diff line
@@ -2227,6 +2227,15 @@ static int get_current_cc(struct qpnp_bms_chip *chip)
	return current_charge;
}

static int get_charge_full(struct qpnp_bms_chip *chip)
{

	if (chip->batt_data)
		return chip->batt_data->fcc * 1000;

	return -EINVAL;
}

static enum power_supply_property bms_power_props[] = {
	POWER_SUPPLY_PROP_CAPACITY,
	POWER_SUPPLY_PROP_STATUS,
@@ -2241,6 +2250,7 @@ static enum power_supply_property bms_power_props[] = {
	POWER_SUPPLY_PROP_TEMP,
	POWER_SUPPLY_PROP_CYCLE_COUNT,
	POWER_SUPPLY_PROP_CHARGE_COUNTER,
	POWER_SUPPLY_PROP_CHARGE_FULL,
};

static int
@@ -2321,6 +2331,9 @@ static int qpnp_vm_bms_power_get_property(struct power_supply *psy,
	case POWER_SUPPLY_PROP_CHARGE_COUNTER:
		val->intval = get_current_cc(chip);
		break;
	case POWER_SUPPLY_PROP_CHARGE_FULL:
		val->intval = get_charge_full(chip);
		break;
	default:
		return -EINVAL;
	}