mmc: core: Extend sysfs with DSR register
authorBojan Prtvar <prtvar.b@gmail.com>
Tue, 19 Jul 2016 09:16:38 +0000 (11:16 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 25 Jul 2016 08:34:51 +0000 (10:34 +0200)
Export DSR register through sysfs same as we did for the CID, CSD and
OCR registers.

Signed-off-by: Bojan Prtvar <prtvar.b@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Documentation/mmc/mmc-dev-attrs.txt
drivers/mmc/core/mmc.c
drivers/mmc/core/sd.c

index 8163eca8522b2052d70973098cd404b195547dc4..404a0e9e92b0c8ea5823271eecc06c965ffaed35 100644 (file)
@@ -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:
 
index 403b97b00bd5c5e1d450859dd2e995133d5220f6..f2d185cf8a8ba52e8f68651c2c517e55313c9d57 100644 (file)
@@ -767,6 +767,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,
@@ -786,6 +802,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);
index 3dd0861f45578ccf95d20b90fc3a7c4e49d9053f..0123936241b06320cf15abb5463b87399c999838 100644 (file)
@@ -678,6 +678,22 @@ MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial);
 MMC_DEV_ATTR(ocr, "%08x\n", card->ocr);
 
 
+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 *sd_std_attrs[] = {
        &dev_attr_cid.attr,
        &dev_attr_csd.attr,
@@ -692,6 +708,7 @@ static struct attribute *sd_std_attrs[] = {
        &dev_attr_oemid.attr,
        &dev_attr_serial.attr,
        &dev_attr_ocr.attr,
+       &dev_attr_dsr.attr,
        NULL,
 };
 ATTRIBUTE_GROUPS(sd_std);