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

Commit 1381878e 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-smbcharger: add module params for default ICL"

parents 6a40b4c3 b48cfd77
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -391,6 +391,18 @@ module_param_named(
	int, S_IRUSR | S_IWUSR
);

static int smbchg_default_hvdcp_icl_ma = 3000;
module_param_named(
	default_hvdcp_icl_ma, smbchg_default_hvdcp_icl_ma,
	int, S_IRUSR | S_IWUSR
);

static int smbchg_default_dcp_icl_ma = 1800;
module_param_named(
	default_dcp_icl_ma, smbchg_default_dcp_icl_ma,
	int, S_IRUSR | S_IWUSR
);

static int wipower_dyn_icl_en;
module_param_named(
	dynamic_icl_wipower_en, wipower_dyn_icl_en,
@@ -4127,8 +4139,6 @@ static int smbchg_set_optimal_charging_mode(struct smbchg_chip *chip, int type)
	return 0;
}

#define DEFAULT_HVDCP_CHG_MA	3000
#define DEFAULT_WALL_CHG_MA	1800
#define DEFAULT_SDP_MA		100
#define DEFAULT_CDP_MA		1500
static int smbchg_change_usb_supply_type(struct smbchg_chip *chip,
@@ -4152,9 +4162,9 @@ static int smbchg_change_usb_supply_type(struct smbchg_chip *chip,
		current_limit_ma = DEFAULT_CDP_MA;
	else if (type == POWER_SUPPLY_TYPE_USB_HVDCP
			|| type == POWER_SUPPLY_TYPE_USB_HVDCP_3)
		current_limit_ma = DEFAULT_HVDCP_CHG_MA;
		current_limit_ma = smbchg_default_hvdcp_icl_ma;
	else
		current_limit_ma = DEFAULT_WALL_CHG_MA;
		current_limit_ma = smbchg_default_dcp_icl_ma;

	pr_smb(PR_STATUS, "Type %d: setting mA = %d\n",
		type, current_limit_ma);
+22 −0
Original line number Diff line number Diff line
@@ -1373,6 +1373,7 @@ static enum power_supply_property smb1351_parallel_properties[] = {
	POWER_SUPPLY_PROP_PRESENT,
	POWER_SUPPLY_PROP_CURRENT_MAX,
	POWER_SUPPLY_PROP_VOLTAGE_MAX,
	POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED,
	POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX,
};

@@ -1503,6 +1504,20 @@ static int smb1351_get_closest_usb_setpoint(int val)
		return i + 1;
}

static bool smb1351_is_input_current_limited(struct smb1351_charger *chip)
{
	int rc;
	u8 reg;

	rc = smb1351_read_reg(chip, IRQ_H_REG, &reg);
	if (rc) {
		pr_err("Failed to read IRQ_H_REG for ICL status: %d\n", rc);
		return false;
	}

	return !!(reg & IRQ_IC_LIMIT_STATUS_BIT);
}

static int smb1351_parallel_set_property(struct power_supply *psy,
				       enum power_supply_property prop,
				       const union power_supply_propval *val)
@@ -1602,6 +1617,13 @@ static int smb1351_parallel_get_property(struct power_supply *psy,
		else
			val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
		break;
	case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED:
		if (chip->parallel_charger_present)
			val->intval =
				smb1351_is_input_current_limited(chip) ? 1 : 0;
		else
			val->intval = 0;
		break;
	default:
		return -EINVAL;
	}