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

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

Merge "drivers: lmh-dcvsh: Add isens vref regulator support"

parents 9175daef 6d393b9f
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -31,12 +31,29 @@ Properties:
	Definition: Should specify the cluster affinity this hardware
			corresponds to.

- isens_vref-supply:
	Usage: optional
	Value type: <phandle>
	Definition: Should specify the phandle of the vref regulator used by
			the isens hardware. This active only regulator will be
			enabled by LMH DCVSh.

- isens-vref-settings:
	Usage: optional
	Value type: <u32 array>
	Definition: Should specify the min voltage(uV), max voltage(uV) and
			max load(uA) for the isens vref regulator. This
			property is valid only if there is valid entry for
			isens_vref-supply.

Example:

	lmh_dcvs0: qcom,limits-dcvs@0 {
		compatible = "qcom,msm-hw-limits";
		interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>;
		qcom,affinity = <0>;
		isens_vref-supply = <&pm8998_l1_ao>;
		isens-vref-settings = <880000 880000 36000>;
	};

	CPU0: cpu@0 {
+46 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include <linux/pm_opp.h>
#include <linux/cpu_cooling.h>
#include <linux/atomic.h>
#include <linux/regulator/consumer.h>

#include <asm/smp_plat.h>
#include <asm/cacheflush.h>
@@ -106,6 +107,7 @@ struct limits_dcvs_hw {
	atomic_t is_irq_enabled;
	struct mutex access_lock;
	struct __limits_cdev_data *cdev_data;
	struct regulator *isens_reg;
};

LIST_HEAD(lmh_dcvs_hw_list);
@@ -430,6 +432,49 @@ static int limits_cpu_online(unsigned int online_cpu)
	return 0;
}

static void limits_isens_vref_ldo_init(struct platform_device *pdev,
					struct limits_dcvs_hw *hw)
{
	int ret = 0;
	uint32_t settings[3];

	hw->isens_reg = devm_regulator_get(&pdev->dev, "isens_vref");
	if (IS_ERR_OR_NULL(hw->isens_reg)) {
		if (PTR_ERR(hw->isens_reg) == -ENODEV)
			return;

		pr_err("Regulator:isens_vref init error:%ld\n",
			PTR_ERR(hw->isens_reg));
		return;
	}
	ret = of_property_read_u32_array(pdev->dev.of_node,
					"isens-vref-settings",
					settings, 3);
	if (ret) {
		pr_err("Regulator:isens_vref settings read error:%d\n",
				ret);
		devm_regulator_put(hw->isens_reg);
		return;
	}
	ret = regulator_set_voltage(hw->isens_reg, settings[0], settings[1]);
	if (ret) {
		pr_err("Regulator:isens_vref set voltage error:%d\n", ret);
		devm_regulator_put(hw->isens_reg);
		return;
	}
	ret = regulator_set_load(hw->isens_reg, settings[2]);
	if (ret) {
		pr_err("Regulator:isens_vref set load error:%d\n", ret);
		devm_regulator_put(hw->isens_reg);
		return;
	}
	if (regulator_enable(hw->isens_reg)) {
		pr_err("Failed to enable regulator:isens_vref\n");
		devm_regulator_put(hw->isens_reg);
		return;
	}
}

static int limits_dcvs_probe(struct platform_device *pdev)
{
	int ret;
@@ -585,6 +630,7 @@ static int limits_dcvs_probe(struct platform_device *pdev)
		ret = 0;
		goto probe_exit;
	}
	limits_isens_vref_ldo_init(pdev, hw);

probe_exit:
	mutex_lock(&lmh_dcvs_list_access);