Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b2225a04 authored by Santosh Dronamraju's avatar Santosh Dronamraju
Browse files

soc: qcom: Add support for EMMC storage type



Add support for parsing EMMC specific crypto engine type
in crypto qti tz driver.

Test:
Device booted upto UI with File Based Encryption enabled.

Change-Id: Id6354e69dc32a2c68ba81450e8a9c0e015779f4f
Signed-off-by: default avatarSantosh Dronamraju <sdronamr@codeaurora.org>
parent 32339e54
Loading
Loading
Loading
Loading
+33 −5
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
/*
 * Crypto TZ library for storage encryption.
 *
 * Copyright (c) 2020, Linux Foundation. All rights reserved.
 * Copyright (c) 2020-2021, Linux Foundation. All rights reserved.
 */

#include <asm/cacheflush.h>
@@ -10,6 +10,7 @@
#include <linux/qtee_shmbridge.h>
#include <linux/crypto-qti-common.h>
#include <linux/module.h>
#include <linux/of.h>
#include "crypto-qti-platform.h"

#define ICE_CIPHER_MODE_XTS_256 3
@@ -17,6 +18,24 @@
#define SDCC_CE 20
#define UFS_CARD_CE 30

static bool is_boot_dev_type_emmc(void)
{
	struct device_node *np;
	const char *bootparams;

	np = of_find_node_by_path("/chosen");
	of_property_read_string(np, "bootargs", &bootparams);
	if (!bootparams)
		pr_err("%s: failed to get bootargs property\n", __func__);
	else if (strnstr(bootparams, "androidboot.bootdevice",
			strlen(bootparams)) &&
			strnstr(bootparams, "sdhci", strlen(bootparams)))
		return true;

	return false;

}

int crypto_qti_program_key(struct crypto_vops_qti_entry *ice_entry,
			   const struct blk_crypto_key *key, unsigned int slot,
			   unsigned int data_unit_mask, int capid)
@@ -31,6 +50,11 @@ int crypto_qti_program_key(struct crypto_vops_qti_entry *ice_entry,
	memcpy(shm.vaddr, key->raw, key->size);
	qtee_shmbridge_flush_shm_buf(&shm);

	if (is_boot_dev_type_emmc())
		err = qcom_scm_config_set_ice_key(slot, shm.paddr, key->size,
						ICE_CIPHER_MODE_XTS_256,
						data_unit_mask, SDCC_CE);
	else
		err = qcom_scm_config_set_ice_key(slot, shm.paddr, key->size,
						ICE_CIPHER_MODE_XTS_256,
						data_unit_mask, UFS_CE);
@@ -50,7 +74,11 @@ int crypto_qti_invalidate_key(struct crypto_vops_qti_entry *ice_entry,
{
	int err = 0;

	if (is_boot_dev_type_emmc())
		err = qcom_scm_clear_ice_key(slot, SDCC_CE);
	else
		err = qcom_scm_clear_ice_key(slot, UFS_CE);

	if (err)
		pr_err("%s:SCM call Error: 0x%x\n", __func__, err);