sysfs: ufs-qcom: Add sysfs entries for flashpvl

Added entries are bus_speed_mode, clk_status and
err_count.

Change-Id: I459c75048d737651d977f5a5c6aa5dd84553156c
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Sridhar Arra <sarra@codeaurora.org>
This commit is contained in:
Asutosh Das
2020-06-22 11:24:51 -07:00
committed by Gerrit - the friendly Code Review server
parent 431a9b4a57
commit f6e21b2c22
2 changed files with 79 additions and 1 deletions

View File

@@ -1546,8 +1546,11 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on,
if (on && (status == POST_CHANGE)) { if (on && (status == POST_CHANGE)) {
if (!host->is_phy_pwr_on) { if (!host->is_phy_pwr_on) {
phy_power_on(host->generic_phy); err = phy_power_on(host->generic_phy);
host->is_phy_pwr_on = true; host->is_phy_pwr_on = true;
if (!err)
atomic_set(&host->clks_on, on);
} }
/* enable the device ref clock for HS mode*/ /* enable the device ref clock for HS mode*/
if (ufshcd_is_hs_mode(&hba->pwr_info)) if (ufshcd_is_hs_mode(&hba->pwr_info))
@@ -2432,6 +2435,8 @@ static int ufs_qcom_clk_scale_notify(struct ufs_hba *hba,
break; break;
} }
if (!err)
atomic_set(&host->scale_up, scale_up);
return err; return err;
} }
@@ -2813,9 +2818,79 @@ static ssize_t power_mode_show(struct device *dev,
static DEVICE_ATTR_RO(power_mode); static DEVICE_ATTR_RO(power_mode);
static ssize_t bus_speed_mode_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ufs_hba *hba = dev_get_drvdata(dev);
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
return scnprintf(buf, PAGE_SIZE, "%d\n",
!!atomic_read(&host->scale_up));
}
static DEVICE_ATTR_RO(bus_speed_mode);
static ssize_t clk_status_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ufs_hba *hba = dev_get_drvdata(dev);
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
return scnprintf(buf, PAGE_SIZE, "%d\n",
!!atomic_read(&host->clks_on));
}
static DEVICE_ATTR_RO(clk_status);
static unsigned int ufs_qcom_gec(struct ufs_hba *hba,
struct ufs_uic_err_reg_hist *err_hist,
char *err_name)
{
unsigned long flags;
int i, cnt_err = 0;
spin_lock_irqsave(hba->host->host_lock, flags);
for (i = 0; i < UIC_ERR_REG_HIST_LENGTH; i++) {
int p = (i + err_hist->pos) % UIC_ERR_REG_HIST_LENGTH;
if (err_hist->tstamp[p] == 0)
continue;
dev_err(hba->dev, "%s[%d] = 0x%x at %lld us\n", err_name, p,
err_hist->reg[p], ktime_to_us(err_hist->tstamp[p]));
++cnt_err;
}
spin_unlock_irqrestore(hba->host->host_lock, flags);
return cnt_err;
}
static ssize_t err_count_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ufs_hba *hba = dev_get_drvdata(dev);
return scnprintf(buf, PAGE_SIZE,
"%s: %d\n%s: %d\n%s: %d\n",
"pa_err_cnt_total",
ufs_qcom_gec(hba, &hba->ufs_stats.pa_err,
"pa_err_cnt_total"),
"dl_err_cnt_total",
ufs_qcom_gec(hba, &hba->ufs_stats.dl_err,
"dl_err_cnt_total"),
"dme_err_cnt",
ufs_qcom_gec(hba, &hba->ufs_stats.dme_err,
"dme_err_cnt"));
}
static DEVICE_ATTR_RO(err_count);
static struct attribute *ufs_qcom_sysfs_attrs[] = { static struct attribute *ufs_qcom_sysfs_attrs[] = {
&dev_attr_err_state.attr, &dev_attr_err_state.attr,
&dev_attr_power_mode.attr, &dev_attr_power_mode.attr,
&dev_attr_bus_speed_mode.attr,
&dev_attr_clk_status.attr,
&dev_attr_err_count.attr,
NULL NULL
}; };

View File

@@ -366,6 +366,9 @@ struct ufs_qcom_host {
bool work_pending; bool work_pending;
bool is_phy_pwr_on; bool is_phy_pwr_on;
bool err_occurred; bool err_occurred;
/* FlashPVL entries */
atomic_t scale_up;
atomic_t clks_on;
}; };
static inline u32 static inline u32