diff options
author | Venkat Gopalakrishnan <venkatg@codeaurora.org> | 2016-04-20 13:18:37 -0700 |
---|---|---|
committer | Jeevan Shriram <jshriram@codeaurora.org> | 2016-04-25 17:54:14 -0700 |
commit | 32ae49b5653ed24ba120e40ceaf8ab5bc7042fa8 (patch) | |
tree | 434b2d4ded86d469abe9982170f9cca6f58bb236 /drivers | |
parent | 2bb44fdeb8c322aefa087a417decd4fbed3a4cc2 (diff) |
phy: ufs-qcom: add optional ref aux clk
phy-ufs-qcom-qmp-v3 needs an additional ref aux clk to be enabled,
add support for the new ref aux clk and make it optional as its not
needed by other phy versions.
Change-Id: I5e04980eb451b193e9c024bfe35383d10d17feff
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/phy/phy-qcom-ufs-i.h | 1 | ||||
-rw-r--r-- | drivers/phy/phy-qcom-ufs.c | 32 |
2 files changed, 33 insertions, 0 deletions
diff --git a/drivers/phy/phy-qcom-ufs-i.h b/drivers/phy/phy-qcom-ufs-i.h index 9c56264889be..adeabe817174 100644 --- a/drivers/phy/phy-qcom-ufs-i.h +++ b/drivers/phy/phy-qcom-ufs-i.h @@ -91,6 +91,7 @@ struct ufs_qcom_phy { struct clk *ref_clk_src; struct clk *ref_clk_parent; struct clk *ref_clk; + struct clk *ref_aux_clk; bool is_ref_clk_enabled; bool is_dev_ref_clk_enabled; struct ufs_qcom_phy_vreg vdda_pll; diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c index b8184658e66e..b78f03ad6c46 100644 --- a/drivers/phy/phy-qcom-ufs.c +++ b/drivers/phy/phy-qcom-ufs.c @@ -220,7 +220,15 @@ ufs_qcom_phy_init_clks(struct phy *generic_phy, err = ufs_qcom_phy_clk_get(generic_phy, "ref_clk", &phy_common->ref_clk); + if (err) + goto out; + /* + * "ref_aux_clk" is optional and only supported by certain + * phy versions, don't abort init if it's not found. + */ + __ufs_qcom_phy_clk_get(generic_phy, "ref_aux_clk", + &phy_common->ref_aux_clk, false); out: return err; } @@ -434,9 +442,26 @@ int ufs_qcom_phy_enable_ref_clk(struct phy *generic_phy) goto out_disable_parent; } + /* + * "ref_aux_clk" is optional clock and only supported by certain + * phy versions, hence make sure that clk reference is available + * before trying to enable the clock. + */ + if (phy->ref_aux_clk) { + ret = clk_prepare_enable(phy->ref_aux_clk); + if (ret) { + dev_err(phy->dev, "%s: ref_aux_clk enable failed %d\n", + __func__, ret); + goto out_disable_ref; + } + } + phy->is_ref_clk_enabled = true; goto out; +out_disable_ref: + if (phy->ref_clk) + clk_disable_unprepare(phy->ref_clk); out_disable_parent: if (phy->ref_clk_parent) clk_disable_unprepare(phy->ref_clk_parent); @@ -477,6 +502,13 @@ void ufs_qcom_phy_disable_ref_clk(struct phy *generic_phy) struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy); if (phy->is_ref_clk_enabled) { + /* + * "ref_aux_clk" is optional clock and only supported by + * certain phy versions, hence make sure that clk reference + * is available before trying to disable the clock. + */ + if (phy->ref_aux_clk) + clk_disable_unprepare(phy->ref_aux_clk); clk_disable_unprepare(phy->ref_clk); /* * "ref_clk_parent" is optional clock hence make sure that clk |