diff options
author | Namjae Jeon <linkinjeon@gmail.com> | 2011-10-06 10:41:38 -0400 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2011-10-26 16:32:17 -0400 |
commit | e0c368d571d946ff40f068344b5c2df90c93dd2e (patch) | |
tree | 509fdad0059dac018128610723557b4ca12f29d2 /drivers/mmc/core | |
parent | 5238acbe36dd5100fb6b035a995ae5fc89dd0708 (diff) |
mmc: core: general purpose MMC partition support.
It allows gerneral purpose partitions in MMC Device. And I try to simply
make mmc_blk_alloc_parts using mmc_part structure suggested by Andrei
Warkentin. After patching, we see general purpose partitions like this:
> cat /proc/partitions
179 0 847872 mmcblk0
179 192 4096 mmcblk0gp3
179 160 4096 mmcblk0gp2
179 128 4096 mmcblk0gp1
179 96 1052672 mmcblk0gp0
179 64 1024 mmcblk0boot1
179 32 1024 mmcblk0boot0
Signed-off-by: Namjae Jeon <linkinjeon@gmail.com>
Acked-by: Andrei Warkentin <awarkentin@vmware.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc/core')
-rw-r--r-- | drivers/mmc/core/mmc.c | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index c632b1faf70..2a4c9a4d3c0 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c | |||
@@ -239,7 +239,9 @@ static int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd) | |||
239 | */ | 239 | */ |
240 | static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) | 240 | static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) |
241 | { | 241 | { |
242 | int err = 0; | 242 | int err = 0, idx; |
243 | unsigned int part_size; | ||
244 | u8 hc_erase_grp_sz = 0, hc_wp_grp_sz = 0; | ||
243 | 245 | ||
244 | BUG_ON(!card); | 246 | BUG_ON(!card); |
245 | 247 | ||
@@ -340,7 +342,14 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) | |||
340 | * There are two boot regions of equal size, defined in | 342 | * There are two boot regions of equal size, defined in |
341 | * multiples of 128K. | 343 | * multiples of 128K. |
342 | */ | 344 | */ |
343 | card->ext_csd.boot_size = ext_csd[EXT_CSD_BOOT_MULT] << 17; | 345 | if (ext_csd[EXT_CSD_BOOT_MULT] && mmc_boot_partition_access(card->host)) { |
346 | for (idx = 0; idx < MMC_NUM_BOOT_PARTITION; idx++) { | ||
347 | part_size = ext_csd[EXT_CSD_BOOT_MULT] << 17; | ||
348 | mmc_part_add(card, part_size, | ||
349 | EXT_CSD_PART_CONFIG_ACC_BOOT0 + idx, | ||
350 | "boot%d", idx, true); | ||
351 | } | ||
352 | } | ||
344 | } | 353 | } |
345 | 354 | ||
346 | card->ext_csd.raw_hc_erase_gap_size = | 355 | card->ext_csd.raw_hc_erase_gap_size = |
@@ -362,9 +371,9 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) | |||
362 | card->ext_csd.raw_partition_support = ext_csd[EXT_CSD_PARTITION_SUPPORT]; | 371 | card->ext_csd.raw_partition_support = ext_csd[EXT_CSD_PARTITION_SUPPORT]; |
363 | if ((ext_csd[EXT_CSD_PARTITION_SUPPORT] & 0x2) && | 372 | if ((ext_csd[EXT_CSD_PARTITION_SUPPORT] & 0x2) && |
364 | (ext_csd[EXT_CSD_PARTITION_ATTRIBUTE] & 0x1)) { | 373 | (ext_csd[EXT_CSD_PARTITION_ATTRIBUTE] & 0x1)) { |
365 | u8 hc_erase_grp_sz = | 374 | hc_erase_grp_sz = |
366 | ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE]; | 375 | ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE]; |
367 | u8 hc_wp_grp_sz = | 376 | hc_wp_grp_sz = |
368 | ext_csd[EXT_CSD_HC_WP_GRP_SIZE]; | 377 | ext_csd[EXT_CSD_HC_WP_GRP_SIZE]; |
369 | 378 | ||
370 | card->ext_csd.enhanced_area_en = 1; | 379 | card->ext_csd.enhanced_area_en = 1; |
@@ -393,6 +402,41 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) | |||
393 | card->ext_csd.enhanced_area_offset = -EINVAL; | 402 | card->ext_csd.enhanced_area_offset = -EINVAL; |
394 | card->ext_csd.enhanced_area_size = -EINVAL; | 403 | card->ext_csd.enhanced_area_size = -EINVAL; |
395 | } | 404 | } |
405 | |||
406 | /* | ||
407 | * General purpose partition feature support -- | ||
408 | * If ext_csd has the size of general purpose partitions, | ||
409 | * set size, part_cfg, partition name in mmc_part. | ||
410 | */ | ||
411 | if (ext_csd[EXT_CSD_PARTITION_SUPPORT] & | ||
412 | EXT_CSD_PART_SUPPORT_PART_EN) { | ||
413 | if (card->ext_csd.enhanced_area_en != 1) { | ||
414 | hc_erase_grp_sz = | ||
415 | ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE]; | ||
416 | hc_wp_grp_sz = | ||
417 | ext_csd[EXT_CSD_HC_WP_GRP_SIZE]; | ||
418 | |||
419 | card->ext_csd.enhanced_area_en = 1; | ||
420 | } | ||
421 | |||
422 | for (idx = 0; idx < MMC_NUM_GP_PARTITION; idx++) { | ||
423 | if (!ext_csd[EXT_CSD_GP_SIZE_MULT + idx * 3] && | ||
424 | !ext_csd[EXT_CSD_GP_SIZE_MULT + idx * 3 + 1] && | ||
425 | !ext_csd[EXT_CSD_GP_SIZE_MULT + idx * 3 + 2]) | ||
426 | continue; | ||
427 | part_size = | ||
428 | (ext_csd[EXT_CSD_GP_SIZE_MULT + idx * 3 + 2] | ||
429 | << 16) + | ||
430 | (ext_csd[EXT_CSD_GP_SIZE_MULT + idx * 3 + 1] | ||
431 | << 8) + | ||
432 | ext_csd[EXT_CSD_GP_SIZE_MULT + idx * 3]; | ||
433 | part_size *= (size_t)(hc_erase_grp_sz * | ||
434 | hc_wp_grp_sz); | ||
435 | mmc_part_add(card, part_size << 19, | ||
436 | EXT_CSD_PART_CONFIG_ACC_GP0 + idx, | ||
437 | "gp%d", idx, false); | ||
438 | } | ||
439 | } | ||
396 | card->ext_csd.sec_trim_mult = | 440 | card->ext_csd.sec_trim_mult = |
397 | ext_csd[EXT_CSD_SEC_TRIM_MULT]; | 441 | ext_csd[EXT_CSD_SEC_TRIM_MULT]; |
398 | card->ext_csd.sec_erase_mult = | 442 | card->ext_csd.sec_erase_mult = |