Commit d235628434657cf1eba58821445cb5ad88e10763
Committed by
Pantelis Antoniou
1 parent
336b6f9048
Exists in
v2017.01-smarct4x
and in
40 other branches
mmc: provide a select_hwpart implementation for get_device()
This enables specifying which eMMC HW partition to target for any U-Boot command that uses the generic get_partition() function to parse its command-line arguments. Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com> Signed-off-by: Stephen Warren <swarren@nvidia.com>
Showing 3 changed files with 33 additions and 1 deletions Side-by-side Diff
disk/part.c
... | ... | @@ -39,7 +39,11 @@ |
39 | 39 | { .name = "usb", .get_dev = usb_stor_get_dev, }, |
40 | 40 | #endif |
41 | 41 | #if defined(CONFIG_MMC) |
42 | - { .name = "mmc", .get_dev = mmc_get_dev, }, | |
42 | + { | |
43 | + .name = "mmc", | |
44 | + .get_dev = mmc_get_dev, | |
45 | + .select_hwpart = mmc_select_hwpart, | |
46 | + }, | |
43 | 47 | #endif |
44 | 48 | #if defined(CONFIG_SYSTEMACE) |
45 | 49 | { .name = "ace", .get_dev = systemace_get_dev, }, |
drivers/mmc/mmc.c
... | ... | @@ -552,6 +552,32 @@ |
552 | 552 | return 0; |
553 | 553 | } |
554 | 554 | |
555 | +int mmc_select_hwpart(int dev_num, int hwpart) | |
556 | +{ | |
557 | + struct mmc *mmc = find_mmc_device(dev_num); | |
558 | + int ret; | |
559 | + | |
560 | + if (!mmc) | |
561 | + return -1; | |
562 | + | |
563 | + if (mmc->part_num == hwpart) | |
564 | + return 0; | |
565 | + | |
566 | + if (mmc->part_config == MMCPART_NOAVAILABLE) { | |
567 | + printf("Card doesn't support part_switch\n"); | |
568 | + return -1; | |
569 | + } | |
570 | + | |
571 | + ret = mmc_switch_part(dev_num, hwpart); | |
572 | + if (ret) | |
573 | + return -1; | |
574 | + | |
575 | + mmc->part_num = hwpart; | |
576 | + | |
577 | + return 0; | |
578 | +} | |
579 | + | |
580 | + | |
555 | 581 | int mmc_switch_part(int dev_num, unsigned int part_num) |
556 | 582 | { |
557 | 583 | struct mmc *mmc = find_mmc_device(dev_num); |
include/part.h
... | ... | @@ -103,6 +103,7 @@ |
103 | 103 | block_dev_desc_t* scsi_get_dev(int dev); |
104 | 104 | block_dev_desc_t* usb_stor_get_dev(int dev); |
105 | 105 | block_dev_desc_t* mmc_get_dev(int dev); |
106 | +int mmc_select_hwpart(int dev_num, int hwpart); | |
106 | 107 | block_dev_desc_t* systemace_get_dev(int dev); |
107 | 108 | block_dev_desc_t* mg_disk_get_dev(int dev); |
108 | 109 | block_dev_desc_t *host_get_dev(int dev); |
... | ... | @@ -126,6 +127,7 @@ |
126 | 127 | static inline block_dev_desc_t* scsi_get_dev(int dev) { return NULL; } |
127 | 128 | static inline block_dev_desc_t* usb_stor_get_dev(int dev) { return NULL; } |
128 | 129 | static inline block_dev_desc_t* mmc_get_dev(int dev) { return NULL; } |
130 | +static inline int mmc_select_hwpart(int dev_num, int hwpart) { return -1; } | |
129 | 131 | static inline block_dev_desc_t* systemace_get_dev(int dev) { return NULL; } |
130 | 132 | static inline block_dev_desc_t* mg_disk_get_dev(int dev) { return NULL; } |
131 | 133 | static inline block_dev_desc_t *host_get_dev(int dev) { return NULL; } |