mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Markus Niebel <list-09_barebox@tqsc.de>
To: barebox@lists.infradead.org
Cc: Markus Niebel <Markus.Niebel@tqs.de>
Subject: [PATCH 2/2] mci: production year for eMMC 4.41 and later
Date: Fri, 10 Jan 2014 10:05:33 +0100	[thread overview]
Message-ID: <1389344733-13203-2-git-send-email-list-09_barebox@tqsc.de> (raw)
In-Reply-To: <1389344733-13203-1-git-send-email-list-09_barebox@tqsc.de>

From: Markus Niebel <Markus.Niebel@tqs.de>

Year is coded in 4 bits of CID. eMMC 4.41
adds a new interpretation rule: production
year for 4.41 cards and newer is between 2010
and 2025 with 0 corresponding to 2013.

This fix was inspired by currect kernel code.

Signed-off-by: Markus Niebel <Markus.Niebel@tqs.de>
---
 drivers/mci/mci-core.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 9bdcdbe..7161af1 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -717,7 +717,7 @@ static void mci_detect_version_from_csd(struct mci *mci)
 			mci->version = MMC_VERSION_4;
 			break;
 		default:
-			printf("unknown card version, fallback to 1.2\n");
+			printf("unknown card version, fallback to 1.02\n");
 			mci->version = MMC_VERSION_1_2;
 			break;
 		}
@@ -1398,10 +1398,17 @@ static unsigned extract_mtd_month(struct mci *mci)
  */
 static unsigned extract_mtd_year(struct mci *mci)
 {
+	unsigned year;
 	if (IS_SD(mci))
-		return UNSTUFF_BITS(mci->cid, 12, 8) + 2000;
-	else
+		year = UNSTUFF_BITS(mci->cid, 12, 8) + 2000;
+	else if (mci->version < MMC_VERSION_4_41)
 		return UNSTUFF_BITS(mci->cid, 8, 4) + 1997;
+	else {
+		year = UNSTUFF_BITS(mci->cid, 8, 4) + 1997;
+		if (year < 2010)
+			year += 16;
+	}
+	return year;
 }
 
 static void mci_print_caps(unsigned caps)
@@ -1448,7 +1455,7 @@ static void mci_info(struct device_d *dev)
 			(mci->version >> 4) & 0xf, mci->version & 0xf);
 	} else {
 		printf("  Attached is an SD Card (Version: %u.%u)\n",
-			(mci->version >> 4) & 0xf, mci->version & 0xf);
+			(mci->version >> 8) & 0xf, mci->version & 0xff);
 	}
 	printf("  Capacity: %u MiB\n", (unsigned)(mci->capacity >> 20));
 
-- 
1.7.9.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2014-01-10  8:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-10  9:05 [PATCH 1/2] mci: Support the correct version for eMMC Markus Niebel
2014-01-10  9:05 ` Markus Niebel [this message]
2014-01-10 13:59 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1389344733-13203-2-git-send-email-list-09_barebox@tqsc.de \
    --to=list-09_barebox@tqsc.de \
    --cc=Markus.Niebel@tqs.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox