mbox series

[V2,0/3] scsi: ufs: Add a vops to configure VCC voltage level

Message ID 1616363857-26760-1-git-send-email-nitirawa@codeaurora.org
Headers show
Series scsi: ufs: Add a vops to configure VCC voltage level | expand

Message

Nitin Rawat March 21, 2021, 9:57 p.m. UTC
UFS specification allows different VCC configurations for UFS devices,
for example,
	(1)2.70V - 3.60V (For UFS 2.x devices)
	(2)2.40V - 2.70V (For UFS 3.x devices)
For platforms supporting both ufs 2.x (2.7v-3.6v) and
ufs 3.x (2.4v-2.7v), the voltage requirements (VCC) is 2.4v-3.6v.
So to support this, we need to start the ufs device initialization with
the common VCC voltage(2.7v) and after reading the device descriptor we
need to switch to the correct range(vcc min and vcc max) of VCC voltage
as per UFS device type since 2.7v is the marginal voltage as per specs
for both type of devices.

Once VCC regulator supply has been intialised to 2.7v and UFS device
type is read from device descriptor, we follows below steps to
change the VCC voltage values.

1. Set the device to SLEEP state.
2. Disable the Vcc Regulator.
3. Set the vcc voltage according to the device type and reenable
   the regulator.
4. Set the device mode back to ACTIVE.

The above changes are done in vendor specific file by
adding a vops which will be needed for platform
supporting both ufs 2.x and ufs 3.x devices.

v1 -> v2
Added suggested-by on patch2 (scsi: ufs: add a vops to configure VCC voltage level)

Nitin Rawat (3):
  scsi: ufs: export api for use in vendor file
  scsi: ufs: add a vops to configure VCC voltage level
  scsi: ufs-qcom: configure VCC voltage level in vendor file

 drivers/scsi/ufs/ufs-qcom.c | 51 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/scsi/ufs/ufshcd.c   | 13 +++++++++---
 drivers/scsi/ufs/ufshcd.h   | 14 +++++++++++++
 3 files changed, 75 insertions(+), 3 deletions(-)

--
2.7.4

Comments

Asutosh Das (asd) March 31, 2021, 6 p.m. UTC | #1
On 3/21/2021 2:57 PM, Nitin Rawat wrote:
> Add a vops to configure VCC voltage VCC voltage level

> for platform supporting both ufs2.x and ufs 3.x devices.

> 

> Suggested-by: Stanley Chu <stanley.chu@mediatek.com>

> Suggested-by: Asutosh Das <asutoshd@codeaurora.org>

> Suggested-by: Bjorn Andersson <bjorn.andersson@linaro.org>

> Signed-off-by: Nitin Rawat <nitirawa@codeaurora.org>

> Signed-off-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>

> ---

>   drivers/scsi/ufs/ufshcd.c |  4 ++++

>   drivers/scsi/ufs/ufshcd.h | 10 ++++++++++

>   2 files changed, 14 insertions(+)

> 

> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c

> index 633ca8e..5bfe987 100644

> --- a/drivers/scsi/ufs/ufshcd.c

> +++ b/drivers/scsi/ufs/ufshcd.c

> @@ -7763,6 +7763,10 @@ static int ufshcd_add_lus(struct ufs_hba *hba)

>   		goto out;

> 

>   	ufshcd_clear_ua_wluns(hba);

> +	if (ufshcd_vops_setup_vcc_regulators(hba))

This would be invoked even for platforms that don't support both 2.x and 
3.x and don't need to set the voltages in the driver.
I guess platforms that support both 2.x and 3.x and can't set the 
regulator voltages from dts due to different voltage requirements of 2.x 
and 3.x, should request the driver to set the voltages. And the driver 
may do so after determining the device version.

> +		dev_err(hba->dev,

> +			"%s: Failed to set the VCC regulator values, continue with 2.7v\n",

> +			__func__);

> 

>   	/* Initialize devfreq after UFS device is detected */

>   	if (ufshcd_is_clkscaling_supported(hba)) {

> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h

> index 0db796a..8f0945d 100644

> --- a/drivers/scsi/ufs/ufshcd.h

> +++ b/drivers/scsi/ufs/ufshcd.h

> @@ -324,6 +324,7 @@ struct ufs_pwr_mode_info {

>    * @device_reset: called to issue a reset pulse on the UFS device

>    * @program_key: program or evict an inline encryption key

>    * @event_notify: called to notify important events

> + * @setup_vcc_regulators : update vcc regulator level

>    */

>   struct ufs_hba_variant_ops {

>   	const char *name;

> @@ -360,6 +361,7 @@ struct ufs_hba_variant_ops {

>   			       const union ufs_crypto_cfg_entry *cfg, int slot);

>   	void	(*event_notify)(struct ufs_hba *hba,

>   				enum ufs_event_type evt, void *data);

> +	int    (*setup_vcc_regulators)(struct ufs_hba *hba);

>   };

> 

>   /* clock gating state  */

> @@ -1269,6 +1271,14 @@ static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba,

>   		hba->vops->config_scaling_param(hba, profile, data);

>   }

> 

> +static inline int ufshcd_vops_setup_vcc_regulators(struct ufs_hba *hba)

> +{

> +	if (hba->vops && hba->vops->setup_vcc_regulators)

> +		return hba->vops->setup_vcc_regulators(hba);

> +

> +	return 0;

> +}

> +

>   extern struct ufs_pm_lvl_states ufs_pm_lvl_states[];

> 

>   /*

> --

> 2.7.4

> 



-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
Linux Foundation Collaborative Project
Nitin Rawat April 1, 2021, 3 p.m. UTC | #2
On 2021-03-31 23:30, Asutosh Das (asd) wrote:
> On 3/21/2021 2:57 PM, Nitin Rawat wrote:

>> Add a vops to configure VCC voltage VCC voltage level

>> for platform supporting both ufs2.x and ufs 3.x devices.

>> 

>> Suggested-by: Stanley Chu <stanley.chu@mediatek.com>

>> Suggested-by: Asutosh Das <asutoshd@codeaurora.org>

>> Suggested-by: Bjorn Andersson <bjorn.andersson@linaro.org>

>> Signed-off-by: Nitin Rawat <nitirawa@codeaurora.org>

>> Signed-off-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>

>> ---

>>   drivers/scsi/ufs/ufshcd.c |  4 ++++

>>   drivers/scsi/ufs/ufshcd.h | 10 ++++++++++

>>   2 files changed, 14 insertions(+)

>> 

>> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c

>> index 633ca8e..5bfe987 100644

>> --- a/drivers/scsi/ufs/ufshcd.c

>> +++ b/drivers/scsi/ufs/ufshcd.c

>> @@ -7763,6 +7763,10 @@ static int ufshcd_add_lus(struct ufs_hba *hba)

>>   		goto out;

>> 

>>   	ufshcd_clear_ua_wluns(hba);

>> +	if (ufshcd_vops_setup_vcc_regulators(hba))

> This would be invoked even for platforms that don't support both 2.x

> and 3.x and don't need to set the voltages in the driver.

> I guess platforms that support both 2.x and 3.x and can't set the

> regulator voltages from dts due to different voltage requirements of

> 2.x and 3.x, should request the driver to set the voltages. And the

> driver may do so after determining the device version.


Hi Asutosh,
Thanks for the suggestion. I will check and try to accommodate your 
suggestion.
Regards,
Nitin
> 

>> +		dev_err(hba->dev,

>> +			"%s: Failed to set the VCC regulator values, continue with 

>> 2.7v\n",

>> +			__func__);

>> 

>>   	/* Initialize devfreq after UFS device is detected */

>>   	if (ufshcd_is_clkscaling_supported(hba)) {

>> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h

>> index 0db796a..8f0945d 100644

>> --- a/drivers/scsi/ufs/ufshcd.h

>> +++ b/drivers/scsi/ufs/ufshcd.h

>> @@ -324,6 +324,7 @@ struct ufs_pwr_mode_info {

>>    * @device_reset: called to issue a reset pulse on the UFS device

>>    * @program_key: program or evict an inline encryption key

>>    * @event_notify: called to notify important events

>> + * @setup_vcc_regulators : update vcc regulator level

>>    */

>>   struct ufs_hba_variant_ops {

>>   	const char *name;

>> @@ -360,6 +361,7 @@ struct ufs_hba_variant_ops {

>>   			       const union ufs_crypto_cfg_entry *cfg, int slot);

>>   	void	(*event_notify)(struct ufs_hba *hba,

>>   				enum ufs_event_type evt, void *data);

>> +	int    (*setup_vcc_regulators)(struct ufs_hba *hba);

>>   };

>> 

>>   /* clock gating state  */

>> @@ -1269,6 +1271,14 @@ static inline void 

>> ufshcd_vops_config_scaling_param(struct ufs_hba *hba,

>>   		hba->vops->config_scaling_param(hba, profile, data);

>>   }

>> 

>> +static inline int ufshcd_vops_setup_vcc_regulators(struct ufs_hba 

>> *hba)

>> +{

>> +	if (hba->vops && hba->vops->setup_vcc_regulators)

>> +		return hba->vops->setup_vcc_regulators(hba);

>> +

>> +	return 0;

>> +}

>> +

>>   extern struct ufs_pm_lvl_states ufs_pm_lvl_states[];

>> 

>>   /*

>> --

>> 2.7.4

>>
Nitin Rawat April 1, 2021, 3:03 p.m. UTC | #3
On 2021-03-31 23:30, Asutosh Das (asd) wrote:
> On 3/21/2021 2:57 PM, Nitin Rawat wrote:

>> Add a vops to configure VCC voltage VCC voltage level

>> for platform supporting both ufs2.x and ufs 3.x devices.

>> 

>> Suggested-by: Stanley Chu <stanley.chu@mediatek.com>

>> Suggested-by: Asutosh Das <asutoshd@codeaurora.org>

>> Suggested-by: Bjorn Andersson <bjorn.andersson@linaro.org>

>> Signed-off-by: Nitin Rawat <nitirawa@codeaurora.org>

>> Signed-off-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>

>> ---

>>   drivers/scsi/ufs/ufshcd.c |  4 ++++

>>   drivers/scsi/ufs/ufshcd.h | 10 ++++++++++

>>   2 files changed, 14 insertions(+)

>> 

>> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c

>> index 633ca8e..5bfe987 100644

>> --- a/drivers/scsi/ufs/ufshcd.c

>> +++ b/drivers/scsi/ufs/ufshcd.c

>> @@ -7763,6 +7763,10 @@ static int ufshcd_add_lus(struct ufs_hba *hba)

>>   		goto out;

>> 

>>   	ufshcd_clear_ua_wluns(hba);

>> +	if (ufshcd_vops_setup_vcc_regulators(hba))

> This would be invoked even for platforms that don't support both 2.x

> and 3.x and don't need to set the voltages in the driver.

> I guess platforms that support both 2.x and 3.x and can't set the

> regulator voltages from dts due to different voltage requirements of

> 2.x and 3.x, should request the driver to set the voltages. And the

> driver may do so after determining the device version.

> 

>> +		dev_err(hba->dev,

>> +			"%s: Failed to set the VCC regulator values, continue with 

>> 2.7v\n",

>> +			__func__);

>> 

>>   	/* Initialize devfreq after UFS device is detected */

>>   	if (ufshcd_is_clkscaling_supported(hba)) {

>> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h

>> index 0db796a..8f0945d 100644

>> --- a/drivers/scsi/ufs/ufshcd.h

>> +++ b/drivers/scsi/ufs/ufshcd.h

>> @@ -324,6 +324,7 @@ struct ufs_pwr_mode_info {

>>    * @device_reset: called to issue a reset pulse on the UFS device

>>    * @program_key: program or evict an inline encryption key

>>    * @event_notify: called to notify important events

>> + * @setup_vcc_regulators : update vcc regulator level

>>    */

>>   struct ufs_hba_variant_ops {

>>   	const char *name;

>> @@ -360,6 +361,7 @@ struct ufs_hba_variant_ops {

>>   			       const union ufs_crypto_cfg_entry *cfg, int slot);

>>   	void	(*event_notify)(struct ufs_hba *hba,

>>   				enum ufs_event_type evt, void *data);

>> +	int    (*setup_vcc_regulators)(struct ufs_hba *hba);

>>   };

>> 

>>   /* clock gating state  */

>> @@ -1269,6 +1271,14 @@ static inline void 

>> ufshcd_vops_config_scaling_param(struct ufs_hba *hba,

>>   		hba->vops->config_scaling_param(hba, profile, data);

>>   }

>> 

>> +static inline int ufshcd_vops_setup_vcc_regulators(struct ufs_hba 

>> *hba)

>> +{

>> +	if (hba->vops && hba->vops->setup_vcc_regulators)

>> +		return hba->vops->setup_vcc_regulators(hba);

>> +

>> +	return 0;

>> +}

>> +

>>   extern struct ufs_pm_lvl_states ufs_pm_lvl_states[];

>> 

>>   /*

>> --

>> 2.7.4

>> 


Hi Asutosh,
Thanks for the suggestion. I will check and try to accommodate your 
suggestion.
Regards,
Nitin