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: Subhash Jadavani <subhashj@codeaurora.org> [gbroner@codeaurora.org: fix minor conflicts] Signed-off-by: Gilad Broner <gbroner@codeaurora.org> [venkatg@codeaurora.org: resolved trivial merge conflict] Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
This commit is contained in:
parent
266a5b094c
commit
f76e7d00c7
1 changed files with 29 additions and 14 deletions
|
@ -157,8 +157,8 @@ out:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ufs_qcom_phy_clk_get(struct phy *phy,
|
static int __ufs_qcom_phy_clk_get(struct phy *phy,
|
||||||
const char *name, struct clk **clk_out)
|
const char *name, struct clk **clk_out, bool err_print)
|
||||||
{
|
{
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
@ -168,6 +168,7 @@ int ufs_qcom_phy_clk_get(struct phy *phy,
|
||||||
clk = devm_clk_get(dev, name);
|
clk = devm_clk_get(dev, name);
|
||||||
if (IS_ERR(clk)) {
|
if (IS_ERR(clk)) {
|
||||||
err = PTR_ERR(clk);
|
err = PTR_ERR(clk);
|
||||||
|
if (err_print)
|
||||||
dev_err(dev, "failed to get %s err %d", name, err);
|
dev_err(dev, "failed to get %s err %d", name, err);
|
||||||
} else {
|
} else {
|
||||||
*clk_out = clk;
|
*clk_out = clk;
|
||||||
|
@ -204,10 +205,12 @@ ufs_qcom_phy_init_clks(struct phy *generic_phy,
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
err = ufs_qcom_phy_clk_get(generic_phy, "ref_clk_parent",
|
/*
|
||||||
&phy_common->ref_clk_parent);
|
* "ref_clk_parent" is optional hence don't abort init if it's not
|
||||||
if (err)
|
* found.
|
||||||
goto out;
|
*/
|
||||||
|
__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",
|
err = ufs_qcom_phy_clk_get(generic_phy, "ref_clk",
|
||||||
&phy_common->ref_clk);
|
&phy_common->ref_clk);
|
||||||
|
@ -382,12 +385,18 @@ int ufs_qcom_phy_enable_ref_clk(struct phy *generic_phy)
|
||||||
goto out;
|
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);
|
ret = clk_prepare_enable(phy->ref_clk_parent);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(phy->dev, "%s: ref_clk_parent enable failed %d\n",
|
dev_err(phy->dev, "%s: ref_clk_parent enable failed %d\n",
|
||||||
__func__, ret);
|
__func__, ret);
|
||||||
goto out_disable_src;
|
goto out_disable_src;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ret = clk_prepare_enable(phy->ref_clk);
|
ret = clk_prepare_enable(phy->ref_clk);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
@ -400,6 +409,7 @@ int ufs_qcom_phy_enable_ref_clk(struct phy *generic_phy)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
out_disable_parent:
|
out_disable_parent:
|
||||||
|
if (phy->ref_clk_parent)
|
||||||
clk_disable_unprepare(phy->ref_clk_parent);
|
clk_disable_unprepare(phy->ref_clk_parent);
|
||||||
out_disable_src:
|
out_disable_src:
|
||||||
clk_disable_unprepare(phy->ref_clk_src);
|
clk_disable_unprepare(phy->ref_clk_src);
|
||||||
|
@ -438,6 +448,11 @@ void ufs_qcom_phy_disable_ref_clk(struct phy *generic_phy)
|
||||||
|
|
||||||
if (phy->is_ref_clk_enabled) {
|
if (phy->is_ref_clk_enabled) {
|
||||||
clk_disable_unprepare(phy->ref_clk);
|
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_parent);
|
||||||
clk_disable_unprepare(phy->ref_clk_src);
|
clk_disable_unprepare(phy->ref_clk_src);
|
||||||
phy->is_ref_clk_enabled = false;
|
phy->is_ref_clk_enabled = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue