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

Commit 1c873eab authored by Sarada Prasanna Garnayak's avatar Sarada Prasanna Garnayak
Browse files

wcnss: update the regulator parsing and config method



Use the resource managed regulator API for the wcnss
regulator parsing and configuration.

CRs-Fixed: 2214888
Change-Id: Ib376893c26bb9aa797e7e9df25cc7302a84a3726
Signed-off-by: default avatarSarada Prasanna Garnayak <sgarna@codeaurora.org>
parent 9d4600a1
Loading
Loading
Loading
Loading
+10 −33
Original line number Original line Diff line number Diff line
@@ -193,27 +193,6 @@ int validate_iris_chip_id(u32 reg)
	}
	}
}
}


void wcnss_free_regulator(void)
{
	int vreg_i;

	/* Free pronto voltage regulators from device node */
	for (vreg_i = 0; vreg_i < PRONTO_REGULATORS; vreg_i++) {
		if (pronto_vregs[vreg_i].state) {
			regulator_put(pronto_vregs[vreg_i].regulator);
			pronto_vregs[vreg_i].state = VREG_NULL_CONFIG;
		}
	}

	/* Free IRIS voltage regulators from device node */
	for (vreg_i = 0; vreg_i < IRIS_REGULATORS; vreg_i++) {
		if (iris_vregs[vreg_i].state) {
			regulator_put(iris_vregs[vreg_i].regulator);
			iris_vregs[vreg_i].state = VREG_NULL_CONFIG;
		}
	}
}

static int
static int
wcnss_dt_parse_vreg_level(struct device *dev, int index,
wcnss_dt_parse_vreg_level(struct device *dev, int index,
			  const char *current_vreg_name, const char *vreg_name,
			  const char *current_vreg_name, const char *vreg_name,
@@ -256,13 +235,14 @@ wcnss_parse_voltage_regulator(struct wcnss_wlan_config *wlan_config,
	/* Parse pronto voltage regulators from device node */
	/* Parse pronto voltage regulators from device node */
	for (vreg_i = 0; vreg_i < PRONTO_REGULATORS; vreg_i++) {
	for (vreg_i = 0; vreg_i < PRONTO_REGULATORS; vreg_i++) {
		pronto_vregs[vreg_i].regulator =
		pronto_vregs[vreg_i].regulator =
			regulator_get(dev, pronto_vregs[vreg_i].name);
			devm_regulator_get_optional(dev,
						    pronto_vregs[vreg_i].name);
		if (IS_ERR(pronto_vregs[vreg_i].regulator)) {
		if (IS_ERR(pronto_vregs[vreg_i].regulator)) {
			if (pronto_vregs[vreg_i].required) {
			if (pronto_vregs[vreg_i].required) {
				rc = PTR_ERR(pronto_vregs[vreg_i].regulator);
				rc = PTR_ERR(pronto_vregs[vreg_i].regulator);
				dev_err(dev, "regulator get of %s failed (%d)\n",
				dev_err(dev, "regulator get of %s failed (%d)\n",
					pronto_vregs[vreg_i].name, rc);
					pronto_vregs[vreg_i].name, rc);
				goto wcnss_vreg_get_err;
				return rc;
			} else {
			} else {
				dev_dbg(dev, "Skip optional regulator configuration: %s\n",
				dev_dbg(dev, "Skip optional regulator configuration: %s\n",
					pronto_vregs[vreg_i].name);
					pronto_vregs[vreg_i].name);
@@ -270,27 +250,28 @@ wcnss_parse_voltage_regulator(struct wcnss_wlan_config *wlan_config,
			}
			}
		}
		}


		pronto_vregs[vreg_i].state |= VREG_GET_REGULATOR_MASK;
		rc = wcnss_dt_parse_vreg_level(dev, vreg_i,
		rc = wcnss_dt_parse_vreg_level(dev, vreg_i,
					       pronto_vregs[vreg_i].curr,
					       pronto_vregs[vreg_i].curr,
					       pronto_vregs[vreg_i].volt,
					       pronto_vregs[vreg_i].volt,
					       wlan_config->pronto_vlevel);
					       wlan_config->pronto_vlevel);
		if (rc) {
		if (rc) {
			dev_err(dev, "error reading voltage-level property\n");
			dev_err(dev, "error reading voltage-level property\n");
			goto wcnss_vreg_get_err;
			return rc;
		}
		}
		pronto_vregs[vreg_i].state |= VREG_GET_REGULATOR_MASK;
	}
	}


	/* Parse iris voltage regulators from device node */
	/* Parse iris voltage regulators from device node */
	for (vreg_i = 0; vreg_i < IRIS_REGULATORS; vreg_i++) {
	for (vreg_i = 0; vreg_i < IRIS_REGULATORS; vreg_i++) {
		iris_vregs[vreg_i].regulator =
		iris_vregs[vreg_i].regulator =
			regulator_get(dev, iris_vregs[vreg_i].name);
			devm_regulator_get_optional(dev,
						    iris_vregs[vreg_i].name);
		if (IS_ERR(iris_vregs[vreg_i].regulator)) {
		if (IS_ERR(iris_vregs[vreg_i].regulator)) {
			if (iris_vregs[vreg_i].required) {
			if (iris_vregs[vreg_i].required) {
				rc = PTR_ERR(iris_vregs[vreg_i].regulator);
				rc = PTR_ERR(iris_vregs[vreg_i].regulator);
				dev_err(dev, "regulator get of %s failed (%d)\n",
				dev_err(dev, "regulator get of %s failed (%d)\n",
					iris_vregs[vreg_i].name, rc);
					iris_vregs[vreg_i].name, rc);
				goto wcnss_vreg_get_err;
				return rc;
			} else {
			} else {
				dev_dbg(dev, "Skip optional regulator configuration: %s\n",
				dev_dbg(dev, "Skip optional regulator configuration: %s\n",
					iris_vregs[vreg_i].name);
					iris_vregs[vreg_i].name);
@@ -298,22 +279,18 @@ wcnss_parse_voltage_regulator(struct wcnss_wlan_config *wlan_config,
			}
			}
		}
		}


		iris_vregs[vreg_i].state |= VREG_GET_REGULATOR_MASK;
		rc = wcnss_dt_parse_vreg_level(dev, vreg_i,
		rc = wcnss_dt_parse_vreg_level(dev, vreg_i,
					       iris_vregs[vreg_i].curr,
					       iris_vregs[vreg_i].curr,
					       iris_vregs[vreg_i].volt,
					       iris_vregs[vreg_i].volt,
					       wlan_config->iris_vlevel);
					       wlan_config->iris_vlevel);
		if (rc) {
		if (rc) {
			dev_err(dev, "error reading voltage-level property\n");
			dev_err(dev, "error reading voltage-level property\n");
			goto wcnss_vreg_get_err;
			return rc;
		}
		}
		iris_vregs[vreg_i].state |= VREG_GET_REGULATOR_MASK;
	}
	}


	return 0;
	return 0;

wcnss_vreg_get_err:
	wcnss_free_regulator();
	return rc;
}
}


void  wcnss_iris_reset(u32 reg, void __iomem *pmu_conf_reg)
void  wcnss_iris_reset(u32 reg, void __iomem *pmu_conf_reg)
+0 −1
Original line number Original line Diff line number Diff line
@@ -3524,7 +3524,6 @@ wcnss_wlan_probe(struct platform_device *pdev)
static int
static int
wcnss_wlan_remove(struct platform_device *pdev)
wcnss_wlan_remove(struct platform_device *pdev)
{
{
	wcnss_free_regulator();
	if (penv->wcnss_notif_hdle)
	if (penv->wcnss_notif_hdle)
		subsys_notif_unregister_notifier(penv->wcnss_notif_hdle, &wnb);
		subsys_notif_unregister_notifier(penv->wcnss_notif_hdle, &wnb);
	wcnss_cdev_unregister(pdev);
	wcnss_cdev_unregister(pdev);
+0 −1
Original line number Original line Diff line number Diff line
@@ -132,7 +132,6 @@ int wcnss_device_ready(void);
bool wcnss_cbc_complete(void);
bool wcnss_cbc_complete(void);
int wcnss_device_is_shutdown(void);
int wcnss_device_is_shutdown(void);
void wcnss_riva_dump_pmic_regs(void);
void wcnss_riva_dump_pmic_regs(void);
void wcnss_free_regulator(void);
int wcnss_xo_auto_detect_enabled(void);
int wcnss_xo_auto_detect_enabled(void);
u32 wcnss_get_wlan_rx_buff_count(void);
u32 wcnss_get_wlan_rx_buff_count(void);
int wcnss_wlan_iris_xo_mode(void);
int wcnss_wlan_iris_xo_mode(void);