soc: rockchip: thunderboot_sfc: calculate the ramdisk hash

Open CONFIG_ROCKCHIP_THUNDER_BOOT_CRYPTO to enable it.

Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: If87598ae61c4490bd2dd23cf33ab30827bdc2d27
This commit is contained in:
Jason Zhu 2021-03-09 17:12:11 +08:00 committed by Tao Huang
parent 1c9b72894e
commit 048b3bf402

View File

@ -12,6 +12,7 @@
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/soc/rockchip/rockchip_decompress.h>
#include <linux/soc/rockchip/rockchip_thunderboot_crypto.h>
#define SFC_ICLR 0x08
#define SFC_SR 0x24
@ -63,9 +64,18 @@ static int rk_tb_sfc_thread(void *p)
/* Parse ramdisk addr and help start decompressing */
if (rds && rdd) {
struct resource src, dst;
u32 rdk_size = 0;
const u32 *digest_org;
if (of_address_to_resource(rds, 0, &src) >= 0 &&
of_address_to_resource(rdd, 0, &dst) >= 0) {
if (IS_ENABLED(CONFIG_ROCKCHIP_THUNDER_BOOT_CRYPTO)) {
of_property_read_u32(rds, "size", &rdk_size);
digest_org = of_get_property(rds->child, "value", NULL);
if (digest_org && rdk_size)
rk_tb_sha256((dma_addr_t)src.start, rdk_size,
(void *)digest_org);
}
/*
* Decompress HW driver will free reserved area of
* memory-region-src.