]> git.sur5r.net Git - u-boot/commitdiff
mmc: provide a select_hwpart implementation for get_device()
authorStephen Warren <swarren@nvidia.com>
Wed, 7 May 2014 18:19:02 +0000 (12:19 -0600)
committerPantelis Antoniou <panto@antoniou-consulting.com>
Fri, 23 May 2014 09:11:44 +0000 (12:11 +0300)
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>
disk/part.c
drivers/mmc/mmc.c
include/part.h

index 5e10cae015e54e7dc7b5193cd67d5f76ee631582..2827089d8d5f74eeb0d0a6b12863bf30e110f63e 100644 (file)
@@ -39,7 +39,11 @@ static const struct block_drvr block_drvr[] = {
        { .name = "usb", .get_dev = usb_stor_get_dev, },
 #endif
 #if defined(CONFIG_MMC)
-       { .name = "mmc", .get_dev = mmc_get_dev, },
+       {
+               .name = "mmc",
+               .get_dev = mmc_get_dev,
+               .select_hwpart = mmc_select_hwpart,
+       },
 #endif
 #if defined(CONFIG_SYSTEMACE)
        { .name = "ace", .get_dev = systemace_get_dev, },
index bb9014dc064296daacd7c548a427dcacac6420c4..8b53ead98f802ccc60906f43fbad039aa7852f98 100644 (file)
@@ -552,6 +552,32 @@ static int mmc_set_capacity(struct mmc *mmc, int part_num)
        return 0;
 }
 
+int mmc_select_hwpart(int dev_num, int hwpart)
+{
+       struct mmc *mmc = find_mmc_device(dev_num);
+       int ret;
+
+       if (!mmc)
+               return -1;
+
+       if (mmc->part_num == hwpart)
+               return 0;
+
+       if (mmc->part_config == MMCPART_NOAVAILABLE) {
+               printf("Card doesn't support part_switch\n");
+               return -1;
+       }
+
+       ret = mmc_switch_part(dev_num, hwpart);
+       if (ret)
+               return -1;
+
+       mmc->part_num = hwpart;
+
+       return 0;
+}
+
+
 int mmc_switch_part(int dev_num, unsigned int part_num)
 {
        struct mmc *mmc = find_mmc_device(dev_num);
index 53532dcd6120a5959ddcc5f133f5f3f0a6466df6..f2c8c641faa8e77c0d47a7fdfaae10d210a25515 100644 (file)
@@ -103,6 +103,7 @@ block_dev_desc_t* sata_get_dev(int dev);
 block_dev_desc_t* scsi_get_dev(int dev);
 block_dev_desc_t* usb_stor_get_dev(int dev);
 block_dev_desc_t* mmc_get_dev(int dev);
+int mmc_select_hwpart(int dev_num, int hwpart);
 block_dev_desc_t* systemace_get_dev(int dev);
 block_dev_desc_t* mg_disk_get_dev(int dev);
 block_dev_desc_t *host_get_dev(int dev);
@@ -126,6 +127,7 @@ static inline block_dev_desc_t* sata_get_dev(int dev) { return NULL; }
 static inline block_dev_desc_t* scsi_get_dev(int dev) { return NULL; }
 static inline block_dev_desc_t* usb_stor_get_dev(int dev) { return NULL; }
 static inline block_dev_desc_t* mmc_get_dev(int dev) { return NULL; }
+static inline int mmc_select_hwpart(int dev_num, int hwpart) { return -1; }
 static inline block_dev_desc_t* systemace_get_dev(int dev) { return NULL; }
 static inline block_dev_desc_t* mg_disk_get_dev(int dev) { return NULL; }
 static inline block_dev_desc_t *host_get_dev(int dev) { return NULL; }