scsi: ufs: Fix ufs power down/on specs violation
Subsystems (3)
RFC PATCH v2 1/1 scsi: ufs: Fix ufs power down/on specs violation
As per specs, e.g, JESD220E chapter 7.2, while powering off/on the ufs device, RST_N signal and REF_CLK signal should be between VSS(Ground) and VCCQ/VCCQ2.
To flexibly control device reset line, re-name the function ufschd_vops_device_reset(sturct ufs_hba *hba) to ufshcd_ vops_toggle_device_reset(sturct ufs_hba *hba, bool up). The new parameter "bool up" is used to separate device reset line pulling up from pulling down.
Cc Kiwoong Kim <[email protected]>
Cc Stanley Chu <[email protected]>
Signed-off-by Ziqi Chen <[email protected]>
--- drivers/scsi/ufs/ufs-mediatek.c | 27 +++++++++----------------- drivers/scsi/ufs/ufs-qcom.c | 22 ++++++++++----------- drivers/scsi/ufs/ufshcd.c | 43 ++++++++++++++++++++++++++++++----------- drivers/scsi/ufs/ufshcd.h | 10 +++++----- 4 files changed, 56 insertions(+), 46 deletions(-)
drivers/scsi/ufs/ufs-mediatek.c +9 -18
@@ -841,27 +841,18 @@ static int ufs_mtk_link_startup_notify(struct ufs_hba *hba,return ret; } -static int ufs_mtk_device_reset (struct ufs_hba *hba) +static int ufs_mtk_toggle_device_reset (struct ufs_hba *hba,bool down) {struct arm_smccc_res res; -ufs_mtk_device_reset_ctrl (0 , res); - -/* -* The reset signal is active low. UFS devices shall detect -* more than or equal to 1us of positive or negative RST_n -* pulse width. -* -* To be on safe side, keep the reset low for at least 10us. -*/ -usleep_range (10 ,15 ); - -ufs_mtk_device_reset_ctrl (1 , res); - -/* Some devices may need time to respond to rst_n */ -usleep_range (10000 ,15000 ); +if (down) { +ufs_mtk_device_reset_ctrl (0 , res); + }else { +ufs_mtk_device_reset_ctrl (1 , res); -dev_info (hba->dev,"device reset done\n" ); +/* Some devices may need time to respond to rst_n */ +usleep_range (10000 ,15000 ); + }return 0 ; }
@@ -1052,7 +1043,7 @@ static const struct ufs_hba_variant_ops ufs_hba_mtk_vops = { .suspend = ufs_mtk_suspend, .resume = ufs_mtk_resume, .dbg_register_dump = ufs_mtk_dbg_register_dump, - .device_reset = ufs_mtk_device_reset, + .toggle_device_reset = ufs_mtk_toggle_device_reset, .event_notify = ufs_mtk_event_notify, };
drivers/scsi/ufs/ufs-qcom.c +10 -12
@@ -1404,12 +1404,13 @@ static void ufs_qcom_dump_dbg_regs(struct ufs_hba *hba) }/** -* ufs_qcom_device_reset() - toggle the (optional) device reset line +* ufs_qcom_toggle_device_reset() - toggle the (optional) device reset line * @hba: per-adapter instance +* @down: pull down or pull up device reset line * * Toggles the (optional) reset line to reset the attached device. */ -static int ufs_qcom_device_reset (struct ufs_hba *hba) +static int ufs_qcom_toggle_device_reset (struct ufs_hba *hba,bool down) {struct ufs_qcom_host *host =ufshcd_get_variant (hba);
@@ -1417,15 +1418,12 @@ static int ufs_qcom_device_reset(struct ufs_hba *hba)if (!host->device_reset)return -EOPNOTSUPP ; -/* -* 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 ); +if (down) { +gpiod_set_value_cansleep (host->device_reset,1 ); + }else { +gpiod_set_value_cansleep (host->device_reset,0 ); +usleep_range (10 ,15 ); + }return 0 ; }
@@ -1473,7 +1471,7 @@ static const 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, + .toggle_device_reset = ufs_qcom_toggle_device_reset, .config_scaling_param = ufs_qcom_config_scaling_param, .program_key = ufs_qcom_ice_program_key, };
drivers/scsi/ufs/ufshcd.c +32 -11
105 lines not on this page · raw message
drivers/scsi/ufs/ufshcd.h +5 -5
@@ -319,7 +319,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 +* @toggle_device_reset: called to change logic level of reset gpio on the UFS device * @program_key: program or evict an inline encryption key * @event_notify: called to notify important events */
@@ -350,7 +350,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 *); -int (*device_reset)(struct ufs_hba *hba); +int (*toggle_device_reset)(struct ufs_hba *hba,bool down);void (*config_scaling_param)(struct ufs_hba *hba,struct devfreq_dev_profile *profile,void *data);
@@ -1216,10 +1216,10 @@ static inline void ufshcd_vops_dbg_register_dump(struct ufs_hba *hba) hba->vops->dbg_register_dump (hba); } -static inline int ufshcd_vops_device_reset (struct ufs_hba *hba) +static inline int ufshcd_vops_toggle_device_reset (struct ufs_hba *hba,bool down) { -if (hba->vops && hba->vops->device_reset) -return hba->vops->device_reset (hba); +if (hba->vops && hba->vops->toggle_device_reset) +return hba->vops->toggle_device_reset (hba, down);return -EOPNOTSUPP ; }
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek