Skip to contentSkip to conversation

Supports Reading UFS's Vcc Voltage Levels from DT

PATCH In review Bao D. Nguyen 4 participants 21 messages Sep 1, 2020 – Sep 23, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Supports Reading UFS's Vcc Voltage Levels from DT

UFS's specification supports a range of Vcc operating voltages. Allows selecting the UFS Vcc operating voltage levels by reading the UFS's vcc-voltage-level in the device tree.

Bao D. Nguyen (2):
scsi: dt-bindings: ufs: Add vcc-voltage-level for UFS
scsi: ufs: Support reading UFS's Vcc voltage from device tree

 Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt |  2 ++
 drivers/scsi/ufs/ufshcd-pltfrm.c                        | 15 ++++++++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#1 lore raw

PATCH 1/2 scsi: dt-bindings: ufs: Add vcc-voltage-level for UFS

UFS's specifications supports a range of Vcc operating voltage levels. Add documentation for the UFS's Vcc voltage levels setting.

---
 Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +2 -0
index 415ccdd..7257b32 100644
@@ -23,6 +23,8 @@ Optional properties:
                           with "phys" attribute, provides phandle to UFS PHY node
 - vdd-hba-supply        : phandle to UFS host controller supply regulator node
 - vcc-supply            : phandle to VCC supply regulator node
+- vcc-voltage-level     : specifies voltage levels for VCC supply.
+                          Should be specified in pairs (min, max), units uV.
 - vccq-supply           : phandle to VCCQ supply regulator node
 - vccq2-supply          : phandle to VCCQ2 supply regulator node
 - vcc-supply-1p8        : For embedded UFS devices, valid VCC range is 1.7-1.95V
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
reviewer
#2 lore raw

RE: [PATCH v1 1/2] scsi: dt-bindings: ufs: Add vcc-voltage-level for UFS

Quoted 21 lines

UFS's specifications supports a range of Vcc operating voltage levels. Add documentation for the UFS's Vcc voltage levels setting.

---
 Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +0 -0
index 415ccdd..7257b32 100644

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

Quoted 4 lines
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +1 -0
@@ -23,6 +23,8 @@ Optional properties:
                           with "phys" attribute, provides phandle to UFS PHY node
 - vdd-hba-supply        : phandle to UFS host controller supply regulator node
 - vcc-supply            : phandle to VCC supply regulator node
+- vcc-voltage-level     : specifies voltage levels for VCC supply.

For ufs3.1+ devices

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

Quoted 5 lines
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +1 -1
+                          Should be specified in pairs (min, max), units uV.
 - vccq-supply           : phandle to VCCQ supply regulator node
 - vccq2-supply          : phandle to VCCQ2 supply regulator node
 - vcc-supply-1p8        : For embedded UFS devices, valid VCC range is 1.7-1.95V
--

Why are you removing all other docs?
They are still relevant for non ufs3.1 devices.

#3 lore raw

Re: [PATCH v1 1/2] scsi: dt-bindings: ufs: Add vcc-voltage-level for UFS

Quoted 13 lines · Avri Altman
Quoted 13 lines

UFS's specifications supports a range of Vcc operating voltage levels. Add documentation for the UFS's Vcc voltage levels setting.

---
 Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 ++
 1 file changed, 2 insertions(+)
Quoted 13 lines
Quoted 7 lines
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +0 -0
index 415ccdd..7257b32 100644
@@ -23,6 +23,8 @@ Optional properties:
                           with "phys" attribute, provides phandle to 
Quoted 5 lines

UFS PHY node
- vdd-hba-supply : phandle to UFS host controller supply
regulator node
- vcc-supply : phandle to VCC supply regulator node
+- vcc-voltage-level : specifies voltage levels for VCC supply.

For ufs3.1+ devices

Thanks for the comments, Avri.
I am not clear what this comment means. Could you please clarify?

Quoted 10 lines
Quoted 8 lines

+ Should be specified in pairs (min, max),
units uV.

 - vccq-supply           : phandle to VCCQ supply regulator node
 - vccq2-supply          : phandle to VCCQ2 supply regulator node
 - vcc-supply-1p8        : For embedded UFS devices, valid VCC range 

is 1.7-1.95V
--

Why are you removing all other docs?
They are still relevant for non ufs3.1 devices.

I did not remove anything. You may be confused by the "-" used as listing in the original document.

maintainer
#4 lore raw

Re: [PATCH v1 1/2] scsi: dt-bindings: ufs: Add vcc-voltage-level for UFS

In reply to Bao D. Nguyen
Quoted 16 lines · Bao D. Nguyen

UFS's specifications supports a range of Vcc operating voltage levels. Add documentation for the UFS's Vcc voltage levels setting.

---
 Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +0 -0
index 415ccdd..7257b32 100644

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

Quoted 5 lines
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +2 -0
@@ -23,6 +23,8 @@ Optional properties:
                           with "phys" attribute, provides phandle to UFS PHY node
 - vdd-hba-supply        : phandle to UFS host controller supply regulator node
 - vcc-supply            : phandle to VCC supply regulator node
+- vcc-voltage-level     : specifies voltage levels for VCC supply.
+                          Should be specified in pairs (min, max), units uV.

The expectation is the regulator pointed to by 'vcc-supply' has the voltage constraints. Those constraints are supposed to be the board constraints, not the regulator operating design constraints. If that doesn't work for your case, then it should be addressed in a common way for the regulator binding.

Also, properties with units must have a unit suffix.

Rob

#5 lore raw

Re: [PATCH v1 1/2] scsi: dt-bindings: ufs: Add vcc-voltage-level for UFS

Quoted 23 lines · Rob Herring
Quoted 22 lines · Bao D. Nguyen

UFS's specifications supports a range of Vcc operating voltage levels. Add documentation for the UFS's Vcc voltage levels setting.

---
 Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +0 -0
index 415ccdd..7257b32 100644
@@ -23,6 +23,8 @@ Optional properties:
                           with "phys" attribute, provides phandle to 

UFS PHY node
- vdd-hba-supply : phandle to UFS host controller supply
regulator node
- vcc-supply : phandle to VCC supply regulator node
+- vcc-voltage-level : specifies voltage levels for VCC supply.

Quoted 8 lines
Quoted 2 lines

+ Should be specified in pairs (min, max),
units uV.

The expectation is the regulator pointed to by 'vcc-supply' has the voltage constraints. Those constraints are supposed to be the board constraints, not the regulator operating design constraints. If that doesn't work for your case, then it should be addressed in a common way for the regulator binding.

The UFS regulator has a min_uV and max_uV limits. Currently, the min and max are hardcoded to UFS2.1 Spec allowed values of 2.7V and 3.6V respectively.
With this change, I am trying to fix a couple issues:
1. The 2.7V min value only applies to UFS2.1 devices. with UFS3.0+ devices, the VCC min should be 2.4V. Hardcoding the min_uV to 2.7V does not work for UFS3.0+ devices.

2. Allow users to select a different Vcc voltage within the allowed range. Using the min value, the UFS device is operating at marginal Vcc voltage. In addition the PMIC and the board designs may add some variables especially at extreme temperatures. We observe stability issues when using the min Vcc voltage.

Quoted 2 lines

Also, properties with units must have a unit suffix.

Yes, I agree.

Quoted 2 lines

Rob

maintainer
#6 lore raw

Re: [PATCH v1 1/2] scsi: dt-bindings: ufs: Add vcc-voltage-level for UFS

Quoted 34 lines · On Tue, Sep 15, 2020 at 2:10 AM <[email protected]> wrote:
Quoted 24 lines · Rob Herring
Quoted 23 lines · Bao D. Nguyen

UFS's specifications supports a range of Vcc operating voltage levels. Add documentation for the UFS's Vcc voltage levels setting.

---
 Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +0 -0
index 415ccdd..7257b32 100644
@@ -23,6 +23,8 @@ Optional properties:
                           with "phys" attribute, provides phandle to

UFS PHY node
- vdd-hba-supply : phandle to UFS host controller supply
regulator node
- vcc-supply : phandle to VCC supply regulator node
+- vcc-voltage-level : specifies voltage levels for VCC supply.

Quoted 8 lines
Quoted 2 lines

+ Should be specified in pairs (min, max),
units uV.

The expectation is the regulator pointed to by 'vcc-supply' has the voltage constraints. Those constraints are supposed to be the board constraints, not the regulator operating design constraints. If that doesn't work for your case, then it should be addressed in a common way for the regulator binding.

Quoted 7 lines

The UFS regulator has a min_uV and max_uV limits. Currently, the min and max are hardcoded
to UFS2.1 Spec allowed values of 2.7V and 3.6V respectively. With this change, I am trying to fix a couple issues:
1. The 2.7V min value only applies to UFS2.1 devices. with UFS3.0+ devices, the VCC min should be 2.4V.
Hardcoding the min_uV to 2.7V does not work for UFS3.0+ devices.

Don't you know the device version attached and can adjust the voltage based on that? Or you have to set the voltage first?

Quoted 8 lines

2. Allow users to select a different Vcc voltage within the allowed range.
Using the min value, the UFS device is operating at marginal Vcc voltage.
In addition the PMIC and the board designs may add some variables especially at extreme
temperatures. We observe stability issues when using the min Vcc voltage.

Again, we have standard regulator properties for this already that you can tune per board.

Rob

#7 lore raw

Re: [PATCH v1 1/2] scsi: dt-bindings: ufs: Add vcc-voltage-level for UFS

Quoted 43 lines · Rob Herring
Quoted 34 lines · On Tue, Sep 15, 2020 at 2:10 AM <[email protected]> wrote:
Quoted 24 lines · Rob Herring
Quoted 23 lines · Bao D. Nguyen

UFS's specifications supports a range of Vcc operating voltage levels. Add documentation for the UFS's Vcc voltage levels setting.

---
 Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +0 -0
index 415ccdd..7257b32 100644
@@ -23,6 +23,8 @@ Optional properties:
                           with "phys" attribute, provides phandle to

UFS PHY node
- vdd-hba-supply : phandle to UFS host controller supply
regulator node
- vcc-supply : phandle to VCC supply regulator node
+- vcc-voltage-level : specifies voltage levels for VCC supply.

Quoted 8 lines
Quoted 2 lines

+ Should be specified in pairs (min, max),
units uV.

The expectation is the regulator pointed to by 'vcc-supply' has the voltage constraints. Those constraints are supposed to be the board constraints, not the regulator operating design constraints. If that doesn't work for your case, then it should be addressed in a common way for the regulator binding.

Quoted 7 lines

The UFS regulator has a min_uV and max_uV limits. Currently, the min and max are hardcoded
to UFS2.1 Spec allowed values of 2.7V and 3.6V respectively. With this change, I am trying to fix a couple issues:
1. The 2.7V min value only applies to UFS2.1 devices. with UFS3.0+ devices, the VCC min should be 2.4V.
Hardcoding the min_uV to 2.7V does not work for UFS3.0+ devices.

Quoted 2 lines

Don't you know the device version attached and can adjust the voltage based on that? Or you have to set the voltage first?

Yes it is one of the solutions. Once detect the UFS device is version 3.0+, you can lower the voltage to 2.5V from the hardcoded value used by the driver. However, to change the Vcc voltage, the host needs to follow a sequence to ensure safe operations after Vcc change (device has to be in sleep mode, Vcc needs to go down to 0 then up to 2.5V.) Also same sequence is repeated for every host initialization which is inconvenient.

Quoted 10 lines
Quoted 9 lines

2. Allow users to select a different Vcc voltage within the allowed range.
Using the min value, the UFS device is operating at marginal Vcc voltage.
In addition the PMIC and the board designs may add some variables especially at extreme
temperatures. We observe stability issues when using the min Vcc voltage.

Quoted 2 lines

Again, we have standard regulator properties for this already that you can tune per board.

Thank you for the suggestion.

Quoted 2 lines

Rob

#8 lore raw

Re: [PATCH v1 1/2] scsi: dt-bindings: ufs: Add vcc-voltage-level for UFS

Quoted 47 lines · On Mon 21 Sep 19:22 CDT 2020, [email protected] wrote:
Quoted 44 lines · Rob Herring
Quoted 34 lines · On Tue, Sep 15, 2020 at 2:10 AM <[email protected]> wrote:
Quoted 24 lines · Rob Herring
Quoted 23 lines · Bao D. Nguyen

UFS's specifications supports a range of Vcc operating voltage levels. Add documentation for the UFS's Vcc voltage levels setting.

---
 Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +0 -0
index 415ccdd..7257b32 100644
@@ -23,6 +23,8 @@ Optional properties:
                           with "phys" attribute, provides phandle to

UFS PHY node
- vdd-hba-supply : phandle to UFS host controller supply
regulator node
- vcc-supply : phandle to VCC supply regulator node
+- vcc-voltage-level : specifies voltage levels for VCC supply.

Quoted 8 lines
Quoted 2 lines

+ Should be specified in pairs (min, max),
units uV.

The expectation is the regulator pointed to by 'vcc-supply' has the voltage constraints. Those constraints are supposed to be the board constraints, not the regulator operating design constraints. If that doesn't work for your case, then it should be addressed in a common way for the regulator binding.

Quoted 8 lines

The UFS regulator has a min_uV and max_uV limits. Currently, the min and
max are hardcoded
to UFS2.1 Spec allowed values of 2.7V and 3.6V respectively. With this change, I am trying to fix a couple issues:
1. The 2.7V min value only applies to UFS2.1 devices. with UFS3.0+ devices, the VCC min should be 2.4V.
Hardcoding the min_uV to 2.7V does not work for UFS3.0+ devices.

Quoted 2 lines

Don't you know the device version attached and can adjust the voltage based on that? Or you have to set the voltage first?

Quoted 10 lines

Yes it is one of the solutions. Once detect the UFS device is version 3.0+, you can lower
the voltage to 2.5V from the hardcoded value used by the driver. However, to change the
Vcc voltage, the host needs to follow a sequence to ensure safe operations after Vcc change
(device has to be in sleep mode, Vcc needs to go down to 0 then up to 2.5V.) Also same sequence is repeated for every host initialization which is inconvenient.

It sounds like you're suggesting that we detect the UFS device using some voltage, then depending on version we might lower it to 2.5V.

I'm afraid I don't see any of this either documented or implemented in these patches.

What is this initial detection voltage and how to you configure it?

Regards,
Bjorn

Quoted 16 lines
Quoted 10 lines
Quoted 9 lines

2. Allow users to select a different Vcc voltage within the allowed range.
Using the min value, the UFS device is operating at marginal Vcc voltage.
In addition the PMIC and the board designs may add some variables especially at extreme
temperatures. We observe stability issues when using the min Vcc voltage.

Quoted 2 lines

Again, we have standard regulator properties for this already that you can tune per board.

Thank you for the suggestion.

Quoted 2 lines

Rob

#9 lore raw

Re: [PATCH v1 1/2] scsi: dt-bindings: ufs: Add vcc-voltage-level for UFS

Quoted 60 lines · Bjorn Andersson
Quoted 47 lines · On Mon 21 Sep 19:22 CDT 2020, [email protected] wrote:
Quoted 44 lines · Rob Herring
Quoted 34 lines · On Tue, Sep 15, 2020 at 2:10 AM <[email protected]> wrote:
Quoted 24 lines · Rob Herring
Quoted 23 lines · Bao D. Nguyen

UFS's specifications supports a range of Vcc operating voltage levels. Add documentation for the UFS's Vcc voltage levels setting.

---
 Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +0 -0
index 415ccdd..7257b32 100644
@@ -23,6 +23,8 @@ Optional properties:
                           with "phys" attribute, provides phandle to

UFS PHY node
- vdd-hba-supply : phandle to UFS host controller supply
regulator node
- vcc-supply : phandle to VCC supply regulator node
+- vcc-voltage-level : specifies voltage levels for VCC supply.

Quoted 8 lines
Quoted 2 lines

+ Should be specified in pairs (min, max),
units uV.

The expectation is the regulator pointed to by 'vcc-supply' has the voltage constraints. Those constraints are supposed to be the board constraints, not the regulator operating design constraints. If that doesn't work for your case, then it should be addressed in a common way for the regulator binding.

Quoted 8 lines

The UFS regulator has a min_uV and max_uV limits. Currently, the min and
max are hardcoded
to UFS2.1 Spec allowed values of 2.7V and 3.6V respectively. With this change, I am trying to fix a couple issues:
1. The 2.7V min value only applies to UFS2.1 devices. with UFS3.0+ devices, the VCC min should be 2.4V.
Hardcoding the min_uV to 2.7V does not work for UFS3.0+ devices.

Quoted 2 lines

Don't you know the device version attached and can adjust the voltage based on that? Or you have to set the voltage first?

Quoted 10 lines

Yes it is one of the solutions. Once detect the UFS device is version 3.0+, you can lower
the voltage to 2.5V from the hardcoded value used by the driver. However, to change the
Vcc voltage, the host needs to follow a sequence to ensure safe operations after Vcc change
(device has to be in sleep mode, Vcc needs to go down to 0 then up to 2.5V.) Also same sequence is repeated for every host initialization which is inconvenient.

Quoted 2 lines

It sounds like you're suggesting that we detect the UFS device using some voltage, then depending on version we might lower it to 2.5V.

Yes, that is one possible solution.

Quoted 2 lines

I'm afraid I don't see any of this either documented or implemented in these patches.

I was responding to a comment about detecting the device version and change the voltage based on the detection. It is not implemented in this patch. Maybe I should stop discussing another possible solution, even though related to the topic, it is not implemented in this patch.

Quoted 2 lines

What is this initial detection voltage and how to you configure it?

The initial voltage would be 2.9V and is lowered to 2.5V if UFS3.0+ device is detected. We would call the regulator_set_voltage() to set to a specific voltage level.

Regards,
Bao

Quoted 20 lines

Regards,
Bjorn

Quoted 16 lines
Quoted 10 lines
Quoted 9 lines

2. Allow users to select a different Vcc voltage within the allowed range.
Using the min value, the UFS device is operating at marginal Vcc voltage.
In addition the PMIC and the board designs may add some variables especially at extreme
temperatures. We observe stability issues when using the min Vcc voltage.

Quoted 2 lines

Again, we have standard regulator properties for this already that you can tune per board.

Thank you for the suggestion.

Quoted 2 lines

Rob

#10 lore raw

Re: [PATCH v1 1/2] scsi: dt-bindings: ufs: Add vcc-voltage-level for UFS

In reply to Bao D. Nguyen
Quoted 16 lines · Bao D. Nguyen

UFS's specifications supports a range of Vcc operating voltage levels. Add documentation for the UFS's Vcc voltage levels setting.

---
 Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +0 -0
index 415ccdd..7257b32 100644

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

Quoted 5 lines
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +2 -0
@@ -23,6 +23,8 @@ Optional properties:
                           with "phys" attribute, provides phandle to UFS PHY node
 - vdd-hba-supply        : phandle to UFS host controller supply regulator node
 - vcc-supply            : phandle to VCC supply regulator node
+- vcc-voltage-level     : specifies voltage levels for VCC supply.
+                          Should be specified in pairs (min, max), units uV.

What exactly are these pairs representing?

Is this supposed to be 3 pairs of (min,max) for vcc, vcc and vccq2 to be passed into a regulator_set_voltage() for each regulator?

Or are these some sort of "operating points" for the vcc-supply?

Regards,
Bjorn

Quoted 7 lines
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +0 -0
 - vccq-supply           : phandle to VCCQ supply regulator node
 - vccq2-supply          : phandle to VCCQ2 supply regulator node
 - vcc-supply-1p8        : For embedded UFS devices, valid VCC range is 1.7-1.95V
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#11 lore raw

Re: [PATCH v1 1/2] scsi: dt-bindings: ufs: Add vcc-voltage-level for UFS

Quoted 13 lines · Bjorn Andersson
Quoted 11 lines · Bao D. Nguyen

UFS's specifications supports a range of Vcc operating voltage levels. Add documentation for the UFS's Vcc voltage levels setting.

---
 Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 ++
 1 file changed, 2 insertions(+)
Quoted 15 lines
Quoted 10 lines
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +0 -0
index 415ccdd..7257b32 100644
@@ -23,6 +23,8 @@ Optional properties:
                           with "phys" attribute, provides phandle to 

UFS PHY node
- vdd-hba-supply : phandle to UFS host controller supply
regulator node
- vcc-supply : phandle to VCC supply regulator node

Quoted 3 lines
+- vcc-voltage-level     : specifies voltage levels for VCC supply.
+                          Should be specified in pairs (min, max), 

units uV.

What exactly are these pairs representing?

The pair is the min and max Vcc voltage request to the PMIC chip. As a result, the regulator output voltage would only be in this range.

Quoted 3 lines

Is this supposed to be 3 pairs of (min,max) for vcc, vcc and vccq2 to be passed into a regulator_set_voltage() for each regulator?

Yes, that's right. I should include the other power supplies in this change as well.

Quoted 14 lines

Or are these some sort of "operating points" for the vcc-supply?

Regards,
Bjorn

Quoted 8 lines
 - vccq-supply           : phandle to VCCQ supply regulator node
 - vccq2-supply          : phandle to VCCQ2 supply regulator node
 - vcc-supply-1p8        : For embedded UFS devices, valid VCC range 

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

#12 lore raw

Re: [PATCH v1 1/2] scsi: dt-bindings: ufs: Add vcc-voltage-level for UFS

Quoted 30 lines · On Tue 15 Sep 03:14 CDT 2020, [email protected] wrote:
Quoted 13 lines · Bjorn Andersson
Quoted 11 lines · Bao D. Nguyen

UFS's specifications supports a range of Vcc operating voltage levels. Add documentation for the UFS's Vcc voltage levels setting.

---
 Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 ++
 1 file changed, 2 insertions(+)
Quoted 16 lines
Quoted 11 lines
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +0 -0
index 415ccdd..7257b32 100644
@@ -23,6 +23,8 @@ Optional properties:
                           with "phys" attribute, provides phandle

to UFS PHY node
- vdd-hba-supply : phandle to UFS host controller supply
regulator node
- vcc-supply : phandle to VCC supply regulator node

Quoted 3 lines
+- vcc-voltage-level     : specifies voltage levels for VCC supply.
+                          Should be specified in pairs (min, max),

units uV.

What exactly are these pairs representing?

Quoted 3 lines

The pair is the min and max Vcc voltage request to the PMIC chip. As a result, the regulator output voltage would only be in this range.

If you have static min/max voltage constraints for a device on a particular board the right way to handle this is to adjust the board's regulator-min-microvolt and regulator-max-microvolt accordingly - and not call regulator_set_voltage() from the river at all.

In other words, you shouldn't add this new property to describe something already described in the node vcc-supply points to.

Regards,
Bjorn

Quoted 20 lines
Quoted 3 lines

Is this supposed to be 3 pairs of (min,max) for vcc, vcc and vccq2 to be passed into a regulator_set_voltage() for each regulator?

Yes, that's right. I should include the other power supplies in this change as well.

Quoted 15 lines

Or are these some sort of "operating points" for the vcc-supply?

Regards,
Bjorn

Quoted 9 lines
 - vccq-supply           : phandle to VCCQ supply regulator node
 - vccq2-supply          : phandle to VCCQ2 supply regulator node
 - vcc-supply-1p8        : For embedded UFS devices, valid VCC range

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

#13 lore raw

Re: [PATCH v1 1/2] scsi: dt-bindings: ufs: Add vcc-voltage-level for UFS

Quoted 41 lines · Bjorn Andersson
Quoted 30 lines · On Tue 15 Sep 03:14 CDT 2020, [email protected] wrote:
Quoted 13 lines · Bjorn Andersson
Quoted 11 lines · Bao D. Nguyen

UFS's specifications supports a range of Vcc operating voltage levels. Add documentation for the UFS's Vcc voltage levels setting.

---
 Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 ++
 1 file changed, 2 insertions(+)
Quoted 16 lines
Quoted 11 lines
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +0 -0
index 415ccdd..7257b32 100644
@@ -23,6 +23,8 @@ Optional properties:
                           with "phys" attribute, provides phandle

to UFS PHY node
- vdd-hba-supply : phandle to UFS host controller supply
regulator node
- vcc-supply : phandle to VCC supply regulator node

Quoted 3 lines
+- vcc-voltage-level     : specifies voltage levels for VCC supply.
+                          Should be specified in pairs (min, max),

units uV.

What exactly are these pairs representing?

Quoted 3 lines

The pair is the min and max Vcc voltage request to the PMIC chip. As a result, the regulator output voltage would only be in this range.

If you have static min/max voltage constraints for a device on a particular board the right way to handle this is to adjust the board's regulator-min-microvolt and regulator-max-microvolt accordingly - and not call regulator_set_voltage() from the river at all.

Quoted 5 lines

In other words, you shouldn't add this new property to describe something already described in the node vcc-supply points to.

Regards,
Bjorn

Thank you all for your comments. The current driver hardcoding 2.7V Vcc min voltage does not work for UFS3.0+ devices according to the UFS device JEDEC spec. However, we will try to address it in a different way.

Regards,
Bao

Quoted 21 lines
Quoted 21 lines
Quoted 4 lines

Is this supposed to be 3 pairs of (min,max) for vcc, vcc and vccq2 to be passed into a regulator_set_voltage() for each regulator?

Yes, that's right. I should include the other power supplies in this change as well.

Quoted 15 lines

Or are these some sort of "operating points" for the vcc-supply?

Regards,
Bjorn

Quoted 9 lines
 - vccq-supply           : phandle to VCCQ supply regulator node
 - vccq2-supply          : phandle to VCCQ2 supply regulator node
 - vcc-supply-1p8        : For embedded UFS devices, valid VCC range

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

#14 lore raw

Re: [PATCH v1 1/2] scsi: dt-bindings: ufs: Add vcc-voltage-level for UFS

Quoted 45 lines · On Tue 15 Sep 16:47 UTC 2020, [email protected] wrote:
Quoted 44 lines · Bjorn Andersson
Quoted 30 lines · On Tue 15 Sep 03:14 CDT 2020, [email protected] wrote:
Quoted 13 lines · Bjorn Andersson
Quoted 11 lines · Bao D. Nguyen

UFS's specifications supports a range of Vcc operating voltage levels. Add documentation for the UFS's Vcc voltage levels setting.

---
 Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 ++
 1 file changed, 2 insertions(+)
Quoted 16 lines
Quoted 11 lines
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +0 -0
index 415ccdd..7257b32 100644
@@ -23,6 +23,8 @@ Optional properties:
                           with "phys" attribute, provides phandle

to UFS PHY node
- vdd-hba-supply : phandle to UFS host controller supply
regulator node
- vcc-supply : phandle to VCC supply regulator node

Quoted 3 lines
+- vcc-voltage-level     : specifies voltage levels for VCC supply.
+                          Should be specified in pairs (min, max),

units uV.

What exactly are these pairs representing?

Quoted 3 lines

The pair is the min and max Vcc voltage request to the PMIC chip. As a result, the regulator output voltage would only be in this range.

If you have static min/max voltage constraints for a device on a particular board the right way to handle this is to adjust the board's regulator-min-microvolt and regulator-max-microvolt accordingly - and not call regulator_set_voltage() from the river at all.

In other words, you shouldn't add this new property to describe something already described in the node vcc-supply points to.

Quoted 8 lines
Quoted 2 lines

Regards,
Bjorn

Thank you all for your comments. The current driver hardcoding 2.7V Vcc min voltage
does not work for UFS3.0+ devices according to the UFS device JEDEC spec. However, we will
try to address it in a different way.

Right, but what I'm saying is that you should remove the regulator_set_voltage() call from the driver and rely on the device's dts, in which case you won't have this problem.

Thanks,
Bjorn

Quoted 25 lines

Regards,
Bao

Quoted 22 lines
Quoted 22 lines
Quoted 4 lines

Is this supposed to be 3 pairs of (min,max) for vcc, vcc and vccq2 to be passed into a regulator_set_voltage() for each regulator?

Yes, that's right. I should include the other power supplies in this change
as well.

Quoted 15 lines

Or are these some sort of "operating points" for the vcc-supply?

Regards,
Bjorn

Quoted 9 lines
 - vccq-supply           : phandle to VCCQ supply regulator node
 - vccq2-supply          : phandle to VCCQ2 supply regulator node
 - vcc-supply-1p8        : For embedded UFS devices, valid VCC range

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

#15 lore raw

PATCH 2/2 scsi: ufs: Support reading UFS's Vcc voltage from device tree

In reply to Bao D. Nguyen

The UFS specifications supports a range of Vcc operating voltage from 2.4-3.6V depending on the device and manufacturers. Allows selecting the UFS Vcc voltage level by setting the UFS's entry vcc-voltage-level in the device tree. If UFS's vcc-voltage-level setting is not found in the device tree, use default values provided by the driver.

---
 drivers/scsi/ufs/ufshcd-pltfrm.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/scsi/ufs/ufshcd-pltfrm.c +12 -3
index 3db0af6..48f429c 100644
@@ -104,10 +104,11 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba)
 static int ufshcd_populate_vreg(struct device *dev, const char *name,
 		struct ufs_vreg **out_vreg)
 {
-	int ret = 0;
+	int len, ret = 0;
 	char prop_name[MAX_PROP_SIZE];
 	struct ufs_vreg *vreg = NULL;
 	struct device_node *np = dev->of_node;
+	const __be32 *prop;
 
 	if (!np) {
 		dev_err(dev, "%s: non DT initialization\n", __func__);
@@ -138,8 +139,16 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name,
 			vreg->min_uV = UFS_VREG_VCC_1P8_MIN_UV;
 			vreg->max_uV = UFS_VREG_VCC_1P8_MAX_UV;
 		} else {
-			vreg->min_uV = UFS_VREG_VCC_MIN_UV;
-			vreg->max_uV = UFS_VREG_VCC_MAX_UV;
+			prop = of_get_property(np, "vcc-voltage-level", &len);
+			if (!prop || (len != (2 * sizeof(__be32)))) {
+				dev_warn(dev, "%s vcc-voltage-level property.\n",
+					prop ? "invalid format" : "no");
+				vreg->min_uV = UFS_VREG_VCC_MIN_UV;
+				vreg->max_uV = UFS_VREG_VCC_MAX_UV;
+			} else {
+				vreg->min_uV = be32_to_cpup(&prop[0]);
+				vreg->max_uV = be32_to_cpup(&prop[1]);
+			}
 		}
 	} else if (!strcmp(name, "vccq")) {
 		vreg->min_uV = UFS_VREG_VCCQ_MIN_UV;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
reviewer
#16 lore raw

RE: [PATCH v1 2/2] scsi: ufs: Support reading UFS's Vcc voltage from device tree

Quoted 54 lines

The UFS specifications supports a range of Vcc operating voltage from 2.4-3.6V depending on the device and manufacturers. Allows selecting the UFS Vcc voltage level by setting the UFS's entry vcc-voltage-level in the device tree. If UFS's vcc-voltage-level setting is not found in the device tree, use default values provided by the driver.

---
 drivers/scsi/ufs/ufshcd-pltfrm.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/scsi/ufs/ufshcd-pltfrm.c +2 -1
index 3db0af6..48f429c 100644
@@ -104,10 +104,11 @@ static int ufshcd_parse_clock_info(struct ufs_hba
 *hba)
 static int ufshcd_populate_vreg(struct device *dev, const char *name,
                struct ufs_vreg **out_vreg)
 {
-       int ret = 0;
+       int len, ret = 0;
        char prop_name[MAX_PROP_SIZE];
        struct ufs_vreg *vreg = NULL;
        struct device_node *np = dev->of_node;
+       const __be32 *prop;
 
        if (!np) {
                dev_err(dev, "%s: non DT initialization\n", __func__);
drivers/scsi/ufs/ufshcd-pltfrm.c +10 -2
@@ -138,8 +139,16 @@ static int ufshcd_populate_vreg(struct device *dev,
 const char *name,
                        vreg->min_uV = UFS_VREG_VCC_1P8_MIN_UV;
                        vreg->max_uV = UFS_VREG_VCC_1P8_MAX_UV;
                } else {
-                       vreg->min_uV = UFS_VREG_VCC_MIN_UV;
-                       vreg->max_uV = UFS_VREG_VCC_MAX_UV;
+                       prop = of_get_property(np, "vcc-voltage-level", &len);
+                       if (!prop || (len != (2 * sizeof(__be32)))) {
+                               dev_warn(dev, "%s vcc-voltage-level property.\n",
+                                       prop ? "invalid format" : "no");
+                               vreg->min_uV = UFS_VREG_VCC_MIN_UV;
+                               vreg->max_uV = UFS_VREG_VCC_MAX_UV;
+                       } else {
+                               vreg->min_uV = be32_to_cpup(&prop[0]);
+                               vreg->max_uV = be32_to_cpup(&prop[1]);
+                       }
                }
        } else if (!strcmp(name, "vccq")) {
                vreg->min_uV = UFS_VREG_VCCQ_MIN_UV;
Quoted 1 line

--

Maybe instead call ufshcd_populate_vreg with the new name, To not break the function flow, and just add another else if ?

#17 lore raw

Re: [PATCH v1 2/2] scsi: ufs: Support reading UFS's Vcc voltage from device tree

Quoted 53 lines · Avri Altman
Quoted 53 lines

The UFS specifications supports a range of Vcc operating voltage from 2.4-3.6V depending on the device and manufacturers. Allows selecting the UFS Vcc voltage level by setting the UFS's entry vcc-voltage-level in the device tree. If UFS's vcc-voltage-level setting is not found in the device tree, use default values provided by the driver.

---
 drivers/scsi/ufs/ufshcd-pltfrm.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/scsi/ufs/ufshcd-pltfrm.c +0 -0
index 3db0af6..48f429c 100644
@@ -104,10 +104,11 @@ static int ufshcd_parse_clock_info(struct 

ufs_hba
*hba)
static int ufshcd_populate_vreg(struct device *dev, const char *name,
struct ufs_vreg **out_vreg)
{

drivers/scsi/ufs/ufshcd-pltfrm.c +5 -3
-       int ret = 0;
+       int len, ret = 0;
        char prop_name[MAX_PROP_SIZE];
        struct ufs_vreg *vreg = NULL;
        struct device_node *np = dev->of_node;
+       const __be32 *prop;
 
        if (!np) {
                dev_err(dev, "%s: non DT initialization\n", __func__);
@@ -138,8 +139,16 @@ static int ufshcd_populate_vreg(struct device 
 *dev,
 const char *name,
                        vreg->min_uV = UFS_VREG_VCC_1P8_MIN_UV;
                        vreg->max_uV = UFS_VREG_VCC_1P8_MAX_UV;
                } else {
-                       vreg->min_uV = UFS_VREG_VCC_MIN_UV;
-                       vreg->max_uV = UFS_VREG_VCC_MAX_UV;
+                       prop = of_get_property(np, 
 "vcc-voltage-level", &len);
+                       if (!prop || (len != (2 * sizeof(__be32)))) {
+                               dev_warn(dev, "%s vcc-voltage-level 

property.\n",
+ prop ? "invalid format" :
"no");

drivers/scsi/ufs/ufshcd-pltfrm.c +4 -0
+                               vreg->min_uV = UFS_VREG_VCC_MIN_UV;
+                               vreg->max_uV = UFS_VREG_VCC_MAX_UV;
+                       } else {
+                               vreg->min_uV = be32_to_cpup(&prop[0]);
Quoted 8 lines

drivers/scsi/ufs/ufshcd-pltfrm.c static int ufshcd_populate_vreg(struct device *dev, const char *name,

Quoted 6 lines
drivers/scsi/ufs/ufshcd-pltfrm.c +2 -1
+                               vreg->max_uV = be32_to_cpup(&prop[1]);
+                       }
                }
        } else if (!strcmp(name, "vccq")) {
                vreg->min_uV = UFS_VREG_VCCQ_MIN_UV;
--

Maybe instead call ufshcd_populate_vreg with the new name, To not break the function flow, and just add another else if ?

Could you please clarify your comments? Are you suggesting to create a new function? Thank you.

reviewer
#18 lore raw

RE: [PATCH v1 2/2] scsi: ufs: Support reading UFS's Vcc voltage from device tree

Quoted 5 lines
Quoted 2 lines

Maybe instead call ufshcd_populate_vreg with the new name, To not break the function flow, and just add another else if ?

Could you please clarify your comments? Are you suggesting to create a new function?
Thank you.

No, just call ufshcd_populate_vreg with the new name, e.g. something like:

drivers/scsi/ufs/ufshcd-pltfrm.c +8 -2
index 3db0af6..9798d4c 100644
@@ -141,6 +141,8 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name,
                        vreg->min_uV = UFS_VREG_VCC_MIN_UV;
                        vreg->max_uV = UFS_VREG_VCC_MAX_UV;
                }
+       } else if (!strcmp(name, "vcc-voltage-level")) {
+               /* add your changes here */
        } else if (!strcmp(name, "vccq")) {
                vreg->min_uV = UFS_VREG_VCCQ_MIN_UV;
                vreg->max_uV = UFS_VREG_VCCQ_MAX_UV;
@@ -177,8 +179,12 @@ static int ufshcd_parse_regulator_info(struct ufs_hba *hba)
                goto out;
 
        err = ufshcd_populate_vreg(dev, "vcc", &info->vcc);
-       if (err)
-               goto out;
+       if (err) {
+               err = ufshcd_populate_vreg(dev, "vcc-voltage-level",
+                                          &info->vcc);
+               if (err)
+                       goto out;
+       }
 
        err = ufshcd_populate_vreg(dev, "vccq", &info->vccq);
        if (err)
#19 lore raw

Re: [PATCH v1 2/2] scsi: ufs: Support reading UFS's Vcc voltage from device tree

In reply to Bao D. Nguyen
Quoted 7 lines · Bao D. Nguyen

The UFS specifications supports a range of Vcc operating voltage from 2.4-3.6V depending on the device and manufacturers. Allows selecting the UFS Vcc voltage level by setting the UFS's entry vcc-voltage-level in the device tree. If UFS's vcc-voltage-level setting is not found in the device tree, use default values provided by the driver.

As stated in the reply to patch 1, this is not the right approach. As long as you have static min/max values requested by the driver you should rely on the board's constraints for the regulator levels and instead remove the min_uV/max_uV code from the driver.

Thanks,
Bjorn

Quoted 47 lines
---
 drivers/scsi/ufs/ufshcd-pltfrm.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/scsi/ufs/ufshcd-pltfrm.c +12 -3
index 3db0af6..48f429c 100644
@@ -104,10 +104,11 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba)
 static int ufshcd_populate_vreg(struct device *dev, const char *name,
 		struct ufs_vreg **out_vreg)
 {
-	int ret = 0;
+	int len, ret = 0;
 	char prop_name[MAX_PROP_SIZE];
 	struct ufs_vreg *vreg = NULL;
 	struct device_node *np = dev->of_node;
+	const __be32 *prop;
 
 	if (!np) {
 		dev_err(dev, "%s: non DT initialization\n", __func__);
@@ -138,8 +139,16 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name,
 			vreg->min_uV = UFS_VREG_VCC_1P8_MIN_UV;
 			vreg->max_uV = UFS_VREG_VCC_1P8_MAX_UV;
 		} else {
-			vreg->min_uV = UFS_VREG_VCC_MIN_UV;
-			vreg->max_uV = UFS_VREG_VCC_MAX_UV;
+			prop = of_get_property(np, "vcc-voltage-level", &len);
+			if (!prop || (len != (2 * sizeof(__be32)))) {
+				dev_warn(dev, "%s vcc-voltage-level property.\n",
+					prop ? "invalid format" : "no");
+				vreg->min_uV = UFS_VREG_VCC_MIN_UV;
+				vreg->max_uV = UFS_VREG_VCC_MAX_UV;
+			} else {
+				vreg->min_uV = be32_to_cpup(&prop[0]);
+				vreg->max_uV = be32_to_cpup(&prop[1]);
+			}
 		}
 	} else if (!strcmp(name, "vccq")) {
 		vreg->min_uV = UFS_VREG_VCCQ_MIN_UV;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#20 lore raw
In reply to Bao D. Nguyen
Quoted 4 lines · Bao D. Nguyen

UFS's specification supports a range of Vcc operating voltages. Allows selecting the UFS Vcc operating voltage levels by reading the UFS's vcc-voltage-level in the device tree.

Quoted 8 lines

Bao D. Nguyen (2):
scsi: dt-bindings: ufs: Add vcc-voltage-level for UFS
scsi: ufs: Support reading UFS's Vcc voltage from device tree

 Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt |  2 ++
 drivers/scsi/ufs/ufshcd-pltfrm.c                        | 15 
++++++++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)

Hello, please help review the change and comment if any.

Thanks!
Bao