linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd
@ 2016-10-29 20:22 Vivek Gautam
  2016-10-29 20:22 ` [PATCH v3 01/12] phy: qcom-ufs: Remove unnecessary BUG_ON Vivek Gautam
                   ` (12 more replies)
  0 siblings, 13 replies; 25+ messages in thread
From: Vivek Gautam @ 2016-10-29 20:22 UTC (permalink / raw)
  To: kishon, jejb, vinholikatti, martin.petersen
  Cc: sboyd, subhashj, ygardi, linux-scsi, linux-arm-msm, Vivek Gautam

These patches cleanup the ufs phy driver to an extent.
Subsequent patches will target to clean the phy_init() of
these qcom-ufs phy drivers in order to get rid of a number of
exported APIs that phy drivers expose for ufs-qcom hcd driver
to use.

These patches are based on linux-phy next branch, and have been
tested with on db820c hardware with integration branch -
'integration-linux-qcomlt' of qualcomm linaro lt tree [1].

Changes since v2:
 1) Addressed review comment for the patch making tx/rx_iface clocks
    as optional.
    Added a new compatible string for 14nm ufs phy present on msm8996
    chips, and skipping the tx/r_iface clock fetching based on this
    compatible string.
 2) Added phy_power_off() and phy_power_on() calls in setup_clock()
    callback of ufs-qcom platform driver. This is to follow the
    turning off of the clocks during aggressive clock gating.
 3) Addressed review comment for fixing commit message for patch:
    phy: qcom-ufs-qmp-xx: Discard remove callback for drivers.
 4) Added a patch to remove the call to devm_free() for resource
    allocated through devm_kzalloc().

Changes since v1:
 1) Added a patch to the series to remove following unnecessary
    function declarations by moving the code:
    - __ufs_qcom_phy_init_vreg(),
    - ufs_qcom_phy_init_vreg(),
    - ufs_qcom_phy_base_init()
 2) Cleaned up following functions further for patch [2]:
    - ufs_qcom_phy_enable(/disable)_ref_clk()
    - ufs_qcom_phy_enable(/disable)_iface_clk()
 3) Added patch to add phy_exit() call to ufs-qcom exit path.
 4) Added a patch to remove ufs_qcom_phy_exit() from 'phy-qcom-ufs'
    driver, since this api just powers off the phy.

[1] https://git.linaro.org/landing-teams/working/qualcomm/kernel.git
[2] ufs-qcom: phy/hcd: Refactoring phy clock handling


Vivek Gautam (12):
  phy: qcom-ufs: Remove unnecessary BUG_ON
  phy: qcom-ufs: Use devm sibling of kstrdup for regulator names
  phy: qcom-ufs: Cleanup clock and regulator initialization
  phy: qcom-ufs-14nm: Add new compatible for msm8996 based phy
  phy: qcom-ufs: Skip obtaining rx/tx_iface_clk for msm8996 based phy
  phy: qcom-ufs-qmp-xx: Discard remove callback for drivers.
  phy: qcom-ufs: Remove unnecessary function declarations
  phy: qcom-ufs-qmp-xx: Move clock and regulator init out of phy init
  ufs-qcom: phy/hcd: Refactoring phy clock handling
  phy: qcom-ufs: Remove common layer phy exit callback
  scsi/ufs: qcom: Add phy_exit call in hcd exit path
  scsi/ufs: qcom: Don't free resource-managed kmalloc element

 Documentation/devicetree/bindings/ufs/ufs-qcom.txt |   7 +-
 drivers/phy/phy-qcom-ufs-i.h                       |   7 +-
 drivers/phy/phy-qcom-ufs-qmp-14nm.c                |  72 +++---
 drivers/phy/phy-qcom-ufs-qmp-20nm.c                |  65 ++---
 drivers/phy/phy-qcom-ufs.c                         | 269 +++++++++------------
 drivers/scsi/ufs/ufs-qcom.c                        |  20 +-
 include/linux/phy/phy-qcom-ufs.h                   |  18 --
 7 files changed, 184 insertions(+), 274 deletions(-)

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH v3 01/12] phy: qcom-ufs: Remove unnecessary BUG_ON
  2016-10-29 20:22 [PATCH v3 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd Vivek Gautam
@ 2016-10-29 20:22 ` Vivek Gautam
  2016-10-29 20:22 ` [PATCH v3 02/12] phy: qcom-ufs: Use devm sibling of kstrdup for regulator names Vivek Gautam
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Vivek Gautam @ 2016-10-29 20:22 UTC (permalink / raw)
  To: kishon, jejb, vinholikatti, martin.petersen
  Cc: sboyd, subhashj, ygardi, linux-scsi, linux-arm-msm, Vivek Gautam

BUG_ON() are not preferred in the driver, plus the variable
on which BUG_ON is asserted is already checked in the code
before passing.

Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
---

No changes since v1.

 drivers/phy/phy-qcom-ufs.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
index 18a5b49..455064c 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -322,8 +322,6 @@ int ufs_qcom_phy_cfg_vreg(struct phy *phy,
 	struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(phy);
 	struct device *dev = ufs_qcom_phy->dev;
 
-	BUG_ON(!vreg);
-
 	if (regulator_count_voltages(reg) > 0) {
 		min_uV = on ? vreg->min_uV : 0;
 		ret = regulator_set_voltage(reg, min_uV, vreg->max_uV);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 02/12] phy: qcom-ufs: Use devm sibling of kstrdup for regulator names
  2016-10-29 20:22 [PATCH v3 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd Vivek Gautam
  2016-10-29 20:22 ` [PATCH v3 01/12] phy: qcom-ufs: Remove unnecessary BUG_ON Vivek Gautam
@ 2016-10-29 20:22 ` Vivek Gautam
  2016-10-29 20:22 ` [PATCH v3 03/12] phy: qcom-ufs: Cleanup clock and regulator initialization Vivek Gautam
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Vivek Gautam @ 2016-10-29 20:22 UTC (permalink / raw)
  To: kishon, jejb, vinholikatti, martin.petersen
  Cc: sboyd, subhashj, ygardi, linux-scsi, linux-arm-msm, Vivek Gautam

This helps us in avoiding any requirement for kfree() operation
to be called exclusively over the allocated string pointer.

Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
---

No changes since v1.

 drivers/phy/phy-qcom-ufs.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
index 455064c..5dc24d8 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -251,7 +251,7 @@ static int __ufs_qcom_phy_init_vreg(struct phy *phy,
 
 	char prop_name[MAX_PROP_NAME];
 
-	vreg->name = kstrdup(name, GFP_KERNEL);
+	vreg->name = devm_kstrdup(dev, name, GFP_KERNEL);
 	if (!vreg->name) {
 		err = -ENOMEM;
 		goto out;
@@ -637,9 +637,6 @@ int ufs_qcom_phy_remove(struct phy *generic_phy,
 {
 	phy_power_off(generic_phy);
 
-	kfree(ufs_qcom_phy->vdda_pll.name);
-	kfree(ufs_qcom_phy->vdda_phy.name);
-
 	return 0;
 }
 EXPORT_SYMBOL_GPL(ufs_qcom_phy_remove);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 03/12] phy: qcom-ufs: Cleanup clock and regulator initialization
  2016-10-29 20:22 [PATCH v3 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd Vivek Gautam
  2016-10-29 20:22 ` [PATCH v3 01/12] phy: qcom-ufs: Remove unnecessary BUG_ON Vivek Gautam
  2016-10-29 20:22 ` [PATCH v3 02/12] phy: qcom-ufs: Use devm sibling of kstrdup for regulator names Vivek Gautam
@ 2016-10-29 20:22 ` Vivek Gautam
  2016-10-29 20:22 ` [PATCH v3 04/12] phy: qcom-ufs-14nm: Add new compatible for msm8996 based phy Vivek Gautam
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Vivek Gautam @ 2016-10-29 20:22 UTC (permalink / raw)
  To: kishon, jejb, vinholikatti, martin.petersen
  Cc: sboyd, subhashj, ygardi, linux-scsi, linux-arm-msm, Vivek Gautam

Different menthods pass around generic phy pointer to
extract device pointer. Instead, pass the device pointer
directly between function calls.

Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
---

No changes since v1.

 drivers/phy/phy-qcom-ufs-i.h        |  6 +--
 drivers/phy/phy-qcom-ufs-qmp-14nm.c |  4 +-
 drivers/phy/phy-qcom-ufs-qmp-20nm.c |  4 +-
 drivers/phy/phy-qcom-ufs.c          | 74 ++++++++++++++++---------------------
 4 files changed, 37 insertions(+), 51 deletions(-)

diff --git a/drivers/phy/phy-qcom-ufs-i.h b/drivers/phy/phy-qcom-ufs-i.h
index 2bd5ce4..69e836d 100644
--- a/drivers/phy/phy-qcom-ufs-i.h
+++ b/drivers/phy/phy-qcom-ufs-i.h
@@ -142,10 +142,8 @@ struct ufs_qcom_phy_specific_ops {
 int ufs_qcom_phy_power_on(struct phy *generic_phy);
 int ufs_qcom_phy_power_off(struct phy *generic_phy);
 int ufs_qcom_phy_exit(struct phy *generic_phy);
-int ufs_qcom_phy_init_clks(struct phy *generic_phy,
-			struct ufs_qcom_phy *phy_common);
-int ufs_qcom_phy_init_vregulators(struct phy *generic_phy,
-			struct ufs_qcom_phy *phy_common);
+int ufs_qcom_phy_init_clks(struct ufs_qcom_phy *phy_common);
+int ufs_qcom_phy_init_vregulators(struct ufs_qcom_phy *phy_common);
 int ufs_qcom_phy_remove(struct phy *generic_phy,
 		       struct ufs_qcom_phy *ufs_qcom_phy);
 struct phy *ufs_qcom_phy_generic_probe(struct platform_device *pdev,
diff --git a/drivers/phy/phy-qcom-ufs-qmp-14nm.c b/drivers/phy/phy-qcom-ufs-qmp-14nm.c
index 6ee5149..e3bede7 100644
--- a/drivers/phy/phy-qcom-ufs-qmp-14nm.c
+++ b/drivers/phy/phy-qcom-ufs-qmp-14nm.c
@@ -48,14 +48,14 @@ static int ufs_qcom_phy_qmp_14nm_init(struct phy *generic_phy)
 	struct ufs_qcom_phy *phy_common = &phy->common_cfg;
 	int err;
 
-	err = ufs_qcom_phy_init_clks(generic_phy, phy_common);
+	err = ufs_qcom_phy_init_clks(phy_common);
 	if (err) {
 		dev_err(phy_common->dev, "%s: ufs_qcom_phy_init_clks() failed %d\n",
 			__func__, err);
 		goto out;
 	}
 
-	err = ufs_qcom_phy_init_vregulators(generic_phy, phy_common);
+	err = ufs_qcom_phy_init_vregulators(phy_common);
 	if (err) {
 		dev_err(phy_common->dev, "%s: ufs_qcom_phy_init_vregulators() failed %d\n",
 			__func__, err);
diff --git a/drivers/phy/phy-qcom-ufs-qmp-20nm.c b/drivers/phy/phy-qcom-ufs-qmp-20nm.c
index 770087a..e09ecb8c 100644
--- a/drivers/phy/phy-qcom-ufs-qmp-20nm.c
+++ b/drivers/phy/phy-qcom-ufs-qmp-20nm.c
@@ -67,14 +67,14 @@ static int ufs_qcom_phy_qmp_20nm_init(struct phy *generic_phy)
 	struct ufs_qcom_phy *phy_common = &phy->common_cfg;
 	int err = 0;
 
-	err = ufs_qcom_phy_init_clks(generic_phy, phy_common);
+	err = ufs_qcom_phy_init_clks(phy_common);
 	if (err) {
 		dev_err(phy_common->dev, "%s: ufs_qcom_phy_init_clks() failed %d\n",
 			__func__, err);
 		goto out;
 	}
 
-	err = ufs_qcom_phy_init_vregulators(generic_phy, phy_common);
+	err = ufs_qcom_phy_init_vregulators(phy_common);
 	if (err) {
 		dev_err(phy_common->dev, "%s: ufs_qcom_phy_init_vregulators() failed %d\n",
 			__func__, err);
diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
index 5dc24d8..a173b30 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -22,9 +22,9 @@
 #define VDDP_REF_CLK_MIN_UV        1200000
 #define VDDP_REF_CLK_MAX_UV        1200000
 
-static int __ufs_qcom_phy_init_vreg(struct phy *, struct ufs_qcom_phy_vreg *,
+static int __ufs_qcom_phy_init_vreg(struct device *, struct ufs_qcom_phy_vreg *,
 				    const char *, bool);
-static int ufs_qcom_phy_init_vreg(struct phy *, struct ufs_qcom_phy_vreg *,
+static int ufs_qcom_phy_init_vreg(struct device *, struct ufs_qcom_phy_vreg *,
 				  const char *);
 static int ufs_qcom_phy_base_init(struct platform_device *pdev,
 				  struct ufs_qcom_phy *phy_common);
@@ -154,13 +154,11 @@ int ufs_qcom_phy_base_init(struct platform_device *pdev,
 	return 0;
 }
 
-static int __ufs_qcom_phy_clk_get(struct phy *phy,
+static int __ufs_qcom_phy_clk_get(struct device *dev,
 			 const char *name, struct clk **clk_out, bool err_print)
 {
 	struct clk *clk;
 	int err = 0;
-	struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(phy);
-	struct device *dev = ufs_qcom_phy->dev;
 
 	clk = devm_clk_get(dev, name);
 	if (IS_ERR(clk)) {
@@ -175,29 +173,28 @@ static int __ufs_qcom_phy_clk_get(struct phy *phy,
 }
 
 static
-int ufs_qcom_phy_clk_get(struct phy *phy,
+int ufs_qcom_phy_clk_get(struct device *dev,
 			 const char *name, struct clk **clk_out)
 {
-	return __ufs_qcom_phy_clk_get(phy, name, clk_out, true);
+	return __ufs_qcom_phy_clk_get(dev, name, clk_out, true);
 }
 
 int
-ufs_qcom_phy_init_clks(struct phy *generic_phy,
-		       struct ufs_qcom_phy *phy_common)
+ufs_qcom_phy_init_clks(struct ufs_qcom_phy *phy_common)
 {
 	int err;
 
-	err = ufs_qcom_phy_clk_get(generic_phy, "tx_iface_clk",
+	err = ufs_qcom_phy_clk_get(phy_common->dev, "tx_iface_clk",
 				   &phy_common->tx_iface_clk);
 	if (err)
 		goto out;
 
-	err = ufs_qcom_phy_clk_get(generic_phy, "rx_iface_clk",
+	err = ufs_qcom_phy_clk_get(phy_common->dev, "rx_iface_clk",
 				   &phy_common->rx_iface_clk);
 	if (err)
 		goto out;
 
-	err = ufs_qcom_phy_clk_get(generic_phy, "ref_clk_src",
+	err = ufs_qcom_phy_clk_get(phy_common->dev, "ref_clk_src",
 				   &phy_common->ref_clk_src);
 	if (err)
 		goto out;
@@ -206,10 +203,10 @@ int ufs_qcom_phy_clk_get(struct phy *phy,
 	 * "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",
+	__ufs_qcom_phy_clk_get(phy_common->dev, "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(phy_common->dev, "ref_clk",
 				   &phy_common->ref_clk);
 
 out:
@@ -218,36 +215,33 @@ int ufs_qcom_phy_clk_get(struct phy *phy,
 EXPORT_SYMBOL_GPL(ufs_qcom_phy_init_clks);
 
 int
-ufs_qcom_phy_init_vregulators(struct phy *generic_phy,
-			      struct ufs_qcom_phy *phy_common)
+ufs_qcom_phy_init_vregulators(struct ufs_qcom_phy *phy_common)
 {
 	int err;
 
-	err = ufs_qcom_phy_init_vreg(generic_phy, &phy_common->vdda_pll,
+	err = ufs_qcom_phy_init_vreg(phy_common->dev, &phy_common->vdda_pll,
 		"vdda-pll");
 	if (err)
 		goto out;
 
-	err = ufs_qcom_phy_init_vreg(generic_phy, &phy_common->vdda_phy,
+	err = ufs_qcom_phy_init_vreg(phy_common->dev, &phy_common->vdda_phy,
 		"vdda-phy");
 
 	if (err)
 		goto out;
 
 	/* vddp-ref-clk-* properties are optional */
-	__ufs_qcom_phy_init_vreg(generic_phy, &phy_common->vddp_ref_clk,
+	__ufs_qcom_phy_init_vreg(phy_common->dev, &phy_common->vddp_ref_clk,
 				 "vddp-ref-clk", true);
 out:
 	return err;
 }
 EXPORT_SYMBOL_GPL(ufs_qcom_phy_init_vregulators);
 
-static int __ufs_qcom_phy_init_vreg(struct phy *phy,
+static int __ufs_qcom_phy_init_vreg(struct device *dev,
 		struct ufs_qcom_phy_vreg *vreg, const char *name, bool optional)
 {
 	int err = 0;
-	struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(phy);
-	struct device *dev = ufs_qcom_phy->dev;
 
 	char prop_name[MAX_PROP_NAME];
 
@@ -304,14 +298,14 @@ static int __ufs_qcom_phy_init_vreg(struct phy *phy,
 	return err;
 }
 
-static int ufs_qcom_phy_init_vreg(struct phy *phy,
+static int ufs_qcom_phy_init_vreg(struct device *dev,
 			struct ufs_qcom_phy_vreg *vreg, const char *name)
 {
-	return __ufs_qcom_phy_init_vreg(phy, vreg, name, false);
+	return __ufs_qcom_phy_init_vreg(dev, vreg, name, false);
 }
 
 static
-int ufs_qcom_phy_cfg_vreg(struct phy *phy,
+int ufs_qcom_phy_cfg_vreg(struct device *dev,
 			  struct ufs_qcom_phy_vreg *vreg, bool on)
 {
 	int ret = 0;
@@ -319,8 +313,6 @@ int ufs_qcom_phy_cfg_vreg(struct phy *phy,
 	const char *name = vreg->name;
 	int min_uV;
 	int uA_load;
-	struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(phy);
-	struct device *dev = ufs_qcom_phy->dev;
 
 	if (regulator_count_voltages(reg) > 0) {
 		min_uV = on ? vreg->min_uV : 0;
@@ -349,17 +341,15 @@ int ufs_qcom_phy_cfg_vreg(struct phy *phy,
 }
 
 static
-int ufs_qcom_phy_enable_vreg(struct phy *phy,
+int ufs_qcom_phy_enable_vreg(struct device *dev,
 			     struct ufs_qcom_phy_vreg *vreg)
 {
-	struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(phy);
-	struct device *dev = ufs_qcom_phy->dev;
 	int ret = 0;
 
 	if (!vreg || vreg->enabled)
 		goto out;
 
-	ret = ufs_qcom_phy_cfg_vreg(phy, vreg, true);
+	ret = ufs_qcom_phy_cfg_vreg(dev, vreg, true);
 	if (ret) {
 		dev_err(dev, "%s: ufs_qcom_phy_cfg_vreg() failed, err=%d\n",
 			__func__, ret);
@@ -431,11 +421,9 @@ int ufs_qcom_phy_enable_ref_clk(struct phy *generic_phy)
 EXPORT_SYMBOL_GPL(ufs_qcom_phy_enable_ref_clk);
 
 static
-int ufs_qcom_phy_disable_vreg(struct phy *phy,
+int ufs_qcom_phy_disable_vreg(struct device *dev,
 			      struct ufs_qcom_phy_vreg *vreg)
 {
-	struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(phy);
-	struct device *dev = ufs_qcom_phy->dev;
 	int ret = 0;
 
 	if (!vreg || !vreg->enabled || vreg->is_always_on)
@@ -445,7 +433,7 @@ int ufs_qcom_phy_disable_vreg(struct phy *phy,
 
 	if (!ret) {
 		/* ignore errors on applying disable config */
-		ufs_qcom_phy_cfg_vreg(phy, vreg, false);
+		ufs_qcom_phy_cfg_vreg(dev, vreg, false);
 		vreg->enabled = false;
 	} else {
 		dev_err(dev, "%s: %s disable failed, err=%d\n",
@@ -673,7 +661,7 @@ int ufs_qcom_phy_power_on(struct phy *generic_phy)
 	struct device *dev = phy_common->dev;
 	int err;
 
-	err = ufs_qcom_phy_enable_vreg(generic_phy, &phy_common->vdda_phy);
+	err = ufs_qcom_phy_enable_vreg(dev, &phy_common->vdda_phy);
 	if (err) {
 		dev_err(dev, "%s enable vdda_phy failed, err=%d\n",
 			__func__, err);
@@ -683,7 +671,7 @@ int ufs_qcom_phy_power_on(struct phy *generic_phy)
 	phy_common->phy_spec_ops->power_control(phy_common, true);
 
 	/* vdda_pll also enables ref clock LDOs so enable it first */
-	err = ufs_qcom_phy_enable_vreg(generic_phy, &phy_common->vdda_pll);
+	err = ufs_qcom_phy_enable_vreg(dev, &phy_common->vdda_pll);
 	if (err) {
 		dev_err(dev, "%s enable vdda_pll failed, err=%d\n",
 			__func__, err);
@@ -699,7 +687,7 @@ int ufs_qcom_phy_power_on(struct phy *generic_phy)
 
 	/* enable device PHY ref_clk pad rail */
 	if (phy_common->vddp_ref_clk.reg) {
-		err = ufs_qcom_phy_enable_vreg(generic_phy,
+		err = ufs_qcom_phy_enable_vreg(dev,
 					       &phy_common->vddp_ref_clk);
 		if (err) {
 			dev_err(dev, "%s enable vddp_ref_clk failed, err=%d\n",
@@ -714,9 +702,9 @@ int ufs_qcom_phy_power_on(struct phy *generic_phy)
 out_disable_ref_clk:
 	ufs_qcom_phy_disable_ref_clk(generic_phy);
 out_disable_pll:
-	ufs_qcom_phy_disable_vreg(generic_phy, &phy_common->vdda_pll);
+	ufs_qcom_phy_disable_vreg(dev, &phy_common->vdda_pll);
 out_disable_phy:
-	ufs_qcom_phy_disable_vreg(generic_phy, &phy_common->vdda_phy);
+	ufs_qcom_phy_disable_vreg(dev, &phy_common->vdda_phy);
 out:
 	return err;
 }
@@ -729,12 +717,12 @@ int ufs_qcom_phy_power_off(struct phy *generic_phy)
 	phy_common->phy_spec_ops->power_control(phy_common, false);
 
 	if (phy_common->vddp_ref_clk.reg)
-		ufs_qcom_phy_disable_vreg(generic_phy,
+		ufs_qcom_phy_disable_vreg(phy_common->dev,
 					  &phy_common->vddp_ref_clk);
 	ufs_qcom_phy_disable_ref_clk(generic_phy);
 
-	ufs_qcom_phy_disable_vreg(generic_phy, &phy_common->vdda_pll);
-	ufs_qcom_phy_disable_vreg(generic_phy, &phy_common->vdda_phy);
+	ufs_qcom_phy_disable_vreg(phy_common->dev, &phy_common->vdda_pll);
+	ufs_qcom_phy_disable_vreg(phy_common->dev, &phy_common->vdda_phy);
 	phy_common->is_powered_on = false;
 
 	return 0;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 04/12] phy: qcom-ufs-14nm: Add new compatible for msm8996 based phy
  2016-10-29 20:22 [PATCH v3 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd Vivek Gautam
                   ` (2 preceding siblings ...)
  2016-10-29 20:22 ` [PATCH v3 03/12] phy: qcom-ufs: Cleanup clock and regulator initialization Vivek Gautam
@ 2016-10-29 20:22 ` Vivek Gautam
  2016-10-31 21:11   ` Subhash Jadavani
  2016-10-29 20:22 ` [PATCH v3 05/12] phy: qcom-ufs: Skip obtaining rx/tx_iface_clk " Vivek Gautam
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 25+ messages in thread
From: Vivek Gautam @ 2016-10-29 20:22 UTC (permalink / raw)
  To: kishon, jejb, vinholikatti, martin.petersen
  Cc: sboyd, subhashj, ygardi, linux-scsi, linux-arm-msm, Vivek Gautam

Add a new compatible string for 14nm ufs phy present on msm8996
chipset. This phy is bit different from the legacy 14nm ufs phy
in terms of the clocks that are needed to be handled in the driver.

Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
---

New patch in v3 of this cleanup series.

 Documentation/devicetree/bindings/ufs/ufs-qcom.txt | 7 +++++--
 drivers/phy/phy-qcom-ufs-qmp-14nm.c                | 1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/ufs/ufs-qcom.txt b/Documentation/devicetree/bindings/ufs/ufs-qcom.txt
index 070baf4..b6b5130 100644
--- a/Documentation/devicetree/bindings/ufs/ufs-qcom.txt
+++ b/Documentation/devicetree/bindings/ufs/ufs-qcom.txt
@@ -7,8 +7,11 @@ To bind UFS PHY with UFS host controller, the controller node should
 contain a phandle reference to UFS PHY node.
 
 Required properties:
-- compatible        : compatible list, contains "qcom,ufs-phy-qmp-20nm"
-		      or "qcom,ufs-phy-qmp-14nm" according to the relevant phy in use.
+- compatible        : compatible list, contains one of the following -
+			"qcom,ufs-phy-qmp-20nm" for 20nm ufs phy,
+			"qcom,ufs-phy-qmp-14nm" for legacy 14nm ufs phy,
+			"qcom,msm8996-ufs-phy-qmp-14nm" for 14nm ufs phy
+			 present on MSM8996 chipset.
 - reg               : should contain PHY register address space (mandatory),
 - reg-names         : indicates various resources passed to driver (via reg proptery) by name.
                       Required "reg-names" is "phy_mem".
diff --git a/drivers/phy/phy-qcom-ufs-qmp-14nm.c b/drivers/phy/phy-qcom-ufs-qmp-14nm.c
index e3bede7..b3d2612 100644
--- a/drivers/phy/phy-qcom-ufs-qmp-14nm.c
+++ b/drivers/phy/phy-qcom-ufs-qmp-14nm.c
@@ -180,6 +180,7 @@ static int ufs_qcom_phy_qmp_14nm_remove(struct platform_device *pdev)
 
 static const struct of_device_id ufs_qcom_phy_qmp_14nm_of_match[] = {
 	{.compatible = "qcom,ufs-phy-qmp-14nm"},
+	{.compatible = "qcom,msm8996-ufs-phy-qmp-14nm"},
 	{},
 };
 MODULE_DEVICE_TABLE(of, ufs_qcom_phy_qmp_14nm_of_match);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 05/12] phy: qcom-ufs: Skip obtaining rx/tx_iface_clk for msm8996 based phy
  2016-10-29 20:22 [PATCH v3 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd Vivek Gautam
                   ` (3 preceding siblings ...)
  2016-10-29 20:22 ` [PATCH v3 04/12] phy: qcom-ufs-14nm: Add new compatible for msm8996 based phy Vivek Gautam
@ 2016-10-29 20:22 ` Vivek Gautam
  2016-11-01 18:42   ` Subhash Jadavani
  2016-10-29 20:22 ` [PATCH v3 06/12] phy: qcom-ufs-qmp-xx: Discard remove callback for drivers Vivek Gautam
                   ` (7 subsequent siblings)
  12 siblings, 1 reply; 25+ messages in thread
From: Vivek Gautam @ 2016-10-29 20:22 UTC (permalink / raw)
  To: kishon, jejb, vinholikatti, martin.petersen
  Cc: sboyd, subhashj, ygardi, linux-scsi, linux-arm-msm, Vivek Gautam

The tx_iface_clk and rx_iface_clk no longer exist with UFS Phy
present on msm8996. So skip obtaining these clocks using
compatible match.

Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
---

New patch in v3 of this cleanup series.
Comes in place of the following patch in v2 -
 phy: qcom-ufs: remove failure when rx/tx_iface_clk are absent

 drivers/phy/phy-qcom-ufs.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
index a173b30..11c8cae 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -184,6 +184,10 @@ int ufs_qcom_phy_clk_get(struct device *dev,
 {
 	int err;
 
+	if (of_device_is_compatible(phy_common->dev->of_node,
+				"qcom,msm8996-ufs-phy-qmp-14nm"))
+		goto skip_txrx_clk;
+
 	err = ufs_qcom_phy_clk_get(phy_common->dev, "tx_iface_clk",
 				   &phy_common->tx_iface_clk);
 	if (err)
@@ -199,6 +203,7 @@ int ufs_qcom_phy_clk_get(struct device *dev,
 	if (err)
 		goto out;
 
+skip_txrx_clk:
 	/*
 	 * "ref_clk_parent" is optional hence don't abort init if it's not
 	 * found.
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 06/12] phy: qcom-ufs-qmp-xx: Discard remove callback for drivers.
  2016-10-29 20:22 [PATCH v3 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd Vivek Gautam
                   ` (4 preceding siblings ...)
  2016-10-29 20:22 ` [PATCH v3 05/12] phy: qcom-ufs: Skip obtaining rx/tx_iface_clk " Vivek Gautam
@ 2016-10-29 20:22 ` Vivek Gautam
  2016-10-29 20:22 ` [PATCH v3 07/12] phy: qcom-ufs: Remove unnecessary function declarations Vivek Gautam
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Vivek Gautam @ 2016-10-29 20:22 UTC (permalink / raw)
  To: kishon, jejb, vinholikatti, martin.petersen
  Cc: sboyd, subhashj, ygardi, linux-scsi, linux-arm-msm, Vivek Gautam

remove() callback does a phy_power_off() only over the phy,
and nothing else now.
The phy_power_off() over the generic phy is called from the phy
consumer, and phy provider driver should not explicitly need to
call any phy ops.
So discard the remove callback for qcom-ufs phy platform drivers.

Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
---

Changes since v2:
 - Addressed review comment about commmit message: s/phy_exit/phy_power_off

 drivers/phy/phy-qcom-ufs-qmp-14nm.c | 16 ----------------
 drivers/phy/phy-qcom-ufs-qmp-20nm.c | 16 ----------------
 drivers/phy/phy-qcom-ufs.c          |  9 ---------
 3 files changed, 41 deletions(-)

diff --git a/drivers/phy/phy-qcom-ufs-qmp-14nm.c b/drivers/phy/phy-qcom-ufs-qmp-14nm.c
index b3d2612..560f272 100644
--- a/drivers/phy/phy-qcom-ufs-qmp-14nm.c
+++ b/drivers/phy/phy-qcom-ufs-qmp-14nm.c
@@ -163,21 +163,6 @@ static int ufs_qcom_phy_qmp_14nm_probe(struct platform_device *pdev)
 	return err;
 }
 
-static int ufs_qcom_phy_qmp_14nm_remove(struct platform_device *pdev)
-{
-	struct device *dev = &pdev->dev;
-	struct phy *generic_phy = to_phy(dev);
-	struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(generic_phy);
-	int err = 0;
-
-	err = ufs_qcom_phy_remove(generic_phy, ufs_qcom_phy);
-	if (err)
-		dev_err(dev, "%s: ufs_qcom_phy_remove failed = %d\n",
-			__func__, err);
-
-	return err;
-}
-
 static const struct of_device_id ufs_qcom_phy_qmp_14nm_of_match[] = {
 	{.compatible = "qcom,ufs-phy-qmp-14nm"},
 	{.compatible = "qcom,msm8996-ufs-phy-qmp-14nm"},
@@ -187,7 +172,6 @@ static int ufs_qcom_phy_qmp_14nm_remove(struct platform_device *pdev)
 
 static struct platform_driver ufs_qcom_phy_qmp_14nm_driver = {
 	.probe = ufs_qcom_phy_qmp_14nm_probe,
-	.remove = ufs_qcom_phy_qmp_14nm_remove,
 	.driver = {
 		.of_match_table = ufs_qcom_phy_qmp_14nm_of_match,
 		.name = "ufs_qcom_phy_qmp_14nm",
diff --git a/drivers/phy/phy-qcom-ufs-qmp-20nm.c b/drivers/phy/phy-qcom-ufs-qmp-20nm.c
index e09ecb8c..9a2f53d 100644
--- a/drivers/phy/phy-qcom-ufs-qmp-20nm.c
+++ b/drivers/phy/phy-qcom-ufs-qmp-20nm.c
@@ -219,21 +219,6 @@ static int ufs_qcom_phy_qmp_20nm_probe(struct platform_device *pdev)
 	return err;
 }
 
-static int ufs_qcom_phy_qmp_20nm_remove(struct platform_device *pdev)
-{
-	struct device *dev = &pdev->dev;
-	struct phy *generic_phy = to_phy(dev);
-	struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(generic_phy);
-	int err = 0;
-
-	err = ufs_qcom_phy_remove(generic_phy, ufs_qcom_phy);
-	if (err)
-		dev_err(dev, "%s: ufs_qcom_phy_remove failed = %d\n",
-			__func__, err);
-
-	return err;
-}
-
 static const struct of_device_id ufs_qcom_phy_qmp_20nm_of_match[] = {
 	{.compatible = "qcom,ufs-phy-qmp-20nm"},
 	{},
@@ -242,7 +227,6 @@ static int ufs_qcom_phy_qmp_20nm_remove(struct platform_device *pdev)
 
 static struct platform_driver ufs_qcom_phy_qmp_20nm_driver = {
 	.probe = ufs_qcom_phy_qmp_20nm_probe,
-	.remove = ufs_qcom_phy_qmp_20nm_remove,
 	.driver = {
 		.of_match_table = ufs_qcom_phy_qmp_20nm_of_match,
 		.name = "ufs_qcom_phy_qmp_20nm",
diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
index 11c8cae..1a0c224 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -625,15 +625,6 @@ int ufs_qcom_phy_calibrate_phy(struct phy *generic_phy, bool is_rate_B)
 }
 EXPORT_SYMBOL_GPL(ufs_qcom_phy_calibrate_phy);
 
-int ufs_qcom_phy_remove(struct phy *generic_phy,
-			struct ufs_qcom_phy *ufs_qcom_phy)
-{
-	phy_power_off(generic_phy);
-
-	return 0;
-}
-EXPORT_SYMBOL_GPL(ufs_qcom_phy_remove);
-
 int ufs_qcom_phy_exit(struct phy *generic_phy)
 {
 	struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(generic_phy);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 07/12] phy: qcom-ufs: Remove unnecessary function declarations
  2016-10-29 20:22 [PATCH v3 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd Vivek Gautam
                   ` (5 preceding siblings ...)
  2016-10-29 20:22 ` [PATCH v3 06/12] phy: qcom-ufs-qmp-xx: Discard remove callback for drivers Vivek Gautam
@ 2016-10-29 20:22 ` Vivek Gautam
  2016-10-29 20:22 ` [PATCH v3 08/12] phy: qcom-ufs-qmp-xx: Move clock and regulator init out of phy init Vivek Gautam
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Vivek Gautam @ 2016-10-29 20:22 UTC (permalink / raw)
  To: kishon, jejb, vinholikatti, martin.petersen
  Cc: sboyd, subhashj, ygardi, linux-scsi, linux-arm-msm, Vivek Gautam

Move the functions' definitions to remove unnecessary
declarations.

Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
---

No changes since v2.

 drivers/phy/phy-qcom-ufs.c | 133 +++++++++++++++++++++------------------------
 1 file changed, 63 insertions(+), 70 deletions(-)

diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
index 1a0c224..1ec64d5 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -22,13 +22,6 @@
 #define VDDP_REF_CLK_MIN_UV        1200000
 #define VDDP_REF_CLK_MAX_UV        1200000
 
-static int __ufs_qcom_phy_init_vreg(struct device *, struct ufs_qcom_phy_vreg *,
-				    const char *, bool);
-static int ufs_qcom_phy_init_vreg(struct device *, struct ufs_qcom_phy_vreg *,
-				  const char *);
-static int ufs_qcom_phy_base_init(struct platform_device *pdev,
-				  struct ufs_qcom_phy *phy_common);
-
 int ufs_qcom_phy_calibrate(struct ufs_qcom_phy *ufs_qcom_phy,
 			   struct ufs_qcom_phy_calibration *tbl_A,
 			   int tbl_size_A,
@@ -75,45 +68,6 @@ int ufs_qcom_phy_calibrate(struct ufs_qcom_phy *ufs_qcom_phy,
 }
 EXPORT_SYMBOL_GPL(ufs_qcom_phy_calibrate);
 
-struct phy *ufs_qcom_phy_generic_probe(struct platform_device *pdev,
-				struct ufs_qcom_phy *common_cfg,
-				const struct phy_ops *ufs_qcom_phy_gen_ops,
-				struct ufs_qcom_phy_specific_ops *phy_spec_ops)
-{
-	int err;
-	struct device *dev = &pdev->dev;
-	struct phy *generic_phy = NULL;
-	struct phy_provider *phy_provider;
-
-	err = ufs_qcom_phy_base_init(pdev, common_cfg);
-	if (err) {
-		dev_err(dev, "%s: phy base init failed %d\n", __func__, err);
-		goto out;
-	}
-
-	phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
-	if (IS_ERR(phy_provider)) {
-		err = PTR_ERR(phy_provider);
-		dev_err(dev, "%s: failed to register phy %d\n", __func__, err);
-		goto out;
-	}
-
-	generic_phy = devm_phy_create(dev, NULL, ufs_qcom_phy_gen_ops);
-	if (IS_ERR(generic_phy)) {
-		err =  PTR_ERR(generic_phy);
-		dev_err(dev, "%s: failed to create phy %d\n", __func__, err);
-		generic_phy = NULL;
-		goto out;
-	}
-
-	common_cfg->phy_spec_ops = phy_spec_ops;
-	common_cfg->dev = dev;
-
-out:
-	return generic_phy;
-}
-EXPORT_SYMBOL_GPL(ufs_qcom_phy_generic_probe);
-
 /*
  * This assumes the embedded phy structure inside generic_phy is of type
  * struct ufs_qcom_phy. In order to function properly it's crucial
@@ -154,6 +108,45 @@ int ufs_qcom_phy_base_init(struct platform_device *pdev,
 	return 0;
 }
 
+struct phy *ufs_qcom_phy_generic_probe(struct platform_device *pdev,
+				struct ufs_qcom_phy *common_cfg,
+				const struct phy_ops *ufs_qcom_phy_gen_ops,
+				struct ufs_qcom_phy_specific_ops *phy_spec_ops)
+{
+	int err;
+	struct device *dev = &pdev->dev;
+	struct phy *generic_phy = NULL;
+	struct phy_provider *phy_provider;
+
+	err = ufs_qcom_phy_base_init(pdev, common_cfg);
+	if (err) {
+		dev_err(dev, "%s: phy base init failed %d\n", __func__, err);
+		goto out;
+	}
+
+	phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
+	if (IS_ERR(phy_provider)) {
+		err = PTR_ERR(phy_provider);
+		dev_err(dev, "%s: failed to register phy %d\n", __func__, err);
+		goto out;
+	}
+
+	generic_phy = devm_phy_create(dev, NULL, ufs_qcom_phy_gen_ops);
+	if (IS_ERR(generic_phy)) {
+		err =  PTR_ERR(generic_phy);
+		dev_err(dev, "%s: failed to create phy %d\n", __func__, err);
+		generic_phy = NULL;
+		goto out;
+	}
+
+	common_cfg->phy_spec_ops = phy_spec_ops;
+	common_cfg->dev = dev;
+
+out:
+	return generic_phy;
+}
+EXPORT_SYMBOL_GPL(ufs_qcom_phy_generic_probe);
+
 static int __ufs_qcom_phy_clk_get(struct device *dev,
 			 const char *name, struct clk **clk_out, bool err_print)
 {
@@ -219,30 +212,6 @@ int ufs_qcom_phy_clk_get(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(ufs_qcom_phy_init_clks);
 
-int
-ufs_qcom_phy_init_vregulators(struct ufs_qcom_phy *phy_common)
-{
-	int err;
-
-	err = ufs_qcom_phy_init_vreg(phy_common->dev, &phy_common->vdda_pll,
-		"vdda-pll");
-	if (err)
-		goto out;
-
-	err = ufs_qcom_phy_init_vreg(phy_common->dev, &phy_common->vdda_phy,
-		"vdda-phy");
-
-	if (err)
-		goto out;
-
-	/* vddp-ref-clk-* properties are optional */
-	__ufs_qcom_phy_init_vreg(phy_common->dev, &phy_common->vddp_ref_clk,
-				 "vddp-ref-clk", true);
-out:
-	return err;
-}
-EXPORT_SYMBOL_GPL(ufs_qcom_phy_init_vregulators);
-
 static int __ufs_qcom_phy_init_vreg(struct device *dev,
 		struct ufs_qcom_phy_vreg *vreg, const char *name, bool optional)
 {
@@ -309,6 +278,30 @@ static int ufs_qcom_phy_init_vreg(struct device *dev,
 	return __ufs_qcom_phy_init_vreg(dev, vreg, name, false);
 }
 
+int
+ufs_qcom_phy_init_vregulators(struct ufs_qcom_phy *phy_common)
+{
+	int err;
+
+	err = ufs_qcom_phy_init_vreg(phy_common->dev, &phy_common->vdda_pll,
+		"vdda-pll");
+	if (err)
+		goto out;
+
+	err = ufs_qcom_phy_init_vreg(phy_common->dev, &phy_common->vdda_phy,
+		"vdda-phy");
+
+	if (err)
+		goto out;
+
+	/* vddp-ref-clk-* properties are optional */
+	__ufs_qcom_phy_init_vreg(phy_common->dev, &phy_common->vddp_ref_clk,
+				 "vddp-ref-clk", true);
+out:
+	return err;
+}
+EXPORT_SYMBOL_GPL(ufs_qcom_phy_init_vregulators);
+
 static
 int ufs_qcom_phy_cfg_vreg(struct device *dev,
 			  struct ufs_qcom_phy_vreg *vreg, bool on)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 08/12] phy: qcom-ufs-qmp-xx: Move clock and regulator init out of phy init
  2016-10-29 20:22 [PATCH v3 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd Vivek Gautam
                   ` (6 preceding siblings ...)
  2016-10-29 20:22 ` [PATCH v3 07/12] phy: qcom-ufs: Remove unnecessary function declarations Vivek Gautam
@ 2016-10-29 20:22 ` Vivek Gautam
  2016-10-29 20:22 ` [PATCH v3 09/12] ufs-qcom: phy/hcd: Refactoring phy clock handling Vivek Gautam
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Vivek Gautam @ 2016-10-29 20:22 UTC (permalink / raw)
  To: kishon, jejb, vinholikatti, martin.petersen
  Cc: sboyd, subhashj, ygardi, linux-scsi, linux-arm-msm, Vivek Gautam

The phy init is meant to do phy initialization rather than
just getting the clock and regulator. Move these clock and
regulator get to probe(), to make room for actual phy
initialization sequence.

Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
---

No changes since v1.

 drivers/phy/phy-qcom-ufs-qmp-14nm.c | 52 ++++++++++++++++++-------------------
 drivers/phy/phy-qcom-ufs-qmp-20nm.c | 46 +++++++++++++++-----------------
 2 files changed, 46 insertions(+), 52 deletions(-)

diff --git a/drivers/phy/phy-qcom-ufs-qmp-14nm.c b/drivers/phy/phy-qcom-ufs-qmp-14nm.c
index 560f272..ae74614 100644
--- a/drivers/phy/phy-qcom-ufs-qmp-14nm.c
+++ b/drivers/phy/phy-qcom-ufs-qmp-14nm.c
@@ -44,30 +44,7 @@ void ufs_qcom_phy_qmp_14nm_advertise_quirks(struct ufs_qcom_phy *phy_common)
 
 static int ufs_qcom_phy_qmp_14nm_init(struct phy *generic_phy)
 {
-	struct ufs_qcom_phy_qmp_14nm *phy = phy_get_drvdata(generic_phy);
-	struct ufs_qcom_phy *phy_common = &phy->common_cfg;
-	int err;
-
-	err = ufs_qcom_phy_init_clks(phy_common);
-	if (err) {
-		dev_err(phy_common->dev, "%s: ufs_qcom_phy_init_clks() failed %d\n",
-			__func__, err);
-		goto out;
-	}
-
-	err = ufs_qcom_phy_init_vregulators(phy_common);
-	if (err) {
-		dev_err(phy_common->dev, "%s: ufs_qcom_phy_init_vregulators() failed %d\n",
-			__func__, err);
-		goto out;
-	}
-	phy_common->vdda_phy.max_uV = UFS_PHY_VDDA_PHY_UV;
-	phy_common->vdda_phy.min_uV = UFS_PHY_VDDA_PHY_UV;
-
-	ufs_qcom_phy_qmp_14nm_advertise_quirks(phy_common);
-
-out:
-	return err;
+	return 0;
 }
 
 static
@@ -136,6 +113,7 @@ static int ufs_qcom_phy_qmp_14nm_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct phy *generic_phy;
 	struct ufs_qcom_phy_qmp_14nm *phy;
+	struct ufs_qcom_phy *phy_common;
 	int err = 0;
 
 	phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
@@ -143,8 +121,9 @@ static int ufs_qcom_phy_qmp_14nm_probe(struct platform_device *pdev)
 		err = -ENOMEM;
 		goto out;
 	}
+	phy_common = &phy->common_cfg;
 
-	generic_phy = ufs_qcom_phy_generic_probe(pdev, &phy->common_cfg,
+	generic_phy = ufs_qcom_phy_generic_probe(pdev, phy_common,
 				&ufs_qcom_phy_qmp_14nm_phy_ops, &phy_14nm_ops);
 
 	if (!generic_phy) {
@@ -154,10 +133,29 @@ static int ufs_qcom_phy_qmp_14nm_probe(struct platform_device *pdev)
 		goto out;
 	}
 
+	err = ufs_qcom_phy_init_clks(phy_common);
+	if (err) {
+		dev_err(phy_common->dev,
+			"%s: ufs_qcom_phy_init_clks() failed %d\n",
+			__func__, err);
+		goto out;
+	}
+
+	err = ufs_qcom_phy_init_vregulators(phy_common);
+	if (err) {
+		dev_err(phy_common->dev,
+			"%s: ufs_qcom_phy_init_vregulators() failed %d\n",
+			__func__, err);
+		goto out;
+	}
+	phy_common->vdda_phy.max_uV = UFS_PHY_VDDA_PHY_UV;
+	phy_common->vdda_phy.min_uV = UFS_PHY_VDDA_PHY_UV;
+
+	ufs_qcom_phy_qmp_14nm_advertise_quirks(phy_common);
+
 	phy_set_drvdata(generic_phy, phy);
 
-	strlcpy(phy->common_cfg.name, UFS_PHY_NAME,
-		sizeof(phy->common_cfg.name));
+	strlcpy(phy_common->name, UFS_PHY_NAME, sizeof(phy_common->name));
 
 out:
 	return err;
diff --git a/drivers/phy/phy-qcom-ufs-qmp-20nm.c b/drivers/phy/phy-qcom-ufs-qmp-20nm.c
index 9a2f53d..dfc5175 100644
--- a/drivers/phy/phy-qcom-ufs-qmp-20nm.c
+++ b/drivers/phy/phy-qcom-ufs-qmp-20nm.c
@@ -63,28 +63,7 @@ void ufs_qcom_phy_qmp_20nm_advertise_quirks(struct ufs_qcom_phy *phy_common)
 
 static int ufs_qcom_phy_qmp_20nm_init(struct phy *generic_phy)
 {
-	struct ufs_qcom_phy_qmp_20nm *phy = phy_get_drvdata(generic_phy);
-	struct ufs_qcom_phy *phy_common = &phy->common_cfg;
-	int err = 0;
-
-	err = ufs_qcom_phy_init_clks(phy_common);
-	if (err) {
-		dev_err(phy_common->dev, "%s: ufs_qcom_phy_init_clks() failed %d\n",
-			__func__, err);
-		goto out;
-	}
-
-	err = ufs_qcom_phy_init_vregulators(phy_common);
-	if (err) {
-		dev_err(phy_common->dev, "%s: ufs_qcom_phy_init_vregulators() failed %d\n",
-			__func__, err);
-		goto out;
-	}
-
-	ufs_qcom_phy_qmp_20nm_advertise_quirks(phy_common);
-
-out:
-	return err;
+	return 0;
 }
 
 static
@@ -192,6 +171,7 @@ static int ufs_qcom_phy_qmp_20nm_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct phy *generic_phy;
 	struct ufs_qcom_phy_qmp_20nm *phy;
+	struct ufs_qcom_phy *phy_common;
 	int err = 0;
 
 	phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
@@ -199,8 +179,9 @@ static int ufs_qcom_phy_qmp_20nm_probe(struct platform_device *pdev)
 		err = -ENOMEM;
 		goto out;
 	}
+	phy_common = &phy->common_cfg;
 
-	generic_phy = ufs_qcom_phy_generic_probe(pdev, &phy->common_cfg,
+	generic_phy = ufs_qcom_phy_generic_probe(pdev, phy_common,
 				&ufs_qcom_phy_qmp_20nm_phy_ops, &phy_20nm_ops);
 
 	if (!generic_phy) {
@@ -210,10 +191,25 @@ static int ufs_qcom_phy_qmp_20nm_probe(struct platform_device *pdev)
 		goto out;
 	}
 
+	err = ufs_qcom_phy_init_clks(phy_common);
+	if (err) {
+		dev_err(phy_common->dev, "%s: ufs_qcom_phy_init_clks() failed %d\n",
+			__func__, err);
+		goto out;
+	}
+
+	err = ufs_qcom_phy_init_vregulators(phy_common);
+	if (err) {
+		dev_err(phy_common->dev, "%s: ufs_qcom_phy_init_vregulators() failed %d\n",
+			__func__, err);
+		goto out;
+	}
+
+	ufs_qcom_phy_qmp_20nm_advertise_quirks(phy_common);
+
 	phy_set_drvdata(generic_phy, phy);
 
-	strlcpy(phy->common_cfg.name, UFS_PHY_NAME,
-			sizeof(phy->common_cfg.name));
+	strlcpy(phy_common->name, UFS_PHY_NAME, sizeof(phy_common->name));
 
 out:
 	return err;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 09/12] ufs-qcom: phy/hcd: Refactoring phy clock handling
  2016-10-29 20:22 [PATCH v3 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd Vivek Gautam
                   ` (7 preceding siblings ...)
  2016-10-29 20:22 ` [PATCH v3 08/12] phy: qcom-ufs-qmp-xx: Move clock and regulator init out of phy init Vivek Gautam
@ 2016-10-29 20:22 ` Vivek Gautam
  2016-11-01 18:47   ` Subhash Jadavani
  2016-10-29 20:22 ` [PATCH v3 10/12] phy: qcom-ufs: Remove common layer phy exit callback Vivek Gautam
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 25+ messages in thread
From: Vivek Gautam @ 2016-10-29 20:22 UTC (permalink / raw)
  To: kishon, jejb, vinholikatti, martin.petersen
  Cc: sboyd, subhashj, ygardi, linux-scsi, linux-arm-msm, Vivek Gautam

Add phy clock enable code to phy_power_on/off callbacks, and
remove explicit calls to enable these phy clocks from the
ufs-qcom hcd driver.

Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
---

Changes since v2:
 - Added phy_power_on() and phy_power_off() calls to
   power-cycle the PHY during aggressive clk gating.

Changes since v1:
 - staticized ufs_qcom_phy_enable(/disable)_ref_clk(),
 - staticized ufs_qcom_phy_enable(/disable)_iface_clk()
 - removed function declaration and export symbol for these APIs.

 drivers/phy/phy-qcom-ufs.c       | 36 ++++++++++++++++++------------------
 drivers/scsi/ufs/ufs-qcom.c      | 18 +++---------------
 include/linux/phy/phy-qcom-ufs.h | 18 ------------------
 3 files changed, 21 insertions(+), 51 deletions(-)

diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
index 1ec64d5..9dff4c2 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -366,10 +366,9 @@ int ufs_qcom_phy_enable_vreg(struct device *dev,
 	return ret;
 }
 
-int ufs_qcom_phy_enable_ref_clk(struct phy *generic_phy)
+static int ufs_qcom_phy_enable_ref_clk(struct ufs_qcom_phy *phy)
 {
 	int ret = 0;
-	struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy);
 
 	if (phy->is_ref_clk_enabled)
 		goto out;
@@ -416,7 +415,6 @@ int ufs_qcom_phy_enable_ref_clk(struct phy *generic_phy)
 out:
 	return ret;
 }
-EXPORT_SYMBOL_GPL(ufs_qcom_phy_enable_ref_clk);
 
 static
 int ufs_qcom_phy_disable_vreg(struct device *dev,
@@ -441,10 +439,8 @@ int ufs_qcom_phy_disable_vreg(struct device *dev,
 	return ret;
 }
 
-void ufs_qcom_phy_disable_ref_clk(struct phy *generic_phy)
+static void ufs_qcom_phy_disable_ref_clk(struct ufs_qcom_phy *phy)
 {
-	struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy);
-
 	if (phy->is_ref_clk_enabled) {
 		clk_disable_unprepare(phy->ref_clk);
 		/*
@@ -457,7 +453,6 @@ void ufs_qcom_phy_disable_ref_clk(struct phy *generic_phy)
 		phy->is_ref_clk_enabled = false;
 	}
 }
-EXPORT_SYMBOL_GPL(ufs_qcom_phy_disable_ref_clk);
 
 #define UFS_REF_CLK_EN	(1 << 5)
 
@@ -510,9 +505,8 @@ void ufs_qcom_phy_disable_dev_ref_clk(struct phy *generic_phy)
 EXPORT_SYMBOL_GPL(ufs_qcom_phy_disable_dev_ref_clk);
 
 /* Turn ON M-PHY RMMI interface clocks */
-int ufs_qcom_phy_enable_iface_clk(struct phy *generic_phy)
+static int ufs_qcom_phy_enable_iface_clk(struct ufs_qcom_phy *phy)
 {
-	struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy);
 	int ret = 0;
 
 	if (phy->is_iface_clk_enabled)
@@ -536,20 +530,16 @@ int ufs_qcom_phy_enable_iface_clk(struct phy *generic_phy)
 out:
 	return ret;
 }
-EXPORT_SYMBOL_GPL(ufs_qcom_phy_enable_iface_clk);
 
 /* Turn OFF M-PHY RMMI interface clocks */
-void ufs_qcom_phy_disable_iface_clk(struct phy *generic_phy)
+void ufs_qcom_phy_disable_iface_clk(struct ufs_qcom_phy *phy)
 {
-	struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy);
-
 	if (phy->is_iface_clk_enabled) {
 		clk_disable_unprepare(phy->tx_iface_clk);
 		clk_disable_unprepare(phy->rx_iface_clk);
 		phy->is_iface_clk_enabled = false;
 	}
 }
-EXPORT_SYMBOL_GPL(ufs_qcom_phy_disable_iface_clk);
 
 int ufs_qcom_phy_start_serdes(struct phy *generic_phy)
 {
@@ -667,13 +657,20 @@ int ufs_qcom_phy_power_on(struct phy *generic_phy)
 		goto out_disable_phy;
 	}
 
-	err = ufs_qcom_phy_enable_ref_clk(generic_phy);
+	err = ufs_qcom_phy_enable_iface_clk(phy_common);
 	if (err) {
-		dev_err(dev, "%s enable phy ref clock failed, err=%d\n",
+		dev_err(dev, "%s enable phy iface clock failed, err=%d\n",
 			__func__, err);
 		goto out_disable_pll;
 	}
 
+	err = ufs_qcom_phy_enable_ref_clk(phy_common);
+	if (err) {
+		dev_err(dev, "%s enable phy ref clock failed, err=%d\n",
+			__func__, err);
+		goto out_disable_iface_clk;
+	}
+
 	/* enable device PHY ref_clk pad rail */
 	if (phy_common->vddp_ref_clk.reg) {
 		err = ufs_qcom_phy_enable_vreg(dev,
@@ -689,7 +686,9 @@ int ufs_qcom_phy_power_on(struct phy *generic_phy)
 	goto out;
 
 out_disable_ref_clk:
-	ufs_qcom_phy_disable_ref_clk(generic_phy);
+	ufs_qcom_phy_disable_ref_clk(phy_common);
+out_disable_iface_clk:
+	ufs_qcom_phy_disable_iface_clk(phy_common);
 out_disable_pll:
 	ufs_qcom_phy_disable_vreg(dev, &phy_common->vdda_pll);
 out_disable_phy:
@@ -708,7 +707,8 @@ int ufs_qcom_phy_power_off(struct phy *generic_phy)
 	if (phy_common->vddp_ref_clk.reg)
 		ufs_qcom_phy_disable_vreg(phy_common->dev,
 					  &phy_common->vddp_ref_clk);
-	ufs_qcom_phy_disable_ref_clk(generic_phy);
+	ufs_qcom_phy_disable_ref_clk(phy_common);
+	ufs_qcom_phy_disable_iface_clk(phy_common);
 
 	ufs_qcom_phy_disable_vreg(phy_common->dev, &phy_common->vdda_pll);
 	ufs_qcom_phy_disable_vreg(phy_common->dev, &phy_common->vdda_phy);
diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index 3aedf73..9b6a081 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -1112,17 +1112,7 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on)
 		return 0;
 
 	if (on) {
-		err = ufs_qcom_phy_enable_iface_clk(host->generic_phy);
-		if (err)
-			goto out;
-
-		err = ufs_qcom_phy_enable_ref_clk(host->generic_phy);
-		if (err) {
-			dev_err(hba->dev, "%s enable phy ref clock failed, err=%d\n",
-				__func__, err);
-			ufs_qcom_phy_disable_iface_clk(host->generic_phy);
-			goto out;
-		}
+		phy_power_on(host->generic_phy);
 		/* enable the device ref clock for HS mode*/
 		if (ufshcd_is_hs_mode(&hba->pwr_info))
 			ufs_qcom_dev_ref_clk_ctrl(host, true);
@@ -1131,9 +1121,8 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on)
 			ufs_qcom_update_bus_bw_vote(host);
 
 	} else {
-
-		/* M-PHY RMMI interface clocks can be turned off */
-		ufs_qcom_phy_disable_iface_clk(host->generic_phy);
+		/* powering off PHY during aggressive clk gating */
+		phy_power_off(host->generic_phy);
 		if (!ufs_qcom_is_link_active(hba))
 			/* disable device ref_clk */
 			ufs_qcom_dev_ref_clk_ctrl(host, false);
@@ -1146,7 +1135,6 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on)
 		dev_err(hba->dev, "%s: set bus vote failed %d\n",
 				__func__, err);
 
-out:
 	return err;
 }
 
diff --git a/include/linux/phy/phy-qcom-ufs.h b/include/linux/phy/phy-qcom-ufs.h
index 9d18e9f..35c070e 100644
--- a/include/linux/phy/phy-qcom-ufs.h
+++ b/include/linux/phy/phy-qcom-ufs.h
@@ -18,22 +18,6 @@
 #include "phy.h"
 
 /**
- * ufs_qcom_phy_enable_ref_clk() - Enable the phy
- * ref clock.
- * @phy: reference to a generic phy
- *
- * returns 0 for success, and non-zero for error.
- */
-int ufs_qcom_phy_enable_ref_clk(struct phy *phy);
-
-/**
- * ufs_qcom_phy_disable_ref_clk() - Disable the phy
- * ref clock.
- * @phy: reference to a generic phy.
- */
-void ufs_qcom_phy_disable_ref_clk(struct phy *phy);
-
-/**
  * ufs_qcom_phy_enable_dev_ref_clk() - Enable the device
  * ref clock.
  * @phy: reference to a generic phy.
@@ -47,8 +31,6 @@
  */
 void ufs_qcom_phy_disable_dev_ref_clk(struct phy *phy);
 
-int ufs_qcom_phy_enable_iface_clk(struct phy *phy);
-void ufs_qcom_phy_disable_iface_clk(struct phy *phy);
 int ufs_qcom_phy_start_serdes(struct phy *phy);
 int ufs_qcom_phy_set_tx_lane_enable(struct phy *phy, u32 tx_lanes);
 int ufs_qcom_phy_calibrate_phy(struct phy *phy, bool is_rate_B);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 10/12] phy: qcom-ufs: Remove common layer phy exit callback
  2016-10-29 20:22 [PATCH v3 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd Vivek Gautam
                   ` (8 preceding siblings ...)
  2016-10-29 20:22 ` [PATCH v3 09/12] ufs-qcom: phy/hcd: Refactoring phy clock handling Vivek Gautam
@ 2016-10-29 20:22 ` Vivek Gautam
  2016-10-29 20:22 ` [PATCH v3 11/12] scsi/ufs: qcom: Add phy_exit call in hcd exit path Vivek Gautam
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Vivek Gautam @ 2016-10-29 20:22 UTC (permalink / raw)
  To: kishon, jejb, vinholikatti, martin.petersen
  Cc: sboyd, subhashj, ygardi, linux-scsi, linux-arm-msm, Vivek Gautam

The common layer phy exit callback ufs_qcom_phy_exit()
calls phy_power_off() that has no meaning when phy_power_off()
callback is already registered with the phy provider and
the consumer makes use of the same.
Instead, add a no-op specific phy_exit() callback for now
to add the exit sequence at a later point.

Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
---

No changes since v2.

 drivers/phy/phy-qcom-ufs-i.h        |  1 -
 drivers/phy/phy-qcom-ufs-qmp-14nm.c |  7 ++++++-
 drivers/phy/phy-qcom-ufs-qmp-20nm.c |  7 ++++++-
 drivers/phy/phy-qcom-ufs.c          | 17 ++++++-----------
 4 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/drivers/phy/phy-qcom-ufs-i.h b/drivers/phy/phy-qcom-ufs-i.h
index 69e836d..d505d98 100644
--- a/drivers/phy/phy-qcom-ufs-i.h
+++ b/drivers/phy/phy-qcom-ufs-i.h
@@ -141,7 +141,6 @@ struct ufs_qcom_phy_specific_ops {
 struct ufs_qcom_phy *get_ufs_qcom_phy(struct phy *generic_phy);
 int ufs_qcom_phy_power_on(struct phy *generic_phy);
 int ufs_qcom_phy_power_off(struct phy *generic_phy);
-int ufs_qcom_phy_exit(struct phy *generic_phy);
 int ufs_qcom_phy_init_clks(struct ufs_qcom_phy *phy_common);
 int ufs_qcom_phy_init_vregulators(struct ufs_qcom_phy *phy_common);
 int ufs_qcom_phy_remove(struct phy *generic_phy,
diff --git a/drivers/phy/phy-qcom-ufs-qmp-14nm.c b/drivers/phy/phy-qcom-ufs-qmp-14nm.c
index ae74614..c71c847 100644
--- a/drivers/phy/phy-qcom-ufs-qmp-14nm.c
+++ b/drivers/phy/phy-qcom-ufs-qmp-14nm.c
@@ -47,6 +47,11 @@ static int ufs_qcom_phy_qmp_14nm_init(struct phy *generic_phy)
 	return 0;
 }
 
+static int ufs_qcom_phy_qmp_14nm_exit(struct phy *generic_phy)
+{
+	return 0;
+}
+
 static
 void ufs_qcom_phy_qmp_14nm_power_control(struct ufs_qcom_phy *phy, bool val)
 {
@@ -94,7 +99,7 @@ static int ufs_qcom_phy_qmp_14nm_is_pcs_ready(struct ufs_qcom_phy *phy_common)
 
 static const struct phy_ops ufs_qcom_phy_qmp_14nm_phy_ops = {
 	.init		= ufs_qcom_phy_qmp_14nm_init,
-	.exit		= ufs_qcom_phy_exit,
+	.exit		= ufs_qcom_phy_qmp_14nm_exit,
 	.power_on	= ufs_qcom_phy_power_on,
 	.power_off	= ufs_qcom_phy_power_off,
 	.owner		= THIS_MODULE,
diff --git a/drivers/phy/phy-qcom-ufs-qmp-20nm.c b/drivers/phy/phy-qcom-ufs-qmp-20nm.c
index dfc5175..1a26a64 100644
--- a/drivers/phy/phy-qcom-ufs-qmp-20nm.c
+++ b/drivers/phy/phy-qcom-ufs-qmp-20nm.c
@@ -66,6 +66,11 @@ static int ufs_qcom_phy_qmp_20nm_init(struct phy *generic_phy)
 	return 0;
 }
 
+static int ufs_qcom_phy_qmp_20nm_exit(struct phy *generic_phy)
+{
+	return 0;
+}
+
 static
 void ufs_qcom_phy_qmp_20nm_power_control(struct ufs_qcom_phy *phy, bool val)
 {
@@ -152,7 +157,7 @@ static int ufs_qcom_phy_qmp_20nm_is_pcs_ready(struct ufs_qcom_phy *phy_common)
 
 static const struct phy_ops ufs_qcom_phy_qmp_20nm_phy_ops = {
 	.init		= ufs_qcom_phy_qmp_20nm_init,
-	.exit		= ufs_qcom_phy_exit,
+	.exit		= ufs_qcom_phy_qmp_20nm_exit,
 	.power_on	= ufs_qcom_phy_power_on,
 	.power_off	= ufs_qcom_phy_power_off,
 	.owner		= THIS_MODULE,
diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
index 9dff4c2..ef340d6 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -608,17 +608,6 @@ int ufs_qcom_phy_calibrate_phy(struct phy *generic_phy, bool is_rate_B)
 }
 EXPORT_SYMBOL_GPL(ufs_qcom_phy_calibrate_phy);
 
-int ufs_qcom_phy_exit(struct phy *generic_phy)
-{
-	struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(generic_phy);
-
-	if (ufs_qcom_phy->is_powered_on)
-		phy_power_off(generic_phy);
-
-	return 0;
-}
-EXPORT_SYMBOL_GPL(ufs_qcom_phy_exit);
-
 int ufs_qcom_phy_is_pcs_ready(struct phy *generic_phy)
 {
 	struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(generic_phy);
@@ -640,6 +629,9 @@ int ufs_qcom_phy_power_on(struct phy *generic_phy)
 	struct device *dev = phy_common->dev;
 	int err;
 
+	if (phy_common->is_powered_on)
+		return 0;
+
 	err = ufs_qcom_phy_enable_vreg(dev, &phy_common->vdda_phy);
 	if (err) {
 		dev_err(dev, "%s enable vdda_phy failed, err=%d\n",
@@ -702,6 +694,9 @@ int ufs_qcom_phy_power_off(struct phy *generic_phy)
 {
 	struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy);
 
+	if (!phy_common->is_powered_on)
+		return 0;
+
 	phy_common->phy_spec_ops->power_control(phy_common, false);
 
 	if (phy_common->vddp_ref_clk.reg)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 11/12] scsi/ufs: qcom: Add phy_exit call in hcd exit path
  2016-10-29 20:22 [PATCH v3 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd Vivek Gautam
                   ` (9 preceding siblings ...)
  2016-10-29 20:22 ` [PATCH v3 10/12] phy: qcom-ufs: Remove common layer phy exit callback Vivek Gautam
@ 2016-10-29 20:22 ` Vivek Gautam
  2016-10-29 20:22 ` [PATCH v3 12/12] scsi/ufs: qcom: Don't free resource-managed kmalloc element Vivek Gautam
  2016-11-01 13:58 ` [PATCH v3 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd Martin K. Petersen
  12 siblings, 0 replies; 25+ messages in thread
From: Vivek Gautam @ 2016-10-29 20:22 UTC (permalink / raw)
  To: kishon, jejb, vinholikatti, martin.petersen
  Cc: sboyd, subhashj, ygardi, linux-scsi, linux-arm-msm, Vivek Gautam

Do a phy_exit() over the ufs phy in the ufs qcom exit path
to de-initialize the phy.

Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
---

No changes since v2.

 drivers/scsi/ufs/ufs-qcom.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index 9b6a081..9590df5 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -1275,6 +1275,7 @@ static void ufs_qcom_exit(struct ufs_hba *hba)
 
 	ufs_qcom_disable_lane_clks(host);
 	phy_power_off(host->generic_phy);
+	phy_exit(host->generic_phy);
 }
 
 static int ufs_qcom_set_dme_vs_core_clk_ctrl_clear_div(struct ufs_hba *hba,
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 12/12] scsi/ufs: qcom: Don't free resource-managed kmalloc element
  2016-10-29 20:22 [PATCH v3 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd Vivek Gautam
                   ` (10 preceding siblings ...)
  2016-10-29 20:22 ` [PATCH v3 11/12] scsi/ufs: qcom: Add phy_exit call in hcd exit path Vivek Gautam
@ 2016-10-29 20:22 ` Vivek Gautam
  2016-10-31 21:14   ` Subhash Jadavani
  2016-11-01 13:58 ` [PATCH v3 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd Martin K. Petersen
  12 siblings, 1 reply; 25+ messages in thread
From: Vivek Gautam @ 2016-10-29 20:22 UTC (permalink / raw)
  To: kishon, jejb, vinholikatti, martin.petersen
  Cc: sboyd, subhashj, ygardi, linux-scsi, linux-arm-msm, Vivek Gautam

Host is allocated by managed kmalloc (devm_kmalloc). The
memory allocated with this function is automatically
freed on driver detach.
So, no need to make an exclusive free call over it.

Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
---

New patch added in v3 of this cleanup series.

 drivers/scsi/ufs/ufs-qcom.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index 9590df5..60a38b1 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -1263,7 +1263,6 @@ static int ufs_qcom_init(struct ufs_hba *hba)
 out_unregister_bus:
 	phy_exit(host->generic_phy);
 out_host_free:
-	devm_kfree(dev, host);
 	ufshcd_set_variant(hba, NULL);
 out:
 	return err;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 04/12] phy: qcom-ufs-14nm: Add new compatible for msm8996 based phy
  2016-10-29 20:22 ` [PATCH v3 04/12] phy: qcom-ufs-14nm: Add new compatible for msm8996 based phy Vivek Gautam
@ 2016-10-31 21:11   ` Subhash Jadavani
  2016-11-03 17:07     ` Vivek Gautam
  0 siblings, 1 reply; 25+ messages in thread
From: Subhash Jadavani @ 2016-10-31 21:11 UTC (permalink / raw)
  To: Vivek Gautam
  Cc: kishon, jejb, vinholikatti, martin.petersen, sboyd, ygardi,
	linux-scsi, linux-arm-msm

On 2016-10-29 13:22, Vivek Gautam wrote:
> Add a new compatible string for 14nm ufs phy present on msm8996
> chipset. This phy is bit different from the legacy 14nm ufs phy
> in terms of the clocks that are needed to be handled in the driver.
> 
> Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
> ---
> 
> New patch in v3 of this cleanup series.
> 
>  Documentation/devicetree/bindings/ufs/ufs-qcom.txt | 7 +++++--
>  drivers/phy/phy-qcom-ufs-qmp-14nm.c                | 1 +
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/ufs/ufs-qcom.txt
> b/Documentation/devicetree/bindings/ufs/ufs-qcom.txt
> index 070baf4..b6b5130 100644
> --- a/Documentation/devicetree/bindings/ufs/ufs-qcom.txt
> +++ b/Documentation/devicetree/bindings/ufs/ufs-qcom.txt
> @@ -7,8 +7,11 @@ To bind UFS PHY with UFS host controller, the
> controller node should
>  contain a phandle reference to UFS PHY node.
> 
>  Required properties:
> -- compatible        : compatible list, contains 
> "qcom,ufs-phy-qmp-20nm"
> -		      or "qcom,ufs-phy-qmp-14nm" according to the relevant phy in 
> use.
> +- compatible        : compatible list, contains one of the following -
> +			"qcom,ufs-phy-qmp-20nm" for 20nm ufs phy,
> +			"qcom,ufs-phy-qmp-14nm" for legacy 14nm ufs phy,
> +			"qcom,msm8996-ufs-phy-qmp-14nm" for 14nm ufs phy
> +			 present on MSM8996 chipset.

For future chipsets (after MSM8996), we have to use this same compatible 
strings? If yes, "msm8996" in compatible string name may cause 
confusions? may be we should start following v1/v2/... terminologies for 
this?
something like "qcom,ufs-phy-qmp-v2" to start with?

>  - reg               : should contain PHY register address space 
> (mandatory),
>  - reg-names         : indicates various resources passed to driver
> (via reg proptery) by name.
>                        Required "reg-names" is "phy_mem".
> diff --git a/drivers/phy/phy-qcom-ufs-qmp-14nm.c
> b/drivers/phy/phy-qcom-ufs-qmp-14nm.c
> index e3bede7..b3d2612 100644
> --- a/drivers/phy/phy-qcom-ufs-qmp-14nm.c
> +++ b/drivers/phy/phy-qcom-ufs-qmp-14nm.c
> @@ -180,6 +180,7 @@ static int ufs_qcom_phy_qmp_14nm_remove(struct
> platform_device *pdev)
> 
>  static const struct of_device_id ufs_qcom_phy_qmp_14nm_of_match[] = {
>  	{.compatible = "qcom,ufs-phy-qmp-14nm"},
> +	{.compatible = "qcom,msm8996-ufs-phy-qmp-14nm"},
>  	{},
>  };
>  MODULE_DEVICE_TABLE(of, ufs_qcom_phy_qmp_14nm_of_match);

-- 
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 12/12] scsi/ufs: qcom: Don't free resource-managed kmalloc element
  2016-10-29 20:22 ` [PATCH v3 12/12] scsi/ufs: qcom: Don't free resource-managed kmalloc element Vivek Gautam
@ 2016-10-31 21:14   ` Subhash Jadavani
  0 siblings, 0 replies; 25+ messages in thread
From: Subhash Jadavani @ 2016-10-31 21:14 UTC (permalink / raw)
  To: Vivek Gautam
  Cc: kishon, jejb, vinholikatti, martin.petersen, sboyd, ygardi,
	linux-scsi, linux-arm-msm

On 2016-10-29 13:22, Vivek Gautam wrote:
> Host is allocated by managed kmalloc (devm_kmalloc). The
> memory allocated with this function is automatically
> freed on driver detach.
> So, no need to make an exclusive free call over it.
> 
> Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
> ---
> 
> New patch added in v3 of this cleanup series.
> 
>  drivers/scsi/ufs/ufs-qcom.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
> index 9590df5..60a38b1 100644
> --- a/drivers/scsi/ufs/ufs-qcom.c
> +++ b/drivers/scsi/ufs/ufs-qcom.c
> @@ -1263,7 +1263,6 @@ static int ufs_qcom_init(struct ufs_hba *hba)
>  out_unregister_bus:
>  	phy_exit(host->generic_phy);
>  out_host_free:
> -	devm_kfree(dev, host);
>  	ufshcd_set_variant(hba, NULL);
>  out:
>  	return err;

LGTM, Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>

-- 
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd
  2016-10-29 20:22 [PATCH v3 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd Vivek Gautam
                   ` (11 preceding siblings ...)
  2016-10-29 20:22 ` [PATCH v3 12/12] scsi/ufs: qcom: Don't free resource-managed kmalloc element Vivek Gautam
@ 2016-11-01 13:58 ` Martin K. Petersen
  12 siblings, 0 replies; 25+ messages in thread
From: Martin K. Petersen @ 2016-11-01 13:58 UTC (permalink / raw)
  To: Vivek Gautam
  Cc: kishon, jejb, vinholikatti, martin.petersen, sboyd, subhashj,
	ygardi, linux-scsi, linux-arm-msm

>>>>> "Vivek" == Vivek Gautam <vivek.gautam@codeaurora.org> writes:

Vivek> These patches cleanup the ufs phy driver to an extent.
Vivek> Subsequent patches will target to clean the phy_init() of these
Vivek> qcom-ufs phy drivers in order to get rid of a number of exported
Vivek> APIs that phy drivers expose for ufs-qcom hcd driver to use.

Vivek: Please address the comments to patch 4.

Subhash: Please review patches 5 and 9.

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 05/12] phy: qcom-ufs: Skip obtaining rx/tx_iface_clk for msm8996 based phy
  2016-10-29 20:22 ` [PATCH v3 05/12] phy: qcom-ufs: Skip obtaining rx/tx_iface_clk " Vivek Gautam
@ 2016-11-01 18:42   ` Subhash Jadavani
  2016-11-04  6:11     ` Subhash Jadavani
  0 siblings, 1 reply; 25+ messages in thread
From: Subhash Jadavani @ 2016-11-01 18:42 UTC (permalink / raw)
  To: Vivek Gautam
  Cc: kishon, jejb, vinholikatti, martin.petersen, sboyd, ygardi,
	linux-scsi, linux-arm-msm, linux-scsi-owner

On 2016-10-29 13:22, Vivek Gautam wrote:
> The tx_iface_clk and rx_iface_clk no longer exist with UFS Phy
> present on msm8996. So skip obtaining these clocks using
> compatible match.
> 
> Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
> ---
> 
> New patch in v3 of this cleanup series.
> Comes in place of the following patch in v2 -
>  phy: qcom-ufs: remove failure when rx/tx_iface_clk are absent
> 
>  drivers/phy/phy-qcom-ufs.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
> index a173b30..11c8cae 100644
> --- a/drivers/phy/phy-qcom-ufs.c
> +++ b/drivers/phy/phy-qcom-ufs.c
> @@ -184,6 +184,10 @@ int ufs_qcom_phy_clk_get(struct device *dev,
>  {
>  	int err;
> 
> +	if (of_device_is_compatible(phy_common->dev->of_node,
> +				"qcom,msm8996-ufs-phy-qmp-14nm"))

Vivek, This change looks good but you might need a minor change if we 
agree to change the compatible string name 
("qcom,msm8996-ufs-phy-qmp-14nm") as commented on patch #4.

> +		goto skip_txrx_clk;
> +
>  	err = ufs_qcom_phy_clk_get(phy_common->dev, "tx_iface_clk",
>  				   &phy_common->tx_iface_clk);
>  	if (err)
> @@ -199,6 +203,7 @@ int ufs_qcom_phy_clk_get(struct device *dev,
>  	if (err)
>  		goto out;
> 
> +skip_txrx_clk:
>  	/*
>  	 * "ref_clk_parent" is optional hence don't abort init if it's not
>  	 * found.

-- 
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 09/12] ufs-qcom: phy/hcd: Refactoring phy clock handling
  2016-10-29 20:22 ` [PATCH v3 09/12] ufs-qcom: phy/hcd: Refactoring phy clock handling Vivek Gautam
@ 2016-11-01 18:47   ` Subhash Jadavani
  2016-11-02  7:34     ` Vivek Gautam
  0 siblings, 1 reply; 25+ messages in thread
From: Subhash Jadavani @ 2016-11-01 18:47 UTC (permalink / raw)
  To: Vivek Gautam
  Cc: kishon, jejb, vinholikatti, martin.petersen, sboyd, ygardi,
	linux-scsi, linux-arm-msm, linux-scsi-owner

On 2016-10-29 13:22, Vivek Gautam wrote:
> Add phy clock enable code to phy_power_on/off callbacks, and
> remove explicit calls to enable these phy clocks from the
> ufs-qcom hcd driver.
> 
> Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
> ---
> 
> Changes since v2:
>  - Added phy_power_on() and phy_power_off() calls to
>    power-cycle the PHY during aggressive clk gating.
> 
> Changes since v1:
>  - staticized ufs_qcom_phy_enable(/disable)_ref_clk(),
>  - staticized ufs_qcom_phy_enable(/disable)_iface_clk()
>  - removed function declaration and export symbol for these APIs.
> 
>  drivers/phy/phy-qcom-ufs.c       | 36 
> ++++++++++++++++++------------------
>  drivers/scsi/ufs/ufs-qcom.c      | 18 +++---------------
>  include/linux/phy/phy-qcom-ufs.h | 18 ------------------
>  3 files changed, 21 insertions(+), 51 deletions(-)
> 
> diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
> index 1ec64d5..9dff4c2 100644
> --- a/drivers/phy/phy-qcom-ufs.c
> +++ b/drivers/phy/phy-qcom-ufs.c
> @@ -366,10 +366,9 @@ int ufs_qcom_phy_enable_vreg(struct device *dev,
>  	return ret;
>  }
> 
> -int ufs_qcom_phy_enable_ref_clk(struct phy *generic_phy)
> +static int ufs_qcom_phy_enable_ref_clk(struct ufs_qcom_phy *phy)
>  {
>  	int ret = 0;
> -	struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy);
> 
>  	if (phy->is_ref_clk_enabled)
>  		goto out;
> @@ -416,7 +415,6 @@ int ufs_qcom_phy_enable_ref_clk(struct phy 
> *generic_phy)
>  out:
>  	return ret;
>  }
> -EXPORT_SYMBOL_GPL(ufs_qcom_phy_enable_ref_clk);
> 
>  static
>  int ufs_qcom_phy_disable_vreg(struct device *dev,
> @@ -441,10 +439,8 @@ int ufs_qcom_phy_disable_vreg(struct device *dev,
>  	return ret;
>  }
> 
> -void ufs_qcom_phy_disable_ref_clk(struct phy *generic_phy)
> +static void ufs_qcom_phy_disable_ref_clk(struct ufs_qcom_phy *phy)
>  {
> -	struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy);
> -
>  	if (phy->is_ref_clk_enabled) {
>  		clk_disable_unprepare(phy->ref_clk);
>  		/*
> @@ -457,7 +453,6 @@ void ufs_qcom_phy_disable_ref_clk(struct phy 
> *generic_phy)
>  		phy->is_ref_clk_enabled = false;
>  	}
>  }
> -EXPORT_SYMBOL_GPL(ufs_qcom_phy_disable_ref_clk);
> 
>  #define UFS_REF_CLK_EN	(1 << 5)
> 
> @@ -510,9 +505,8 @@ void ufs_qcom_phy_disable_dev_ref_clk(struct phy
> *generic_phy)
>  EXPORT_SYMBOL_GPL(ufs_qcom_phy_disable_dev_ref_clk);
> 
>  /* Turn ON M-PHY RMMI interface clocks */
> -int ufs_qcom_phy_enable_iface_clk(struct phy *generic_phy)
> +static int ufs_qcom_phy_enable_iface_clk(struct ufs_qcom_phy *phy)
>  {
> -	struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy);
>  	int ret = 0;
> 
>  	if (phy->is_iface_clk_enabled)
> @@ -536,20 +530,16 @@ int ufs_qcom_phy_enable_iface_clk(struct phy 
> *generic_phy)
>  out:
>  	return ret;
>  }
> -EXPORT_SYMBOL_GPL(ufs_qcom_phy_enable_iface_clk);
> 
>  /* Turn OFF M-PHY RMMI interface clocks */
> -void ufs_qcom_phy_disable_iface_clk(struct phy *generic_phy)
> +void ufs_qcom_phy_disable_iface_clk(struct ufs_qcom_phy *phy)
>  {
> -	struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy);
> -
>  	if (phy->is_iface_clk_enabled) {
>  		clk_disable_unprepare(phy->tx_iface_clk);
>  		clk_disable_unprepare(phy->rx_iface_clk);
>  		phy->is_iface_clk_enabled = false;
>  	}
>  }
> -EXPORT_SYMBOL_GPL(ufs_qcom_phy_disable_iface_clk);
> 
>  int ufs_qcom_phy_start_serdes(struct phy *generic_phy)
>  {
> @@ -667,13 +657,20 @@ int ufs_qcom_phy_power_on(struct phy 
> *generic_phy)
>  		goto out_disable_phy;
>  	}
> 
> -	err = ufs_qcom_phy_enable_ref_clk(generic_phy);
> +	err = ufs_qcom_phy_enable_iface_clk(phy_common);
>  	if (err) {
> -		dev_err(dev, "%s enable phy ref clock failed, err=%d\n",
> +		dev_err(dev, "%s enable phy iface clock failed, err=%d\n",
>  			__func__, err);
>  		goto out_disable_pll;
>  	}
> 
> +	err = ufs_qcom_phy_enable_ref_clk(phy_common);
> +	if (err) {
> +		dev_err(dev, "%s enable phy ref clock failed, err=%d\n",
> +			__func__, err);
> +		goto out_disable_iface_clk;
> +	}
> +
>  	/* enable device PHY ref_clk pad rail */
>  	if (phy_common->vddp_ref_clk.reg) {
>  		err = ufs_qcom_phy_enable_vreg(dev,
> @@ -689,7 +686,9 @@ int ufs_qcom_phy_power_on(struct phy *generic_phy)
>  	goto out;
> 
>  out_disable_ref_clk:
> -	ufs_qcom_phy_disable_ref_clk(generic_phy);
> +	ufs_qcom_phy_disable_ref_clk(phy_common);
> +out_disable_iface_clk:
> +	ufs_qcom_phy_disable_iface_clk(phy_common);
>  out_disable_pll:
>  	ufs_qcom_phy_disable_vreg(dev, &phy_common->vdda_pll);
>  out_disable_phy:
> @@ -708,7 +707,8 @@ int ufs_qcom_phy_power_off(struct phy *generic_phy)
>  	if (phy_common->vddp_ref_clk.reg)
>  		ufs_qcom_phy_disable_vreg(phy_common->dev,
>  					  &phy_common->vddp_ref_clk);
> -	ufs_qcom_phy_disable_ref_clk(generic_phy);
> +	ufs_qcom_phy_disable_ref_clk(phy_common);
> +	ufs_qcom_phy_disable_iface_clk(phy_common);
> 
>  	ufs_qcom_phy_disable_vreg(phy_common->dev, &phy_common->vdda_pll);
>  	ufs_qcom_phy_disable_vreg(phy_common->dev, &phy_common->vdda_phy);
> diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
> index 3aedf73..9b6a081 100644
> --- a/drivers/scsi/ufs/ufs-qcom.c
> +++ b/drivers/scsi/ufs/ufs-qcom.c
> @@ -1112,17 +1112,7 @@ static int ufs_qcom_setup_clocks(struct ufs_hba
> *hba, bool on)
>  		return 0;
> 
>  	if (on) {
> -		err = ufs_qcom_phy_enable_iface_clk(host->generic_phy);
> -		if (err)
> -			goto out;
> -
> -		err = ufs_qcom_phy_enable_ref_clk(host->generic_phy);
> -		if (err) {
> -			dev_err(hba->dev, "%s enable phy ref clock failed, err=%d\n",
> -				__func__, err);
> -			ufs_qcom_phy_disable_iface_clk(host->generic_phy);
> -			goto out;
> -		}
> +		phy_power_on(host->generic_phy);
>  		/* enable the device ref clock for HS mode*/
>  		if (ufshcd_is_hs_mode(&hba->pwr_info))
>  			ufs_qcom_dev_ref_clk_ctrl(host, true);
> @@ -1131,9 +1121,8 @@ static int ufs_qcom_setup_clocks(struct ufs_hba
> *hba, bool on)
>  			ufs_qcom_update_bus_bw_vote(host);
> 
>  	} else {
> -
> -		/* M-PHY RMMI interface clocks can be turned off */
> -		ufs_qcom_phy_disable_iface_clk(host->generic_phy);
> +		/* powering off PHY during aggressive clk gating */
> +		phy_power_off(host->generic_phy);


We can only power off PHY if link isn't active so phy_power_off call 
should be under phy link not active condition check below. Rest all 
looks good in this patch.

>  		if (!ufs_qcom_is_link_active(hba))
>  			/* disable device ref_clk */
>  			ufs_qcom_dev_ref_clk_ctrl(host, false);
> @@ -1146,7 +1135,6 @@ static int ufs_qcom_setup_clocks(struct ufs_hba
> *hba, bool on)
>  		dev_err(hba->dev, "%s: set bus vote failed %d\n",
>  				__func__, err);
> 
> -out:
>  	return err;
>  }
> 
> diff --git a/include/linux/phy/phy-qcom-ufs.h 
> b/include/linux/phy/phy-qcom-ufs.h
> index 9d18e9f..35c070e 100644
> --- a/include/linux/phy/phy-qcom-ufs.h
> +++ b/include/linux/phy/phy-qcom-ufs.h
> @@ -18,22 +18,6 @@
>  #include "phy.h"
> 
>  /**
> - * ufs_qcom_phy_enable_ref_clk() - Enable the phy
> - * ref clock.
> - * @phy: reference to a generic phy
> - *
> - * returns 0 for success, and non-zero for error.
> - */
> -int ufs_qcom_phy_enable_ref_clk(struct phy *phy);
> -
> -/**
> - * ufs_qcom_phy_disable_ref_clk() - Disable the phy
> - * ref clock.
> - * @phy: reference to a generic phy.
> - */
> -void ufs_qcom_phy_disable_ref_clk(struct phy *phy);
> -
> -/**
>   * ufs_qcom_phy_enable_dev_ref_clk() - Enable the device
>   * ref clock.
>   * @phy: reference to a generic phy.
> @@ -47,8 +31,6 @@
>   */
>  void ufs_qcom_phy_disable_dev_ref_clk(struct phy *phy);
> 
> -int ufs_qcom_phy_enable_iface_clk(struct phy *phy);
> -void ufs_qcom_phy_disable_iface_clk(struct phy *phy);
>  int ufs_qcom_phy_start_serdes(struct phy *phy);
>  int ufs_qcom_phy_set_tx_lane_enable(struct phy *phy, u32 tx_lanes);
>  int ufs_qcom_phy_calibrate_phy(struct phy *phy, bool is_rate_B);

-- 
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 09/12] ufs-qcom: phy/hcd: Refactoring phy clock handling
  2016-11-01 18:47   ` Subhash Jadavani
@ 2016-11-02  7:34     ` Vivek Gautam
  2016-11-03 17:30       ` [PATCH v4 " Vivek Gautam
  0 siblings, 1 reply; 25+ messages in thread
From: Vivek Gautam @ 2016-11-02  7:34 UTC (permalink / raw)
  To: Subhash Jadavani
  Cc: kishon, jejb, Vinayak Holikatti, Martin K. Petersen,
	Stephen Boyd, Yaniv Gardi, linux-scsi, linux-arm-msm,
	linux-scsi-owner

Hi Subhash,

On Wed, Nov 2, 2016 at 12:17 AM, Subhash Jadavani
<subhashj@codeaurora.org> wrote:
> On 2016-10-29 13:22, Vivek Gautam wrote:
>>
>> Add phy clock enable code to phy_power_on/off callbacks, and
>> remove explicit calls to enable these phy clocks from the
>> ufs-qcom hcd driver.
>>
>> Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
>> ---
>>
>> Changes since v2:
>>  - Added phy_power_on() and phy_power_off() calls to
>>    power-cycle the PHY during aggressive clk gating.
>>
>> Changes since v1:
>>  - staticized ufs_qcom_phy_enable(/disable)_ref_clk(),
>>  - staticized ufs_qcom_phy_enable(/disable)_iface_clk()
>>  - removed function declaration and export symbol for these APIs.
>>
>>  drivers/phy/phy-qcom-ufs.c       | 36
>> ++++++++++++++++++------------------
>>  drivers/scsi/ufs/ufs-qcom.c      | 18 +++---------------
>>  include/linux/phy/phy-qcom-ufs.h | 18 ------------------
>>  3 files changed, 21 insertions(+), 51 deletions(-)
>>

[snip]

>> diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
>> index 3aedf73..9b6a081 100644
>> --- a/drivers/scsi/ufs/ufs-qcom.c
>> +++ b/drivers/scsi/ufs/ufs-qcom.c
>> @@ -1112,17 +1112,7 @@ static int ufs_qcom_setup_clocks(struct ufs_hba
>> *hba, bool on)
>>                 return 0;
>>
>>         if (on) {
>> -               err = ufs_qcom_phy_enable_iface_clk(host->generic_phy);
>> -               if (err)
>> -                       goto out;
>> -
>> -               err = ufs_qcom_phy_enable_ref_clk(host->generic_phy);
>> -               if (err) {
>> -                       dev_err(hba->dev, "%s enable phy ref clock failed,
>> err=%d\n",
>> -                               __func__, err);
>> -                       ufs_qcom_phy_disable_iface_clk(host->generic_phy);
>> -                       goto out;
>> -               }
>> +               phy_power_on(host->generic_phy);
>>                 /* enable the device ref clock for HS mode*/
>>                 if (ufshcd_is_hs_mode(&hba->pwr_info))
>>                         ufs_qcom_dev_ref_clk_ctrl(host, true);
>> @@ -1131,9 +1121,8 @@ static int ufs_qcom_setup_clocks(struct ufs_hba
>> *hba, bool on)
>>                         ufs_qcom_update_bus_bw_vote(host);
>>
>>         } else {
>> -
>> -               /* M-PHY RMMI interface clocks can be turned off */
>> -               ufs_qcom_phy_disable_iface_clk(host->generic_phy);
>> +               /* powering off PHY during aggressive clk gating */
>> +               phy_power_off(host->generic_phy);
>
>
> We can only power off PHY if link isn't active so phy_power_off call should
> be under phy link not active condition check below. Rest all looks good in
> this patch.

Correct, will update this.
Thanks!

>
>
>>                 if (!ufs_qcom_is_link_active(hba))
>>                         /* disable device ref_clk */
>>                         ufs_qcom_dev_ref_clk_ctrl(host, false);
>> @@ -1146,7 +1135,6 @@ static int ufs_qcom_setup_clocks(struct ufs_hba
>> *hba, bool on)
>>                 dev_err(hba->dev, "%s: set bus vote failed %d\n",
>>                                 __func__, err);
>>
>> -out:
>>         return err;
>>  }



-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 04/12] phy: qcom-ufs-14nm: Add new compatible for msm8996 based phy
  2016-10-31 21:11   ` Subhash Jadavani
@ 2016-11-03 17:07     ` Vivek Gautam
  2016-11-04  6:09       ` Subhash Jadavani
  0 siblings, 1 reply; 25+ messages in thread
From: Vivek Gautam @ 2016-11-03 17:07 UTC (permalink / raw)
  To: Subhash Jadavani
  Cc: kishon, jejb, Vinayak Holikatti, Martin K. Petersen,
	Stephen Boyd, Yaniv Gardi, linux-scsi, linux-arm-msm

Hi,


On Tue, Nov 1, 2016 at 2:41 AM, Subhash Jadavani
<subhashj@codeaurora.org> wrote:
> On 2016-10-29 13:22, Vivek Gautam wrote:
>>
>> Add a new compatible string for 14nm ufs phy present on msm8996
>> chipset. This phy is bit different from the legacy 14nm ufs phy
>> in terms of the clocks that are needed to be handled in the driver.
>>
>> Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
>> ---
>>
>> New patch in v3 of this cleanup series.
>>
>>  Documentation/devicetree/bindings/ufs/ufs-qcom.txt | 7 +++++--
>>  drivers/phy/phy-qcom-ufs-qmp-14nm.c                | 1 +
>>  2 files changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/ufs/ufs-qcom.txt
>> b/Documentation/devicetree/bindings/ufs/ufs-qcom.txt
>> index 070baf4..b6b5130 100644
>> --- a/Documentation/devicetree/bindings/ufs/ufs-qcom.txt
>> +++ b/Documentation/devicetree/bindings/ufs/ufs-qcom.txt
>> @@ -7,8 +7,11 @@ To bind UFS PHY with UFS host controller, the
>> controller node should
>>  contain a phandle reference to UFS PHY node.
>>
>>  Required properties:
>> -- compatible        : compatible list, contains "qcom,ufs-phy-qmp-20nm"
>> -                     or "qcom,ufs-phy-qmp-14nm" according to the relevant
>> phy in use.
>> +- compatible        : compatible list, contains one of the following -
>> +                       "qcom,ufs-phy-qmp-20nm" for 20nm ufs phy,
>> +                       "qcom,ufs-phy-qmp-14nm" for legacy 14nm ufs phy,
>> +                       "qcom,msm8996-ufs-phy-qmp-14nm" for 14nm ufs phy
>> +                        present on MSM8996 chipset.
>
> For future chipsets (after MSM8996), we have to use this same compatible
> strings? If yes, "msm8996" in compatible string name may cause confusions?
> may be we should start following v1/v2/... terminologies for this?
> something like "qcom,ufs-phy-qmp-v2" to start with?

Are we trying to complement the actual IP hardware versioning with this ?
Isn't it possible that we will end up using v2 for more than a couple of
actual IP hardware versions ?

I have seen cases wherein the IP versions are preceded by the
SOC names, the IPs appeared first in. And if the same IP is used in
subsequent SOCs, we use same compatible string. This, rather,
makes things easier to comprehend - it's the same IP that was
used on older SoC.

I am fine with adding versions to the compatible string as well.
But like i asked earlier - are we just creating versions for our
own understanding, or are we also complementing the actual
IP hardware versions ?


Thanks
Vivek

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH v4 09/12] ufs-qcom: phy/hcd: Refactoring phy clock handling
  2016-11-02  7:34     ` Vivek Gautam
@ 2016-11-03 17:30       ` Vivek Gautam
  2016-11-04  6:05         ` Subhash Jadavani
  2016-11-04 16:29         ` Martin K. Petersen
  0 siblings, 2 replies; 25+ messages in thread
From: Vivek Gautam @ 2016-11-03 17:30 UTC (permalink / raw)
  To: kishon, jejb, vinholikatti, martin.petersen
  Cc: sboyd, subhashj, ygardi, linux-scsi, linux-arm-msm, Vivek Gautam

Add phy clock enable code to phy_power_on/off callbacks, and
remove explicit calls to enable these phy clocks from the
ufs-qcom hcd driver.

Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
---

Changes since v3:
 - Moved phy_power_off() under *link not active* check
   during aggressive clock gating.

Changes since v2:
 - Added phy_power_on() and phy_power_off() calls to
   power-cycle the PHY during aggressive clk gating.

Changes since v1:
 - staticized ufs_qcom_phy_enable(/disable)_ref_clk(),
 - staticized ufs_qcom_phy_enable(/disable)_iface_clk()
 - removed function declaration and export symbol for these APIs.

 drivers/phy/phy-qcom-ufs.c       | 36 ++++++++++++++++++------------------
 drivers/scsi/ufs/ufs-qcom.c      | 21 ++++++---------------
 include/linux/phy/phy-qcom-ufs.h | 18 ------------------
 3 files changed, 24 insertions(+), 51 deletions(-)

diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
index 1ec64d5..9dff4c2 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -366,10 +366,9 @@ int ufs_qcom_phy_enable_vreg(struct device *dev,
 	return ret;
 }
 
-int ufs_qcom_phy_enable_ref_clk(struct phy *generic_phy)
+static int ufs_qcom_phy_enable_ref_clk(struct ufs_qcom_phy *phy)
 {
 	int ret = 0;
-	struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy);
 
 	if (phy->is_ref_clk_enabled)
 		goto out;
@@ -416,7 +415,6 @@ int ufs_qcom_phy_enable_ref_clk(struct phy *generic_phy)
 out:
 	return ret;
 }
-EXPORT_SYMBOL_GPL(ufs_qcom_phy_enable_ref_clk);
 
 static
 int ufs_qcom_phy_disable_vreg(struct device *dev,
@@ -441,10 +439,8 @@ int ufs_qcom_phy_disable_vreg(struct device *dev,
 	return ret;
 }
 
-void ufs_qcom_phy_disable_ref_clk(struct phy *generic_phy)
+static void ufs_qcom_phy_disable_ref_clk(struct ufs_qcom_phy *phy)
 {
-	struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy);
-
 	if (phy->is_ref_clk_enabled) {
 		clk_disable_unprepare(phy->ref_clk);
 		/*
@@ -457,7 +453,6 @@ void ufs_qcom_phy_disable_ref_clk(struct phy *generic_phy)
 		phy->is_ref_clk_enabled = false;
 	}
 }
-EXPORT_SYMBOL_GPL(ufs_qcom_phy_disable_ref_clk);
 
 #define UFS_REF_CLK_EN	(1 << 5)
 
@@ -510,9 +505,8 @@ void ufs_qcom_phy_disable_dev_ref_clk(struct phy *generic_phy)
 EXPORT_SYMBOL_GPL(ufs_qcom_phy_disable_dev_ref_clk);
 
 /* Turn ON M-PHY RMMI interface clocks */
-int ufs_qcom_phy_enable_iface_clk(struct phy *generic_phy)
+static int ufs_qcom_phy_enable_iface_clk(struct ufs_qcom_phy *phy)
 {
-	struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy);
 	int ret = 0;
 
 	if (phy->is_iface_clk_enabled)
@@ -536,20 +530,16 @@ int ufs_qcom_phy_enable_iface_clk(struct phy *generic_phy)
 out:
 	return ret;
 }
-EXPORT_SYMBOL_GPL(ufs_qcom_phy_enable_iface_clk);
 
 /* Turn OFF M-PHY RMMI interface clocks */
-void ufs_qcom_phy_disable_iface_clk(struct phy *generic_phy)
+void ufs_qcom_phy_disable_iface_clk(struct ufs_qcom_phy *phy)
 {
-	struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy);
-
 	if (phy->is_iface_clk_enabled) {
 		clk_disable_unprepare(phy->tx_iface_clk);
 		clk_disable_unprepare(phy->rx_iface_clk);
 		phy->is_iface_clk_enabled = false;
 	}
 }
-EXPORT_SYMBOL_GPL(ufs_qcom_phy_disable_iface_clk);
 
 int ufs_qcom_phy_start_serdes(struct phy *generic_phy)
 {
@@ -667,13 +657,20 @@ int ufs_qcom_phy_power_on(struct phy *generic_phy)
 		goto out_disable_phy;
 	}
 
-	err = ufs_qcom_phy_enable_ref_clk(generic_phy);
+	err = ufs_qcom_phy_enable_iface_clk(phy_common);
 	if (err) {
-		dev_err(dev, "%s enable phy ref clock failed, err=%d\n",
+		dev_err(dev, "%s enable phy iface clock failed, err=%d\n",
 			__func__, err);
 		goto out_disable_pll;
 	}
 
+	err = ufs_qcom_phy_enable_ref_clk(phy_common);
+	if (err) {
+		dev_err(dev, "%s enable phy ref clock failed, err=%d\n",
+			__func__, err);
+		goto out_disable_iface_clk;
+	}
+
 	/* enable device PHY ref_clk pad rail */
 	if (phy_common->vddp_ref_clk.reg) {
 		err = ufs_qcom_phy_enable_vreg(dev,
@@ -689,7 +686,9 @@ int ufs_qcom_phy_power_on(struct phy *generic_phy)
 	goto out;
 
 out_disable_ref_clk:
-	ufs_qcom_phy_disable_ref_clk(generic_phy);
+	ufs_qcom_phy_disable_ref_clk(phy_common);
+out_disable_iface_clk:
+	ufs_qcom_phy_disable_iface_clk(phy_common);
 out_disable_pll:
 	ufs_qcom_phy_disable_vreg(dev, &phy_common->vdda_pll);
 out_disable_phy:
@@ -708,7 +707,8 @@ int ufs_qcom_phy_power_off(struct phy *generic_phy)
 	if (phy_common->vddp_ref_clk.reg)
 		ufs_qcom_phy_disable_vreg(phy_common->dev,
 					  &phy_common->vddp_ref_clk);
-	ufs_qcom_phy_disable_ref_clk(generic_phy);
+	ufs_qcom_phy_disable_ref_clk(phy_common);
+	ufs_qcom_phy_disable_iface_clk(phy_common);
 
 	ufs_qcom_phy_disable_vreg(phy_common->dev, &phy_common->vdda_pll);
 	ufs_qcom_phy_disable_vreg(phy_common->dev, &phy_common->vdda_phy);
diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index 3aedf73..3a86ff3 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -1112,17 +1112,8 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on)
 		return 0;
 
 	if (on) {
-		err = ufs_qcom_phy_enable_iface_clk(host->generic_phy);
-		if (err)
-			goto out;
+		phy_power_on(host->generic_phy);
 
-		err = ufs_qcom_phy_enable_ref_clk(host->generic_phy);
-		if (err) {
-			dev_err(hba->dev, "%s enable phy ref clock failed, err=%d\n",
-				__func__, err);
-			ufs_qcom_phy_disable_iface_clk(host->generic_phy);
-			goto out;
-		}
 		/* enable the device ref clock for HS mode*/
 		if (ufshcd_is_hs_mode(&hba->pwr_info))
 			ufs_qcom_dev_ref_clk_ctrl(host, true);
@@ -1131,13 +1122,14 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on)
 			ufs_qcom_update_bus_bw_vote(host);
 
 	} else {
-
-		/* M-PHY RMMI interface clocks can be turned off */
-		ufs_qcom_phy_disable_iface_clk(host->generic_phy);
-		if (!ufs_qcom_is_link_active(hba))
+		if (!ufs_qcom_is_link_active(hba)) {
 			/* disable device ref_clk */
 			ufs_qcom_dev_ref_clk_ctrl(host, false);
 
+			/* powering off PHY during aggressive clk gating */
+			phy_power_off(host->generic_phy);
+		}
+
 		vote = host->bus_vote.min_bw_vote;
 	}
 
@@ -1146,7 +1138,6 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on)
 		dev_err(hba->dev, "%s: set bus vote failed %d\n",
 				__func__, err);
 
-out:
 	return err;
 }
 
diff --git a/include/linux/phy/phy-qcom-ufs.h b/include/linux/phy/phy-qcom-ufs.h
index 9d18e9f..35c070e 100644
--- a/include/linux/phy/phy-qcom-ufs.h
+++ b/include/linux/phy/phy-qcom-ufs.h
@@ -18,22 +18,6 @@
 #include "phy.h"
 
 /**
- * ufs_qcom_phy_enable_ref_clk() - Enable the phy
- * ref clock.
- * @phy: reference to a generic phy
- *
- * returns 0 for success, and non-zero for error.
- */
-int ufs_qcom_phy_enable_ref_clk(struct phy *phy);
-
-/**
- * ufs_qcom_phy_disable_ref_clk() - Disable the phy
- * ref clock.
- * @phy: reference to a generic phy.
- */
-void ufs_qcom_phy_disable_ref_clk(struct phy *phy);
-
-/**
  * ufs_qcom_phy_enable_dev_ref_clk() - Enable the device
  * ref clock.
  * @phy: reference to a generic phy.
@@ -47,8 +31,6 @@
  */
 void ufs_qcom_phy_disable_dev_ref_clk(struct phy *phy);
 
-int ufs_qcom_phy_enable_iface_clk(struct phy *phy);
-void ufs_qcom_phy_disable_iface_clk(struct phy *phy);
 int ufs_qcom_phy_start_serdes(struct phy *phy);
 int ufs_qcom_phy_set_tx_lane_enable(struct phy *phy, u32 tx_lanes);
 int ufs_qcom_phy_calibrate_phy(struct phy *phy, bool is_rate_B);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: [PATCH v4 09/12] ufs-qcom: phy/hcd: Refactoring phy clock handling
  2016-11-03 17:30       ` [PATCH v4 " Vivek Gautam
@ 2016-11-04  6:05         ` Subhash Jadavani
  2016-11-04 16:29         ` Martin K. Petersen
  1 sibling, 0 replies; 25+ messages in thread
From: Subhash Jadavani @ 2016-11-04  6:05 UTC (permalink / raw)
  To: Vivek Gautam
  Cc: kishon, jejb, vinholikatti, martin.petersen, sboyd, ygardi,
	linux-scsi, linux-arm-msm

On 2016-11-03 10:30, Vivek Gautam wrote:
> Add phy clock enable code to phy_power_on/off callbacks, and
> remove explicit calls to enable these phy clocks from the
> ufs-qcom hcd driver.
> 
> Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
> ---
> 
> Changes since v3:
>  - Moved phy_power_off() under *link not active* check
>    during aggressive clock gating.
> 
> Changes since v2:
>  - Added phy_power_on() and phy_power_off() calls to
>    power-cycle the PHY during aggressive clk gating.
> 
> Changes since v1:
>  - staticized ufs_qcom_phy_enable(/disable)_ref_clk(),
>  - staticized ufs_qcom_phy_enable(/disable)_iface_clk()
>  - removed function declaration and export symbol for these APIs.
> 
>  drivers/phy/phy-qcom-ufs.c       | 36 
> ++++++++++++++++++------------------
>  drivers/scsi/ufs/ufs-qcom.c      | 21 ++++++---------------
>  include/linux/phy/phy-qcom-ufs.h | 18 ------------------
>  3 files changed, 24 insertions(+), 51 deletions(-)
> 
> diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
> index 1ec64d5..9dff4c2 100644
> --- a/drivers/phy/phy-qcom-ufs.c
> +++ b/drivers/phy/phy-qcom-ufs.c
> @@ -366,10 +366,9 @@ int ufs_qcom_phy_enable_vreg(struct device *dev,
>  	return ret;
>  }
> 
> -int ufs_qcom_phy_enable_ref_clk(struct phy *generic_phy)
> +static int ufs_qcom_phy_enable_ref_clk(struct ufs_qcom_phy *phy)
>  {
>  	int ret = 0;
> -	struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy);
> 
>  	if (phy->is_ref_clk_enabled)
>  		goto out;
> @@ -416,7 +415,6 @@ int ufs_qcom_phy_enable_ref_clk(struct phy 
> *generic_phy)
>  out:
>  	return ret;
>  }
> -EXPORT_SYMBOL_GPL(ufs_qcom_phy_enable_ref_clk);
> 
>  static
>  int ufs_qcom_phy_disable_vreg(struct device *dev,
> @@ -441,10 +439,8 @@ int ufs_qcom_phy_disable_vreg(struct device *dev,
>  	return ret;
>  }
> 
> -void ufs_qcom_phy_disable_ref_clk(struct phy *generic_phy)
> +static void ufs_qcom_phy_disable_ref_clk(struct ufs_qcom_phy *phy)
>  {
> -	struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy);
> -
>  	if (phy->is_ref_clk_enabled) {
>  		clk_disable_unprepare(phy->ref_clk);
>  		/*
> @@ -457,7 +453,6 @@ void ufs_qcom_phy_disable_ref_clk(struct phy 
> *generic_phy)
>  		phy->is_ref_clk_enabled = false;
>  	}
>  }
> -EXPORT_SYMBOL_GPL(ufs_qcom_phy_disable_ref_clk);
> 
>  #define UFS_REF_CLK_EN	(1 << 5)
> 
> @@ -510,9 +505,8 @@ void ufs_qcom_phy_disable_dev_ref_clk(struct phy
> *generic_phy)
>  EXPORT_SYMBOL_GPL(ufs_qcom_phy_disable_dev_ref_clk);
> 
>  /* Turn ON M-PHY RMMI interface clocks */
> -int ufs_qcom_phy_enable_iface_clk(struct phy *generic_phy)
> +static int ufs_qcom_phy_enable_iface_clk(struct ufs_qcom_phy *phy)
>  {
> -	struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy);
>  	int ret = 0;
> 
>  	if (phy->is_iface_clk_enabled)
> @@ -536,20 +530,16 @@ int ufs_qcom_phy_enable_iface_clk(struct phy 
> *generic_phy)
>  out:
>  	return ret;
>  }
> -EXPORT_SYMBOL_GPL(ufs_qcom_phy_enable_iface_clk);
> 
>  /* Turn OFF M-PHY RMMI interface clocks */
> -void ufs_qcom_phy_disable_iface_clk(struct phy *generic_phy)
> +void ufs_qcom_phy_disable_iface_clk(struct ufs_qcom_phy *phy)
>  {
> -	struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy);
> -
>  	if (phy->is_iface_clk_enabled) {
>  		clk_disable_unprepare(phy->tx_iface_clk);
>  		clk_disable_unprepare(phy->rx_iface_clk);
>  		phy->is_iface_clk_enabled = false;
>  	}
>  }
> -EXPORT_SYMBOL_GPL(ufs_qcom_phy_disable_iface_clk);
> 
>  int ufs_qcom_phy_start_serdes(struct phy *generic_phy)
>  {
> @@ -667,13 +657,20 @@ int ufs_qcom_phy_power_on(struct phy 
> *generic_phy)
>  		goto out_disable_phy;
>  	}
> 
> -	err = ufs_qcom_phy_enable_ref_clk(generic_phy);
> +	err = ufs_qcom_phy_enable_iface_clk(phy_common);
>  	if (err) {
> -		dev_err(dev, "%s enable phy ref clock failed, err=%d\n",
> +		dev_err(dev, "%s enable phy iface clock failed, err=%d\n",
>  			__func__, err);
>  		goto out_disable_pll;
>  	}
> 
> +	err = ufs_qcom_phy_enable_ref_clk(phy_common);
> +	if (err) {
> +		dev_err(dev, "%s enable phy ref clock failed, err=%d\n",
> +			__func__, err);
> +		goto out_disable_iface_clk;
> +	}
> +
>  	/* enable device PHY ref_clk pad rail */
>  	if (phy_common->vddp_ref_clk.reg) {
>  		err = ufs_qcom_phy_enable_vreg(dev,
> @@ -689,7 +686,9 @@ int ufs_qcom_phy_power_on(struct phy *generic_phy)
>  	goto out;
> 
>  out_disable_ref_clk:
> -	ufs_qcom_phy_disable_ref_clk(generic_phy);
> +	ufs_qcom_phy_disable_ref_clk(phy_common);
> +out_disable_iface_clk:
> +	ufs_qcom_phy_disable_iface_clk(phy_common);
>  out_disable_pll:
>  	ufs_qcom_phy_disable_vreg(dev, &phy_common->vdda_pll);
>  out_disable_phy:
> @@ -708,7 +707,8 @@ int ufs_qcom_phy_power_off(struct phy *generic_phy)
>  	if (phy_common->vddp_ref_clk.reg)
>  		ufs_qcom_phy_disable_vreg(phy_common->dev,
>  					  &phy_common->vddp_ref_clk);
> -	ufs_qcom_phy_disable_ref_clk(generic_phy);
> +	ufs_qcom_phy_disable_ref_clk(phy_common);
> +	ufs_qcom_phy_disable_iface_clk(phy_common);
> 
>  	ufs_qcom_phy_disable_vreg(phy_common->dev, &phy_common->vdda_pll);
>  	ufs_qcom_phy_disable_vreg(phy_common->dev, &phy_common->vdda_phy);
> diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
> index 3aedf73..3a86ff3 100644
> --- a/drivers/scsi/ufs/ufs-qcom.c
> +++ b/drivers/scsi/ufs/ufs-qcom.c
> @@ -1112,17 +1112,8 @@ static int ufs_qcom_setup_clocks(struct ufs_hba
> *hba, bool on)
>  		return 0;
> 
>  	if (on) {
> -		err = ufs_qcom_phy_enable_iface_clk(host->generic_phy);
> -		if (err)
> -			goto out;
> +		phy_power_on(host->generic_phy);
> 
> -		err = ufs_qcom_phy_enable_ref_clk(host->generic_phy);
> -		if (err) {
> -			dev_err(hba->dev, "%s enable phy ref clock failed, err=%d\n",
> -				__func__, err);
> -			ufs_qcom_phy_disable_iface_clk(host->generic_phy);
> -			goto out;
> -		}
>  		/* enable the device ref clock for HS mode*/
>  		if (ufshcd_is_hs_mode(&hba->pwr_info))
>  			ufs_qcom_dev_ref_clk_ctrl(host, true);
> @@ -1131,13 +1122,14 @@ static int ufs_qcom_setup_clocks(struct
> ufs_hba *hba, bool on)
>  			ufs_qcom_update_bus_bw_vote(host);
> 
>  	} else {
> -
> -		/* M-PHY RMMI interface clocks can be turned off */
> -		ufs_qcom_phy_disable_iface_clk(host->generic_phy);
> -		if (!ufs_qcom_is_link_active(hba))
> +		if (!ufs_qcom_is_link_active(hba)) {
>  			/* disable device ref_clk */
>  			ufs_qcom_dev_ref_clk_ctrl(host, false);
> 
> +			/* powering off PHY during aggressive clk gating */
> +			phy_power_off(host->generic_phy);
> +		}
> +
>  		vote = host->bus_vote.min_bw_vote;
>  	}
> 
> @@ -1146,7 +1138,6 @@ static int ufs_qcom_setup_clocks(struct ufs_hba
> *hba, bool on)
>  		dev_err(hba->dev, "%s: set bus vote failed %d\n",
>  				__func__, err);
> 
> -out:
>  	return err;
>  }
> 
> diff --git a/include/linux/phy/phy-qcom-ufs.h 
> b/include/linux/phy/phy-qcom-ufs.h
> index 9d18e9f..35c070e 100644
> --- a/include/linux/phy/phy-qcom-ufs.h
> +++ b/include/linux/phy/phy-qcom-ufs.h
> @@ -18,22 +18,6 @@
>  #include "phy.h"
> 
>  /**
> - * ufs_qcom_phy_enable_ref_clk() - Enable the phy
> - * ref clock.
> - * @phy: reference to a generic phy
> - *
> - * returns 0 for success, and non-zero for error.
> - */
> -int ufs_qcom_phy_enable_ref_clk(struct phy *phy);
> -
> -/**
> - * ufs_qcom_phy_disable_ref_clk() - Disable the phy
> - * ref clock.
> - * @phy: reference to a generic phy.
> - */
> -void ufs_qcom_phy_disable_ref_clk(struct phy *phy);
> -
> -/**
>   * ufs_qcom_phy_enable_dev_ref_clk() - Enable the device
>   * ref clock.
>   * @phy: reference to a generic phy.
> @@ -47,8 +31,6 @@
>   */
>  void ufs_qcom_phy_disable_dev_ref_clk(struct phy *phy);
> 
> -int ufs_qcom_phy_enable_iface_clk(struct phy *phy);
> -void ufs_qcom_phy_disable_iface_clk(struct phy *phy);
>  int ufs_qcom_phy_start_serdes(struct phy *phy);
>  int ufs_qcom_phy_set_tx_lane_enable(struct phy *phy, u32 tx_lanes);
>  int ufs_qcom_phy_calibrate_phy(struct phy *phy, bool is_rate_B);

Looks good to me.
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>

-- 
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 04/12] phy: qcom-ufs-14nm: Add new compatible for msm8996 based phy
  2016-11-03 17:07     ` Vivek Gautam
@ 2016-11-04  6:09       ` Subhash Jadavani
  0 siblings, 0 replies; 25+ messages in thread
From: Subhash Jadavani @ 2016-11-04  6:09 UTC (permalink / raw)
  To: Vivek Gautam
  Cc: kishon, jejb, Vinayak Holikatti, Martin K. Petersen,
	Stephen Boyd, Yaniv Gardi, linux-scsi, linux-arm-msm,
	linux-scsi-owner

On 2016-11-03 10:07, Vivek Gautam wrote:
> Hi,
> 
> 
> On Tue, Nov 1, 2016 at 2:41 AM, Subhash Jadavani
> <subhashj@codeaurora.org> wrote:
>> On 2016-10-29 13:22, Vivek Gautam wrote:
>>> 
>>> Add a new compatible string for 14nm ufs phy present on msm8996
>>> chipset. This phy is bit different from the legacy 14nm ufs phy
>>> in terms of the clocks that are needed to be handled in the driver.
>>> 
>>> Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
>>> ---
>>> 
>>> New patch in v3 of this cleanup series.
>>> 
>>>  Documentation/devicetree/bindings/ufs/ufs-qcom.txt | 7 +++++--
>>>  drivers/phy/phy-qcom-ufs-qmp-14nm.c                | 1 +
>>>  2 files changed, 6 insertions(+), 2 deletions(-)
>>> 
>>> diff --git a/Documentation/devicetree/bindings/ufs/ufs-qcom.txt
>>> b/Documentation/devicetree/bindings/ufs/ufs-qcom.txt
>>> index 070baf4..b6b5130 100644
>>> --- a/Documentation/devicetree/bindings/ufs/ufs-qcom.txt
>>> +++ b/Documentation/devicetree/bindings/ufs/ufs-qcom.txt
>>> @@ -7,8 +7,11 @@ To bind UFS PHY with UFS host controller, the
>>> controller node should
>>>  contain a phandle reference to UFS PHY node.
>>> 
>>>  Required properties:
>>> -- compatible        : compatible list, contains 
>>> "qcom,ufs-phy-qmp-20nm"
>>> -                     or "qcom,ufs-phy-qmp-14nm" according to the 
>>> relevant
>>> phy in use.
>>> +- compatible        : compatible list, contains one of the following 
>>> -
>>> +                       "qcom,ufs-phy-qmp-20nm" for 20nm ufs phy,
>>> +                       "qcom,ufs-phy-qmp-14nm" for legacy 14nm ufs 
>>> phy,
>>> +                       "qcom,msm8996-ufs-phy-qmp-14nm" for 14nm ufs 
>>> phy
>>> +                        present on MSM8996 chipset.
>> 
>> For future chipsets (after MSM8996), we have to use this same 
>> compatible
>> strings? If yes, "msm8996" in compatible string name may cause 
>> confusions?
>> may be we should start following v1/v2/... terminologies for this?
>> something like "qcom,ufs-phy-qmp-v2" to start with?
> 
> Are we trying to complement the actual IP hardware versioning with this 
> ?
> Isn't it possible that we will end up using v2 for more than a couple 
> of
> actual IP hardware versions ?
> 
> I have seen cases wherein the IP versions are preceded by the
> SOC names, the IPs appeared first in. And if the same IP is used in
> subsequent SOCs, we use same compatible string. This, rather,
> makes things easier to comprehend - it's the same IP that was
> used on older SoC.

Ok, if this is the standard practice across the board then we should be 
fine with this. You may add my Reviewed-by: Subhash Jadavani 
<subhashj@codeaurora.org>

> 
> I am fine with adding versions to the compatible string as well.
> But like i asked earlier - are we just creating versions for our
> own understanding, or are we also complementing the actual
> IP hardware versions ?
> 
> 
> Thanks
> Vivek

-- 
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 05/12] phy: qcom-ufs: Skip obtaining rx/tx_iface_clk for msm8996 based phy
  2016-11-01 18:42   ` Subhash Jadavani
@ 2016-11-04  6:11     ` Subhash Jadavani
  0 siblings, 0 replies; 25+ messages in thread
From: Subhash Jadavani @ 2016-11-04  6:11 UTC (permalink / raw)
  To: Vivek Gautam
  Cc: kishon, jejb, vinholikatti, martin.petersen, sboyd, ygardi,
	linux-scsi, linux-arm-msm, linux-scsi-owner

On 2016-11-01 11:42, Subhash Jadavani wrote:
> On 2016-10-29 13:22, Vivek Gautam wrote:
>> The tx_iface_clk and rx_iface_clk no longer exist with UFS Phy
>> present on msm8996. So skip obtaining these clocks using
>> compatible match.
>> 
>> Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
>> ---
>> 
>> New patch in v3 of this cleanup series.
>> Comes in place of the following patch in v2 -
>>  phy: qcom-ufs: remove failure when rx/tx_iface_clk are absent
>> 
>>  drivers/phy/phy-qcom-ufs.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>> 
>> diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
>> index a173b30..11c8cae 100644
>> --- a/drivers/phy/phy-qcom-ufs.c
>> +++ b/drivers/phy/phy-qcom-ufs.c
>> @@ -184,6 +184,10 @@ int ufs_qcom_phy_clk_get(struct device *dev,
>>  {
>>  	int err;
>> 
>> +	if (of_device_is_compatible(phy_common->dev->of_node,
>> +				"qcom,msm8996-ufs-phy-qmp-14nm"))
> 
> Vivek, This change looks good but you might need a minor change if we
> agree to change the compatible string name
> ("qcom,msm8996-ufs-phy-qmp-14nm") as commented on patch #4.

As I am ok with patch #4 after Vivek's clarifications, I am ok with this 
patch as well.
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>

> 
>> +		goto skip_txrx_clk;
>> +
>>  	err = ufs_qcom_phy_clk_get(phy_common->dev, "tx_iface_clk",
>>  				   &phy_common->tx_iface_clk);
>>  	if (err)
>> @@ -199,6 +203,7 @@ int ufs_qcom_phy_clk_get(struct device *dev,
>>  	if (err)
>>  		goto out;
>> 
>> +skip_txrx_clk:
>>  	/*
>>  	 * "ref_clk_parent" is optional hence don't abort init if it's not
>>  	 * found.

-- 
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v4 09/12] ufs-qcom: phy/hcd: Refactoring phy clock handling
  2016-11-03 17:30       ` [PATCH v4 " Vivek Gautam
  2016-11-04  6:05         ` Subhash Jadavani
@ 2016-11-04 16:29         ` Martin K. Petersen
  1 sibling, 0 replies; 25+ messages in thread
From: Martin K. Petersen @ 2016-11-04 16:29 UTC (permalink / raw)
  To: Vivek Gautam
  Cc: kishon, jejb, vinholikatti, martin.petersen, sboyd, subhashj,
	ygardi, linux-scsi, linux-arm-msm

>>>>> "Vivek" == Vivek Gautam <vivek.gautam@codeaurora.org> writes:

Vivek> Add phy clock enable code to phy_power_on/off callbacks, and
Vivek> remove explicit calls to enable these phy clocks from the
Vivek> ufs-qcom hcd driver.

Vivek: I tried to apply v3 with the revised patch 9/12 but that didn't
fly. Please send a v5 series against 4.10/scsi-queue with the review
tags from Subhash applied.

Subhash and others: Please make sure you put your Reviewed-by: tags on a
separate line. There were a few patches that had "LGTM, Reviewed-by:..."
and patchwork sadly does not pick those up.

Thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2016-11-04 16:30 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-29 20:22 [PATCH v3 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd Vivek Gautam
2016-10-29 20:22 ` [PATCH v3 01/12] phy: qcom-ufs: Remove unnecessary BUG_ON Vivek Gautam
2016-10-29 20:22 ` [PATCH v3 02/12] phy: qcom-ufs: Use devm sibling of kstrdup for regulator names Vivek Gautam
2016-10-29 20:22 ` [PATCH v3 03/12] phy: qcom-ufs: Cleanup clock and regulator initialization Vivek Gautam
2016-10-29 20:22 ` [PATCH v3 04/12] phy: qcom-ufs-14nm: Add new compatible for msm8996 based phy Vivek Gautam
2016-10-31 21:11   ` Subhash Jadavani
2016-11-03 17:07     ` Vivek Gautam
2016-11-04  6:09       ` Subhash Jadavani
2016-10-29 20:22 ` [PATCH v3 05/12] phy: qcom-ufs: Skip obtaining rx/tx_iface_clk " Vivek Gautam
2016-11-01 18:42   ` Subhash Jadavani
2016-11-04  6:11     ` Subhash Jadavani
2016-10-29 20:22 ` [PATCH v3 06/12] phy: qcom-ufs-qmp-xx: Discard remove callback for drivers Vivek Gautam
2016-10-29 20:22 ` [PATCH v3 07/12] phy: qcom-ufs: Remove unnecessary function declarations Vivek Gautam
2016-10-29 20:22 ` [PATCH v3 08/12] phy: qcom-ufs-qmp-xx: Move clock and regulator init out of phy init Vivek Gautam
2016-10-29 20:22 ` [PATCH v3 09/12] ufs-qcom: phy/hcd: Refactoring phy clock handling Vivek Gautam
2016-11-01 18:47   ` Subhash Jadavani
2016-11-02  7:34     ` Vivek Gautam
2016-11-03 17:30       ` [PATCH v4 " Vivek Gautam
2016-11-04  6:05         ` Subhash Jadavani
2016-11-04 16:29         ` Martin K. Petersen
2016-10-29 20:22 ` [PATCH v3 10/12] phy: qcom-ufs: Remove common layer phy exit callback Vivek Gautam
2016-10-29 20:22 ` [PATCH v3 11/12] scsi/ufs: qcom: Add phy_exit call in hcd exit path Vivek Gautam
2016-10-29 20:22 ` [PATCH v3 12/12] scsi/ufs: qcom: Don't free resource-managed kmalloc element Vivek Gautam
2016-10-31 21:14   ` Subhash Jadavani
2016-11-01 13:58 ` [PATCH v3 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).