From: Hao Ying Date: Wed, 20 Jul 2011 07:11:38 +0000 (+0800) Subject: mmc: export the speed class info of SD card to sysfs X-Git-Tag: 2.1b_release~1924 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=19165fef0cf23ba82816999611b6222858c965cf;p=kernel%2Fkernel-mfld-blackbay.git mmc: export the speed class info of SD card to sysfs BZ: 5474 This patch exports the SD status register's speed class info to sysfs Change-Id: I847ced0d3a632c706c0f7ab93b0dac2f7d6c8d00 Signed-off-by: Hao Ying Reviewed-on: http://android.intel.com:8080/23129 Reviewed-by: Gross, Mark Tested-by: Gross, Mark --- diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 35fcc0e..a6a43bf 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -213,7 +213,7 @@ static int mmc_decode_scr(struct mmc_card *card) */ static int mmc_read_ssr(struct mmc_card *card) { - unsigned int au, es, et, eo; + unsigned int sc, au, es, et, eo; int err, i; u32 *ssr; @@ -242,6 +242,26 @@ static int mmc_read_ssr(struct mmc_card *card) * UNSTUFF_BITS only works with four u32s so we have to offset the * bitfield positions accordingly. */ + sc = UNSTUFF_BITS(ssr, 440 - 384, 8); + switch (sc) { + case 0: + card->ssr.speed_class = 0; + break; + case 1: + card->ssr.speed_class = 2; + break; + case 2: + card->ssr.speed_class = 4; + break; + case 3: + card->ssr.speed_class = 6; + break; + case 4: + card->ssr.speed_class = 10; + break; + default: + card->ssr.speed_class = -1; + } au = UNSTUFF_BITS(ssr, 428 - 384, 4); if (au > 0 || au <= 9) { card->ssr.au = 1 << (au + 4); @@ -657,7 +677,7 @@ MMC_DEV_ATTR(manfid, "0x%06x\n", card->cid.manfid); MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name); MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid); MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial); - +MMC_DEV_ATTR(speed_class, "%u\n", card->ssr.speed_class); static struct attribute *sd_std_attrs[] = { &dev_attr_cid.attr, @@ -672,6 +692,7 @@ static struct attribute *sd_std_attrs[] = { &dev_attr_name.attr, &dev_attr_oemid.attr, &dev_attr_serial.attr, + &dev_attr_speed_class.attr, NULL, }; diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index a45c5b8..58ffd35 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -92,6 +92,7 @@ struct sd_scr { }; struct sd_ssr { + unsigned short speed_class; unsigned int au; /* In sectors */ unsigned int erase_timeout; /* In milliseconds */ unsigned int erase_offset; /* In milliseconds */