Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1223694
| From | Yaniv Gardi <ygardi@codeaurora.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v1 09/17] scsi: ufs: disable vccq if it's not needed by UFS device |
| Date | 2015-09-13 17:00 +0200 |
| Message-ID | <q8gV5-2l2-35@gated-at.bofh.it> (permalink) |
| References | <q8gV4-2l2-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Some UFS devices don't require VCCQ rail for device operations hence
this change adds support to recognize such devices and remove vote for
the unused VCCQ rail.
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
---
drivers/scsi/ufs/ufs.h | 1 +
drivers/scsi/ufs/ufshcd.c | 60 +++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 57 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h
index 85c46b9..05e0f23 100644
--- a/drivers/scsi/ufs/ufs.h
+++ b/drivers/scsi/ufs/ufs.h
@@ -500,6 +500,7 @@ struct ufs_vreg {
struct regulator *reg;
const char *name;
bool enabled;
+ bool unused;
int min_uV;
int max_uV;
int min_uA;
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 411ec17..101648f 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -222,6 +222,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba);
static int __ufshcd_setup_clocks(struct ufs_hba *hba, bool on,
bool skip_ref_clk);
static int ufshcd_setup_clocks(struct ufs_hba *hba, bool on);
+static int ufshcd_set_vccq_rail_unused(struct ufs_hba *hba, bool unused);
static int ufshcd_uic_hibern8_exit(struct ufs_hba *hba);
static int ufshcd_uic_hibern8_enter(struct ufs_hba *hba);
static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba *hba);
@@ -4637,6 +4638,12 @@ static int ufshcd_probe_hba(struct ufs_hba *hba)
goto out;
ufs_advertise_fixup_device(hba);
+
+ ret = ufshcd_set_vccq_rail_unused(hba,
+ (hba->dev_quirks & UFS_DEVICE_NO_VCCQ) ? true : false);
+ if (ret)
+ goto out;
+
/* UFS device is also active now */
ufshcd_set_ufs_dev_active(hba);
ufshcd_force_reset_auto_bkops(hba);
@@ -4788,13 +4795,24 @@ static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg,
static inline int ufshcd_config_vreg_lpm(struct ufs_hba *hba,
struct ufs_vreg *vreg)
{
- return ufshcd_config_vreg_load(hba->dev, vreg, UFS_VREG_LPM_LOAD_UA);
+ if (!vreg)
+ return 0;
+ else if (vreg->unused)
+ return 0;
+ else
+ return ufshcd_config_vreg_load(hba->dev, vreg,
+ UFS_VREG_LPM_LOAD_UA);
}
static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba,
struct ufs_vreg *vreg)
{
- return ufshcd_config_vreg_load(hba->dev, vreg, vreg->max_uA);
+ if (!vreg)
+ return 0;
+ else if (vreg->unused)
+ return 0;
+ else
+ return ufshcd_config_vreg_load(hba->dev, vreg, vreg->max_uA);
}
static int ufshcd_config_vreg(struct device *dev,
@@ -4829,7 +4847,9 @@ static int ufshcd_enable_vreg(struct device *dev, struct ufs_vreg *vreg)
{
int ret = 0;
- if (!vreg || vreg->enabled)
+ if (!vreg)
+ goto out;
+ else if (vreg->enabled || vreg->unused)
goto out;
ret = ufshcd_config_vreg(dev, vreg, true);
@@ -4849,7 +4869,9 @@ static int ufshcd_disable_vreg(struct device *dev, struct ufs_vreg *vreg)
{
int ret = 0;
- if (!vreg || !vreg->enabled)
+ if (!vreg)
+ goto out;
+ else if (!vreg->enabled || vreg->unused)
goto out;
ret = regulator_disable(vreg->reg);
@@ -4955,6 +4977,36 @@ static int ufshcd_init_hba_vreg(struct ufs_hba *hba)
return 0;
}
+static int ufshcd_set_vccq_rail_unused(struct ufs_hba *hba, bool unused)
+{
+ int ret = 0;
+ struct ufs_vreg_info *info = &hba->vreg_info;
+
+ if (!info)
+ goto out;
+ else if (!info->vccq)
+ goto out;
+
+ if (unused) {
+ /* shut off the rail here */
+ ret = ufshcd_toggle_vreg(hba->dev, info->vccq, false);
+ /*
+ * Mark this rail as no longer used, so it doesn't get enabled
+ * later by mistake
+ */
+ if (!ret)
+ info->vccq->unused = true;
+ } else {
+ /*
+ * rail should have been already enabled hence just make sure
+ * that unused flag is cleared.
+ */
+ info->vccq->unused = false;
+ }
+out:
+ return ret;
+}
+
static int __ufshcd_setup_clocks(struct ufs_hba *hba, bool on,
bool skip_ref_clk)
{
--
1.8.5.2
--
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v1 00/17] add fixes, device quirks, error recovery, Yaniv Gardi <ygardi@codeaurora.org> - 2015-09-13 17:00 +0200 [PATCH v1 04/17] scsi: ufs: avoid spurious UFS host controller interrupts Yaniv Gardi <ygardi@codeaurora.org> - 2015-09-13 17:00 +0200 [PATCH v1 10/17] scsi: ufs: make error handling bit faster Yaniv Gardi <ygardi@codeaurora.org> - 2015-09-13 17:00 +0200 [PATCH v1 08/17] scsi: ufs: split broken LCC quirk Yaniv Gardi <ygardi@codeaurora.org> - 2015-09-13 17:00 +0200 [PATCH v1 12/17] scsi: ufs: add retry for query descriptors Yaniv Gardi <ygardi@codeaurora.org> - 2015-09-13 17:00 +0200 [PATCH v1 16/17] scsi: ufs: add delay before putting UFS rails in low power modes Yaniv Gardi <ygardi@codeaurora.org> - 2015-09-13 17:00 +0200 [PATCH v1 13/17] scsi: ufs: handle non spec compliant bkops behaviour by device Yaniv Gardi <ygardi@codeaurora.org> - 2015-09-13 17:00 +0200 [PATCH v1 15/17] scsi: ufs: fix leakage during link off state Yaniv Gardi <ygardi@codeaurora.org> - 2015-09-13 17:00 +0200 [PATCH v1 05/17] scsi: ufs: implement scsi host timeout handler Yaniv Gardi <ygardi@codeaurora.org> - 2015-09-13 17:00 +0200 [PATCH v1 17/17] scsi: ufs-qcom: set PA_Local_TX_LCC_Enable before link startup Yaniv Gardi <ygardi@codeaurora.org> - 2015-09-13 17:00 +0200 [PATCH v1 14/17] scsi: ufs: tune UniPro parameters to optimize hibern8 exit time Yaniv Gardi <ygardi@codeaurora.org> - 2015-09-13 17:00 +0200 [PATCH v1 09/17] scsi: ufs: disable vccq if it's not needed by UFS device Yaniv Gardi <ygardi@codeaurora.org> - 2015-09-13 17:00 +0200 [PATCH v1 06/17] scsi :ufs: verify hba controller hce reg value Yaniv Gardi <ygardi@codeaurora.org> - 2015-09-13 17:00 +0200 [PATCH v1 11/17] scsi: ufs: add error recovery after DL NAC error Yaniv Gardi <ygardi@codeaurora.org> - 2015-09-13 17:00 +0200 [PATCH v1 03/17] scsi: ufs: optimize system suspend handling Yaniv Gardi <ygardi@codeaurora.org> - 2015-09-13 17:00 +0200 [PATCH v1 02/17] scsi: ufs: add option to change default UFS power management level Yaniv Gardi <ygardi@codeaurora.org> - 2015-09-13 17:00 +0200 [PATCH v1 01/17] scsi: ufs-qcom: add number of lanes per direction Yaniv Gardi <ygardi@codeaurora.org> - 2015-09-13 17:00 +0200 [PATCH v1 07/17] scsi: ufs: separate device and host quirks Yaniv Gardi <ygardi@codeaurora.org> - 2015-09-13 17:00 +0200
csiph-web