All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alim Akhtar <alim.akhtar@samsung.com>
To: Marc Gonzalez <marc.w.gonzalez@free.fr>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Linus Walleij <linus.walleij@linaro.org>
Cc: Avri Altman <avri.altman@wdc.com>,
	MSM <linux-arm-msm@vger.kernel.org>,
	SCSI <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH 2/3] scsi: ufs: Allow resetting the UFS device
Date: Fri, 7 Jun 2019 16:11:17 +0530	[thread overview]
Message-ID: <875adde9-1a4b-6bb6-1990-9bb78610546c@samsung.com> (raw)
In-Reply-To: <53775224-5418-1235-20a2-c46d76ef56da@free.fr>

Hi Marc
Thanks for coping me.

On 6/4/19 1:23 PM, Marc Gonzalez wrote:
> [ Shuffling the recipients list ]
> 
> On 04/06/2019 09:20, Bjorn Andersson wrote:
> 
>> Acquire the device-reset GPIO and toggle this to reset the UFS device
>> during initialization and host reset.
>>
>> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
>> ---
>>   drivers/scsi/ufs/ufshcd.c | 44 +++++++++++++++++++++++++++++++++++++++
>>   drivers/scsi/ufs/ufshcd.h |  4 ++++
>>   2 files changed, 48 insertions(+)
>>
>> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
>> index 8c1c551f2b42..951a0efee536 100644
>> --- a/drivers/scsi/ufs/ufshcd.c
>> +++ b/drivers/scsi/ufs/ufshcd.c
>> @@ -42,6 +42,7 @@
>>   #include <linux/nls.h>
>>   #include <linux/of.h>
>>   #include <linux/bitfield.h>
>> +#include <linux/gpio/consumer.h>
>>   #include "ufshcd.h"
>>   #include "ufs_quirks.h"
>>   #include "unipro.h"
>> @@ -6104,6 +6105,25 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
>>   	return err;
>>   }
>>   
>> +/**
>> + ufshcd_device_reset() - toggle the (optional) device reset line
>> + * @hba: per-adapter instance
>> + *
>> + * Toggles the (optional) reset line to reset the attached device.
>> + */
>> +static void ufshcd_device_reset(struct ufs_hba *hba)
>> +{
>> +	/*
>> +	 * The USB device shall detect reset pulses of 1us, sleep for 10us to
>> +	 * be on the safe side.
>> +	 */
>> +	gpiod_set_value_cansleep(hba->device_reset, 1);
>> +	usleep_range(10, 15);
>> +
>> +	gpiod_set_value_cansleep(hba->device_reset, 0);
>> +	usleep_range(10, 15);
>> +}
>> +
>>   /**
>>    * ufshcd_host_reset_and_restore - reset and restore host controller
>>    * @hba: per-adapter instance
>> @@ -6159,6 +6179,9 @@ static int ufshcd_reset_and_restore(struct ufs_hba *hba)
>>   	int retries = MAX_HOST_RESET_RETRIES;
>>   
>>   	do {
>> +		/* Reset the attached device */
>> +		ufshcd_device_reset(hba);
>> +
>>   		err = ufshcd_host_reset_and_restore(hba);
>>   	} while (err && --retries);
>>   
>> @@ -7355,6 +7378,18 @@ static void ufshcd_variant_hba_exit(struct ufs_hba *hba)
>>   	ufshcd_vops_exit(hba);
>>   }
>>   
>> +static int ufshcd_init_device_reset(struct ufs_hba *hba)
>> +{
>> +	hba->device_reset = devm_gpiod_get_optional(hba->dev, "device-reset",
>> +						    GPIOD_OUT_HIGH);
>> +	if (IS_ERR(hba->device_reset)) {
>> +		dev_err(hba->dev, "failed to acquire reset gpio: %ld\n",
>> +			PTR_ERR(hba->device_reset));
>> +	}
>> +
>> +	return PTR_ERR_OR_ZERO(hba->device_reset);
>> +}
>> +
>>   static int ufshcd_hba_init(struct ufs_hba *hba)
>>   {
>>   	int err;
>> @@ -7394,9 +7429,15 @@ static int ufshcd_hba_init(struct ufs_hba *hba)
>>   	if (err)
>>   		goto out_disable_vreg;
>>   
>> +	err = ufshcd_init_device_reset(hba);
>> +	if (err)
>> +		goto out_disable_variant;
>> +
>>   	hba->is_powered = true;
>>   	goto out;
>>   
>> +out_disable_variant:
>> +	ufshcd_vops_setup_regulators(hba, false);
>>   out_disable_vreg:
>>   	ufshcd_setup_vreg(hba, false);
>>   out_disable_clks:
>> @@ -8290,6 +8331,9 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
>>   		goto exit_gating;
>>   	}
>>   
>> +	/* Reset the attached device */
>> +	ufshcd_device_reset(hba);
>> +
>>   	/* Host controller enable */
>>   	err = ufshcd_hba_enable(hba);
>>   	if (err) {
>> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
>> index ecfa898b9ccc..d8be67742168 100644
>> --- a/drivers/scsi/ufs/ufshcd.h
>> +++ b/drivers/scsi/ufs/ufshcd.h
>> @@ -72,6 +72,8 @@
>>   #define UFSHCD "ufshcd"
>>   #define UFSHCD_DRIVER_VERSION "0.2"
>>   
>> +struct gpio_desc;
>> +
>>   struct ufs_hba;
>>   
>>   enum dev_cmd_type {
>> @@ -706,6 +708,8 @@ struct ufs_hba {
>>   
>>   	struct device		bsg_dev;
>>   	struct request_queue	*bsg_queue;
>> +
>> +	struct gpio_desc *device_reset;
>>   };
>>   
>>   /* Returns true if clocks can be gated. Otherwise false */
>>
> 
> Why is this needed on 845 and not on 8998?
> 
Not sure about MSM, but this is high implementation dependent, different 
SoC vendors implement device reset in different way, like one mentioned 
above in this patch, and in case of Samsung/exynos, HCI register control 
device reset. AFA ufs spec is concerns, it just mandate about connecting 
a active low signal to RST_n pin of the ufs device.
> On 8998 we already have:
> 
> 			resets = <&gcc GCC_UFS_BCR>;
> 			reset-names = "rst";
> 
> The above reset line gets wiggled/frobbed when appropriate.
> 
> (What's the difference between gpio and pinctrl? vs a reset "clock" as above)
> 
> ufshcd_device_reset_ctrl() vs ufshcd_init_device_reset()
> 
> Sounds like the nomenclature could be unified or clarified.
> 
> Regards.
> 
> 

  parent reply	other threads:[~2019-06-07 11:01 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-04  7:19 [PATCH 0/3] (Qualcomm) UFS device reset support Bjorn Andersson
2019-06-04  7:19 ` Bjorn Andersson
2019-06-04  7:19 ` [PATCH 1/3] pinctrl: qcom: sdm845: Expose ufs_reset as gpio Bjorn Andersson
2019-06-07 21:26   ` Linus Walleij
2019-06-07 21:26     ` Linus Walleij
2019-06-04  7:20 ` [PATCH 2/3] scsi: ufs: Allow resetting the UFS device Bjorn Andersson
2019-06-04  7:53   ` Marc Gonzalez
2019-06-04 22:14     ` Bjorn Andersson
2019-06-07 10:41     ` Alim Akhtar [this message]
2019-06-07 18:27       ` Bjorn Andersson
2019-06-04  8:13   ` [EXT] " Bean Huo (beanhuo)
2019-06-04 18:10     ` John Stultz
2019-06-04 22:30     ` Bjorn Andersson
2019-06-05 21:17       ` Bean Huo (beanhuo)
2019-06-04 15:25   ` Stephen Boyd
2019-06-04 22:20     ` Bjorn Andersson
2019-06-04  7:20 ` [PATCH 3/3] arm64: dts: qcom: sdm845-mtp: Specify UFS device-reset GPIO Bjorn Andersson
2019-06-04 16:22   ` Stephen Boyd
2019-06-04 22:09     ` Bjorn Andersson
2019-06-07 22:20   ` Linus Walleij
2019-06-07 22:20     ` Linus Walleij
2019-06-04 22:00 ` [PATCH 0/3] (Qualcomm) UFS device reset support John Stultz
2019-06-05  5:50   ` Avri Altman
2019-06-05  6:01     ` Bjorn Andersson
2019-06-05  9:32       ` Avri Altman
2019-06-06  0:39         ` Bjorn Andersson
2019-06-06  6:32           ` Avri Altman
2019-06-06  7:09             ` Bjorn Andersson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875adde9-1a4b-6bb6-1990-9bb78610546c@samsung.com \
    --to=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=marc.w.gonzalez@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.