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

Commit 98451418 authored by Ram Chandrasekar's avatar Ram Chandrasekar
Browse files

drivers: lmh-dcvs: Add support for two QREF regulators



Isens hardware requires the QREF regulators to be active for its
functionality. There are two QREF regulators at different supply
voltages.

Add support to use and vote for both the QREF regulators for Isens
functionality.

Change-Id: Id865d7c7df976f6802e480a7610fefbdadef544b
Signed-off-by: default avatarRam Chandrasekar <rkumbako@codeaurora.org>
parent 6f545b76
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -31,20 +31,23 @@ Properties:
	Definition: Should specify the cluster affinity this hardware
			corresponds to.

- isens_vref-supply:
- isens_vref_1p8-supply:
- isens_vref_0p8-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.
			enabled by LMH DCVSh. Isens hardware needs 1.8v and
			0.8v supply regulators.

- isens-vref-settings:
- isens-vref-1p8-settings:
- isens-vref-0p8-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.
			isens_vref_1p8-supply and isens_vref_0p8-supply.

- reg:
	Usage: Required
@@ -60,8 +63,10 @@ Example:
		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>;
		isens_vref_1p8-supply = <&pm8998_l1_ao>;
		isens-vref-1p8-settings = <880000 880000 36000>;
		isens_vref_0p8-supply = <&pm8998_l12_ao>;
		isens-vref-0p8-settings = <880000 880000 36000>;
		reg =  <0x18350800 0x1000>, //LLM
			<0x18323000 0x1000>; //OSM
	};
+31 −21
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ struct limits_dcvs_hw {
	struct mutex cdev_reg_lock;
	struct __limits_cdev_data *cdev_data;
	uint32_t cdev_registered;
	struct regulator *isens_reg;
	struct regulator *isens_reg[2];
	struct work_struct cdev_register_work;
};

@@ -435,49 +435,59 @@ 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)
static void limits_isens_qref_init(struct platform_device *pdev,
					struct limits_dcvs_hw *hw,
					int idx, char *reg_name,
					char *reg_setting)
{
	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);
					reg_setting, settings, 3);
	if (ret) {
		if (ret == -EINVAL)
			return;

		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]);
	hw->isens_reg[idx] = devm_regulator_get(&pdev->dev, reg_name);
	if (IS_ERR_OR_NULL(hw->isens_reg[idx])) {
		pr_err("Regulator:isens_vref init error:%ld\n",
			PTR_ERR(hw->isens_reg[idx]));
		return;
	}
	ret = regulator_set_voltage(hw->isens_reg[idx], settings[0],
					settings[1]);
	if (ret) {
		pr_err("Regulator:isens_vref set voltage error:%d\n", ret);
		devm_regulator_put(hw->isens_reg);
		devm_regulator_put(hw->isens_reg[idx]);
		return;
	}
	ret = regulator_set_load(hw->isens_reg, settings[2]);
	ret = regulator_set_load(hw->isens_reg[idx], settings[2]);
	if (ret) {
		pr_err("Regulator:isens_vref set load error:%d\n", ret);
		devm_regulator_put(hw->isens_reg);
		devm_regulator_put(hw->isens_reg[idx]);
		return;
	}
	if (regulator_enable(hw->isens_reg)) {
	if (regulator_enable(hw->isens_reg[idx])) {
		pr_err("Failed to enable regulator:isens_vref\n");
		devm_regulator_put(hw->isens_reg);
		devm_regulator_put(hw->isens_reg[idx]);
		return;
	}
}

static void limits_isens_vref_ldo_init(struct platform_device *pdev,
					struct limits_dcvs_hw *hw)
{
	limits_isens_qref_init(pdev, hw, 0, "isens_vref_1p8",
				"isens-vref-1p8-settings");
	limits_isens_qref_init(pdev, hw, 1, "isens_vref_0p8",
				"isens-vref-0p8-settings");
}

static ssize_t
lmh_freq_limit_show(struct device *dev, struct device_attribute *devattr,
		       char *buf)