#include <log.h>
#include <tee.h>
#include <mmc.h>
+#include <dm/device_compat.h>
#include "optee_msg.h"
#include "optee_private.h"
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",
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;
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);
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;