r1292 - trunk/src/target/u-boot/patches

werner at sita.openmoko.org werner at sita.openmoko.org
Fri Mar 9 01:11:37 CET 2007


Author: werner
Date: 2007-03-09 01:11:33 +0100 (Fri, 09 Mar 2007)
New Revision: 1292

Modified:
   trunk/src/target/u-boot/patches/mmc-fixes.patch
Log:
cpu/arm920t/s3c24x0/mmc.c (mmc_init): added SD CID extraction besides MMC CID
  version



Modified: trunk/src/target/u-boot/patches/mmc-fixes.patch
===================================================================
--- trunk/src/target/u-boot/patches/mmc-fixes.patch	2007-03-09 00:07:50 UTC (rev 1291)
+++ trunk/src/target/u-boot/patches/mmc-fixes.patch	2007-03-09 00:11:33 UTC (rev 1292)
@@ -40,14 +40,135 @@
  
  static u_int32_t mmc_size(const struct mmc_csd *csd)
  {
-@@ -361,7 +361,6 @@ int mmc_init(int verbose)
+@@ -331,6 +331,56 @@ static u_int32_t mmc_size(const struct m
+ 	return blocknr * block_len;
+ }
  
++struct sd_cid {
++	char		pnm_0;	/* product name */
++	char		oid_1;	/* OEM/application ID */
++	char		oid_0;
++	uint8_t		mid;	/* manufacturer ID */
++	char		pnm_4;
++	char		pnm_3;
++	char		pnm_2;
++	char		pnm_1;
++	uint8_t		psn_2;	/* product serial number */
++	uint8_t		psn_1;
++	uint8_t		psn_0;	/* MSB */
++	uint8_t		prv;	/* product revision */
++	uint8_t		crc;	/* CRC7 checksum, b0 is unused and set to 1 */
++	uint8_t		mdt_1;	/* manufacturing date, LSB, RRRRyyyy yyyymmmm */
++	uint8_t		mdt_0;	/* MSB */
++	uint8_t		psn_3;	/* LSB */
++};
++
++static void print_mmc_cid(mmc_cid_t *cid)
++{
++	printf("MMC found. Card desciption is:\n");
++	printf("Manufacturer ID = %02x%02x%02x\n",
++		cid->id[0], cid->id[1], cid->id[2]);
++	printf("HW/FW Revision = %x %x\n",cid->hwrev, cid->fwrev);
++	cid->hwrev = cid->fwrev = 0;	/* null terminate string */
++	printf("Product Name = %s\n",cid->name);
++	printf("Serial Number = %02x%02x%02x\n",
++		cid->sn[0], cid->sn[1], cid->sn[2]);
++	printf("Month = %d\n",cid->month);
++	printf("Year = %d\n",1997 + cid->year);
++}
++
++static void print_sd_cid(const struct sd_cid *cid)
++{
++	printf("Manufacturer:       0x%02x, OEM \"%c%c\"\n",
++	    cid->mid, cid->oid_0, cid->oid_1);
++	printf("Product name:       \"%c%c%c%c%c\", revision %d.%d\n",
++	    cid->pnm_0, cid->pnm_1, cid->pnm_2, cid->pnm_3, cid->pnm_4,
++	    cid->prv >> 4, cid->prv & 15);
++	printf("Serial number:      %u\n",
++	    cid->psn_0 << 24 | cid->psn_1 << 16 | cid->psn_2 << 8 |
++	    cid->psn_3);
++	printf("Manufacturing date: %d/%d\n",
++	    cid->mdt_1 & 15,
++	    2000+((cid->mdt_0 & 15) << 4)+((cid->mdt_1 & 0xf0) >> 4));
++	printf("CRC:                0x%02x, b0 = %d\n",
++	    cid->crc >> 1, cid->crc & 1);
++}
++
+ int mmc_init(int verbose)
+ {
+  	int retries, rc = -ENODEV;
+@@ -361,7 +411,6 @@ int mmc_init(int verbose)
+ 
  	printf("trying to detect SD Card...\n");
  	while (retries--) {
 -		int i;
  		udelay(100000);
  		resp = mmc_cmd(55, 0x00000000, CMD_F_RESP);
  		resp = mmc_cmd(41, 0x00300000, CMD_F_RESP);
+@@ -386,20 +435,38 @@ int mmc_init(int verbose)
+ 	/* try to get card id */
+ 	resp = mmc_cmd(MMC_CMD_ALL_SEND_CID, 0, CMD_F_RESP|CMD_F_RESP_LONG);
+ 	if (resp) {
+-		/* TODO configure mmc driver depending on card attributes */
+-		mmc_cid_t *cid = (mmc_cid_t *)resp;
+-		if (verbose) {
+-			printf("MMC found. Card desciption is:\n");
+-			printf("Manufacturer ID = %02x%02x%02x\n",
+-							cid->id[0], cid->id[1], cid->id[2]);
+-			printf("HW/FW Revision = %x %x\n",cid->hwrev, cid->fwrev);
+-			cid->hwrev = cid->fwrev = 0;	/* null terminate string */
+-			printf("Product Name = %s\n",cid->name);
+-			printf("Serial Number = %02x%02x%02x\n",
+-							cid->sn[0], cid->sn[1], cid->sn[2]);
+-			printf("Month = %d\n",cid->month);
+-			printf("Year = %d\n",1997 + cid->year);
++		if (!is_sd) {
++			/* TODO configure mmc driver depending on card
++			   attributes */
++			mmc_cid_t *cid = (mmc_cid_t *)resp;
++
++			if (verbose)
++				print_mmc_cid(cid);
++			sprintf(mmc_dev.vendor,
++				"Man %02x%02x%02x Snr %02x%02x%02x",
++				cid->id[0], cid->id[1], cid->id[2],
++				cid->sn[0], cid->sn[1], cid->sn[2]);
++			sprintf(mmc_dev.product,"%s",cid->name);
++			sprintf(mmc_dev.revision,"%x %x",
++				cid->hwrev, cid->fwrev);
++		}
++		else {
++			struct sd_cid *cid = (struct sd_cid *) resp;
++
++			if (verbose)
++				print_sd_cid(cid);
++			sprintf((char *) mmc_dev.vendor,
++			    "Man %02 OEM %c%c \"%c%c%c%c%c\"",
++			    cid->mid, cid->oid_0, cid->oid_1,
++			    cid->pnm_0, cid->pnm_1, cid->pnm_2, cid->pnm_3,
++			    cid->pnm_4);
++			sprintf((char *) mmc_dev.product, "%d",
++			    cid->psn_0 << 24 | cid->psn_1 << 16 |
++			    cid->psn_2 << 8 | cid->psn_3);
++			sprintf((char *) mmc_dev.revision, "%d.%d",
++			    cid->prv >> 4, cid->prv & 15);
+ 		}
++
+ 		/* fill in device description */
+ 		mmc_dev.if_type = IF_TYPE_MMC;
+ 		mmc_dev.part_type = PART_TYPE_DOS;
+@@ -409,11 +476,6 @@ int mmc_init(int verbose)
+ 		/* FIXME fill in the correct size (is set to 32MByte) */
+ 		mmc_dev.blksz = 512;
+ 		mmc_dev.lba = 0x10000;
+-		sprintf(mmc_dev.vendor,"Man %02x%02x%02x Snr %02x%02x%02x",
+-				cid->id[0], cid->id[1], cid->id[2],
+-				cid->sn[0], cid->sn[1], cid->sn[2]);
+-		sprintf(mmc_dev.product,"%s",cid->name);
+-		sprintf(mmc_dev.revision,"%x %x",cid->hwrev, cid->fwrev);
+ 		mmc_dev.removable = 0;
+ 		mmc_dev.block_read = mmc_bread;
+ 
 Index: u-boot/include/asm-arm/arch-s3c24x0/regs-sdi.h
 ===================================================================
 --- u-boot.orig/include/asm-arm/arch-s3c24x0/regs-sdi.h





More information about the commitlog mailing list