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

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

Merge "cnss: Correct boot sequence for WLAN hardware"

parents 5cb12017 05ef8317
Loading
Loading
Loading
Loading
+46 −41
Original line number Diff line number Diff line
@@ -137,6 +137,8 @@ static struct cnss_fw_files FW_FILES_DEFAULT = {
#define WLAN_VREG_SP2T_MIN	2700000

#define POWER_ON_DELAY		2
#define WLAN_VREG_IO_DELAY_MIN	100
#define WLAN_VREG_IO_DELAY_MAX	1000
#define WLAN_ENABLE_DELAY	10
#define WLAN_RECOVERY_DELAY	1
#define PCIE_ENABLE_DELAY	100
@@ -325,13 +327,6 @@ static int cnss_wlan_vreg_on(struct cnss_wlan_vreg_info *vreg_info)
		}
	}

	ret = regulator_enable(vreg_info->wlan_reg);
	if (ret) {
		pr_err("%s: regulator enable failed for WLAN power\n",
				__func__);
		goto error_enable;
	}

	if (vreg_info->wlan_reg_io) {
		ret = regulator_enable(vreg_info->wlan_reg_io);
		if (ret) {
@@ -339,6 +334,8 @@ static int cnss_wlan_vreg_on(struct cnss_wlan_vreg_info *vreg_info)
				__func__);
			goto error_enable_reg_io;
		}

		usleep_range(WLAN_VREG_IO_DELAY_MIN, WLAN_VREG_IO_DELAY_MAX);
	}

	if (vreg_info->wlan_reg_xtal_aon) {
@@ -359,6 +356,13 @@ static int cnss_wlan_vreg_on(struct cnss_wlan_vreg_info *vreg_info)
		}
	}

	ret = regulator_enable(vreg_info->wlan_reg);
	if (ret) {
		pr_err("%s: regulator enable failed for WLAN power\n",
		       __func__);
		goto error_enable;
	}

	if (vreg_info->wlan_reg_sp2t) {
		ret = regulator_enable(vreg_info->wlan_reg_sp2t);
		if (ret) {
@@ -395,6 +399,8 @@ error_enable_ant_switch:
	if (vreg_info->wlan_reg_sp2t)
		regulator_disable(vreg_info->wlan_reg_sp2t);
error_enable_reg_sp2t:
	regulator_disable(vreg_info->wlan_reg);
error_enable:
	if (vreg_info->wlan_reg_xtal)
		regulator_disable(vreg_info->wlan_reg_xtal);
error_enable_reg_xtal:
@@ -404,8 +410,6 @@ error_enable_reg_xtal_aon:
	if (vreg_info->wlan_reg_io)
		regulator_disable(vreg_info->wlan_reg_io);
error_enable_reg_io:
	regulator_disable(vreg_info->wlan_reg);
error_enable:
	if (vreg_info->wlan_reg_core)
		regulator_disable(vreg_info->wlan_reg_core);
error_enable_reg_core:
@@ -443,6 +447,13 @@ static int cnss_wlan_vreg_off(struct cnss_wlan_vreg_info *vreg_info)
		}
	}

	ret = regulator_disable(vreg_info->wlan_reg);
	if (ret) {
		pr_err("%s: regulator disable failed for WLAN power\n",
		       __func__);
		goto error_disable;
	}

	if (vreg_info->wlan_reg_xtal) {
		ret = regulator_disable(vreg_info->wlan_reg_xtal);
		if (ret) {
@@ -470,13 +481,6 @@ static int cnss_wlan_vreg_off(struct cnss_wlan_vreg_info *vreg_info)
		}
	}

	ret = regulator_disable(vreg_info->wlan_reg);
	if (ret) {
		pr_err("%s: regulator disable failed for WLAN power\n",
				__func__);
		goto error_disable;
	}

	if (vreg_info->wlan_reg_core) {
		ret = regulator_disable(vreg_info->wlan_reg_core);
		if (ret) {
@@ -736,24 +740,6 @@ static int cnss_wlan_get_resources(struct platform_device *pdev)
		}
	}

	vreg_info->wlan_reg = regulator_get(&pdev->dev, WLAN_VREG_NAME);

	if (IS_ERR(vreg_info->wlan_reg)) {
		if (PTR_ERR(vreg_info->wlan_reg) == -EPROBE_DEFER)
			pr_err("%s: vreg probe defer\n", __func__);
		else
			pr_err("%s: vreg regulator get failed\n", __func__);
		ret = PTR_ERR(vreg_info->wlan_reg);
		goto err_reg_get;
	}

	ret = regulator_enable(vreg_info->wlan_reg);

	if (ret) {
		pr_err("%s: vreg initial vote failed\n", __func__);
		goto err_reg_enable;
	}

	if (of_get_property(pdev->dev.of_node,
		WLAN_VREG_IO_NAME"-supply", NULL)) {
		vreg_info->wlan_reg_io = regulator_get(&pdev->dev,
@@ -773,12 +759,33 @@ static int cnss_wlan_get_resources(struct platform_device *pdev)
					__func__);
				goto err_reg_io_enable;
			}

			usleep_range(WLAN_VREG_IO_DELAY_MIN,
				     WLAN_VREG_IO_DELAY_MAX);
		}
	}

	if (cnss_enable_xtal_ldo(pdev))
		goto err_reg_xtal_enable;

	vreg_info->wlan_reg = regulator_get(&pdev->dev, WLAN_VREG_NAME);

	if (IS_ERR(vreg_info->wlan_reg)) {
		if (PTR_ERR(vreg_info->wlan_reg) == -EPROBE_DEFER)
			pr_err("%s: vreg probe defer\n", __func__);
		else
			pr_err("%s: vreg regulator get failed\n", __func__);
		ret = PTR_ERR(vreg_info->wlan_reg);
		goto err_reg_get;
	}

	ret = regulator_enable(vreg_info->wlan_reg);

	if (ret) {
		pr_err("%s: vreg initial vote failed\n", __func__);
		goto err_reg_enable;
	}

	if (of_get_property(pdev->dev.of_node,
		WLAN_VREG_SP2T_NAME"-supply", NULL)) {
		vreg_info->wlan_reg_sp2t =
@@ -947,7 +954,11 @@ err_reg_sp2t_enable:
err_reg_sp2t_set:
	if (vreg_info->wlan_reg_sp2t)
		regulator_put(vreg_info->wlan_reg_sp2t);
	regulator_disable(vreg_info->wlan_reg);

err_reg_enable:
	regulator_put(vreg_info->wlan_reg);
err_reg_get:
	cnss_disable_xtal_ldo(pdev);

err_reg_xtal_enable:
@@ -958,12 +969,6 @@ err_reg_io_enable:
err_reg_io_set:
	if (vreg_info->wlan_reg_io)
		regulator_put(vreg_info->wlan_reg_io);
	regulator_disable(vreg_info->wlan_reg);

err_reg_enable:
	regulator_put(vreg_info->wlan_reg);

err_reg_get:
	if (vreg_info->wlan_reg_core)
		regulator_disable(vreg_info->wlan_reg_core);

@@ -993,13 +998,13 @@ static void cnss_wlan_release_resources(void)
		regulator_put(vreg_info->ant_switch);
	if (vreg_info->wlan_reg_sp2t)
		regulator_put(vreg_info->wlan_reg_sp2t);
	regulator_put(vreg_info->wlan_reg);
	if (vreg_info->wlan_reg_xtal)
		regulator_put(vreg_info->wlan_reg_xtal);
	if (vreg_info->wlan_reg_xtal_aon)
		regulator_put(vreg_info->wlan_reg_xtal_aon);
	if (vreg_info->wlan_reg_io)
		regulator_put(vreg_info->wlan_reg_io);
	regulator_put(vreg_info->wlan_reg);
	if (vreg_info->wlan_reg_core)
		regulator_put(vreg_info->wlan_reg_core);
	vreg_info->state = VREG_OFF;