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

Commit ed0df370 authored by Subhash Jadavani's avatar Subhash Jadavani
Browse files

drivers: phy: qcom: make "ref_clk_parent" clock as optional



On some chipsets, "ref_clk_parent" clock is not required for the UFS PHY
ref_clk activation hence change this property as optional.

Change-Id: I487fa7c4da7e64e3fb4d0321cc8296dca5091eb3
Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
parent 3a82db8d
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -16,9 +16,9 @@ Required properties:
- vdda-pll-supply   : phandle to PHY PLL and Power-Gen block power supply
- clocks	    : List of phandle and clock specifier pairs
- clock-names       : List of clock input name strings sorted in the same
		      order as the clocks property. "ref_clk_src",
		      "ref_clk_parent", "ref_clk", "tx_iface_clk" &
		      "rx_iface_clk" are mandatory
		      order as the clocks property. "ref_clk_src", "ref_clk",
		      "tx_iface_clk" & "rx_iface_clk" are mandatory but
		      "ref_clk_parent" is optional

Optional properties:
- vdda-phy-max-microamp : specifies max. load that can be drawn from phy supply
+35 −14
Original line number Diff line number Diff line
@@ -142,8 +142,8 @@ out:
	return err;
}

int ufs_qcom_phy_clk_get(struct phy *phy,
			 const char *name, struct clk **clk_out)
static int __ufs_qcom_phy_clk_get(struct phy *phy,
			 const char *name, struct clk **clk_out, bool err_print)
{
	struct clk *clk;
	int err = 0;
@@ -153,6 +153,7 @@ int ufs_qcom_phy_clk_get(struct phy *phy,
	clk = devm_clk_get(dev, name);
	if (IS_ERR(clk)) {
		err = PTR_ERR(clk);
		if (err_print)
			dev_err(dev, "failed to get %s err %d", name, err);
	} else {
		*clk_out = clk;
@@ -161,6 +162,12 @@ int ufs_qcom_phy_clk_get(struct phy *phy,
	return err;
}

int ufs_qcom_phy_clk_get(struct phy *phy,
			 const char *name, struct clk **clk_out)
{
	return __ufs_qcom_phy_clk_get(phy, name, clk_out, true);
}

int
ufs_qcom_phy_init_clks(struct phy *generic_phy,
		       struct ufs_qcom_phy *phy_common)
@@ -182,10 +189,12 @@ ufs_qcom_phy_init_clks(struct phy *generic_phy,
	if (err)
		goto out;

	err = ufs_qcom_phy_clk_get(generic_phy, "ref_clk_parent",
				   &phy_common->ref_clk_parent);
	if (err)
		goto out;
	/*
	 * "ref_clk_parent" is optional hence don't abort init if it's not
	 * found.
	 */
	__ufs_qcom_phy_clk_get(generic_phy, "ref_clk_parent",
				   &phy_common->ref_clk_parent, false);

	err = ufs_qcom_phy_clk_get(generic_phy, "ref_clk",
				   &phy_common->ref_clk);
@@ -352,12 +361,18 @@ int ufs_qcom_phy_enable_ref_clk(struct phy *generic_phy)
		goto out;
	}

	/*
	 * "ref_clk_parent" is optional clock hence make sure that clk reference
	 * is available before trying to enable the clock.
	 */
	if (phy->ref_clk_parent) {
		ret = clk_prepare_enable(phy->ref_clk_parent);
		if (ret) {
			dev_err(phy->dev, "%s: ref_clk_parent enable failed %d\n",
					__func__, ret);
			goto out_disable_src;
		}
	}

	ret = clk_prepare_enable(phy->ref_clk);
	if (ret) {
@@ -370,6 +385,7 @@ int ufs_qcom_phy_enable_ref_clk(struct phy *generic_phy)
	goto out;

out_disable_parent:
	if (phy->ref_clk_parent)
		clk_disable_unprepare(phy->ref_clk_parent);
out_disable_src:
	clk_disable_unprepare(phy->ref_clk_src);
@@ -407,6 +423,11 @@ void ufs_qcom_phy_disable_ref_clk(struct phy *generic_phy)

	if (phy->is_ref_clk_enabled) {
		clk_disable_unprepare(phy->ref_clk);
		/*
		 * "ref_clk_parent" is optional clock hence make sure that clk
		 * reference is available before trying to disable the clock.
		 */
		if (phy->ref_clk_parent)
			clk_disable_unprepare(phy->ref_clk_parent);
		clk_disable_unprepare(phy->ref_clk_src);
		phy->is_ref_clk_enabled = false;