Skip to contentSkip to conversation

scsi: ufs-qcom: add number of lanes per direction

PATCH In review Can Guo 2 participants 3 messages Feb 5, 2018 – Feb 27, 2018

Subsystems (3)
lore
Share & tools
lore

Can Guo

author
#0 lore raw

PATCH 1/1 scsi: ufs-qcom: add number of lanes per direction

From: Gilad Broner <[email protected]>

Different platforms may have different number of lanes for the UFS link. Add parameter to device tree specifying how many lanes should be configured for the UFS link. And don't print err message for clocks that are optional, this leads to unnecessary confusion about failure.

Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +3 -0
index 5357919..4cee3f9 100644
@@ -31,6 +31,9 @@ Optional properties:
 			  defined or a value in the array is "0" then it is assumed
 			  that the frequency is set by the parent clock or a
 			  fixed rate clock source.
+- lanes-per-direction:	number of lanes available per direction - either 1 or 2.
+			Note that it is assume same number of lanes is used both directions at once.
+			If not specified, default is 2 lanes per direction.
 
 Note: If above properties are not defined it can be assumed that the supply
 regulators or clocks are always on.
drivers/scsi/ufs/ufs-qcom.c +37 -25

101 lines not on this page · raw message

drivers/scsi/ufs/ufshcd.c +20 -0
index b0ade73..b9e1ecd 100644
@@ -39,6 +39,7 @@
 
 #include <linux/async.h>
 #include <linux/devfreq.h>
+#include <linux/of.h>
 
 #include "ufshcd.h"
 #include "unipro.h"
@@ -74,6 +75,8 @@
 /* Interrupt aggregation default timeout, unit: 40us */
 #define INT_AGGR_DEF_TO	0x02
 
+#define UFSHCD_DEFAULT_LANES_PER_DIRECTION		2
+
 #define ufshcd_toggle_vreg(_dev, _vreg, _on)				\
 	({                                                              \
 		int _ret;                                               \
@@ -5530,6 +5533,21 @@ static struct devfreq_dev_profile ufs_devfreq_profile = {
 	.get_dev_status	= ufshcd_devfreq_get_dev_status,
 };
 
+static void ufshcd_init_lanes_per_dir(struct ufs_hba *hba)
+{
+	struct device *dev = hba->dev;
+	int ret;
+
+	ret = of_property_read_u32(dev->of_node, "lanes-per-direction",
+		&hba->lanes_per_direction);
+	if (ret) {
+		dev_dbg(hba->dev,
+			"%s: failed to read lanes-per-direction, ret=%d\n",
+			__func__, ret);
+		hba->lanes_per_direction = UFSHCD_DEFAULT_LANES_PER_DIRECTION;
+	}
+}
+
 /**
  * ufshcd_init - Driver initialization routine
  * @hba: per-adapter instance
@@ -5553,6 +5571,8 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
 	hba->mmio_base = mmio_base;
 	hba->irq = irq;
 
+	ufshcd_init_lanes_per_dir(hba);
+
 	err = ufshcd_hba_init(hba);
 	if (err)
 		goto out_error;
drivers/scsi/ufs/ufshcd.h +3 -0
index c40a0e7..3d9bdc7 100644
@@ -500,6 +500,9 @@ struct ufs_hba {
 
 	bool wlun_dev_clr_ua;
 
+	/* Number of lanes available (1 or 2) for Rx/Tx */
+	u32 lanes_per_direction;
+
 	struct ufs_pa_layer_attr pwr_info;
 	struct ufs_pwr_mode_info max_pwr_info;
 
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
maintainer
#1 lore raw
Quoted 16 lines · Can Guo

From: Gilad Broner <[email protected]>

Different platforms may have different number of lanes for the UFS link. Add parameter to device tree specifying how many lanes should be configured for the UFS link. And don't print err message for clocks that are optional, this leads to unnecessary confusion about failure.

Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +0 -0
index 5357919..4cee3f9 100644

Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt Optional properties: · line 35

Quoted 5 lines
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +2 -0
@@ -31,6 +31,9 @@ Optional properties:
 			  defined or a value in the array is "0" then it is assumed
 			  that the frequency is set by the parent clock or a
 			  fixed rate clock source.
+- lanes-per-direction:	number of lanes available per direction - either 1 or 2.
+			Note that it is assume same number of lanes is used both directions at once.

Seems reasonable until someone does not make things symmetrical. We should design for that case.

Quoted 4 lines
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +1 -0
+			If not specified, default is 2 lanes per direction.
 
 Note: If above properties are not defined it can be assumed that the supply
 regulators or clocks are always on.
#2 lore raw
Quoted 12 lines · Rob Herring
Quoted 11 lines · Can Guo

From: Gilad Broner <[email protected]>

Different platforms may have different number of lanes for the UFS link. Add parameter to device tree specifying how many lanes should be configured for the UFS link. And don't print err message for clocks that are optional, this leads to unnecessary confusion about failure.

Quoted 16 lines
Quoted 11 lines
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +1 -0
index 5357919..4cee3f9 100644
@@ -31,6 +31,9 @@ Optional properties:
 			  defined or a value in the array is "0" then it is assumed
 			  that the frequency is set by the parent clock or a
 			  fixed rate clock source.
+- lanes-per-direction:	number of lanes available per direction - 

either 1 or 2.

Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +1 -0
+			Note that it is assume same number of lanes is used both 
Quoted 1 line

directions at once.

Seems reasonable until someone does not make things symmetrical. We should design for that case.

You are right, I will make changes like using lanes-tx and lanes-rx for Tx/Rx links for asymmetrial senarios and upload V2 patch

Quoted 5 lines
Quoted 5 lines
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +1 -0
+			If not specified, default is 2 lanes per direction.
 
 Note: If above properties are not defined it can be assumed that the 

supply
regulators or clocks are always on.