Qualcomm UFS device reset support
Subsystems (5)
v3 cover Qualcomm UFS device reset support
This series adds a new ufs vops to allow platform specific methods for resetting an attached UFS device, then implements this for the Qualcomm driver.
Bjorn Andersson (3):
scsi: ufs: Introduce vops for resetting device
scsi: ufs-qcom: Implement device_reset vops
arm64: dts: qcom: sdm845-mtp: Specify UFS device-reset GPIO
.../devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 ++ arch/arm64/boot/dts/qcom/sdm845-mtp.dts | 2 ++ drivers/scsi/ufs/ufs-qcom.c | 32 +++++++++++++++++++ drivers/scsi/ufs/ufs-qcom.h | 4 +++ drivers/scsi/ufs/ufshcd.c | 6 ++++ drivers/scsi/ufs/ufshcd.h | 8 +++++ 6 files changed, 54 insertions(+)
Signature · 1 line
2.18.0
PATCH v3 1/3 scsi: ufs: Introduce vops for resetting device
Some UFS memory devices needs their reset line toggled in order to get them into a good state for initialization. Provide a new vops to allow the platform driver to implement this operation.
---
Changes since v2:
- New patch, to allow moving implementation to platform driver
drivers/scsi/ufs/ufshcd.c | 6 ++++++ drivers/scsi/ufs/ufshcd.h | 8 ++++++++ 2 files changed, 14 insertions(+)
drivers/scsi/ufs/ufshcd.c +6 -0
@@ -6191,6 +6191,9 @@ static int ufshcd_reset_and_restore(struct ufs_hba *hba)int retries =MAX_HOST_RESET_RETRIES ;do { +/* Reset the attached device */ +ufshcd_vops_device_reset (hba); + err =ufshcd_host_reset_and_restore (hba); }while (err && --retries);
@@ -8322,6 +8325,9 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) goto exit_gating; } +/* Reset the attached device */ +ufshcd_vops_device_reset (hba); +/* Host controller enable */ err =ufshcd_hba_enable (hba);if (err) {
drivers/scsi/ufs/ufshcd.h +8 -0
@@ -298,6 +298,7 @@ struct ufs_pwr_mode_info {* @resume: called during host controller PM callback * @dbg_register_dump: used to dump controller debug information * @phy_initialization: used to initialize phys +* @device_reset: called to issue a reset pulse on the UFS device */ struct ufs_hba_variant_ops {const char *name;
@@ -326,6 +327,7 @@ struct ufs_hba_variant_ops {int (*resume)(struct ufs_hba *,enum ufs_pm_op );void (*dbg_register_dump)(struct ufs_hba *hba);int (*phy_initialization)(struct ufs_hba *); +void (*device_reset)(struct ufs_hba *); };/* clock gating state */
@@ -1045,6 +1047,12 @@ static inline void ufshcd_vops_dbg_register_dump(struct ufs_hba *hba) hba->vops->dbg_register_dump (hba); } +static inline void ufshcd_vops_device_reset (struct ufs_hba *hba) +{ +if (hba->vops && hba->vops->device_reset) + hba->vops->device_reset (hba); +} +extern struct ufs_pm_lvl_states ufs_pm_lvl_states[];/*
Signature · 1 line
2.18.0
Re: [PATCH v3 1/3] scsi: ufs: Introduce vops for resetting device
Hi Bjorn,
Are you planning to address Bean's comment on patch#2 and want to re-spin this series?
I am ok with taking this patch as it is and take a Softreset patch as a separate patch.
Quoted 6 lines · Bjorn Andersson
Some UFS memory devices needs their reset line toggled in order to get them into a good state for initialization. Provide a new vops to allow the platform driver to implement this operation.
Signed-off-by Bjorn Andersson <[email protected]>---
feel free to add
Quoted 66 lines
Changes since v2:
- New patch, to allow moving implementation to platform driverdrivers/scsi/ufs/ufshcd.c | 6 ++++++ drivers/scsi/ufs/ufshcd.h | 8 ++++++++ 2 files changed, 14 insertions(+)drivers/scsi/ufs/ufshcd.c +6
-0@@ -6191,6 +6191,9 @@ static int ufshcd_reset_and_restore(struct ufs_hba *hba)int retries =MAX_HOST_RESET_RETRIES ;do { +/* Reset the attached device */ +ufshcd_vops_device_reset (hba); + err =ufshcd_host_reset_and_restore (hba); }while (err && --retries);@@ -8322,6 +8325,9 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) goto exit_gating; } +/* Reset the attached device */ +ufshcd_vops_device_reset (hba); +/* Host controller enable */ err =ufshcd_hba_enable (hba);if (err) {drivers/scsi/ufs/ufshcd.h +8
-0@@ -298,6 +298,7 @@ struct ufs_pwr_mode_info {* @resume: called during host controller PM callback * @dbg_register_dump: used to dump controller debug information * @phy_initialization: used to initialize phys +* @device_reset: called to issue a reset pulse on the UFS device */ struct ufs_hba_variant_ops {const char *name;@@ -326,6 +327,7 @@ struct ufs_hba_variant_ops {int (*resume)(struct ufs_hba *,enum ufs_pm_op );void (*dbg_register_dump)(struct ufs_hba *hba);int (*phy_initialization)(struct ufs_hba *); +void (*device_reset)(struct ufs_hba *); };/* clock gating state */ @@ -1045,6 +1047,12 @@ static inline void ufshcd_vops_dbg_register_dump(struct ufs_hba *hba) hba->vops->dbg_register_dump (hba); } +static inline void ufshcd_vops_device_reset (struct ufs_hba *hba) +{ +if (hba->vops && hba->vops->device_reset) + hba->vops->device_reset (hba); +} +extern struct ufs_pm_lvl_states ufs_pm_lvl_states[];/*
Re: [PATCH v3 1/3] scsi: ufs: Introduce vops for resetting device
Quoted 6 lines · Alim Akhtar
Hi Bjorn,
Are you planning to address Bean's comment on patch#2 and want to re-spin this series?
I am ok with taking this patch as it is and take a Softreset patch as a separate patch.
I still intend to attempt to implement a softreset "fallback", per Bean's suggestion - just haven't found the time yet. But I would be happy to see these patches merged in the meantime, as they do resolve the issue of failing to being up the UFS link on a significant number of Qualcomm devices.
I think it's best if you take patch 1 and 2 through your tree and we take the dts patch through the Qualcomm/arm-soc tree.
Thanks,
Bjorn
Quoted 75 lines · Bjorn Andersson
Quoted 6 lines
Some UFS memory devices needs their reset line toggled in order to get them into a good state for initialization. Provide a new vops to allow the platform driver to implement this operation.
Signed-off-by Bjorn Andersson <[email protected]>---
feel free to add
Reviewed-by Alim Akhtar <[email protected]>Quoted 66 lines
Changes since v2:
- New patch, to allow moving implementation to platform driverdrivers/scsi/ufs/ufshcd.c | 6 ++++++ drivers/scsi/ufs/ufshcd.h | 8 ++++++++ 2 files changed, 14 insertions(+)drivers/scsi/ufs/ufshcd.c +6
-0@@ -6191,6 +6191,9 @@ static int ufshcd_reset_and_restore(struct ufs_hba *hba)int retries =MAX_HOST_RESET_RETRIES ;do { +/* Reset the attached device */ +ufshcd_vops_device_reset (hba); + err =ufshcd_host_reset_and_restore (hba); }while (err && --retries);@@ -8322,6 +8325,9 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) goto exit_gating; } +/* Reset the attached device */ +ufshcd_vops_device_reset (hba); +/* Host controller enable */ err =ufshcd_hba_enable (hba);if (err) {drivers/scsi/ufs/ufshcd.h +8
-0@@ -298,6 +298,7 @@ struct ufs_pwr_mode_info {* @resume: called during host controller PM callback * @dbg_register_dump: used to dump controller debug information * @phy_initialization: used to initialize phys +* @device_reset: called to issue a reset pulse on the UFS device */ struct ufs_hba_variant_ops {const char *name;@@ -326,6 +327,7 @@ struct ufs_hba_variant_ops {int (*resume)(struct ufs_hba *,enum ufs_pm_op );void (*dbg_register_dump)(struct ufs_hba *hba);int (*phy_initialization)(struct ufs_hba *); +void (*device_reset)(struct ufs_hba *); };/* clock gating state */ @@ -1045,6 +1047,12 @@ static inline void ufshcd_vops_dbg_register_dump(struct ufs_hba *hba) hba->vops->dbg_register_dump (hba); } +static inline void ufshcd_vops_device_reset (struct ufs_hba *hba) +{ +if (hba->vops && hba->vops->device_reset) + hba->vops->device_reset (hba); +} +extern struct ufs_pm_lvl_states ufs_pm_lvl_states[];/*
PATCH v3 2/3 scsi: ufs-qcom: Implement device_reset vops
In reply to Bjorn AnderssonThe UFS_RESET pin on Qualcomm SoCs are controlled by TLMM and exposed through the GPIO framework. Acquire the device-reset GPIO and use this to implement the device_reset vops, to allow resetting the attached memory.
Based on downstream support implemented by Subhash Jadavani <[email protected]>.
---
Changes since v2:
- Moved implementation to Qualcomm driver
.../devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 ++ drivers/scsi/ufs/ufs-qcom.c | 32 +++++++++++++++++++ drivers/scsi/ufs/ufs-qcom.h | 4 +++ 3 files changed, 38 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/ufs-qcom.c +32 -0
@@ -16,6 +16,7 @@#include <linux/of.h> #include <linux/platform_device.h> #include <linux/phy/phy.h> +#include <linux/gpio/consumer.h> #include <linux/reset-controller.h> #include "ufshcd.h"
@@ -1141,6 +1142,15 @@ static int ufs_qcom_init(struct ufs_hba *hba) goto out_variant_clear; } + host->device_reset =devm_gpiod_get_optional (dev,"device-reset" , +GPIOD_OUT_HIGH ); +if (IS_ERR (host->device_reset)) { + err =PTR_ERR (host->device_reset); +if (err != -EPROBE_DEFER ) +dev_err (dev,"failed to acquire reset gpio: %d\n" , err); + goto out_variant_clear; + } + err =ufs_qcom_bus_register (host);if (err) goto out_variant_clear;
@@ -1546,6 +1556,27 @@ static void ufs_qcom_dump_dbg_regs(struct ufs_hba *hba)usleep_range (1000 ,1100 ); } +/** +* ufs_qcom_device_reset() - toggle the (optional) device reset line +* @hba: per-adapter instance +* +* Toggles the (optional) reset line to reset the attached device. +*/ +static void ufs_qcom_device_reset (struct ufs_hba *hba) +{ +struct ufs_qcom_host *host =ufshcd_get_variant (hba); + +/* +* The UFS device shall detect reset pulses of 1us, sleep for 10us to +* be on the safe side. +*/ +gpiod_set_value_cansleep (host->device_reset,1 ); +usleep_range (10 ,15 ); + +gpiod_set_value_cansleep (host->device_reset,0 ); +usleep_range (10 ,15 ); +} +/** * struct ufs_hba_qcom_vops - UFS QCOM specific variant operations *
@@ -1566,6 +1597,7 @@ static struct ufs_hba_variant_ops ufs_hba_qcom_vops = { .suspend = ufs_qcom_suspend, .resume = ufs_qcom_resume, .dbg_register_dump = ufs_qcom_dump_dbg_regs, + .device_reset = ufs_qcom_device_reset, };/**
drivers/scsi/ufs/ufs-qcom.h +4 -0
@@ -204,6 +204,8 @@ struct ufs_qcom_testbus {u8 select_minor; }; +struct gpio_desc ; +struct ufs_qcom_host {/* * Set this capability if host controller supports the QUniPro mode
@@ -241,6 +243,8 @@ struct ufs_qcom_host {struct ufs_qcom_testbus testbus;struct reset_controller_dev rcdev; + +struct gpio_desc *device_reset; }; static inline u32
Signature · 1 line
2.18.0
RE: [EXT] [PATCH v3 2/3] scsi: ufs-qcom: Implement device_reset vops
Hi, Bjorn
This HW reset is dedicated to QUALCOMM based platform case.
how about adding a SW reset as to be default reset routine if platform doesn't support HW reset?
Quoted 137 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Bjorn Andersson
Sent: Saturday, June 8, 2019 7:05 AM
To: Rob Herring <[email protected]>; Mark Rutland <[email protected]>; Alim Akhtar <[email protected]>; Avri Altman <[email protected]>; Pedro Sousa <[email protected]>; James E.J. Bottomley <[email protected]>; Martin K. Petersen <[email protected]>
Cc: Andy Gross <[email protected]>; [email protected]; linux- [email protected]; [email protected]; linux- [email protected]
Subject: [EXT] [PATCH v3 2/3] scsi: ufs-qcom: Implementdevice_resetvopsThe
UFS_RESETpin on Qualcomm SoCs are controlled by TLMM and exposed through the GPIO framework. Acquire the device-reset GPIO and use this to implement thedevice_resetvops, to allow resetting the attached memory.Based on downstream support implemented by Subhash Jadavani <[email protected]>.
Signed-off-by Bjorn Andersson <[email protected]>---
Changes since v2:
- Moved implementation to Qualcomm driver.../devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 ++ drivers/scsi/ufs/ufs-qcom.c | 32 +++++++++++++++++++ drivers/scsi/ufs/ufs-qcom.h | 4 +++ 3 files changed, 38 insertions(+)Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +0
-2@@ -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 toreset the whole UFS IP.
+- device-reset-gpios : A phandle and gpio specifier denoting the GPIO
connectedDocumentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +1
-0+ 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/ufs-qcom.c index renamed from drivers/scsi/ufs/ufs-qcom.c +0
-0
ea7219407309..efaf57ba618a100644drivers/scsi/ufs/ufs-qcom.c +31
-0@@ -16,6 +16,7 @@#include <linux/of.h> #include <linux/platform_device.h> #include <linux/phy/phy.h> +#include <linux/gpio/consumer.h> #include <linux/reset-controller.h> #include "ufshcd.h" @@ -1141,6 +1142,15 @@ static int ufs_qcom_init(struct ufs_hba *hba) goto out_variant_clear; } + host->device_reset =devm_gpiod_get_optional (dev,"device-reset" , +GPIOD_OUT_HIGH ); +if (IS_ERR (host->device_reset)) { + err =PTR_ERR (host->device_reset); +if (err != -EPROBE_DEFER ) +dev_err (dev,"failed to acquire reset gpio: %d\n" , err); + goto out_variant_clear; + } + err =ufs_qcom_bus_register (host);if (err) goto out_variant_clear;@@ -1546,6 +1556,27 @@ static void ufs_qcom_dump_dbg_regs(struct ufs_hba *hba) usleep_range(1000, 1100); } +/** +* ufs_qcom_device_reset() - toggle the (optional) device reset line +* @hba: per-adapter instance +* +* Toggles the (optional) reset line to reset the attached device. +*/ +static void ufs_qcom_device_reset (struct ufs_hba *hba) { +struct ufs_qcom_host *host =ufshcd_get_variant (hba); + +/* +* The UFS device shall detect reset pulses of 1us, sleep for 10us to +* be on the safe side. +*/ +gpiod_set_value_cansleep (host->device_reset,1 ); +usleep_range (10 ,15 ); + +gpiod_set_value_cansleep (host->device_reset,0 ); +usleep_range (10 ,15 ); +} +/** * struct ufs_hba_qcom_vops - UFS QCOM specific variant operations * @@ -1566,6 +1597,7 @@ static struct ufs_hba_variant_ops ufs_hba_qcom_vops = { .suspend = ufs_qcom_suspend, .resume = ufs_qcom_resume, .dbg_register_dump = ufs_qcom_dump_dbg_regs, + .device_reset = ufs_qcom_device_reset, };/**
drivers/scsi/ufs/ufs-qcom.h index renamed from drivers/scsi/ufs/ufs-qcom.h +0
-0
68a880185752..b96ffb6804e4100644drivers/scsi/ufs/ufs-qcom.h +4
-0@@ -204,6 +204,8 @@ struct ufs_qcom_testbus {u8 select_minor; }; +struct gpio_desc ; +struct ufs_qcom_host {/* * Set this capability if host controller supports the QUniPro mode @@ -241,6 +243,8 @@ struct ufs_qcom_host {struct ufs_qcom_testbus testbus;struct reset_controller_dev rcdev; + +struct gpio_desc *device_reset; };static inline u32
--
2.18.0
Re: [EXT] [PATCH v3 2/3] scsi: ufs-qcom: Implement device_reset vops
Quoted 4 lines · Bean Huo (beanhuo)
Hi, Bjorn
This HW reset is dedicated to QUALCOMM based platform case.
how about adding a SW reset as to be default reset routine if platform doesn't support HW reset?
Can you please advice how I perform such software reset?
Regards,
Bjorn
Quoted 138 lines
Quoted 137 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Bjorn Andersson
Sent: Saturday, June 8, 2019 7:05 AM
To: Rob Herring <[email protected]>; Mark Rutland <[email protected]>; Alim Akhtar <[email protected]>; Avri Altman <[email protected]>; Pedro Sousa <[email protected]>; James E.J. Bottomley <[email protected]>; Martin K. Petersen <[email protected]>
Cc: Andy Gross <[email protected]>; [email protected]; linux- [email protected]; [email protected]; linux- [email protected]
Subject: [EXT] [PATCH v3 2/3] scsi: ufs-qcom: Implementdevice_resetvopsThe
UFS_RESETpin on Qualcomm SoCs are controlled by TLMM and exposed through the GPIO framework. Acquire the device-reset GPIO and use this to implement thedevice_resetvops, to allow resetting the attached memory.Based on downstream support implemented by Subhash Jadavani <[email protected]>.
Signed-off-by Bjorn Andersson <[email protected]>---
Changes since v2:
- Moved implementation to Qualcomm driver.../devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 ++ drivers/scsi/ufs/ufs-qcom.c | 32 +++++++++++++++++++ drivers/scsi/ufs/ufs-qcom.h | 4 +++ 3 files changed, 38 insertions(+)Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +0
-2@@ -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 toreset the whole UFS IP.
+- device-reset-gpios : A phandle and gpio specifier denoting the GPIO
connectedDocumentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +1
-0+ 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/ufs-qcom.c index renamed from drivers/scsi/ufs/ufs-qcom.c +0
-0
ea7219407309..efaf57ba618a100644drivers/scsi/ufs/ufs-qcom.c +31
-0@@ -16,6 +16,7 @@#include <linux/of.h> #include <linux/platform_device.h> #include <linux/phy/phy.h> +#include <linux/gpio/consumer.h> #include <linux/reset-controller.h> #include "ufshcd.h" @@ -1141,6 +1142,15 @@ static int ufs_qcom_init(struct ufs_hba *hba) goto out_variant_clear; } + host->device_reset =devm_gpiod_get_optional (dev,"device-reset" , +GPIOD_OUT_HIGH ); +if (IS_ERR (host->device_reset)) { + err =PTR_ERR (host->device_reset); +if (err != -EPROBE_DEFER ) +dev_err (dev,"failed to acquire reset gpio: %d\n" , err); + goto out_variant_clear; + } + err =ufs_qcom_bus_register (host);if (err) goto out_variant_clear;@@ -1546,6 +1556,27 @@ static void ufs_qcom_dump_dbg_regs(struct ufs_hba *hba) usleep_range(1000, 1100); } +/** +* ufs_qcom_device_reset() - toggle the (optional) device reset line +* @hba: per-adapter instance +* +* Toggles the (optional) reset line to reset the attached device. +*/ +static void ufs_qcom_device_reset (struct ufs_hba *hba) { +struct ufs_qcom_host *host =ufshcd_get_variant (hba); + +/* +* The UFS device shall detect reset pulses of 1us, sleep for 10us to +* be on the safe side. +*/ +gpiod_set_value_cansleep (host->device_reset,1 ); +usleep_range (10 ,15 ); + +gpiod_set_value_cansleep (host->device_reset,0 ); +usleep_range (10 ,15 ); +} +/** * struct ufs_hba_qcom_vops - UFS QCOM specific variant operations * @@ -1566,6 +1597,7 @@ static struct ufs_hba_variant_ops ufs_hba_qcom_vops = { .suspend = ufs_qcom_suspend, .resume = ufs_qcom_resume, .dbg_register_dump = ufs_qcom_dump_dbg_regs, + .device_reset = ufs_qcom_device_reset, };/**
drivers/scsi/ufs/ufs-qcom.h index renamed from drivers/scsi/ufs/ufs-qcom.h +0
-0
68a880185752..b96ffb6804e4100644drivers/scsi/ufs/ufs-qcom.h +4
-0@@ -204,6 +204,8 @@ struct ufs_qcom_testbus {u8 select_minor; }; +struct gpio_desc ; +struct ufs_qcom_host {/* * Set this capability if host controller supports the QUniPro mode @@ -241,6 +243,8 @@ struct ufs_qcom_host {struct ufs_qcom_testbus testbus;struct reset_controller_dev rcdev; + +struct gpio_desc *device_reset; };static inline u32
--
2.18.0
RE: [EXT] [PATCH v3 2/3] scsi: ufs-qcom: Implement device_reset vops
Hi, Bjorn
Sorry just saw your message.
You can use UIC command,through function ufshcd_send_uic_cmd( ) with UIC_CMD_DME_END_PT_RST command.
DME_ENDPOINTRESET: It is used when UFS host wants the UFS device to perform a reset.
//bean
Quoted 157 lines · Bean Huo (beanhuo)
Quoted 4 lines
Hi, Bjorn
This HW reset is dedicated to QUALCOMM based platform case. how about adding a SW reset as to be default reset routine if platformdoesn't support HW reset?
Quoted 1 line
Can you please advice how I perform such software reset?
Regards,
BjornQuoted 16 lines
Quoted 16 lines
-----Original Message-----
From: [email protected] <[email protected]>
On Behalf Of Bjorn Andersson
Sent: Saturday, June 8, 2019 7:05 AM
To: Rob Herring <[email protected]>; Mark Rutland <[email protected]>; Alim Akhtar <[email protected]>; Avri Altman <[email protected]>; Pedro Sousa <[email protected]>; James E.J. Bottomley <[email protected]>; Martin K. Petersen <[email protected]>
Cc: Andy Gross <[email protected]>; [email protected]; linux- [email protected]; [email protected]; linux- [email protected]
Subject: [EXT] [PATCH v3 2/3] scsi: ufs-qcom: Implementdevice_resetvopsQuoted 1 line
Quoted 1 line
The
UFS_RESETpin on Qualcomm SoCs are controlled by TLMM andexposed
Quoted 2 lines
Quoted 2 lines
through the GPIO framework. Acquire the device-reset GPIO and use this to implement the
device_resetvops, to allow resetting the attachedmemory.
Quoted 15 lines
Quoted 15 lines
Based on downstream support implemented by Subhash Jadavani <[email protected]>.
Signed-off-by Bjorn Andersson <[email protected]>---
Changes since v2:
- Moved implementation to Qualcomm driver.../devicetree/bindings/ufs/ufshcd-pltfrm.txt | 2 ++ drivers/scsi/ufs/ufs-qcom.c | 32 +++++++++++++++++++ drivers/scsi/ufs/ufs-qcom.h | 4 +++ 3 files changed, 38 insertions(+)Quoted 11 lines
Quoted 11 lines
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +0
-2@@ -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 toreset the whole UFS IP.
+- device-reset-gpios : A phandle and gpio specifier denoting theGPIO
Quoted 96 lines
Quoted 95 lines
connected
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +1
-0+ 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.
(quoted diff) +0
-0
b/drivers/scsi/ufs/ufs-qcom.cindexea7219407309..efaf57ba618a100644drivers/scsi/ufs/ufs-qcom.c +31
-0@@ -16,6 +16,7 @@#include <linux/of.h> #include <linux/platform_device.h> #include <linux/phy/phy.h> +#include <linux/gpio/consumer.h> #include <linux/reset-controller.h> #include "ufshcd.h" @@ -1141,6 +1142,15 @@ static int ufs_qcom_init(struct ufs_hba *hba) goto out_variant_clear; } + host->device_reset =devm_gpiod_get_optional (dev,"device-reset" , +GPIOD_OUT_HIGH ); +if (IS_ERR (host->device_reset)) { + err =PTR_ERR (host->device_reset); +if (err != -EPROBE_DEFER ) +dev_err (dev,"failed to acquire reset gpio: %d\n" , err); + goto out_variant_clear; + } + err =ufs_qcom_bus_register (host);if (err) goto out_variant_clear;@@ -1546,6 +1556,27 @@ static void ufs_qcom_dump_dbg_regs(struct ufs_hba *hba) usleep_range(1000, 1100); } +/** +* ufs_qcom_device_reset() - toggle the (optional) device reset line +* @hba: per-adapter instance +* +* Toggles the (optional) reset line to reset the attached device. +*/ +static void ufs_qcom_device_reset (struct ufs_hba *hba) { +struct ufs_qcom_host *host =ufshcd_get_variant (hba); + +/* +* The UFS device shall detect reset pulses of 1us, sleep for 10us to +* be on the safe side. +*/ +gpiod_set_value_cansleep (host->device_reset,1 ); +usleep_range (10 ,15 ); + +gpiod_set_value_cansleep (host->device_reset,0 ); +usleep_range (10 ,15 ); +} +/** * struct ufs_hba_qcom_vops - UFS QCOM specific variant operations * @@ -1566,6 +1597,7 @@ static struct ufs_hba_variant_ops ufs_hba_qcom_vops = { .suspend = ufs_qcom_suspend, .resume = ufs_qcom_resume, .dbg_register_dump = ufs_qcom_dump_dbg_regs, + .device_reset = ufs_qcom_device_reset, };/**
(quoted diff) +0
-0
b/drivers/scsi/ufs/ufs-qcom.hindex68a880185752..b96ffb6804e4100644drivers/scsi/ufs/ufs-qcom.h +4
-0@@ -204,6 +204,8 @@ struct ufs_qcom_testbus {u8 select_minor; }; +struct gpio_desc ; +struct ufs_qcom_host {/* * Set this capability if host controller supports the QUniPro mode @@ -241,6 +243,8 @@ struct ufs_qcom_host {struct ufs_qcom_testbus testbus;struct reset_controller_dev rcdev; + +struct gpio_desc *device_reset; };static inline u32
--
2.18.0
PATCH v3 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 v2:
- 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
@@ -467,6 +467,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