]> Git Repo - u-boot.git/blobdiff - drivers/tee/optee/rpmb.c
blk: Switch over to using uclass IDs
[u-boot.git] / drivers / tee / optee / rpmb.c
index 955155b3f8b1212b9b9fe3dcb6afba36e177b8f3..5bc13757ea8d72930a84e7001223fbe847b542c3 100644 (file)
@@ -8,6 +8,7 @@
 #include <log.h>
 #include <tee.h>
 #include <mmc.h>
+#include <dm/device_compat.h>
 
 #include "optee_msg.h"
 #include "optee_private.h"
@@ -47,7 +48,7 @@ static void release_mmc(struct optee_private *priv)
        if (!priv->rpmb_mmc)
                return;
 
-       rc = blk_select_hwpart_devnum(IF_TYPE_MMC, priv->rpmb_dev_id,
+       rc = blk_select_hwpart_devnum(UCLASS_MMC, priv->rpmb_dev_id,
                                      priv->rpmb_original_part);
        if (rc)
                debug("%s: blk_select_hwpart_devnum() failed: %d\n",
@@ -71,6 +72,10 @@ static struct mmc *get_mmc(struct optee_private *priv, int dev_id)
                debug("Cannot find RPMB device\n");
                return NULL;
        }
+       if (mmc_init(mmc)) {
+               log(LOGC_BOARD, LOGL_ERR, "%s:MMC device %d init failed\n", __func__, dev_id);
+               return NULL;
+       }
        if (!(mmc->version & MMC_VERSION_MMC)) {
                debug("Device id %d is not an eMMC device\n", dev_id);
                return NULL;
@@ -83,7 +88,7 @@ static struct mmc *get_mmc(struct optee_private *priv, int dev_id)
 
        priv->rpmb_original_part = mmc_get_blk_desc(mmc)->hwpart;
 
-       rc = blk_select_hwpart_devnum(IF_TYPE_MMC, dev_id, MMC_PART_RPMB);
+       rc = blk_select_hwpart_devnum(UCLASS_MMC, dev_id, MMC_PART_RPMB);
        if (rc) {
                debug("Device id %d: cannot select RPMB partition: %d\n",
                      dev_id, rc);
@@ -98,14 +103,22 @@ static struct mmc *get_mmc(struct optee_private *priv, int dev_id)
 static u32 rpmb_get_dev_info(u16 dev_id, struct rpmb_dev_info *info)
 {
        struct mmc *mmc = find_mmc_device(dev_id);
+       int i;
 
        if (!mmc)
                return TEE_ERROR_ITEM_NOT_FOUND;
 
+       if (mmc_init(mmc)) {
+               log(LOGC_BOARD, LOGL_ERR, "%s:MMC device %d init failed\n", __func__, dev_id);
+               return TEE_ERROR_NOT_SUPPORTED;
+       }
+
        if (!mmc->ext_csd)
                return TEE_ERROR_GENERIC;
 
-       memcpy(info->cid, mmc->cid, sizeof(info->cid));
+       for (i = 0; i < ARRAY_SIZE(mmc->cid); i++)
+               ((u32 *) info->cid)[i] = cpu_to_be32(mmc->cid[i]);
+
        info->rel_wr_sec_c = mmc->ext_csd[222];
        info->rpmb_size_mult = mmc->ext_csd[168];
        info->ret_code = RPMB_CMD_GET_DEV_INFO_RET_OK;
This page took 0.027362 seconds and 4 git commands to generate.