mmc: check if mmc cards < 2GB do sector addressing
authorPhilip Rakity <prakity@marvell.com>
Mon, 14 Feb 2011 07:13:09 +0000 (23:13 -0800)
committerChris Ball <cjb@laptop.org>
Wed, 16 Mar 2011 16:30:25 +0000 (12:30 -0400)
Some TOSHIBA MMC cards only support sector addressing even though the
size is < 2GB.  According to JEDEC Spec JESD84-A441-1 the ocr register
(bits 30, 29) determine byte/sector mode.  Use them.

Signed-off-by: Philip Rakity <prakity@marvell.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
drivers/mmc/core/mmc.c

index 6396c5d..14e95f3 100644 (file)
@@ -421,6 +421,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
        int err, ddr = 0;
        u32 cid[4];
        unsigned int max_dtr;
+       u32 rocr;
 
        BUG_ON(!host);
        WARN_ON(!host->claimed);
@@ -434,7 +435,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
        mmc_go_idle(host);
 
        /* The extra bit indicates that we support high capacity */
-       err = mmc_send_op_cond(host, ocr | (1 << 30), NULL);
+       err = mmc_send_op_cond(host, ocr | (1 << 30), &rocr);
        if (err)
                goto err;
 
@@ -522,6 +523,15 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
                err = mmc_read_ext_csd(card);
                if (err)
                        goto free_card;
+
+               /* If doing byte addressing, check if required to do sector
+                * addressing.  Handle the case of <2GB cards needing sector
+                * addressing.  See section 8.1 JEDEC Standard JED84-A441;
+                * ocr register has bit 30 set for sector addressing.
+                */
+               if (!(mmc_card_blockaddr(card)) && (rocr & (1<<30)))
+                       mmc_card_set_blockaddr(card);
+
                /* Erase size depends on CSD and Extended CSD */
                mmc_set_erase_size(card);
        }