(Qualcomm) UFS device reset support
Subsystems (9)
v2 cover (Qualcomm) UFS device reset support
This series exposes the ufs_reset line as a gpio, adds support for ufshcd to acquire and toggle this and then adds this to SDM845 MTP.
Bjorn Andersson (3):
pinctrl: qcom: sdm845: Expose ufs_reset as gpio
scsi: ufs: Allow resetting the UFS device
arm64: dts: qcom: sdm845-mtp: Specify UFS device-reset GPIO
.../bindings/pinctrl/qcom,sdm845-pinctrl.txt | 2 +- .../devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 + arch/arm64/boot/dts/qcom/sdm845-mtp.dts | 2 + drivers/pinctrl/qcom/pinctrl-sdm845.c | 12 ++--- drivers/scsi/ufs/ufshcd.c | 44 +++++++++++++++++++ drivers/scsi/ufs/ufshcd.h | 4 ++ 6 files changed, 59 insertions(+), 7 deletions(-)
Signature · 1 line
2.18.0
PATCH v2 1/3 pinctrl: qcom: sdm845: Expose ufs_reset as gpio
The ufs_reset pin is expected to be wired to the reset pin of the primary UFS memory but is pretty much just a general purpose output pinr
Reorder the pins and expose it as gpio 150, so that the UFS driver can toggle it.
---
Changes since v1:
- None
.../bindings/pinctrl/qcom,sdm845-pinctrl.txt | 2 +- drivers/pinctrl/qcom/pinctrl-sdm845.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/pinctrl/qcom,sdm845-pinctrl.txt +1 -1
@@ -79,7 +79,7 @@ to specify in a pin configuration subnode: gpio0-gpio149 Supports mux, bias and drive-strength - sdc2_clk, sdc2_cmd, sdc2_data + sdc2_clk, sdc2_cmd, sdc2_data, ufs_reset Supports bias and drive-strength - function:
drivers/pinctrl/qcom/pinctrl-sdm845.c +6 -6
@@ -420,10 +420,10 @@ DECLARE_MSM_GPIO_PINS(147);DECLARE_MSM_GPIO_PINS (148 );DECLARE_MSM_GPIO_PINS (149 ); -static const unsigned int sdc2_clk_pins[] = {150 }; -static const unsigned int sdc2_cmd_pins[] = {151 }; -static const unsigned int sdc2_data_pins[] = {152 }; -static const unsigned int ufs_reset_pins[] = {153 }; +static const unsigned int ufs_reset_pins[] = {150 }; +static const unsigned int sdc2_clk_pins[] = {151 }; +static const unsigned int sdc2_cmd_pins[] = {152 }; +static const unsigned int sdc2_data_pins[] = {153 };enum sdm845_functions { msm_mux_gpio,
@@ -1271,10 +1271,10 @@ static const struct msm_pingroup sdm845_groups[] = {PINGROUP (147 ,NORTH , _, _, _, _, _, _, _, _, _, _),PINGROUP (148 ,NORTH , _, _, _, _, _, _, _, _, _, _),PINGROUP (149 ,NORTH , _, _, _, _, _, _, _, _, _, _), +UFS_RESET (ufs_reset,0x99f000 ),SDC_QDSD_PINGROUP (sdc2_clk,0x99a000 ,14 ,6 ),SDC_QDSD_PINGROUP (sdc2_cmd,0x99a000 ,11 ,3 ), SDC_QDSD_PINGROUP(sdc2_data, 0x99a000, 9, 0), - UFS_RESET(ufs_reset, 0x99f000), }; static const struct msm_pinctrl_soc_data sdm845_pinctrl = {
@@ -1284,7 +1284,7 @@ static const struct msm_pinctrl_soc_data sdm845_pinctrl = { .nfunctions = ARRAY_SIZE(sdm845_functions), .groups = sdm845_groups, .ngroups = ARRAY_SIZE(sdm845_groups), - .ngpios = 150, + .ngpios = 151, };static int sdm845_pinctrl_probe (struct platform_device *pdev)
Signature · 1 line
2.18.0
PATCH v2 2/3 scsi: ufs: Allow resetting the UFS device
In reply to Bjorn AnderssonAcquire the device-reset GPIO and toggle this to reset the UFS device during initialization and host reset.
Based on downstream support implemented by Subhash Jadavani <[email protected]>.
---
Changes since v1:
- Added gpio to DT binding document
- Fixed spelling of UFS
.../devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 + drivers/scsi/ufs/ufshcd.c | 44 +++++++++++++++++++ drivers/scsi/ufs/ufshcd.h | 4 ++ 3 files changed, 50 insertions(+)
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +2 -0
@@ -54,6 +54,8 @@ Optional properties: PHY reset from the UFS controller. - resets : reset node register - reset-names : describe reset node register, the "rst" corresponds to reset the whole UFS IP. +- device-reset-gpios : A phandle and gpio specifier denoting the GPIO connected + to the RESET pin of the UFS memory device. Note: If above properties are not defined it can be assumed that the supply regulators or clocks are always on.
drivers/scsi/ufs/ufshcd.c +44 -0
83 lines not on this page · raw message
drivers/scsi/ufs/ufshcd.h +4 -0
@@ -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 */
Signature · 1 line
2.18.0
Avri Altman
reviewerRE: [PATCH v2 2/3] scsi: ufs: Allow resetting the UFS device
Quoted 7 lines
static int
ufshcd_hba_init(struct ufs_hba *hba)
{drivers/scsi/ufs/ufshcd.c +0
-0int err;@@ -7425,9 +7460,15 @@ static int ufshcd_hba_init(struct ufs_hba *hba)if (err) goto out_disable_vreg;
drivers/scsi/ufs/ufshcd.c static int ufshcd_hba_init(struct ufs_hba *hba) · line 7471
Quoted 10 lines
drivers/scsi/ufs/ufshcd.c +6
-0+ 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);
Is this necessary?ufshcd_vops_setup_regulators() was just called as part of ufshcd_variant_hba_init
Thanks,
Avri
Re: [PATCH v2 2/3] scsi: ufs: Allow resetting the UFS device
Quoted 15 lines · Avri Altman
Quoted 15 lines
static int
ufshcd_hba_init(struct ufs_hba *hba)
{drivers/scsi/ufs/ufshcd.c +4
-0int err;@@ -7425,9 +7460,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;
Quoted 5 lines
drivers/scsi/ufs/ufshcd.c static int ufshcd_hba_init(struct ufs_hba *hba) · line 7471
Quoted 2 lines
drivers/scsi/ufs/ufshcd.c +2
-0+out_disable_variant: +ufshcd_vops_setup_regulators (hba, false);Is this necessary?
ufshcd_vops_setup_regulators()was just called as part ofufshcd_variant_hba_init
Yes, so my attempt here is to reverse the enablement of the vops regulators (hence passing false). But looking at it again I see that we should also do ufshcd_vops_exit(), so the right thing to call here is ufshcd_variant_hba_exit().
PS. This initialization sequence should really be rewritten to first acquire all resources and then turn them on. This mixes init/setup sequence is really hard to reason about.
Regards,
Bjorn
Rob Herring
maintainerRe: [PATCH v2 2/3] scsi: ufs: Allow resetting the UFS device
In reply to Bjorn AnderssonQuoted 24 lines · Bjorn Andersson
Acquire the device-reset GPIO and toggle this to reset the UFS device during initialization and host reset.
Based on downstream support implemented by Subhash Jadavani <[email protected]>.
Tested-by John Stultz <[email protected]>Signed-off-by Bjorn Andersson <[email protected]>---
Changes since v1:
- Added gpio to DT binding document
- Fixed spelling of UFS.../devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 + drivers/scsi/ufs/ufshcd.c | 44 +++++++++++++++++++ drivers/scsi/ufs/ufshcd.h | 4 ++ 3 files changed, 50 insertions(+)Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +0
-0
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt Optional properties: · line 58
Quoted 5 lines
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +2
-0@@ -54,6 +54,8 @@ Optional properties: PHY reset from the UFS controller. - resets : reset node register - reset-names : describe reset node register, the "rst" corresponds to reset the whole UFS IP. +- device-reset-gpios : A phandle and gpio specifier denoting the GPIO connected + to the RESET pin of the UFS memory device.
A sign we should have a child node for the device...
Doesn't using 'reset-gpios' work as I doubt one would have a GPIO reset for the host controller.
Rob
Re: [PATCH v2 2/3] scsi: ufs: Allow resetting the UFS device
In reply to Bjorn AnderssonQuoted 8 lines · Bjorn Andersson
Acquire the device-reset GPIO and toggle this to reset the UFS device during initialization and host reset.
Based on downstream support implemented by Subhash Jadavani <[email protected]>.
Tested-by John Stultz <[email protected]>Signed-off-by Bjorn Andersson <[email protected]>
I agree with Rob that just "reset-gpios" looks better. Otherwise:
Yours,
Linus Walleij
PATCH v2 3/3 arm64: dts: qcom: sdm845-mtp: Specify UFS device-reset GPIO
In reply to Bjorn AnderssonSpecify the UFS device-reset gpio, so that the controller will issue a reset of the UFS device.
---
Changes since v1:
- None
arch/arm64/boot/dts/qcom/sdm845-mtp.dts | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/qcom/sdm845-mtp.dts +2 -0
@@ -388,6 +388,8 @@ &ufs_mem_hc { status = "okay"; + device-reset-gpios = <&tlmm 150 GPIO_ACTIVE_LOW>; + vcc-supply = <&vreg_l20a_2p95>; vcc-max-microamp = <600000>; };
Signature · 1 line
2.18.0