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

Commit 1008b667 authored by Amir Samuelov's avatar Amir Samuelov
Browse files

soc: qcom: spss_utils: call IAR callbacks from ioctl



Now that spss is brought up by UEFI and not by HLOS,
the IAR callback is not called on power up.
Call the iar callback functions from ioctl,
to read the spu pbl fw cmac from shared memory.
The PIL should still call the IAR callback on spss SSR.
Remove the call to hyp-assign as this is done by UEFI.

Change-Id: I78dde36dcdc3ae310930c6901bf367c2df789a25
Signed-off-by: default avatarAmir Samuelov <amirs@codeaurora.org>
parent 83b13249
Loading
Loading
Loading
Loading
+18 −23
Original line number Diff line number Diff line
@@ -94,6 +94,10 @@ struct spss_utils_device {
/* Device State */
static struct spss_utils_device *spss_utils_dev;

/* static functions declaration */
static int spss_set_fw_cmac(u32 *cmac, size_t cmac_size);
static int spss_get_pbl_calc_cmac(u32 *cmac, size_t cmac_size);

/*==========================================================================*/
/*		Device Sysfs */
/*==========================================================================*/
@@ -390,6 +394,20 @@ static long spss_utils_ioctl(struct file *file,
		memcpy(cmac_buf, data, sizeof(cmac_buf));
		pr_info("cmac_buf: 0x%x,0x%x,0x%x,0x%x\n",
			cmac_buf[0], cmac_buf[1], cmac_buf[2], cmac_buf[3]);

		/*
		 * SPSS is loaded now by UEFI,
		 * so IAR callback is not being called on powerup by PIL.
		 * therefore read the spu pbl fw cmac from ioctl.
		 * The callback shall be called on spss SSR.
		 */
		pr_info("read pbl cmac from shared memory\n");
		spss_set_fw_cmac(cmac_buf, sizeof(cmac_buf));
		spss_get_pbl_calc_cmac(pbl_cmac_buf, sizeof(pbl_cmac_buf));
		if (memcmp(cmac_buf, pbl_cmac_buf, sizeof(cmac_buf)) != 0)
			is_pbl_ce = true; /* cmacs not the same */
		else
			is_pbl_ce = false;
		break;

	default:
@@ -717,24 +735,8 @@ static int spss_parse_dt(struct device_node *node)
	return 0;
}

static int spss_assign_mem_to_spss_and_hlos(phys_addr_t addr, size_t size)
{
	int ret;
	int srcVM[1] = {VMID_HLOS};
	int destVM[2] = {VMID_HLOS, VMID_CP_SPSS_HLOS_SHARED};
	int destVMperm[2] = {PERM_READ | PERM_WRITE, PERM_READ | PERM_WRITE};

	ret = hyp_assign_phys(addr, size, srcVM, 1, destVM, destVMperm, 2);
	if (ret)
		pr_err("hyp_assign_phys() failed, addr [%pa] size [%zx] ret [%d]\n",
				&addr, size, ret);

	return ret;
}

static int spss_set_fw_cmac(u32 *cmac, size_t cmac_size)
{
	int ret;
	u8 __iomem *reg = NULL;
	int i;

@@ -746,10 +748,6 @@ static int spss_set_fw_cmac(u32 *cmac, size_t cmac_size)
		}
	}

	ret = spss_assign_mem_to_spss_and_hlos(cmac_mem_addr, cmac_mem_size);
	if (ret)
		return ret;

	pr_debug("pil_addr [0x%x]\n", pil_addr);
	pr_debug("pil_size [0x%x]\n", pil_size);
	pr_debug("cmac_mem [%pK]\n", cmac_mem);
@@ -762,9 +760,6 @@ static int spss_set_fw_cmac(u32 *cmac, size_t cmac_size)
	}
	reg += cmac_size;

	for (i = 0; i < cmac_size/4; i++)
		writel_relaxed(0, reg + i*sizeof(u32));

	return 0;
}