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

Commit 33de94a4 authored by Ashay Jaiswal's avatar Ashay Jaiswal
Browse files

qcom: smb138x/smb1351: add support to expose BATFET configuration



Add support to expose how BATFET of main and parallel chargers
are configured. BATFET configuration is used for configuring
FCC of main charger.

Change-Id: I1fa47840dee08754425dc4540a61401313f0878a
Signed-off-by: default avatarAshay Jaiswal <ashayj@codeaurora.org>
parent 45142d95
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -71,6 +71,8 @@ Optional Properties:
				If not specified the default value is active-low.
- qcom,parallel-external-current-sense If present specifies external rsense is
				used for charge current sensing.
- qcom,stacked-batfet:		Boolean flag. Specifies if parallel charger has stacked BATFET
				cofiguration.

Example for standalone charger:

+6 −0
Original line number Diff line number Diff line
@@ -93,6 +93,12 @@ Charger specific properties:
		will use io-channel-names to match IIO input names
		with IIO specifiers.

- qcom,stacked-batfet
  Usage:      optional
  Value type: <empty>
  Definition: boolean flag. Specifies if parallel charger has stacked BATFET
              cofiguration.

================================================
Second Level Nodes - SMB138X Charger Peripherals
================================================
+9 −0
Original line number Diff line number Diff line
@@ -461,6 +461,7 @@ struct smb1351_charger {

	int			parallel_pin_polarity_setting;
	int			parallel_mode;
	int			pl_batfet_mode;
	bool			parallel_charger;
	bool			parallel_charger_suspended;
	bool			bms_controlled_charging;
@@ -1417,6 +1418,7 @@ static enum power_supply_property smb1351_parallel_properties[] = {
	POWER_SUPPLY_PROP_CHARGE_TYPE,
	POWER_SUPPLY_PROP_PARALLEL_MODE,
	POWER_SUPPLY_PROP_INPUT_SUSPEND,
	POWER_SUPPLY_PROP_PARALLEL_BATFET_MODE,
};

static int smb1351_parallel_set_chg_suspend(struct smb1351_charger *chip,
@@ -1706,6 +1708,9 @@ static int smb1351_parallel_get_property(struct power_supply *psy,
	case POWER_SUPPLY_PROP_INPUT_SUSPEND:
		val->intval = chip->parallel_charger_suspended;
		break;
	case POWER_SUPPLY_PROP_PARALLEL_BATFET_MODE:
		val->intval = chip->pl_batfet_mode;
		break;
	default:
		return -EINVAL;
	}
@@ -3197,6 +3202,10 @@ static int smb1351_parallel_charger_probe(struct i2c_client *client,
	else
		chip->parallel_mode = POWER_SUPPLY_PL_USBIN_USBIN;

	chip->pl_batfet_mode = POWER_SUPPLY_PL_NON_STACKED_BATFET;
	if (of_property_read_bool(node, "qcom,stacked-batfet"))
		chip->pl_batfet_mode = POWER_SUPPLY_PL_STACKED_BATFET;

	i2c_set_clientdata(client, chip);

	chip->parallel_psy_d.name = "parallel";
+9 −0
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ struct smb_dt_props {
	int	chg_temp_max_mdegc;
	int	connector_temp_max_mdegc;
	int	pl_mode;
	int	pl_batfet_mode;
};

struct smb138x {
@@ -205,6 +206,10 @@ static int smb138x_parse_dt(struct smb138x *chip)
	if (rc < 0)
		chip->dt.connector_temp_max_mdegc = 105000;

	chip->dt.pl_batfet_mode = POWER_SUPPLY_PL_NON_STACKED_BATFET;
	if (of_property_read_bool(node, "qcom,stacked-batfet"))
		chip->dt.pl_batfet_mode = POWER_SUPPLY_PL_STACKED_BATFET;

	return 0;
}

@@ -664,6 +669,7 @@ static enum power_supply_property smb138x_parallel_props[] = {
	POWER_SUPPLY_PROP_PARALLEL_MODE,
	POWER_SUPPLY_PROP_CONNECTOR_HEALTH,
	POWER_SUPPLY_PROP_SET_SHIP_MODE,
	POWER_SUPPLY_PROP_PARALLEL_BATFET_MODE,
};

static int smb138x_parallel_get_prop(struct power_supply *psy,
@@ -738,6 +744,9 @@ static int smb138x_parallel_get_prop(struct power_supply *psy,
		/* Not in ship mode as long as device is active */
		val->intval = 0;
		break;
	case POWER_SUPPLY_PROP_PARALLEL_BATFET_MODE:
		val->intval = chip->dt.pl_batfet_mode;
		break;
	default:
		pr_err("parallel power supply get prop %d not supported\n",
			prop);