Skip to contentSkip to conversation

mmc: core: Extend sysfs with DSR register

RFC PATCH In review Bojan Prtvar 2 participants 2 messages Jul 7, 2016 – Jul 12, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 mmc: core: Extend sysfs with DSR register

Hi,

On embedded platform we have a small diagnostic application which has to record following emmc registers on every power cycle:
CID, CSD, EXT_CSD, OCR, RCA and DSR. The CID, CSD, EXT_CSD and OCR are accessible via ioctl(MMC_IOC_CMD) or through sysfs. The RCA should always be 1 on any linux platform. I can't find a better way for accessing the DSR then as proposed below.

Regards,
Bojan

User space access to Driver Stage Register (DSR) can be useful for diagnostics purpose.

---
 Documentation/mmc/mmc-dev-attrs.txt |  1 +
 drivers/mmc/core/mmc.c              | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)
Documentation/mmc/mmc-dev-attrs.txt +1 -0
index 8163eca..404a0e9 100644
@@ -29,6 +29,7 @@ All attributes are read-only.
 	raw_rpmb_size_mult	RPMB partition size
 	rel_sectors		Reliable write sector count
 	ocr 			Operation Conditions Register
+	dsr			Driver Stage Register
 
 Note on Erase Size and Preferred Erase Size:
 
drivers/mmc/core/mmc.c +17 -0
index 1848334..4363fdc 100644
@@ -745,6 +745,22 @@ static ssize_t mmc_fwrev_show(struct device *dev,
 
 static DEVICE_ATTR(fwrev, S_IRUGO, mmc_fwrev_show, NULL);
 
+static ssize_t mmc_dsr_show(struct device *dev,
+			    struct device_attribute *attr,
+			    char *buf)
+{
+	struct mmc_card *card = mmc_dev_to_card(dev);
+	struct mmc_host *host = card->host;
+
+	if (card->csd.dsr_imp && host->dsr_req)
+		return sprintf(buf, "0x%x\n", host->dsr);
+	else
+		/* return default DSR value */
+		return sprintf(buf, "0x%x\n", 0x404);
+}
+
+static DEVICE_ATTR(dsr, S_IRUGO, mmc_dsr_show, NULL);
+
 static struct attribute *mmc_std_attrs[] = {
 	&dev_attr_cid.attr,
 	&dev_attr_csd.attr,
@@ -764,6 +780,7 @@ static struct attribute *mmc_std_attrs[] = {
 	&dev_attr_raw_rpmb_size_mult.attr,
 	&dev_attr_rel_sectors.attr,
 	&dev_attr_ocr.attr,
+	&dev_attr_dsr.attr,
 	NULL,
 };
 ATTRIBUTE_GROUPS(mmc_std);
Signature · 1 line
2.8.0.GIT
#1 lore raw
Quoted 9 lines · Bojan Prtvar

Hi,

On embedded platform we have a small diagnostic application which has to record following emmc registers on every power cycle:
CID, CSD, EXT_CSD, OCR, RCA and DSR. The CID, CSD, EXT_CSD and OCR are accessible via ioctl(MMC_IOC_CMD) or through sysfs. The RCA should always be 1 on any linux platform. I can't find a better way for accessing the DSR then as proposed below.

Quoted 5 lines

Regards,
Bojan

User space access to Driver Stage Register (DSR) can be useful for diagnostics purpose.

Can you please rephrase this changelog, similar to how changlog looks like for the patch which added the OCR register to sysfs.

Kind regards
Uffe

Quoted 61 lines
---
 Documentation/mmc/mmc-dev-attrs.txt |  1 +
 drivers/mmc/core/mmc.c              | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)
Documentation/mmc/mmc-dev-attrs.txt +1 -0
index 8163eca..404a0e9 100644
@@ -29,6 +29,7 @@ All attributes are read-only.
        raw_rpmb_size_mult      RPMB partition size
        rel_sectors             Reliable write sector count
        ocr                     Operation Conditions Register
+       dsr                     Driver Stage Register
 
 Note on Erase Size and Preferred Erase Size:
 
drivers/mmc/core/mmc.c +17 -1
index 1848334..4363fdc 100644
@@ -745,6 +745,22 @@ static ssize_t mmc_fwrev_show(struct device *dev,
 
 static DEVICE_ATTR(fwrev, S_IRUGO, mmc_fwrev_show, NULL);
 
+static ssize_t mmc_dsr_show(struct device *dev,
+                           struct device_attribute *attr,
+                           char *buf)
+{
+       struct mmc_card *card = mmc_dev_to_card(dev);
+       struct mmc_host *host = card->host;
+
+       if (card->csd.dsr_imp && host->dsr_req)
+               return sprintf(buf, "0x%x\n", host->dsr);
+       else
+               /* return default DSR value */
+               return sprintf(buf, "0x%x\n", 0x404);
+}
+
+static DEVICE_ATTR(dsr, S_IRUGO, mmc_dsr_show, NULL);
+
 static struct attribute *mmc_std_attrs[] = {
        &dev_attr_cid.attr,
        &dev_attr_csd.attr,
@@ -764,6 +780,7 @@ static struct attribute *mmc_std_attrs[] = {
        &dev_attr_raw_rpmb_size_mult.attr,
        &dev_attr_rel_sectors.attr,
        &dev_attr_ocr.attr,
+       &dev_attr_dsr.attr,
        NULL,
 };
 ATTRIBUTE_GROUPS(mmc_std);
--

2.8.0.GIT

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html