platform: msm_shared: Add wrapper functions to support flashing images to all LUNs
CRs-Fixed: 573103
Change-Id: Ie7fc592a7d341e28898837a398dc54ce0c004444
diff --git a/platform/msm_shared/include/mmc_wrapper.h b/platform/msm_shared/include/mmc_wrapper.h
index a05b42b..57f74a0 100644
--- a/platform/msm_shared/include/mmc_wrapper.h
+++ b/platform/msm_shared/include/mmc_wrapper.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -45,4 +45,7 @@
uint32_t mmc_get_device_blocksize();
uint32_t mmc_page_size();
void mmc_device_sleep();
+void mmc_set_lun(uint8_t lun);
+uint8_t mmc_get_lun(void);
+void mmc_read_partition_table(uint8_t arg);
#endif
diff --git a/platform/msm_shared/mmc_wrapper.c b/platform/msm_shared/mmc_wrapper.c
index 5488d48..29eeaee 100644
--- a/platform/msm_shared/mmc_wrapper.c
+++ b/platform/msm_shared/mmc_wrapper.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -75,6 +75,12 @@
{
return 0;
}
+
+__WEAK uint8_t ufs_get_num_of_luns(struct ufs_dev* dev)
+{
+ return 0;
+}
+
/*
* Function: get mmc card
* Arg : None
@@ -502,3 +508,72 @@
mmc_put_card_to_sleep((struct mmc_device *)dev);
}
}
+
+/*
+ * Function : mmc set LUN for ufs
+ * Arg : LUN number
+ * Return type : void
+ */
+void mmc_set_lun(uint8_t lun)
+{
+ void *dev;
+ dev = target_mmc_device();
+
+ if (!target_boot_device_emmc())
+ {
+ ((struct ufs_dev*)dev)->current_lun = lun;
+ }
+}
+
+/*
+ * Function : mmc get LUN from ufs
+ * Arg : LUN number
+ * Return type : lun number for UFS and 0 for emmc
+ */
+uint8_t mmc_get_lun(void)
+{
+ void *dev;
+ uint8_t lun=0;
+
+ dev = target_mmc_device();
+
+ if (!target_boot_device_emmc())
+ {
+ lun = ((struct ufs_dev*)dev)->current_lun;
+ }
+
+ return lun;
+}
+
+void mmc_read_partition_table(uint8_t arg)
+{
+ void *dev;
+ uint8_t lun = 0;
+ uint8_t max_luns;
+
+ dev = target_mmc_device();
+
+ if(!target_boot_device_emmc())
+ {
+ max_luns = ufs_get_num_of_luns((struct ufs_dev*)dev);
+
+ ASSERT(max_luns);
+
+ for(lun = arg; lun < max_luns; lun++)
+ {
+ mmc_set_lun(lun);
+
+ if(partition_read_table())
+ {
+ dprintf(CRITICAL, "Error reading the partition table info for lun %d\n", lun);
+ }
+ }
+ }
+ else
+ {
+ if(partition_read_table())
+ {
+ dprintf(CRITICAL, "Error reading the partition table info\n");
+ }
+ }
+}