platform: msm_shared: Add support for rpmb
Add support to perform read and write from rpmb partition in
emmc driver.
Change-Id: I41ded88d079973dbc6dddd5bfcd69a9d9bb8a3b4
diff --git a/platform/msm_shared/include/mmc_sdhci.h b/platform/msm_shared/include/mmc_sdhci.h
index 1612e61..95d636e 100644
--- a/platform/msm_shared/include/mmc_sdhci.h
+++ b/platform/msm_shared/include/mmc_sdhci.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2015, 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
@@ -101,6 +101,7 @@
#define MMC_USR_WP 171
#define MMC_ERASE_TIMEOUT_MULT 223
#define MMC_HC_ERASE_GRP_SIZE 224
+#define MMC_PARTITION_CONFIG 179
/* Values for ext csd fields */
#define MMC_HS_TIMING 0x1
@@ -117,6 +118,13 @@
#define MMC_HC_ERASE_MULT (512 * 1024)
#define RST_N_FUNC_ENABLE BIT(0)
+/* RPMB Related */
+#define RPMB_PART_MIN_SIZE (128 * 2014)
+#define RPMB_SIZE_MULT 168
+#define REL_WR_SEC_C 222
+#define PARTITION_ACCESS_MASK 0x7
+#define MAX_RPMB_CMDS 0x3
+
/* Command related */
#define MMC_MAX_COMMAND_RETRY 1000
#define MMC_MAX_CARD_STAT_RETRY 10000
@@ -226,6 +234,12 @@
#define MMC_CARD_MMC(card) ((card->type == MMC_TYPE_STD_MMC) || \
(card->type == MMC_TYPE_MMCHC))
+enum part_access_type
+{
+ PART_ACCESS_DEFAULT = 0x0,
+ PART_ACCESS_RPMB = 0x3,
+};
+
/* CSD Register.
* Note: not all the fields have been defined here
*/
@@ -292,6 +306,8 @@
uint8_t *ext_csd; /* Ext CSD for the card info */
uint32_t raw_csd[4]; /* Raw CSD for the card */
uint32_t raw_scr[2]; /* SCR for SD card */
+ uint32_t rpmb_size; /* Size of rpmb partition */
+ uint32_t rel_wr_count; /* Reliable write count */
struct mmc_cid cid; /* CID structure */
struct mmc_csd csd; /* CSD structure */
struct mmc_sd_scr scr; /* SCR structure */
@@ -337,4 +353,6 @@
void mmc_put_card_to_sleep(struct mmc_device *dev);
/* API: Change the driver type of the card */
bool mmc_set_drv_type(struct sdhci_host *host, struct mmc_card *card, uint8_t drv_type);
+/* API: Send the read & write command sequence to rpmb */
+uint32_t mmc_sdhci_rpmb_send(struct mmc_device *dev, struct mmc_command *cmd);
#endif
diff --git a/platform/msm_shared/include/sdhci.h b/platform/msm_shared/include/sdhci.h
index 604ac81..c0b484d 100644
--- a/platform/msm_shared/include/sdhci.h
+++ b/platform/msm_shared/include/sdhci.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2015, 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
@@ -100,6 +100,7 @@
uint32_t cmd_retry; /* Retry the command, if card is busy */
uint32_t cmd23_support; /* If card supports cmd23 */
uint64_t cmd_timeout; /* Command timeout in us */
+ bool write_flag; /* Write flag, for reliable write cases */
struct mmc_data data; /* Data pointer */
};