MMC card of Size > 4GB support in Linu
RFC PATCH 1/1 MMC card of Size > 4GB support in Linu
Pierre & all,
This is the email continuing the discussion about the 4GB MMC card support in Linux MMC/SD driver. Note that the discussion is for MMC card only, not for SD card.
There are two register as below are used to check the card capability including size of the Card.
1. The Card-Specific Data (CSD) register defines the data format, error correction type, maximum data access time, data transfer speed etc. used for how to access the card contents.
2. And Extended CSD register (EXT_CSD: 512 bytes long) defines the card capabilities and cannot be modified by the host. This EXT_CSD is supported by MMC card only (not for SD).
I). How to check the card Size?
The Card size (C_SIZE) in CSD register used to compute the card capacity. And the maximal capacity which can be coded is 4 GBytes. But higher than 2GB of density of card the maximum possible value should be set to this register (0xFFF).
II). How to check whether is card is >=4GBytes size?
We could check in access mode from OCR register and/or read the EXT_CSD register. Check the SEC_COUNT filed in EXT_CSD register.
The device density is calculated from the value of SEC_COUNT and multiplying by 512B/sector. The maximum density possible to be indicated is thus 2 Tera bytes.
III). So we need to check / validate the response from card for CSD and EXT_CSD register.
Two of the fields in CSD Structure Version (CSD_STRUCTURE) and Extended CSD Revision (EXT_CSD_REV) and the details of the bit filed as follows. i.e. CSD_STRUCTURE should be >= 2 support card more than 4GB and EXT_CSD_REV should be <3;
CSD_STRUCTURE| CSD structure version| Valid for System Specification Ver
------------------------------------------------------------------------
0 | CSD version No. 1.0 | Version 1.0 - 1.2
1 | CSD version No. 1.1 | Version 1.4 - 2.2
2 | CSD version No. 1.2 | Version 3.1 - 3.2-3.31 - 4.0-4.1-4.2
3-255 | Reserved for future useEXT_CSD_REV | Extended CSD Revision
-------------------------------------
255-3 | Reserved
2 | Revision 1.2
1 | Revision 1.1
0 | Revision 1.0IV). And what I understood from MMCA specification is that -
EXT_CSD[EXT_CSD_REV]: Defines the fixed parameters and related to the EXT_CSD register, according to its revision. And it's nothing to do with MMCA specification version or to support > 4GB card.
V). But in current Linux MMC code it's expecting EXT_CSD_REV should be >=2; And if any card of size >= 4GB and EXT_CSD_REV field value is <2, And MMC card won't work.
I have seen cards which having EXT_CSD_REV is <2 and working in other OS. So, Here I am sending the possible solution. `
----------------------------------------------------------------------------
RFC PATCH 1/1 MMC card of Size > 4GB support in Linu
Quoted 11 lines · Sukumar
IV). And what I understood from MMCA specification is that -
EXT_CSD[EXT_CSD_REV]: Defines the fixed parameters and related to theEXT_CSDregister, according to its revision. And it's nothing to do with MMCA specification version or to support > 4GB card.V). But in current Linux MMC code it's expecting
EXT_CSD_REVshould be >=2; And if any card of size >= 4GB andEXT_CSD_REVfield value is <2, And MMC card won't work.I have seen cards which having
EXT_CSD_REVis <2 and working in other OS. So, Here I am sending the possible solution. `
We've been over this already. Your card is broken. Making the stack misbehave for not only your card, but every card, is not a good solution.
The SEC_COUNT field wasn't added until MMC v4.2, and they changed the EXT_CSD_REV to 1.2 to indicate this new format. You're suggesting that we ignore the revision field and just read undefined bits, hoping that they are meaningful. Nobody can consider that a reliable system.
include/linux/mmc/mmc.h struct _mmc_csd { · line 258
Quoted 12 lines
include/linux/mmc/mmc.h +1
-0@@ -252,6 +252,7 @@ struct _mmc_csd {#define EXT_CSD_BUS_WIDTH 183/* R/W */ #define EXT_CSD_HS_TIMING 185/* R/W */ #define EXT_CSD_CARD_TYPE 196/* RO */ +#define EXT_CSD_STRUCT_REV 194/* RO */ #define EXT_CSD_REV 192/* RO */ #define EXT_CSD_SEC_CNT 212/* RO, 4 bytes */
And this is just even more wrong. You're telling the stack to check the revision of the CSD, a completely different structure, for what fields are valid in the EXT_CSD.
Signature · 13 lines
-- Pierre Ossman WARNING: This correspondence is being monitored by the Swedish government. Make sure your server uses encryption for SMTP traffic and consider using PGP for end-to-end encryption. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20090923/d838e051/attachment-0001.sig>