From bc215bc7f44a78e03625541ece4089884b57b44b Mon Sep 17 00:00:00 2001 From: Stanley Chu Date: Wed, 18 Mar 2020 18:40:14 +0800 Subject: [PATCH] BACKPORT: scsi: ufs: allow custom delay prior to host enabling Currently a 1 ms delay is applied before polling CONTROLLER_ENABLE bit. This delay may not be required or can be changed in different controllers. Make the delay as a changeable value in struct ufs_hba to allow it customized by vendors. Bug: 151050916 Change-Id: I7b7551669bd63c38874c3e6f229dcf61a6b91695 (cherry picked from commit b9dc8aca2899fb494d66b6c5f50c25563d1636a7) [ Resolved minor conflict in drivers/scsi/ufs/ufshcd.h ] Link: https://lore.kernel.org/r/20200318104016.28049-6-stanley.chu@mediatek.com Reviewed-by: Avri Altman Reviewed-by: Can Guo Signed-off-by: Stanley Chu Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/ufs/ufshcd.c | 3 ++- drivers/scsi/ufs/ufshcd.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index f432f2d2621b..8e9d5ace47cb 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4487,7 +4487,7 @@ static int ufshcd_hba_execute_hce(struct ufs_hba *hba) * instruction might be read back. * This delay can be changed based on the controller. */ - usleep_range(1000, 1100); + ufshcd_delay_us(hba->hba_enable_delay_us, 100); /* wait for the host controller to complete initialization */ retry = 10; @@ -8866,6 +8866,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) hba->mmio_base = mmio_base; hba->irq = irq; + hba->hba_enable_delay_us = 1000; err = ufshcd_hba_init(hba); if (err) diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 1a42e6c2dfe6..f92c2308983e 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -732,6 +732,7 @@ struct ufs_hba { u32 eh_flags; u32 intr_mask; u16 ee_ctrl_mask; + u16 hba_enable_delay_us; bool is_powered; /* Work Queues */