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

Commit c9d6972f authored by Manaf Meethalavalappu Pallikunhi's avatar Manaf Meethalavalappu Pallikunhi
Browse files

power: bcl: Add IAVAIL BCL monitor mode support for non-bms targets



IAVAIL BCL monitor mode gets rbat value from power supply bms module
to calculate iavail. Some targets don't have bms module and hence bcl
fails, but rbat value is availabale in power supply battery module for
these targets. Add IAVAIL BCL monitor mode support for non-bms
targets by reading rbat from battery module. BCL checks rbat value
from battery module only if 'qcom,bcl-no-bms' entry is defined in DT.

Change-Id: Id3e9a01c7c447abfceaa0fafe833b6c7542b258c
Signed-off-by: default avatarManaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
parent d5fc7ff6
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -45,6 +45,9 @@ Optional parameters:
- qcom,bcl-hotplug-list = <hotplug-phandle-list>: List of phandles to the cores
		that are to be hotplugged, when battery current limit condition
		is reached.
- qcom,bcl-no-bms: This is an optional node for BCL IAVAIL monitor mode.
		If this property is defined, BCL IAVAIL monitor gets rbat value
		from power supply battery module instead of bms module.

Optional nodes:
- qcom,ibat-monitor: This optional node defines all the parameters for the
@@ -92,6 +95,7 @@ Example:
		compatible = "qcom,bcl";
		qcom,ibat-vadc = <&pma8084_vadc>;
		qcom,ibat-threshold-adc_tm = <&pma8084_adc_tm>;
		qcom,bcl-no-bms;
		qcom,ibat-monitor {
			qcom,high-threshold-uamp = <1500>;
			qcom,low-threshold-uamp = <500>;
+11 −2
Original line number Diff line number Diff line
@@ -142,6 +142,8 @@ struct bcl_context {
	int bcl_vbat_min;
	/* BCL period poll delay work structure  */
	struct delayed_work bcl_iavail_work;
	/* For non-bms target */
	bool bcl_no_bms;
	/* The max CPU frequency the BTM restricts during high load */
	uint32_t btm_freq_max;
	/* Indicates whether there is a high load */
@@ -337,9 +339,11 @@ static int bcl_get_resistance(int *rbatt_mohm)
	union power_supply_propval ret = {0,};

	if (psy == NULL) {
		psy = power_supply_get_by_name("bms");
		psy =
		power_supply_get_by_name(gbcl->bcl_no_bms ? "battery" : "bms");
		if (psy == NULL) {
			pr_err("failed to get ps bms\n");
			pr_err("failed to get ps %s\n",
				gbcl->bcl_no_bms ? "battery" : "bms");
			return -EINVAL;
		}
	}
@@ -1582,6 +1586,11 @@ static int bcl_probe(struct platform_device *pdev)
			bcl_type[BCL_IAVAIL_MONITOR_TYPE]);
	bcl->bcl_poll_interval_msec = BCL_POLL_INTERVAL;

	if (of_property_read_bool(pdev->dev.of_node, "qcom,bcl-no-bms"))
		bcl->bcl_no_bms = true;
	else
		bcl->bcl_no_bms = false;

	core_phandle = of_parse_phandle(pdev->dev.of_node,
			"qcom,bcl-hotplug-list", i++);
	while (core_phandle) {