Re: [PATCH 1/1] scsi/ufs: qcom: Don't enable PHY_QCOM_UFS by default

2018-04-19 Thread Vivek Gautam

Hi Bjorn,


On 4/18/2018 4:41 AM, Bjorn Andersson wrote:

On Mon 09 Apr 23:31 PDT 2018, Vivek Gautam wrote:



On 4/10/2018 1:39 AM, Bjorn Andersson wrote:

On Mon 09 Apr 10:38 PDT 2018, Vivek Gautam wrote:

On 4/9/2018 10:21 PM, Bjorn Andersson wrote:

On Mon 09 Apr 06:24 PDT 2018, Vivek Gautam wrote:

[..]

diff --git a/include/linux/phy/phy-qcom-ufs.h b/include/linux/phy/phy-qcom-ufs.h
index 0a2c18a9771d..1388c2a2965e 100644
--- a/include/linux/phy/phy-qcom-ufs.h
+++ b/include/linux/phy/phy-qcom-ufs.h
@@ -31,8 +31,21 @@ void ufs_qcom_phy_enable_dev_ref_clk(struct phy *phy);
 */
void ufs_qcom_phy_disable_dev_ref_clk(struct phy *phy);
+#if IS_ENABLED(CONFIG_PHY_QCOM_UFS)
int ufs_qcom_phy_set_tx_lane_enable(struct phy *phy, u32 tx_lanes);
void ufs_qcom_phy_save_controller_version(struct phy *phy,
-   u8 major, u16 minor, u16 step);
+ u8 major, u16 minor, u16 step);
+#else
+static inline int ufs_qcom_phy_set_tx_lane_enable(struct phy *phy, u32 
tx_lanes)
+{
+   return -ENOSYS;
+}
+
+static inline void ufs_qcom_phy_save_controller_version(struct phy *phy,
+   u8 major, u16 minor,
+   u16 step)
+{
+}
+#endif /* PHY_QCOM_UFS */

What's the timeline for getting rid of the references to these
functions? I presume that code depending on these being here will
compile but won't actually work?

Yes, these inline definitions are just to keep ufs-qcom happy with the
direct
calls that it makes to these functions.
As you would know these couple of functions are just used by the 20nm phy.
However, we don't have any platform yet in the upstream that enables this
phy.
I am hoping that we will eventually get rid of these functions when we
further
clean up ufs-qcom driver.


I see, but that means that we're calling this function with a struct phy
that might not be a struct ufs_qcom_phy and as such a defconfig with
both enabled will have undefined outcome for the migrated phys.

No, we will have to add support for separate phys as sdm845 has phy per each
lane,
and the older struct phy will exist alongside.
We will call this function only with the older phy pointer.


In particular we do expect that the same kernel will boot on db820c and
sdm845-mtp, so we will have to enable support for the 14nm & 20nm phy
driver (and we don't want random crashes because someone happened to
enable it).

Right, so we create new struct phy while keeping older one intact to keep
the
ufs-qcom work with both - ufs_qcom_phy and qmp_phy.
Some of the controller drivers, such as usb/dwc3/ keep support for old and
new phys,
although there the difference is between generic phy and the usb-phy.
So, I am assuming that if we want to keep ufs-qcom on platforms using 20nm,
14nm and 10nm phys happy, we will have to keep the phys separately for
sometime.
What do you say about it?


My concern is only that the UFS HCI driver doesn't have a way to know if
it's the new or old "type" of phy, but if you can get that working then
I don't have any objections about doing so for a transitional period.

But, you may not use kernel config options to handle this, the same
Image should boot on msm8916, msm8996 and sdm845 (with appropriate dtb
for each one).


Right, i get your concern. I will try to refactor the UFS HCI code to 
handle the two

'types' of phys.
I think Can Guo (CC'ed here) was already working on this. I will check 
with him

if he already has some code to do this.

Thanks
Vivek



On db820c, we can still work with the ufs_qcom_phy.


I do not have an issue with that.

Regards,
Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html




Re: [PATCH 1/1] scsi/ufs: qcom: Don't enable PHY_QCOM_UFS by default

2018-04-10 Thread Vivek Gautam



On 4/10/2018 1:39 AM, Bjorn Andersson wrote:

On Mon 09 Apr 10:38 PDT 2018, Vivek Gautam wrote:

On 4/9/2018 10:21 PM, Bjorn Andersson wrote:

On Mon 09 Apr 06:24 PDT 2018, Vivek Gautam wrote:

[..]

diff --git a/include/linux/phy/phy-qcom-ufs.h b/include/linux/phy/phy-qcom-ufs.h
index 0a2c18a9771d..1388c2a2965e 100644
--- a/include/linux/phy/phy-qcom-ufs.h
+++ b/include/linux/phy/phy-qcom-ufs.h
@@ -31,8 +31,21 @@ void ufs_qcom_phy_enable_dev_ref_clk(struct phy *phy);
*/
   void ufs_qcom_phy_disable_dev_ref_clk(struct phy *phy);
+#if IS_ENABLED(CONFIG_PHY_QCOM_UFS)
   int ufs_qcom_phy_set_tx_lane_enable(struct phy *phy, u32 tx_lanes);
   void ufs_qcom_phy_save_controller_version(struct phy *phy,
-   u8 major, u16 minor, u16 step);
+ u8 major, u16 minor, u16 step);
+#else
+static inline int ufs_qcom_phy_set_tx_lane_enable(struct phy *phy, u32 
tx_lanes)
+{
+   return -ENOSYS;
+}
+
+static inline void ufs_qcom_phy_save_controller_version(struct phy *phy,
+   u8 major, u16 minor,
+   u16 step)
+{
+}
+#endif /* PHY_QCOM_UFS */

What's the timeline for getting rid of the references to these
functions? I presume that code depending on these being here will
compile but won't actually work?

Yes, these inline definitions are just to keep ufs-qcom happy with the
direct
calls that it makes to these functions.
As you would know these couple of functions are just used by the 20nm phy.
However, we don't have any platform yet in the upstream that enables this
phy.
I am hoping that we will eventually get rid of these functions when we
further
clean up ufs-qcom driver.


I see, but that means that we're calling this function with a struct phy
that might not be a struct ufs_qcom_phy and as such a defconfig with
both enabled will have undefined outcome for the migrated phys.


No, we will have to add support for separate phys as sdm845 has phy per 
each lane,

and the older struct phy will exist alongside.
We will call this function only with the older phy pointer.


In particular we do expect that the same kernel will boot on db820c and
sdm845-mtp, so we will have to enable support for the 14nm & 20nm phy
driver (and we don't want random crashes because someone happened to
enable it).


Right, so we create new struct phy while keeping older one intact to 
keep the

ufs-qcom work with both - ufs_qcom_phy and qmp_phy.
Some of the controller drivers, such as usb/dwc3/ keep support for old 
and new phys,

although there the difference is between generic phy and the usb-phy.
So, I am assuming that if we want to keep ufs-qcom on platforms using 20nm,
14nm and 10nm phys happy, we will have to keep the phys separately for 
sometime.

What do you say about it?

On db820c, we can still work with the ufs_qcom_phy.

Regards
Vivek



So either we add the 10nm support to the existing driver or I think we
should migrate, at least, the 14nm support to the QMP driver (and mark
the remaining 20nm BROKEN for now).

Regardless of the path chosen this should be cleaned up to the point
where all three phys are supported.

Regards,
Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html




Re: [PATCH 1/1] scsi/ufs: qcom: Don't enable PHY_QCOM_UFS by default

2018-04-09 Thread Vivek Gautam

Hi Bjorn,


On 4/9/2018 10:21 PM, Bjorn Andersson wrote:

On Mon 09 Apr 06:24 PDT 2018, Vivek Gautam wrote:


While we try to transition from a separate ufs phy driver to a
more integrated qmp phy driver, don't let SCSI_UFS_QCOM to
enable PHY_QCOM_UFS config by default.
The users should enable this in their defconfigs.
Also add inline definitions for couple of functions -
a) ufs_qcom_phy_set_tx_lane_enable()
b) void ufs_qcom_phy_save_controller_version()
to enable clean build for SCSI_UFS_QCOM.

Signed-off-by: Vivek Gautam <vivek.gau...@codeaurora.org>
---
  drivers/scsi/ufs/Kconfig |  1 -
  include/linux/phy/phy-qcom-ufs.h | 15 ++-
  2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index e27b4d4e6ae2..7e8898b6eb67 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -91,7 +91,6 @@ config SCSI_UFS_DWC_TC_PLATFORM
  config SCSI_UFS_QCOM
tristate "QCOM specific hooks to UFS controller platform driver"
depends on SCSI_UFSHCD_PLATFORM && ARCH_QCOM
-   select PHY_QCOM_UFS

As you're depending on function in the UFS phy, which can be compiled as
a module you might end up in a configuration where UFS_QCOM is builtin
and the PHY_QCOM_UFS is module, which will fail to link.

So you need to make this:

depends on PHY_QCOM_UFS || PHY_QCOM_UFS=n

In which case we say that if PHY_QCOM_UFS is a module UFS_QCOM must be a
module and if PHY_QCOM_UFS is not compiled in UFS_QCOM can be either
builtin or a module.


Thanks for reviewing. You are right. I was trying to test all possible
cases for the PHY_QCOM_UFS, and SCSI_UFS_QCOM configs, but clearly i missed
this case.
Will modify as suggested.


help
  This selects the QCOM specific additions to UFSHCD platform driver.
  UFS host on QCOM needs some vendor specific configuration before
diff --git a/include/linux/phy/phy-qcom-ufs.h b/include/linux/phy/phy-qcom-ufs.h
index 0a2c18a9771d..1388c2a2965e 100644
--- a/include/linux/phy/phy-qcom-ufs.h
+++ b/include/linux/phy/phy-qcom-ufs.h
@@ -31,8 +31,21 @@ void ufs_qcom_phy_enable_dev_ref_clk(struct phy *phy);
   */
  void ufs_qcom_phy_disable_dev_ref_clk(struct phy *phy);
  
+#if IS_ENABLED(CONFIG_PHY_QCOM_UFS)

  int ufs_qcom_phy_set_tx_lane_enable(struct phy *phy, u32 tx_lanes);
  void ufs_qcom_phy_save_controller_version(struct phy *phy,
-   u8 major, u16 minor, u16 step);
+ u8 major, u16 minor, u16 step);
+#else
+static inline int ufs_qcom_phy_set_tx_lane_enable(struct phy *phy, u32 
tx_lanes)
+{
+   return -ENOSYS;
+}
+
+static inline void ufs_qcom_phy_save_controller_version(struct phy *phy,
+   u8 major, u16 minor,
+   u16 step)
+{
+}
+#endif /* PHY_QCOM_UFS */

What's the timeline for getting rid of the references to these
functions? I presume that code depending on these being here will
compile but won't actually work?


Yes, these inline definitions are just to keep ufs-qcom happy with the 
direct

calls that it makes to these functions.
As you would know these couple of functions are just used by the 20nm phy.
However, we don't have any platform yet in the upstream that enables 
this phy.
I am hoping that we will eventually get rid of these functions when we 
further

clean up ufs-qcom driver.

Best regards
Vivek


Regards,
Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[PATCH 1/1] scsi/ufs: qcom: Don't enable PHY_QCOM_UFS by default

2018-04-09 Thread Vivek Gautam
While we try to transition from a separate ufs phy driver to a
more integrated qmp phy driver, don't let SCSI_UFS_QCOM to
enable PHY_QCOM_UFS config by default.
The users should enable this in their defconfigs.
Also add inline definitions for couple of functions -
a) ufs_qcom_phy_set_tx_lane_enable()
b) void ufs_qcom_phy_save_controller_version()
to enable clean build for SCSI_UFS_QCOM.

Signed-off-by: Vivek Gautam <vivek.gau...@codeaurora.org>
---
 drivers/scsi/ufs/Kconfig |  1 -
 include/linux/phy/phy-qcom-ufs.h | 15 ++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index e27b4d4e6ae2..7e8898b6eb67 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -91,7 +91,6 @@ config SCSI_UFS_DWC_TC_PLATFORM
 config SCSI_UFS_QCOM
tristate "QCOM specific hooks to UFS controller platform driver"
depends on SCSI_UFSHCD_PLATFORM && ARCH_QCOM
-   select PHY_QCOM_UFS
help
  This selects the QCOM specific additions to UFSHCD platform driver.
  UFS host on QCOM needs some vendor specific configuration before
diff --git a/include/linux/phy/phy-qcom-ufs.h b/include/linux/phy/phy-qcom-ufs.h
index 0a2c18a9771d..1388c2a2965e 100644
--- a/include/linux/phy/phy-qcom-ufs.h
+++ b/include/linux/phy/phy-qcom-ufs.h
@@ -31,8 +31,21 @@ void ufs_qcom_phy_enable_dev_ref_clk(struct phy *phy);
  */
 void ufs_qcom_phy_disable_dev_ref_clk(struct phy *phy);
 
+#if IS_ENABLED(CONFIG_PHY_QCOM_UFS)
 int ufs_qcom_phy_set_tx_lane_enable(struct phy *phy, u32 tx_lanes);
 void ufs_qcom_phy_save_controller_version(struct phy *phy,
-   u8 major, u16 minor, u16 step);
+ u8 major, u16 minor, u16 step);
+#else
+static inline int ufs_qcom_phy_set_tx_lane_enable(struct phy *phy, u32 
tx_lanes)
+{
+   return -ENOSYS;
+}
+
+static inline void ufs_qcom_phy_save_controller_version(struct phy *phy,
+   u8 major, u16 minor,
+   u16 step)
+{
+}
+#endif /* PHY_QCOM_UFS */
 
 #endif /* PHY_QCOM_UFS_H_ */
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation



Re: [PATCH v1] scsi: ufs: add 2 lane support

2018-04-02 Thread Vivek Gautam

Hi Can,


On 3/2/2018 1:48 PM, Can Guo wrote:

From: Venkat Gopalakrishnan 

Qcom ufs controller v3.1.0 supports 2 lanes, add support
to configure 2 lanes during phy initialization.

Signed-off-by: Venkat Gopalakrishnan 
Signed-off-by: Subhash Jadavani 
Signed-off-by: Can Guo 
---
  drivers/scsi/ufs/ufs-qcom.c | 20 +---
  1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index 2b38db2..51889ad 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -113,10 +113,10 @@ static void ufs_qcom_disable_lane_clks(struct 
ufs_qcom_host *host)
if (!host->is_lane_clks_enabled)
return;
  
-	if (host->hba->lanes_per_direction > 1)

+   if (host->tx_l1_sync_clk)
clk_disable_unprepare(host->tx_l1_sync_clk);
clk_disable_unprepare(host->tx_l0_sync_clk);
-   if (host->hba->lanes_per_direction > 1)
+   if (host->rx_l1_sync_clk)
clk_disable_unprepare(host->rx_l1_sync_clk);
clk_disable_unprepare(host->rx_l0_sync_clk);
  
@@ -147,18 +147,15 @@ static int ufs_qcom_enable_lane_clks(struct ufs_qcom_host *host)

if (err)
goto disable_tx_l0;
  
-		err = ufs_qcom_host_clk_enable(dev, "tx_lane1_sync_clk",

-   host->tx_l1_sync_clk);
-   if (err)
-   goto disable_rx_l1;
+   /* The tx lane1 clk could be muxed, hence keep this optional */


You need a similar change for "rx_l1_sync_clk" also.
And also get rid of 'lanes_per_direction' flag as well for 
ufs_qcom_enable_lane_clks()
and ufs_qcom_init_lane_clks() too, as you are doing in 
ufs_qcom_disable_lane_clks().



+   if (host->tx_l1_sync_clk)
+   ufs_qcom_host_clk_enable(dev, "tx_lane1_sync_clk",
+host->tx_l1_sync_clk);
}
  
  	host->is_lane_clks_enabled = true;

goto out;
  
-disable_rx_l1:

-   if (host->hba->lanes_per_direction > 1)
-   clk_disable_unprepare(host->rx_l1_sync_clk);
  disable_tx_l0:
clk_disable_unprepare(host->tx_l0_sync_clk);
  disable_rx_l0:
@@ -189,8 +186,9 @@ static int ufs_qcom_init_lane_clks(struct ufs_qcom_host 
*host)
if (err)
goto out;
  
-		err = ufs_qcom_host_clk_get(dev, "tx_lane1_sync_clk",

-   >tx_l1_sync_clk);
+   /* The tx lane1 clk could be muxed, hence keep this optional */
+   ufs_qcom_host_clk_get(dev, "tx_lane1_sync_clk",
+   >tx_l1_sync_clk);


same here.

Best regards
Vivek


}
  out:
return err;




Re: [PATCH 1/1] scsi: ufs-qcom: remove broken hci version quirk

2018-01-29 Thread Vivek Gautam

Hi Asutosh,


On 1/30/2018 10:11 AM, Asutosh Das wrote:

From: Subhash Jadavani 

UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION is only applicable for QCOM UFS host
controller version 2.x.y and this has been fixed from version 3.x.y
onwards, hence this change removes this quirk for version 3.x.y onwards.

Signed-off-by: Subhash Jadavani 
Signed-off-by: Asutosh Das 
---


This patch and all other ufs patches that you have posted recently,
do they all fall under one 'ufs-qcom fixes' patch series for fixes that
we would want to do?
If it is so, then please club them together in a series, so that
it's easy for reviewers and maintainers to review, and keep track
of all the patches that can get-in after the reviews.
If they belong to two or more separate patch-series then please
create such patch series.
It's difficult to read through a lot of [PATCH 1/1] ... patch.

Regards
Vivek


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

diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index 2b38db2..221820a 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -1098,7 +1098,7 @@ static void ufs_qcom_advertise_quirks(struct ufs_hba *hba)
hba->quirks |= UFSHCD_QUIRK_BROKEN_LCC;
}
  
-	if (host->hw_ver.major >= 0x2) {

+   if (host->hw_ver.major == 0x2) {
hba->quirks |= UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION;
  
  		if (!ufs_qcom_cap_qunipro(host))




[PATCH v2 4/5] scsi/ufs: qcom: Set phy mode based on the controllers HS MODE

2017-10-12 Thread Vivek Gautam
Set the phy mode based on the UFS HS PA mode. This lets the
controller let phy know the mode in which the PHY Adapter is
running and set the phy rates accordingly.

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

Changes since v1:
 - none.

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

diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index 6a548e74d704..942e40c9eaf7 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -273,6 +273,9 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
bool is_rate_B = (UFS_QCOM_LIMIT_HS_RATE == PA_HS_MODE_B)
? true : false;
 
+   if (is_rate_B)
+   phy_set_mode(phy, PHY_MODE_UFS_HS_B);
+
/* Assert PHY reset and apply PHY calibration values */
ufs_qcom_assert_reset(hba);
/* provide 1ms delay to let the reset pulse propagate */
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation



[PATCH v2 1/5] dt-bindings: phy: Add PHY_TYPE_UFS definition

2017-10-12 Thread Vivek Gautam
Add definition for UFS phy type.

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

Changes since v1:
 - none.

 include/dt-bindings/phy/phy.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/dt-bindings/phy/phy.h b/include/dt-bindings/phy/phy.h
index 6c901930eb3e..d16e8755f6a9 100644
--- a/include/dt-bindings/phy/phy.h
+++ b/include/dt-bindings/phy/phy.h
@@ -15,5 +15,6 @@
 #define PHY_TYPE_PCIE  2
 #define PHY_TYPE_USB2  3
 #define PHY_TYPE_USB3  4
+#define PHY_TYPE_UFS   5
 
 #endif /* _DT_BINDINGS_PHY */
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation



[PATCH v2 3/5] phy: qcom-ufs: Add support to set phy mode

2017-10-12 Thread Vivek Gautam
Adding support to set desired UFS phy mode that can be set
from the host controller.

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

Changes since v1:
 - none.

 drivers/phy/qualcomm/phy-qcom-ufs-i.h|  2 ++
 drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c | 14 ++
 drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c | 14 ++
 3 files changed, 30 insertions(+)

diff --git a/drivers/phy/qualcomm/phy-qcom-ufs-i.h 
b/drivers/phy/qualcomm/phy-qcom-ufs-i.h
index 13b02b7de30b..94326ed107c3 100644
--- a/drivers/phy/qualcomm/phy-qcom-ufs-i.h
+++ b/drivers/phy/qualcomm/phy-qcom-ufs-i.h
@@ -115,6 +115,8 @@ struct ufs_qcom_phy {
int cached_regs_table_size;
bool is_powered_on;
struct ufs_qcom_phy_specific_ops *phy_spec_ops;
+
+   enum phy_mode mode;
 };
 
 /**
diff --git a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c 
b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c
index 12a1b498dc4b..af65785230b5 100644
--- a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c
+++ b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c
@@ -53,6 +53,19 @@ static int ufs_qcom_phy_qmp_14nm_exit(struct phy 
*generic_phy)
 }
 
 static
+int ufs_qcom_phy_qmp_14nm_set_mode(struct phy *generic_phy, enum phy_mode mode)
+{
+   struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy);
+
+   phy_common->mode = PHY_MODE_INVALID;
+
+   if (mode > 0)
+   phy_common->mode = mode;
+
+   return 0;
+}
+
+static
 void ufs_qcom_phy_qmp_14nm_power_control(struct ufs_qcom_phy *phy, bool val)
 {
writel_relaxed(val ? 0x1 : 0x0, phy->mmio + UFS_PHY_POWER_DOWN_CONTROL);
@@ -102,6 +115,7 @@ static int ufs_qcom_phy_qmp_14nm_is_pcs_ready(struct 
ufs_qcom_phy *phy_common)
.exit   = ufs_qcom_phy_qmp_14nm_exit,
.power_on   = ufs_qcom_phy_power_on,
.power_off  = ufs_qcom_phy_power_off,
+   .set_mode   = ufs_qcom_phy_qmp_14nm_set_mode,
.owner  = THIS_MODULE,
 };
 
diff --git a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c 
b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
index 4f68acb58b73..5c18c41dbdb4 100644
--- a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
+++ b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
@@ -72,6 +72,19 @@ static int ufs_qcom_phy_qmp_20nm_exit(struct phy 
*generic_phy)
 }
 
 static
+int ufs_qcom_phy_qmp_20nm_set_mode(struct phy *generic_phy, enum phy_mode mode)
+{
+   struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy);
+
+   phy_common->mode = PHY_MODE_INVALID;
+
+   if (mode > 0)
+   phy_common->mode = mode;
+
+   return 0;
+}
+
+static
 void ufs_qcom_phy_qmp_20nm_power_control(struct ufs_qcom_phy *phy, bool val)
 {
bool hibern8_exit_after_pwr_collapse = phy->quirks &
@@ -160,6 +173,7 @@ static int ufs_qcom_phy_qmp_20nm_is_pcs_ready(struct 
ufs_qcom_phy *phy_common)
.exit   = ufs_qcom_phy_qmp_20nm_exit,
.power_on   = ufs_qcom_phy_power_on,
.power_off  = ufs_qcom_phy_power_off,
+   .set_mode   = ufs_qcom_phy_qmp_20nm_set_mode,
.owner  = THIS_MODULE,
 };
 
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation



[PATCH v2 5/5] ufs/phy: qcom: Refactor to use phy_init call

2017-10-12 Thread Vivek Gautam
Refactor ufs_qcom_power_up_sequence() to get rid of ugly
exported phy APIs and use the phy_init() and phy_power_on()
to do the phy initialization.

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

Changes since v1:
 - The UFS phy retain state in low power mode. The phy can
   enter the low power state and come up without starting the
   serdes again, unless we reprogram the phy.
   So, added a check to start the serdes only once after phy
   initialization.

 drivers/phy/qualcomm/phy-qcom-ufs-i.h|  3 +-
 drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c | 15 --
 drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c | 15 --
 drivers/phy/qualcomm/phy-qcom-ufs.c  | 42 ++--
 drivers/scsi/ufs/ufs-qcom.c  | 36 ++--
 include/linux/phy/phy-qcom-ufs.h |  3 --
 6 files changed, 55 insertions(+), 59 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-ufs-i.h 
b/drivers/phy/qualcomm/phy-qcom-ufs-i.h
index 94326ed107c3..822c83b8efcd 100644
--- a/drivers/phy/qualcomm/phy-qcom-ufs-i.h
+++ b/drivers/phy/qualcomm/phy-qcom-ufs-i.h
@@ -114,6 +114,7 @@ struct ufs_qcom_phy {
struct ufs_qcom_phy_calibration *cached_regs;
int cached_regs_table_size;
bool is_powered_on;
+   bool is_started;
struct ufs_qcom_phy_specific_ops *phy_spec_ops;
 
enum phy_mode mode;
@@ -123,7 +124,6 @@ struct ufs_qcom_phy {
  * struct ufs_qcom_phy_specific_ops - set of pointers to functions which have a
  * specific implementation per phy. Each UFS phy, should implement
  * those functions according to its spec and requirements
- * @calibrate_phy: pointer to a function that calibrate the phy
  * @start_serdes: pointer to a function that starts the serdes
  * @is_physical_coding_sublayer_ready: pointer to a function that
  * checks pcs readiness. returns 0 for success and non-zero for error.
@@ -132,7 +132,6 @@ struct ufs_qcom_phy {
  * and writes to QSERDES_RX_SIGDET_CNTRL attribute
  */
 struct ufs_qcom_phy_specific_ops {
-   int (*calibrate_phy)(struct ufs_qcom_phy *phy, bool is_rate_B);
void (*start_serdes)(struct ufs_qcom_phy *phy);
int (*is_physical_coding_sublayer_ready)(struct ufs_qcom_phy *phy);
void (*set_tx_lane_enable)(struct ufs_qcom_phy *phy, u32 val);
diff --git a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c 
b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c
index af65785230b5..ba1895b76a5d 100644
--- a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c
+++ b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c
@@ -44,7 +44,19 @@ 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)
 {
-   return 0;
+   struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy);
+   bool is_rate_B = false;
+   int ret;
+
+   if (phy_common->mode == PHY_MODE_UFS_HS_B)
+   is_rate_B = true;
+
+   ret = ufs_qcom_phy_qmp_14nm_phy_calibrate(phy_common, is_rate_B);
+   if (!ret)
+   /* phy calibrated, but yet to be started */
+   phy_common->is_started = false;
+
+   return ret;
 }
 
 static int ufs_qcom_phy_qmp_14nm_exit(struct phy *generic_phy)
@@ -120,7 +132,6 @@ static int ufs_qcom_phy_qmp_14nm_is_pcs_ready(struct 
ufs_qcom_phy *phy_common)
 };
 
 static struct ufs_qcom_phy_specific_ops phy_14nm_ops = {
-   .calibrate_phy  = ufs_qcom_phy_qmp_14nm_phy_calibrate,
.start_serdes   = ufs_qcom_phy_qmp_14nm_start_serdes,
.is_physical_coding_sublayer_ready = ufs_qcom_phy_qmp_14nm_is_pcs_ready,
.set_tx_lane_enable = ufs_qcom_phy_qmp_14nm_set_tx_lane_enable,
diff --git a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c 
b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
index 5c18c41dbdb4..49f435c71147 100644
--- a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
+++ b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
@@ -63,7 +63,19 @@ 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)
 {
-   return 0;
+   struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy);
+   bool is_rate_B = false;
+   int ret;
+
+   if (phy_common->mode == PHY_MODE_UFS_HS_B)
+   is_rate_B = true;
+
+   ret = ufs_qcom_phy_qmp_20nm_phy_calibrate(phy_common, is_rate_B);
+   if (!ret)
+   /* phy calibrated, but yet to be started */
+   phy_common->is_started = false;
+
+   return ret;
 }
 
 static int ufs_qcom_phy_qmp_20nm_exit(struct phy *generic_phy)
@@ -178,7 +190,6 @@ static int ufs_qcom_phy_qmp_20nm_is_pcs_ready(struct 
ufs_qcom_phy *phy_common)
 };
 
 static struct ufs_qcom_phy_specific_ops phy_20nm_ops = {
-   .calibrate_phy  = ufs_qcom_phy_qmp_20nm_phy_calibrate,
.start_serdes   = ufs_qcom_phy_qmp

[PATCH v2 2/5] phy: Add UFS PHY modes

2017-10-12 Thread Vivek Gautam
UFS phy has two modes for each High speed generation.
These modes are identified by two rates of operations -
Rate A, and Rate B.
Add these UFS phy modes to phy framework.

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

Changes since v1:
 - Rebased on linux-phy/next.

 include/linux/phy/phy.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index e694d4008c4a..79c341da1b8c 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -29,6 +29,8 @@ enum phy_mode {
PHY_MODE_USB_OTG,
PHY_MODE_SGMII,
PHY_MODE_10GKR,
+   PHY_MODE_UFS_HS_A,
+   PHY_MODE_UFS_HS_B,
 };
 
 /**
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation



[PATCH v2 0/5] qcom-ufs: phy/hcd: Refactor phy initialization code

2017-10-12 Thread Vivek Gautam
Refactoring the qcom-ufs phy and host controller code to move
further towards the generic phy usage. Right now the qcom-ufs exports
a bunch of APIs that are used by the host controller to initialize
the phy.
With this patch series, we populate the phy_init() which was a no-op
earlier. The host controller then calls the phy_init() at the designated
place rather than doing it invariably in ufs_hcd_init().

As part of this series, we introduce phy modes for ufs phy.
The M-PHY has two data rates defined for each generations (Gears) -
Rate A and Rate B. These can serve as the two modes of ufs HS phy.
Host controller can direct the phy to set the respective configurations
based on the phy modes.

The patch-series has been tested with necessary dt patches on db820c.


Hi Kishon,

I shall be on vacation for the next week. Can you kindly consider
picking this series for 4.15. Martin was good with last version
of the patches[1], and Subhash has reviewed the patches of which
he has given 'Reviewed-by' for [PATCH 4/5] , and I have addressed
his comments for the last patch. I hope it's not too late for 4.15.
Subhash, can you please consider giving your 'Reviewed-by' for
the last patch if you find it good.

[1] https://lkml.org/lkml/2017/8/10/958

Vivek Gautam (5):
  dt-bindings: phy: Add PHY_TYPE_UFS definition
  phy: Add UFS PHY modes
  phy: qcom-ufs: Add support to set phy mode
  scsi/ufs: qcom: Set phy mode based on the controllers HS MODE
  ufs/phy: qcom: Refactor to use phy_init call

 drivers/phy/qualcomm/phy-qcom-ufs-i.h|  5 ++--
 drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c | 29 +--
 drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c | 29 +--
 drivers/phy/qualcomm/phy-qcom-ufs.c  | 42 ++--
 drivers/scsi/ufs/ufs-qcom.c  | 39 +++---
 include/dt-bindings/phy/phy.h|  1 +
 include/linux/phy/phy-qcom-ufs.h |  3 --
 include/linux/phy/phy.h  |  2 ++
 8 files changed, 91 insertions(+), 59 deletions(-)

-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation



Re: [PATCH 4/5] scsi/ufs: qcom: Set phy mode based on the controllers HS MODE

2017-09-27 Thread Vivek Gautam



On 09/27/2017 04:14 AM, Subhash Jadavani wrote:

On 2017-08-03 23:48, Vivek Gautam wrote:

Set the phy mode based on the UFS HS PA mode. This lets the
controller let phy know the mode in which the PHY Adapter is
running and set the phy rates accordingly.

Signed-off-by: Vivek Gautam <vivek.gau...@codeaurora.org>
---
 drivers/scsi/ufs/ufs-qcom.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index c87d770b519a..44c21d5818ee 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -273,6 +273,9 @@ static int ufs_qcom_power_up_sequence(struct 
ufs_hba *hba)

 bool is_rate_B = (UFS_QCOM_LIMIT_HS_RATE == PA_HS_MODE_B)
 ? true : false;

+if (is_rate_B)
+phy_set_mode(phy, PHY_MODE_UFS_HS_B);
+
 /* Assert PHY reset and apply PHY calibration values */
 ufs_qcom_assert_reset(hba);
 /* provide 1ms delay to let the reset pulse propagate */


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


Thanks for reviewing Subhash.

BRs
Vivek

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



Re: [PATCH 5/5] ufs/phy: qcom: Refactor to use phy_init call

2017-09-27 Thread Vivek Gautam
Hi Subhash,


On Wed, Sep 27, 2017 at 4:43 AM, Subhash Jadavani
<subha...@codeaurora.org> wrote:
> Hi Vivek,
>
> Please find one comment inline below, rest look good.
>
> Regards,
> Subhash
>
>
> On 2017-08-03 23:48, Vivek Gautam wrote:
>>
>> Refactor ufs_qcom_power_up_sequence() to get rid of ugly
>> exported phy APIs and use the phy_init() and phy_power_on()
>> to do the phy initialization.
>>
>> Signed-off-by: Vivek Gautam <vivek.gau...@codeaurora.org>
>> ---
>>  drivers/phy/qualcomm/phy-qcom-ufs-i.h|  2 --
>>  drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c |  9 +--
>>  drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c |  9 +--
>>  drivers/phy/qualcomm/phy-qcom-ufs.c  | 38
>> 
>>  drivers/scsi/ufs/ufs-qcom.c  | 36
>> ++
>>  include/linux/phy/phy-qcom-ufs.h |  3 ---
>>  6 files changed, 38 insertions(+), 59 deletions(-)
>>
>> diff --git a/drivers/phy/qualcomm/phy-qcom-ufs-i.h
>> b/drivers/phy/qualcomm/phy-qcom-ufs-i.h
>> index 94326ed107c3..495fd5941231 100644
>> --- a/drivers/phy/qualcomm/phy-qcom-ufs-i.h
>> +++ b/drivers/phy/qualcomm/phy-qcom-ufs-i.h
>> @@ -123,7 +123,6 @@ struct ufs_qcom_phy {
>>   * struct ufs_qcom_phy_specific_ops - set of pointers to functions which
>> have a
>>   * specific implementation per phy. Each UFS phy, should implement
>>   * those functions according to its spec and requirements
>> - * @calibrate_phy: pointer to a function that calibrate the phy
>>   * @start_serdes: pointer to a function that starts the serdes
>>   * @is_physical_coding_sublayer_ready: pointer to a function that
>>   * checks pcs readiness. returns 0 for success and non-zero for error.
>> @@ -132,7 +131,6 @@ struct ufs_qcom_phy {
>>   * and writes to QSERDES_RX_SIGDET_CNTRL attribute
>>   */
>>  struct ufs_qcom_phy_specific_ops {
>> -   int (*calibrate_phy)(struct ufs_qcom_phy *phy, bool is_rate_B);
>> void (*start_serdes)(struct ufs_qcom_phy *phy);
>> int (*is_physical_coding_sublayer_ready)(struct ufs_qcom_phy
>> *phy);
>> void (*set_tx_lane_enable)(struct ufs_qcom_phy *phy, u32 val);
>> diff --git a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c
>> b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c
>> index af65785230b5..c39440b56b6d 100644
>> --- a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c
>> +++ b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c
>> @@ -44,7 +44,13 @@ 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)
>>  {
>> -   return 0;
>> +   struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy);
>> +   bool is_rate_B = false;
>> +
>> +   if (phy_common->mode == PHY_MODE_UFS_HS_B)
>> +   is_rate_B = true;
>> +
>> +   return ufs_qcom_phy_qmp_14nm_phy_calibrate(phy_common, is_rate_B);
>>  }
>>
>>  static int ufs_qcom_phy_qmp_14nm_exit(struct phy *generic_phy)
>> @@ -120,7 +126,6 @@ static int
>> ufs_qcom_phy_qmp_14nm_is_pcs_ready(struct ufs_qcom_phy *phy_common)
>>  };
>>
>>  static struct ufs_qcom_phy_specific_ops phy_14nm_ops = {
>> -   .calibrate_phy  = ufs_qcom_phy_qmp_14nm_phy_calibrate,
>> .start_serdes   = ufs_qcom_phy_qmp_14nm_start_serdes,
>> .is_physical_coding_sublayer_ready =
>> ufs_qcom_phy_qmp_14nm_is_pcs_ready,
>> .set_tx_lane_enable =
>> ufs_qcom_phy_qmp_14nm_set_tx_lane_enable,
>> diff --git a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
>> b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
>> index 5c18c41dbdb4..5705a2d4c6d2 100644
>> --- a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
>> +++ b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
>> @@ -63,7 +63,13 @@ 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)
>>  {
>> -   return 0;
>> +   struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy);
>> +   bool is_rate_B = false;
>> +
>> +   if (phy_common->mode == PHY_MODE_UFS_HS_B)
>> +   is_rate_B = true;
>> +
>> +   return ufs_qcom_phy_qmp_20nm_phy_calibrate(phy_common, is_rate_B);
>>  }
>>
>>  static int ufs_qcom_phy_qmp_20nm_exit(struct phy *generic_phy)
>> @@ -178,7 +184,6 @@ static int
>> ufs_qcom_phy_qmp_20nm_is_pcs_ready(struct ufs_qcom

Re: [PATCH 0/5] qcom-ufs: phy/hcd: Refactor phy initialization code

2017-08-11 Thread Vivek Gautam
On Fri, Aug 11, 2017 at 5:33 AM, Martin K. Petersen
 wrote:
>
> Vivek,
>
>> Can you kindly review this patch series (for UFS controller changes)
>> and consider giving your Ack so that Kishon can pull in the series
>> through phy tree.
>
> SCSI piece looks OK.

Thank you Martin for your review.
>
> Would still like Subhash to review the rest.

Subhash is on vacation with limited access to emails. I will ask
his team to take a look.

regards
Vivek

>
> --
> Martin K. Petersen  Oracle Linux Engineering
> --
> To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



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


Re: [PATCH 0/5] qcom-ufs: phy/hcd: Refactor phy initialization code

2017-08-09 Thread Vivek Gautam
Hi Martin, Subhash


On Wed, Aug 9, 2017 at 11:18 AM, Kishon Vijay Abraham I <kis...@ti.com> wrote:
> Vivek,
>
> On Tuesday 08 August 2017 09:20 PM, Vivek Gautam wrote:
>> Hi Koshon,
>>
>> On 2017-08-08 17:39, Kishon Vijay Abraham I wrote:
>>> Hi,
>>>
>>> On Friday 04 August 2017 12:18 PM, Vivek Gautam wrote:
>>>> Refactoring the qcom-ufs phy and host controller code to move
>>>> further towards the generic phy usage. Right now the qcom-ufs exports
>>>> a bunch of APIs that are used by the host controller to initialize
>>>> the phy.
>>>> With this patch series, we populate the phy_init() which was a no-op
>>>> earlier. The host controller then calls the phy_init() at the designated
>>>> place rather than doing it invariably in ufs_hcd_init().
>>>>
>>>> As part of this series, we introduce phy modes for ufs phy.
>>>> The M-PHY has two data rates defined for each generations (Gears) -
>>>> Rate A and Rate B. These can serve as the two modes of ufs HS phy.
>>>> Host controller can direct the phy to set the respective configurations
>>>> based on the phy modes.
>>>>
>>>> The patch-series has been tested with necessary dt patches on db820c.
>>>
>>> Can the first 3 patches go independently of the other 2 or should all this 
>>> be
>>> merged together?
>>
>> The first 3 patches are independent, but the next 2 patches depend on those 3
>> for functionality.
>> I would prefer all to go in one tree. If you want to pull these in the phy 
>> tree,
>> I will request Subhash/Martin to ack the patches.

Can you kindly review this patch series (for UFS controller changes) and
consider giving your Ack so that Kishon can pull in the series through phy tree.
Thanks.

best regards
Vivek

>
> sure, that should be fine!
>
> Thanks
> Kishon
> --
> To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



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


Re: [PATCH 0/5] qcom-ufs: phy/hcd: Refactor phy initialization code

2017-08-08 Thread Vivek Gautam

Hi Koshon,

On 2017-08-08 17:39, Kishon Vijay Abraham I wrote:

Hi,

On Friday 04 August 2017 12:18 PM, Vivek Gautam wrote:

Refactoring the qcom-ufs phy and host controller code to move
further towards the generic phy usage. Right now the qcom-ufs exports
a bunch of APIs that are used by the host controller to initialize
the phy.
With this patch series, we populate the phy_init() which was a no-op
earlier. The host controller then calls the phy_init() at the 
designated

place rather than doing it invariably in ufs_hcd_init().

As part of this series, we introduce phy modes for ufs phy.
The M-PHY has two data rates defined for each generations (Gears) -
Rate A and Rate B. These can serve as the two modes of ufs HS phy.
Host controller can direct the phy to set the respective 
configurations

based on the phy modes.

The patch-series has been tested with necessary dt patches on db820c.


Can the first 3 patches go independently of the other 2 or should all 
this be

merged together?


The first 3 patches are independent, but the next 2 patches depend on 
those 3 for functionality.
I would prefer all to go in one tree. If you want to pull these in the 
phy tree,

I will request Subhash/Martin to ack the patches.


Regards
Vivek



Thanks
Kishon
--
To unsubscribe from this list: send the line "unsubscribe 
linux-arm-msm" in

the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/5] dt-bindings: phy: Add PHY_TYPE_UFS definition

2017-08-04 Thread Vivek Gautam
Add definition for UFS phy type.

Signed-off-by: Vivek Gautam <vivek.gau...@codeaurora.org>
---
 include/dt-bindings/phy/phy.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/dt-bindings/phy/phy.h b/include/dt-bindings/phy/phy.h
index 6c901930eb3e..d16e8755f6a9 100644
--- a/include/dt-bindings/phy/phy.h
+++ b/include/dt-bindings/phy/phy.h
@@ -15,5 +15,6 @@
 #define PHY_TYPE_PCIE  2
 #define PHY_TYPE_USB2  3
 #define PHY_TYPE_USB3  4
+#define PHY_TYPE_UFS   5
 
 #endif /* _DT_BINDINGS_PHY */
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation



[PATCH 2/5] phy: Add UFS PHY modes

2017-08-04 Thread Vivek Gautam
UFS phy has two modes for each High speed generation.
These modes are identified by two rates of operations -
Rate A, and Rate B.
Add these UFS phy modes to phy framework.

Signed-off-by: Vivek Gautam <vivek.gau...@codeaurora.org>
---
 include/linux/phy/phy.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 78bb0d7f6b11..27e25bb78bfb 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -27,6 +27,8 @@ enum phy_mode {
PHY_MODE_USB_HOST,
PHY_MODE_USB_DEVICE,
PHY_MODE_USB_OTG,
+   PHY_MODE_UFS_HS_A,
+   PHY_MODE_UFS_HS_B,
 };
 
 /**
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation



[PATCH 3/5] phy: qcom-ufs: Add support to set phy mode

2017-08-04 Thread Vivek Gautam
Adding support to set desired UFS phy mode that can be set
from the host controller.

Signed-off-by: Vivek Gautam <vivek.gau...@codeaurora.org>
---
 drivers/phy/qualcomm/phy-qcom-ufs-i.h|  2 ++
 drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c | 14 ++
 drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c | 14 ++
 3 files changed, 30 insertions(+)

diff --git a/drivers/phy/qualcomm/phy-qcom-ufs-i.h 
b/drivers/phy/qualcomm/phy-qcom-ufs-i.h
index 13b02b7de30b..94326ed107c3 100644
--- a/drivers/phy/qualcomm/phy-qcom-ufs-i.h
+++ b/drivers/phy/qualcomm/phy-qcom-ufs-i.h
@@ -115,6 +115,8 @@ struct ufs_qcom_phy {
int cached_regs_table_size;
bool is_powered_on;
struct ufs_qcom_phy_specific_ops *phy_spec_ops;
+
+   enum phy_mode mode;
 };
 
 /**
diff --git a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c 
b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c
index 12a1b498dc4b..af65785230b5 100644
--- a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c
+++ b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c
@@ -53,6 +53,19 @@ static int ufs_qcom_phy_qmp_14nm_exit(struct phy 
*generic_phy)
 }
 
 static
+int ufs_qcom_phy_qmp_14nm_set_mode(struct phy *generic_phy, enum phy_mode mode)
+{
+   struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy);
+
+   phy_common->mode = PHY_MODE_INVALID;
+
+   if (mode > 0)
+   phy_common->mode = mode;
+
+   return 0;
+}
+
+static
 void ufs_qcom_phy_qmp_14nm_power_control(struct ufs_qcom_phy *phy, bool val)
 {
writel_relaxed(val ? 0x1 : 0x0, phy->mmio + UFS_PHY_POWER_DOWN_CONTROL);
@@ -102,6 +115,7 @@ static int ufs_qcom_phy_qmp_14nm_is_pcs_ready(struct 
ufs_qcom_phy *phy_common)
.exit   = ufs_qcom_phy_qmp_14nm_exit,
.power_on   = ufs_qcom_phy_power_on,
.power_off  = ufs_qcom_phy_power_off,
+   .set_mode   = ufs_qcom_phy_qmp_14nm_set_mode,
.owner  = THIS_MODULE,
 };
 
diff --git a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c 
b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
index 4f68acb58b73..5c18c41dbdb4 100644
--- a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
+++ b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
@@ -72,6 +72,19 @@ static int ufs_qcom_phy_qmp_20nm_exit(struct phy 
*generic_phy)
 }
 
 static
+int ufs_qcom_phy_qmp_20nm_set_mode(struct phy *generic_phy, enum phy_mode mode)
+{
+   struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy);
+
+   phy_common->mode = PHY_MODE_INVALID;
+
+   if (mode > 0)
+   phy_common->mode = mode;
+
+   return 0;
+}
+
+static
 void ufs_qcom_phy_qmp_20nm_power_control(struct ufs_qcom_phy *phy, bool val)
 {
bool hibern8_exit_after_pwr_collapse = phy->quirks &
@@ -160,6 +173,7 @@ static int ufs_qcom_phy_qmp_20nm_is_pcs_ready(struct 
ufs_qcom_phy *phy_common)
.exit   = ufs_qcom_phy_qmp_20nm_exit,
.power_on   = ufs_qcom_phy_power_on,
.power_off  = ufs_qcom_phy_power_off,
+   .set_mode   = ufs_qcom_phy_qmp_20nm_set_mode,
.owner  = THIS_MODULE,
 };
 
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation



[PATCH 4/5] scsi/ufs: qcom: Set phy mode based on the controllers HS MODE

2017-08-04 Thread Vivek Gautam
Set the phy mode based on the UFS HS PA mode. This lets the
controller let phy know the mode in which the PHY Adapter is
running and set the phy rates accordingly.

Signed-off-by: Vivek Gautam <vivek.gau...@codeaurora.org>
---
 drivers/scsi/ufs/ufs-qcom.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index c87d770b519a..44c21d5818ee 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -273,6 +273,9 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
bool is_rate_B = (UFS_QCOM_LIMIT_HS_RATE == PA_HS_MODE_B)
? true : false;
 
+   if (is_rate_B)
+   phy_set_mode(phy, PHY_MODE_UFS_HS_B);
+
/* Assert PHY reset and apply PHY calibration values */
ufs_qcom_assert_reset(hba);
/* provide 1ms delay to let the reset pulse propagate */
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation



[PATCH 5/5] ufs/phy: qcom: Refactor to use phy_init call

2017-08-04 Thread Vivek Gautam
Refactor ufs_qcom_power_up_sequence() to get rid of ugly
exported phy APIs and use the phy_init() and phy_power_on()
to do the phy initialization.

Signed-off-by: Vivek Gautam <vivek.gau...@codeaurora.org>
---
 drivers/phy/qualcomm/phy-qcom-ufs-i.h|  2 --
 drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c |  9 +--
 drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c |  9 +--
 drivers/phy/qualcomm/phy-qcom-ufs.c  | 38 
 drivers/scsi/ufs/ufs-qcom.c  | 36 ++
 include/linux/phy/phy-qcom-ufs.h |  3 ---
 6 files changed, 38 insertions(+), 59 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-ufs-i.h 
b/drivers/phy/qualcomm/phy-qcom-ufs-i.h
index 94326ed107c3..495fd5941231 100644
--- a/drivers/phy/qualcomm/phy-qcom-ufs-i.h
+++ b/drivers/phy/qualcomm/phy-qcom-ufs-i.h
@@ -123,7 +123,6 @@ struct ufs_qcom_phy {
  * struct ufs_qcom_phy_specific_ops - set of pointers to functions which have a
  * specific implementation per phy. Each UFS phy, should implement
  * those functions according to its spec and requirements
- * @calibrate_phy: pointer to a function that calibrate the phy
  * @start_serdes: pointer to a function that starts the serdes
  * @is_physical_coding_sublayer_ready: pointer to a function that
  * checks pcs readiness. returns 0 for success and non-zero for error.
@@ -132,7 +131,6 @@ struct ufs_qcom_phy {
  * and writes to QSERDES_RX_SIGDET_CNTRL attribute
  */
 struct ufs_qcom_phy_specific_ops {
-   int (*calibrate_phy)(struct ufs_qcom_phy *phy, bool is_rate_B);
void (*start_serdes)(struct ufs_qcom_phy *phy);
int (*is_physical_coding_sublayer_ready)(struct ufs_qcom_phy *phy);
void (*set_tx_lane_enable)(struct ufs_qcom_phy *phy, u32 val);
diff --git a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c 
b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c
index af65785230b5..c39440b56b6d 100644
--- a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c
+++ b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c
@@ -44,7 +44,13 @@ 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)
 {
-   return 0;
+   struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy);
+   bool is_rate_B = false;
+
+   if (phy_common->mode == PHY_MODE_UFS_HS_B)
+   is_rate_B = true;
+
+   return ufs_qcom_phy_qmp_14nm_phy_calibrate(phy_common, is_rate_B);
 }
 
 static int ufs_qcom_phy_qmp_14nm_exit(struct phy *generic_phy)
@@ -120,7 +126,6 @@ static int ufs_qcom_phy_qmp_14nm_is_pcs_ready(struct 
ufs_qcom_phy *phy_common)
 };
 
 static struct ufs_qcom_phy_specific_ops phy_14nm_ops = {
-   .calibrate_phy  = ufs_qcom_phy_qmp_14nm_phy_calibrate,
.start_serdes   = ufs_qcom_phy_qmp_14nm_start_serdes,
.is_physical_coding_sublayer_ready = ufs_qcom_phy_qmp_14nm_is_pcs_ready,
.set_tx_lane_enable = ufs_qcom_phy_qmp_14nm_set_tx_lane_enable,
diff --git a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c 
b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
index 5c18c41dbdb4..5705a2d4c6d2 100644
--- a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
+++ b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
@@ -63,7 +63,13 @@ 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)
 {
-   return 0;
+   struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy);
+   bool is_rate_B = false;
+
+   if (phy_common->mode == PHY_MODE_UFS_HS_B)
+   is_rate_B = true;
+
+   return ufs_qcom_phy_qmp_20nm_phy_calibrate(phy_common, is_rate_B);
 }
 
 static int ufs_qcom_phy_qmp_20nm_exit(struct phy *generic_phy)
@@ -178,7 +184,6 @@ static int ufs_qcom_phy_qmp_20nm_is_pcs_ready(struct 
ufs_qcom_phy *phy_common)
 };
 
 static struct ufs_qcom_phy_specific_ops phy_20nm_ops = {
-   .calibrate_phy  = ufs_qcom_phy_qmp_20nm_phy_calibrate,
.start_serdes   = ufs_qcom_phy_qmp_20nm_start_serdes,
.is_physical_coding_sublayer_ready = ufs_qcom_phy_qmp_20nm_is_pcs_ready,
.set_tx_lane_enable = ufs_qcom_phy_qmp_20nm_set_tx_lane_enable,
diff --git a/drivers/phy/qualcomm/phy-qcom-ufs.c 
b/drivers/phy/qualcomm/phy-qcom-ufs.c
index 43865ef340e2..1febe3294fe3 100644
--- a/drivers/phy/qualcomm/phy-qcom-ufs.c
+++ b/drivers/phy/qualcomm/phy-qcom-ufs.c
@@ -518,9 +518,8 @@ void ufs_qcom_phy_disable_iface_clk(struct ufs_qcom_phy 
*phy)
}
 }
 
-int ufs_qcom_phy_start_serdes(struct phy *generic_phy)
+static int ufs_qcom_phy_start_serdes(struct ufs_qcom_phy *ufs_qcom_phy)
 {
-   struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(generic_phy);
int ret = 0;
 
if (!ufs_qcom_phy->phy_spec_ops->start_serdes) {
@@ -533,7 +532,6 @@ int ufs_qcom_phy_start_serdes(struct phy *generic_phy)
 
return ret;
 }

[PATCH 0/5] qcom-ufs: phy/hcd: Refactor phy initialization code

2017-08-04 Thread Vivek Gautam
Refactoring the qcom-ufs phy and host controller code to move
further towards the generic phy usage. Right now the qcom-ufs exports
a bunch of APIs that are used by the host controller to initialize
the phy.
With this patch series, we populate the phy_init() which was a no-op
earlier. The host controller then calls the phy_init() at the designated
place rather than doing it invariably in ufs_hcd_init().

As part of this series, we introduce phy modes for ufs phy.
The M-PHY has two data rates defined for each generations (Gears) -
Rate A and Rate B. These can serve as the two modes of ufs HS phy.
Host controller can direct the phy to set the respective configurations
based on the phy modes.

The patch-series has been tested with necessary dt patches on db820c.

Vivek Gautam (5):
  dt-bindings: phy: Add PHY_TYPE_UFS definition
  phy: Add UFS PHY modes
  phy: qcom-ufs: Add support to set phy mode
  scsi/ufs: qcom: Set phy mode based on the controllers HS MODE
  ufs/phy: qcom: Refactor to use phy_init call

 drivers/phy/qualcomm/phy-qcom-ufs-i.h|  4 +--
 drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c | 23 ++--
 drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c | 23 ++--
 drivers/phy/qualcomm/phy-qcom-ufs.c  | 38 +++
 drivers/scsi/ufs/ufs-qcom.c  | 39 
 include/dt-bindings/phy/phy.h|  1 +
 include/linux/phy/phy-qcom-ufs.h |  3 ---
 include/linux/phy/phy.h  |  2 ++
 8 files changed, 74 insertions(+), 59 deletions(-)

-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation



Re: [PATCH v5 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd

2016-11-08 Thread Vivek Gautam
On Wed, Nov 9, 2016 at 4:36 AM, Martin K. Petersen
<martin.peter...@oracle.com> wrote:
>>>>>> "Vivek" == Vivek Gautam <vivek.gau...@codeaurora.org> writes:
>
> Vivek> Here's the rebased version of patches based on 4.10/scsi-queue
> Vivek> branch as requested.  The patches can now be applied and
> Vivek> pulled-in.
>
> Thanks! Applied to 4.10/scsi-queue.

Thanks Martin.


Regards
Vivek


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 08/12] phy: qcom-ufs-qmp-xx: Move clock and regulator init out of phy init

2016-11-08 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@codeaurora.org>
---
 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 = >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 = >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 = >common_cfg;
 
-   generic_phy = ufs_qcom_phy_generic_probe(pdev, >common_cfg,
+   generic_phy = ufs_qcom_phy_generic_probe(pdev, phy_common,
_qcom_phy_qmp_14nm_phy_ops, _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 = >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 = >dev;
struct phy 

[PATCH v5 10/12] phy: qcom-ufs: Remove common layer phy exit callback

2016-11-08 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@codeaurora.org>
---
 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 fdd9b90..c69568b 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -602,17 +602,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);
@@ -634,6 +623,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, _common->vdda_phy);
if (err) {
dev_err(dev, "%s enable vdda_phy failed, err=%d\n",
@@ -696,6 +688,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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 07/12] phy: qcom-ufs: Remove unnecessary function declarations

2016-11-08 Thread Vivek Gautam
Move the functions' definitions to remove unnecessary
declarations.

Signed-off-by: Vivek Gautam <vivek.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@codeaurora.org>
---
 drivers/phy/phy-qcom-ufs.c | 131 +
 1 file changed, 62 insertions(+), 69 deletions(-)

diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
index b85f882..c5c29fe 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -22,13 +22,6 @@
 #define VDDP_REF_CLK_MIN_UV120
 #define VDDP_REF_CLK_MAX_UV120
 
-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 = >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 = >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)
 {
@@ -217,29 +210,6 @@ int ufs_qcom_phy_init_clks(struct ufs_qcom_phy *phy_common)
 }
 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, _common->vdda_pll,
-   "vdda-pll");
-   if (err)
-   goto out;
-
-   err = ufs_qcom_phy_init_vreg(phy_common->dev, _common->vdda_phy,

[PATCH v5 12/12] scsi/ufs: qcom: Don't free resource-managed kmalloc element

2016-11-08 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@codeaurora.org>
---
 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 31df783..804f4e7 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -1268,7 +1268,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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 09/12] ufs-qcom: phy/hcd: Refactoring phy clock handling

2016-11-08 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@codeaurora.org>
---
 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 c5c29fe..fdd9b90 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -361,10 +361,9 @@ static 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;
@@ -411,7 +410,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,
  struct ufs_qcom_phy_vreg *vreg)
@@ -435,10 +433,8 @@ static 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);
/*
@@ -451,7 +447,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)
 
@@ -504,9 +499,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)
@@ -530,20 +524,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)
 {
@@ -661,13 +651,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,
@@ -683,7 +680,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, _common->vdda_pll);
 out_disable_phy:
@@ -702,7 +701,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,
  _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, _common->vdda_pll);
ufs_qcom_

[PATCH v5 11/12] scsi/ufs: qcom: Add phy_exit call in hcd exit path

2016-11-08 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@codeaurora.org>
---
 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 5f70a35..31df783 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -1280,6 +1280,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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 03/12] phy: qcom-ufs: Cleanup clock and regulator initialization

2016-11-08 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@codeaurora.org>
---
 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  | 80 ++---
 4 files changed, 37 insertions(+), 57 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 = >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 = >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..b0171fe 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -22,9 +22,9 @@
 #define VDDP_REF_CLK_MIN_UV120
 #define VDDP_REF_CLK_MAX_UV120
 
-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)) {
@@ -174,30 +172,27 @@ static int __ufs_qcom_phy_clk_get(struct phy *phy,
return err;
 }
 
-static
-int ufs_qcom_phy_clk_get(struct phy *phy,
+static int ufs_qcom_phy_clk_get(struct device *dev,
 const char 

[PATCH v5 04/12] phy: qcom-ufs-14nm: Add new compatible for msm8996 based phy

2016-11-08 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@codeaurora.org>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 02/12] phy: qcom-ufs: Use devm sibling of kstrdup for regulator names

2016-11-08 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@codeaurora.org>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 05/12] phy: qcom-ufs: Skip obtaining rx/tx_iface_clk for msm8996 based phy

2016-11-08 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@codeaurora.org>
---
 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 b0171fe..3fa7b07 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -182,6 +182,10 @@ int ufs_qcom_phy_init_clks(struct ufs_qcom_phy *phy_common)
 {
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",
   _common->tx_iface_clk);
if (err)
@@ -197,6 +201,7 @@ int ufs_qcom_phy_init_clks(struct ufs_qcom_phy *phy_common)
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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 01/12] phy: qcom-ufs: Remove unnecessary BUG_ON

2016-11-08 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@codeaurora.org>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 06/12] phy: qcom-ufs-qmp-xx: Discard remove callback for drivers.

2016-11-08 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@codeaurora.org>
---
 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 = >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 = >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 3fa7b07..b85f882 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -619,15 +619,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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd

2016-11-08 Thread Vivek Gautam
Hi Martin,

Here's the rebased version of patches based on 4.10/scsi-queue branch
as requested.
The patches can now be applied and pulled-in.

Thanks

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 v4:
 - Rebased on top of 4.10/scsi-queue branch.

Changes since v3:
 - Addressed review comment to move phy_power_off() under
   *link not active* check during aggressive clock gating
   from ufs hcd driver (in ufs_qcom_setup_clocks() API).

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 | 273 +
 drivers/scsi/ufs/ufs-qcom.c|  23 +-
 include/linux/phy/phy-qcom-ufs.h   |  18 --
 7 files changed, 186 insertions(+), 279 deletions(-)

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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 09/12] ufs-qcom: phy/hcd: Refactoring phy clock handling

2016-11-03 Thread 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.gau...@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, _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,
 

Re: [PATCH v3 04/12] phy: qcom-ufs-14nm: Add new compatible for msm8996 based phy

2016-11-03 Thread Vivek Gautam
Hi,


On Tue, Nov 1, 2016 at 2:41 AM, Subhash Jadavani
<subha...@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.gau...@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
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 09/12] ufs-qcom: phy/hcd: Refactoring phy clock handling

2016-11-02 Thread Vivek Gautam
Hi Subhash,

On Wed, Nov 2, 2016 at 12:17 AM, Subhash Jadavani
<subha...@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.gau...@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(>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
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 04/12] phy: qcom-ufs-14nm: Add new compatible for msm8996 based phy

2016-10-29 Thread 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.gau...@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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 02/12] phy: qcom-ufs: Use devm sibling of kstrdup for regulator names

2016-10-29 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 12/12] scsi/ufs: qcom: Don't free resource-managed kmalloc element

2016-10-29 Thread 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.gau...@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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 10/12] phy: qcom-ufs: Remove common layer phy exit callback

2016-10-29 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@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, _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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 03/12] phy: qcom-ufs: Cleanup clock and regulator initialization

2016-10-29 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@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 = >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 = >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_UV120
 #define VDDP_REF_CLK_MAX_UV120
 
-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,

[PATCH v3 11/12] scsi/ufs: qcom: Add phy_exit call in hcd exit path

2016-10-29 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 06/12] phy: qcom-ufs-qmp-xx: Discard remove callback for drivers.

2016-10-29 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@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 = >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 = >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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 08/12] phy: qcom-ufs-qmp-xx: Move clock and regulator init out of phy init

2016-10-29 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@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 = >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 = >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 = >common_cfg;
 
-   generic_phy = ufs_qcom_phy_generic_probe(pdev, >common_cfg,
+   generic_phy = ufs_qcom_phy_generic_probe(pdev, phy_common,
_qcom_phy_qmp_14nm_phy_ops, _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 = >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 = >dev;

[PATCH v3 07/12] phy: qcom-ufs: Remove unnecessary function declarations

2016-10-29 Thread Vivek Gautam
Move the functions' definitions to remove unnecessary
declarations.

Signed-off-by: Vivek Gautam <vivek.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@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_UV120
 #define VDDP_REF_CLK_MAX_UV120
 
-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 = >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 = >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, _common->vdda_pll,
-   "vdda-pll");
-   if (err)
-   goto out;
-
-   err = ufs_qcom_phy_init_vreg(phy_common->dev, _common->vdda_phy,

[PATCH v3 05/12] phy: qcom-ufs: Skip obtaining rx/tx_iface_clk for msm8996 based phy

2016-10-29 Thread 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.gau...@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",
   _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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 09/12] ufs-qcom: phy/hcd: Refactoring phy clock handling

2016-10-29 Thread 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.gau...@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, _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,
  _common->vddp_ref_clk);
-   ufs_qcom_phy_disable_ref_clk(generic_phy);
+   ufs_qco

[PATCH v3 01/12] phy: qcom-ufs: Remove unnecessary BUG_ON

2016-10-29 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd

2016-10-29 Thread 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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 01/10] phy: qcom-ufs: remove failure when rx/tx_iface_clk are absent

2016-10-29 Thread Vivek Gautam
Hi,


On Wed, Oct 19, 2016 at 10:50 PM, Vivek Gautam
<vivek.gau...@codeaurora.org> wrote:
> Hi,
>
>
> On Wed, Oct 19, 2016 at 2:48 AM, Stephen Boyd <sb...@codeaurora.org> wrote:
>> On 10/18/2016 07:28 AM, Vivek Gautam wrote:
>>> From: Yaniv Gardi <yga...@codeaurora.org>
>>>
>>> Since in future UFS Phy's the tx_iface_clk and rx_iface_clk
>>> are no longer exist, we should not fail when their initialization
>>> fail, but rather just report with debug message.
>>>
>>> Signed-off-by: Yaniv Gardi <yga...@codeaurora.org>
>>> Signed-off-by: Vivek Gautam <vivek.gau...@codeaurora.org>
>>> ---
>>
>> Shouldn't we have a different compatible string on future UFS phys so
>> that we know which number of clks and what clks are required? That's how
>> we typically handle clk configurations changing. Making them optional
>> should really only be needed when they're really optional, i.e. things
>> will work fine if they're there or not.
>
> Correct. It makes sense to have different compatible strings for different
> versions.
> I will gather more information about previous versions that required
> this clock, and update as suggested.

The tx/rx_face clocks are not available on some of the recent chips,
such as msm8996. Older chips with this 14nm ufs phy had handles
for tx/rx_iface clocks.
So, i will add new compatible string for msm8996 -
"qcom,msm8996-ufs-phy-qmp-14nm"
This can be used with chips further on that are going to use the same ufs phy.


Regards
Vivek

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 04/10] phy: qcom-ufs-qmp-xx: Discard remove callback for drivers.

2016-10-29 Thread Vivek Gautam
Hi,


On Thu, Oct 27, 2016 at 1:50 AM, Kishon Vijay Abraham I <kis...@ti.com> wrote:
>
>
> On Tuesday 18 October 2016 07:58 PM, Vivek Gautam wrote:
>> remove() callback does a phy_exit() only and nothing else now.
>
> remove callback calls a phy_power_off() ;-)

Yea, correct. My bad.  :)
Will correct.

[snip]


Thanks
Vivek

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 00/10] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd

2016-10-25 Thread Vivek Gautam
Hi Martin,



On Tue, Oct 25, 2016 at 6:10 AM, Martin K. Petersen
<martin.peter...@oracle.com> wrote:
>>>>>> "Vivek" == Vivek Gautam <vivek.gau...@codeaurora.org> writes:
>
> Vivek,
>
> 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.
>
> Please submit a v3 which addresses the review comments and adds the
> relevant Reviewed-by: tags.
>
> Thanks!

Sure, i will send the v3 in couple of days.


Thanks
Vivek

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 08/10] ufs-qcom: phy/hcd: Refactoring phy clock handling

2016-10-19 Thread Vivek Gautam
On Thu, Oct 20, 2016 at 12:48 AM, Subhash Jadavani
<subha...@codeaurora.org> wrote:
> On 2016-10-19 10:45, Vivek Gautam wrote:
>>
>> Hi,
>>
>>
>> On Wed, Oct 19, 2016 at 1:43 AM, Subhash Jadavani
>> <subha...@codeaurora.org> wrote:
>>>
>>> On 2016-10-18 07:28, 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.gau...@codeaurora.org>
>>>> ---
>>>>
>>>> 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.
>>
>>
>> [snip]
>>
>>>> --- a/drivers/scsi/ufs/ufs-qcom.c
>>>> +++ b/drivers/scsi/ufs/ufs-qcom.c
>>>> @@ -1112,17 +1112,6 @@ 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;
>>>> -   }
>>>
>>>
>>>
>>> Now that you are moving these ref clk enable/disable to phy_power_on/off
>>> and
>>> these phy_power_on/off are called only in runtime suspend/resume (3
>>> seconds
>>> after last UFS access).
>>> Goal is to disable the phy reference clock during aggressive gating (10ms
>>> from last UFS access) so shouldn't we call the phy_power_on/off from
>>> these
>>> setup_clocks() function as well?
>>>
>>
>> So setup_clocks() is called for aggressive clock gating as well ?
>> If that's the case then yes, we may need to call. But we should try to
>> understand here. The phy_power_off turns off all the clocks - reflclk,
>> and other interface clocks. Do we want all of them to be turned off ?
>
>
> Yes, we want to turn off the ref clock (& other clocks) during aggressive
> gating.

Ok.

>
>>
>> phy_power_off will also turn off the PHY. Do we want all this for
>> aggressive
>> clock gating ?
>
>
> Yes, PHY rails can be powered off both during the aggressive clk gating and
> runtime suspend. But as the regulator on/off latencies could be higher
> (especially for the shared rail), we were turning them off doing it in
> runtime suspend only (via phy_power_off()).
> Now that phy_power_on/off is managing both clocks and regulators, and we
> will really want to turn off the ref clocks during clock gating, there is no
> option but to call phy_power_on/off during aggressive gating.

Alright then, i will update the change to add phy_power_off/on()
during aggressive clock gating.


Thanks
Vivek

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 08/10] ufs-qcom: phy/hcd: Refactoring phy clock handling

2016-10-19 Thread Vivek Gautam
Hi,


On Wed, Oct 19, 2016 at 1:43 AM, Subhash Jadavani
<subha...@codeaurora.org> wrote:
> On 2016-10-18 07:28, 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.gau...@codeaurora.org>
>> ---
>>
>> 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.

[snip]

>> --- a/drivers/scsi/ufs/ufs-qcom.c
>> +++ b/drivers/scsi/ufs/ufs-qcom.c
>> @@ -1112,17 +1112,6 @@ 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;
>> -   }
>
>
> Now that you are moving these ref clk enable/disable to phy_power_on/off and
> these phy_power_on/off are called only in runtime suspend/resume (3 seconds
> after last UFS access).
> Goal is to disable the phy reference clock during aggressive gating (10ms
> from last UFS access) so shouldn't we call the phy_power_on/off from these
> setup_clocks() function as well?
>

So setup_clocks() is called for aggressive clock gating as well ?
If that's the case then yes, we may need to call. But we should try to
understand here. The phy_power_off turns off all the clocks - reflclk,
and other interface clocks. Do we want all of them to be turned off ?

phy_power_off will also turn off the PHY. Do we want all this for aggressive
clock gating ?


[snip]


Regards
Vivek

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 01/10] phy: qcom-ufs: remove failure when rx/tx_iface_clk are absent

2016-10-19 Thread Vivek Gautam
Hi,


On Wed, Oct 19, 2016 at 2:48 AM, Stephen Boyd <sb...@codeaurora.org> wrote:
> On 10/18/2016 07:28 AM, Vivek Gautam wrote:
>> From: Yaniv Gardi <yga...@codeaurora.org>
>>
>> Since in future UFS Phy's the tx_iface_clk and rx_iface_clk
>> are no longer exist, we should not fail when their initialization
>> fail, but rather just report with debug message.
>>
>> Signed-off-by: Yaniv Gardi <yga...@codeaurora.org>
>> Signed-off-by: Vivek Gautam <vivek.gau...@codeaurora.org>
>> ---
>
> Shouldn't we have a different compatible string on future UFS phys so
> that we know which number of clks and what clks are required? That's how
> we typically handle clk configurations changing. Making them optional
> should really only be needed when they're really optional, i.e. things
> will work fine if they're there or not.

Correct. It makes sense to have different compatible strings for different
versions.
I will gather more information about previous versions that required
this clock, and update as suggested.


Regards
Vivek


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 04/10] phy: qcom-ufs-qmp-xx: Discard remove callback for drivers.

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

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

No change since v1.

 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 6ee5149..a305016 100644
--- a/drivers/phy/phy-qcom-ufs-qmp-14nm.c
+++ b/drivers/phy/phy-qcom-ufs-qmp-14nm.c
@@ -163,21 +163,6 @@ out:
return err;
 }
 
-static int ufs_qcom_phy_qmp_14nm_remove(struct platform_device *pdev)
-{
-   struct device *dev = >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"},
{},
@@ -186,7 +171,6 @@ MODULE_DEVICE_TABLE(of, ufs_qcom_phy_qmp_14nm_of_match);
 
 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 770087a..2db1fbb 100644
--- a/drivers/phy/phy-qcom-ufs-qmp-20nm.c
+++ b/drivers/phy/phy-qcom-ufs-qmp-20nm.c
@@ -219,21 +219,6 @@ out:
return err;
 }
 
-static int ufs_qcom_phy_qmp_20nm_remove(struct platform_device *pdev)
-{
-   struct device *dev = >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 @@ MODULE_DEVICE_TABLE(of, ufs_qcom_phy_qmp_20nm_of_match);
 
 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 f639a7c..b8f9286 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -645,15 +645,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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 05/10] phy: qcom-ufs: Cleanup clock and regulator initialization

2016-10-18 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@codeaurora.org>
---

No change 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  | 79 -
 4 files changed, 39 insertions(+), 54 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 *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 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 a305016..55fecbb 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 = >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 2db1fbb..9a2f53d 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 = >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 b8f9286..3a87e88 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -22,9 +22,9 @@
 #define VDDP_REF_CLK_MIN_UV120
 #define VDDP_REF_CLK_MAX_UV120
 
-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,40 +173,38 @@ 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,
 

[PATCH 08/10] ufs-qcom: phy/hcd: Refactoring phy clock handling

2016-10-18 Thread 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.gau...@codeaurora.org>
---

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  | 15 ---
 include/linux/phy/phy-qcom-ufs.h | 18 --
 3 files changed, 18 insertions(+), 51 deletions(-)

diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
index 144b11f..a425cc2 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -373,10 +373,9 @@ out:
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;
@@ -423,7 +422,6 @@ out_disable_src:
 out:
return ret;
 }
-EXPORT_SYMBOL_GPL(ufs_qcom_phy_enable_ref_clk);
 
 static
 int ufs_qcom_phy_disable_vreg(struct device *dev,
@@ -448,10 +446,8 @@ out:
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);
/*
@@ -464,7 +460,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)
 
@@ -517,9 +512,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)
@@ -543,20 +537,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)
 {
@@ -674,13 +664,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,
@@ -696,7 +693,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, _common->vdda_pll);
 out_disable_phy:
@@ -715,7 +714,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,
  _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, _common->vdda_pll);
ufs_qcom_phy_disable_vreg(phy_common->dev, _common->vdda_phy);
diff --git a/drive

[PATCH v2 06/10] phy: qcom-ufs: Remove unnecessary function declarations

2016-10-18 Thread Vivek Gautam
Move the functions' definitions to remove unnecessary
declarations.

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

New patch added in v2 series.

 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 3a87e88..144b11f 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -22,13 +22,6 @@
 #define VDDP_REF_CLK_MIN_UV120
 #define VDDP_REF_CLK_MAX_UV120
 
-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 @@ out:
 }
 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 = >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 = >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)
 {
@@ -224,30 +217,6 @@ out:
 }
 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, _common->vdda_pll,
-   "vdda-pll");
-   if (err)
-   goto out;
-
-   err = ufs_qcom_phy_init_vreg(phy_common->dev, _common->vdda_phy,
-   "vdda-phy");
-
-   if (err)
-   goto out;
-
-   /* vddp-ref-clk-* properties are optional */
-   __

[PATCH v2 01/10] phy: qcom-ufs: remove failure when rx/tx_iface_clk are absent

2016-10-18 Thread Vivek Gautam
From: Yaniv Gardi <yga...@codeaurora.org>

Since in future UFS Phy's the tx_iface_clk and rx_iface_clk
are no longer exist, we should not fail when their initialization
fail, but rather just report with debug message.

Signed-off-by: Yaniv Gardi <yga...@codeaurora.org>
Signed-off-by: Vivek Gautam <vivek.gau...@codeaurora.org>
---

No change since v1.

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

diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
index 107cb57..183ec04 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -186,16 +186,27 @@ ufs_qcom_phy_init_clks(struct phy *generic_phy,
   struct ufs_qcom_phy *phy_common)
 {
int err;
+   struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy);
 
err = ufs_qcom_phy_clk_get(generic_phy, "tx_iface_clk",
   _common->tx_iface_clk);
+   /*
+* tx_iface_clk does not exist in newer version of ufs-phy HW,
+* so don't return error if it is not found
+*/
if (err)
-   goto out;
+   dev_dbg(phy->dev, "%s: failed to get tx_iface_clk\n",
+   __func__);
 
err = ufs_qcom_phy_clk_get(generic_phy, "rx_iface_clk",
   _common->rx_iface_clk);
+   /*
+* rx_iface_clk does not exist in newer version of ufs-phy HW,
+* so don't return error if it is not found
+*/
if (err)
-   goto out;
+   dev_dbg(phy->dev, "%s: failed to get rx_iface_clk\n",
+   __func__);
 
err = ufs_qcom_phy_clk_get(generic_phy, "ref_clk_src",
   _common->ref_clk_src);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 09/10] scsi/ufs: qcom: Add phy_exit call in hcd exit path

2016-10-18 Thread 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.gau...@codeaurora.org>
---

New patch added in v2 series.

 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 6e4ce5f..dfd2af8 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -1272,6 +1272,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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 02/10] phy: qcom-ufs: Remove unnecessary BUG_ON

2016-10-18 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@codeaurora.org>
---

No change 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 183ec04..805c91d 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -335,8 +335,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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 03/10] phy: qcom-ufs: Use devm sibling of kstrdup for regulator names

2016-10-18 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@codeaurora.org>
---

No change 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 805c91d..f639a7c 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -262,7 +262,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;
@@ -650,9 +650,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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 07/10] phy: qcom-ufs-qmp-xx: Move clock and regulator init out of phy init

2016-10-18 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@codeaurora.org>
---

No change 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 55fecbb..a60cf34 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 = >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 = >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 = >common_cfg;
 
-   generic_phy = ufs_qcom_phy_generic_probe(pdev, >common_cfg,
+   generic_phy = ufs_qcom_phy_generic_probe(pdev, phy_common,
_qcom_phy_qmp_14nm_phy_ops, _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 = >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 = >dev;

[PATCH v2 10/10] phy: qcom-ufs: Remove common layer phy exit callback

2016-10-18 Thread 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.gau...@codeaurora.org>
---

New patch added in v2 series.

 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 a60cf34..061604f 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 a425cc2..494f90f 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -615,17 +615,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);
@@ -647,6 +636,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, _common->vdda_phy);
if (err) {
dev_err(dev, "%s enable vdda_phy failed, err=%d\n",
@@ -709,6 +701,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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 00/10] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd

2016-10-18 Thread 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 from 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 (9):
  phy: qcom-ufs: Remove unnecessary BUG_ON
  phy: qcom-ufs: Use devm sibling of kstrdup for regulator names
  phy: qcom-ufs-qmp-xx: Discard remove callback for drivers.
  phy: qcom-ufs: Cleanup clock and regulator initialization
  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
  scsi/ufs: qcom: Add phy_exit call in hcd exit path
  phy: qcom-ufs: Remove common layer phy exit callback

Yaniv Gardi (1):
  phy: qcom-ufs: remove failure when rx/tx_iface_clk are absence

 drivers/phy/phy-qcom-ufs-i.h|   7 +-
 drivers/phy/phy-qcom-ufs-qmp-14nm.c |  71 -
 drivers/phy/phy-qcom-ufs-qmp-20nm.c |  65 -
 drivers/phy/phy-qcom-ufs.c  | 278 
 drivers/scsi/ufs/ufs-qcom.c |  16 +--
 include/linux/phy/phy-qcom-ufs.h|  18 ---
 6 files changed, 182 insertions(+), 273 deletions(-)

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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/7] ufs-qcom: phy/hcd: Refactoring phy clock handling

2016-10-17 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@codeaurora.org>
---
 drivers/phy/phy-qcom-ufs.c  | 12 +++-
 drivers/scsi/ufs/ufs-qcom.c | 15 ---
 2 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
index 3a87e88..687b9b7 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -681,11 +681,18 @@ int ufs_qcom_phy_power_on(struct phy *generic_phy)
goto out_disable_phy;
}
 
+   err = ufs_qcom_phy_enable_iface_clk(generic_phy);
+   if (err) {
+   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(generic_phy);
if (err) {
dev_err(dev, "%s enable phy ref clock failed, err=%d\n",
__func__, err);
-   goto out_disable_pll;
+   goto out_disable_iface_clk;
}
 
/* enable device PHY ref_clk pad rail */
@@ -704,6 +711,8 @@ int ufs_qcom_phy_power_on(struct phy *generic_phy)
 
 out_disable_ref_clk:
ufs_qcom_phy_disable_ref_clk(generic_phy);
+out_disable_iface_clk:
+   ufs_qcom_phy_disable_iface_clk(generic_phy);
 out_disable_pll:
ufs_qcom_phy_disable_vreg(dev, _common->vdda_pll);
 out_disable_phy:
@@ -723,6 +732,7 @@ int ufs_qcom_phy_power_off(struct phy *generic_phy)
ufs_qcom_phy_disable_vreg(phy_common->dev,
  _common->vddp_ref_clk);
ufs_qcom_phy_disable_ref_clk(generic_phy);
+   ufs_qcom_phy_disable_iface_clk(generic_phy);
 
ufs_qcom_phy_disable_vreg(phy_common->dev, _common->vdda_pll);
ufs_qcom_phy_disable_vreg(phy_common->dev, _common->vdda_phy);
diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index 3aedf73..6e4ce5f 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -1112,17 +1112,6 @@ 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;
-   }
/* enable the device ref clock for HS mode*/
if (ufshcd_is_hs_mode(>pwr_info))
ufs_qcom_dev_ref_clk_ctrl(host, true);
@@ -1131,9 +1120,6 @@ 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))
/* disable device ref_clk */
ufs_qcom_dev_ref_clk_ctrl(host, false);
@@ -1146,7 +1132,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;
 }
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/7] phy: qcom-ufs: Use devm sibling of kstrdup for regulator names

2016-10-17 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@codeaurora.org>
---
 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 805c91d..f639a7c 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -262,7 +262,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;
@@ -650,9 +650,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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/7] phy: qcom-ufs: remove failure when rx/tx_iface_clk are absent

2016-10-17 Thread Vivek Gautam
From: Yaniv Gardi <yga...@codeaurora.org>

Since in future UFS Phy's the tx_iface_clk and rx_iface_clk
are no longer exist, we should not fail when their initialization
fail, but rather just report with debug message.

Signed-off-by: Yaniv Gardi <yga...@codeaurora.org>
Signed-off-by: Vivek Gautam <vivek.gau...@codeaurora.org>
---
 drivers/phy/phy-qcom-ufs.c | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
index 107cb57..183ec04 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -186,16 +186,27 @@ ufs_qcom_phy_init_clks(struct phy *generic_phy,
   struct ufs_qcom_phy *phy_common)
 {
int err;
+   struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy);
 
err = ufs_qcom_phy_clk_get(generic_phy, "tx_iface_clk",
   _common->tx_iface_clk);
+   /*
+* tx_iface_clk does not exist in newer version of ufs-phy HW,
+* so don't return error if it is not found
+*/
if (err)
-   goto out;
+   dev_dbg(phy->dev, "%s: failed to get tx_iface_clk\n",
+   __func__);
 
err = ufs_qcom_phy_clk_get(generic_phy, "rx_iface_clk",
   _common->rx_iface_clk);
+   /*
+* rx_iface_clk does not exist in newer version of ufs-phy HW,
+* so don't return error if it is not found
+*/
if (err)
-   goto out;
+   dev_dbg(phy->dev, "%s: failed to get rx_iface_clk\n",
+   __func__);
 
err = ufs_qcom_phy_clk_get(generic_phy, "ref_clk_src",
   _common->ref_clk_src);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/7] phy: qcom-ufs: Cleanup clock and regulator initialization

2016-10-17 Thread Vivek Gautam
Different methods pass around generic phy pointer to
extract device pointer. Instead, pass the device pointer
directly between function calls.

Signed-off-by: Vivek Gautam <vivek.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@codeaurora.org>
---
 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  | 79 -
 4 files changed, 39 insertions(+), 54 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 *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 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 a305016..55fecbb 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 = >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 2db1fbb..9a2f53d 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 = >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 b8f9286..3a87e88 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -22,9 +22,9 @@
 #define VDDP_REF_CLK_MIN_UV120
 #define VDDP_REF_CLK_MAX_UV120
 
-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,40 +173,38 @@ 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 

[PATCH 6/7] phy: qcom-ufs-qmp-xx: Move clock and regulator init out of phy init

2016-10-17 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@codeaurora.org>
---
 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 55fecbb..a60cf34 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 = >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 = >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 = >common_cfg;
 
-   generic_phy = ufs_qcom_phy_generic_probe(pdev, >common_cfg,
+   generic_phy = ufs_qcom_phy_generic_probe(pdev, phy_common,
_qcom_phy_qmp_14nm_phy_ops, _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 = >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 = >dev;
struct phy 

[PATCH 2/7] phy: qcom-ufs: Remove unnecessary BUG_ON

2016-10-17 Thread 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.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@codeaurora.org>
---
 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 183ec04..805c91d 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -335,8 +335,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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/7] phy: qcom-ufs-qmp-xx: Discard remove callback for drivers.

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

Signed-off-by: Vivek Gautam <vivek.gau...@codeaurora.org>
Reviewed-by: Subhash Jadavani <subha...@codeaurora.org>
---
 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 6ee5149..a305016 100644
--- a/drivers/phy/phy-qcom-ufs-qmp-14nm.c
+++ b/drivers/phy/phy-qcom-ufs-qmp-14nm.c
@@ -163,21 +163,6 @@ out:
return err;
 }
 
-static int ufs_qcom_phy_qmp_14nm_remove(struct platform_device *pdev)
-{
-   struct device *dev = >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"},
{},
@@ -186,7 +171,6 @@ MODULE_DEVICE_TABLE(of, ufs_qcom_phy_qmp_14nm_of_match);
 
 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 770087a..2db1fbb 100644
--- a/drivers/phy/phy-qcom-ufs-qmp-20nm.c
+++ b/drivers/phy/phy-qcom-ufs-qmp-20nm.c
@@ -219,21 +219,6 @@ out:
return err;
 }
 
-static int ufs_qcom_phy_qmp_20nm_remove(struct platform_device *pdev)
-{
-   struct device *dev = >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 @@ MODULE_DEVICE_TABLE(of, ufs_qcom_phy_qmp_20nm_of_match);
 
 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 f639a7c..b8f9286 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -645,15 +645,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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/7] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd

2016-10-17 Thread 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].

[1] https://git.linaro.org/landing-teams/working/qualcomm/kernel.git

Vivek Gautam (6):
  phy: qcom-ufs: Remove unnecessary BUG_ON
  phy: qcom-ufs: Use devm sibling of kstrdup for regulator names
  phy: qcom-ufs-qmp-xx: Discard remove callback for drivers.
  phy: qcom-ufs: Cleanup clock and regulator initialization
  phy: qcom-ufs-qmp-xx: Move clock and regulator init out of phy init
  ufs-qcom: phy/hcd: Refactoring phy clock handling

Yaniv Gardi (1):
  phy: qcom-ufs: remove failure when rx/tx_iface_clk are absence

 drivers/phy/phy-qcom-ufs-i.h|   6 +-
 drivers/phy/phy-qcom-ufs-qmp-14nm.c |  66 
 drivers/phy/phy-qcom-ufs-qmp-20nm.c |  60 +++
 drivers/phy/phy-qcom-ufs.c  | 116 +---
 drivers/scsi/ufs/ufs-qcom.c |  15 -
 5 files changed, 101 insertions(+), 162 deletions(-)

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

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html