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

Commit a1c6f1d4 authored by Sylvain Trosset's avatar Sylvain Trosset Committed by Keith Fallows
Browse files

t-base-301B-V001: fix driver for new platform 8994



Change-Id: I06ae3bf7037ed85435df6112fc0c0982e3e70e15
Signed-off-by: default avatarSylvain Trosset <trosset.sylvain@gmail.com>
Git-commit: 61d4d0b678a37a5b6317717a0d2b11aaf685d098
Git-repo: https://code.google.com/p/tee-mobicore-driver.kernel/


[keithf@codeaurora.org: fix scm.h include file path for all targets
 in drivers/gud/MobiCoreDriver/platforms/MSM8960_SURF_STD/platform.h]
Signed-off-by: default avatarKeith Fallows <keithf@codeaurora.org>
Acked-by: default avatarTony Hamilton <tonyh@qti.qualcomm.com>
parent 479a3569
Loading
Loading
Loading
Loading
+25 −18
Original line number Original line Diff line number Diff line
@@ -146,6 +146,12 @@ static inline long _smc(void *data)
	if (data == NULL)
	if (data == NULL)
		return -EPERM;
		return -EPERM;


	#ifdef MC_SMC_FASTCALL
	{
		ret = smc_fastcall(data, sizeof(union fc_generic));
	}
	#else
	{
		union fc_generic *fc_generic = data;
		union fc_generic *fc_generic = data;
		/* SMC expect values in x0-x3 */
		/* SMC expect values in x0-x3 */
		register u64 reg0 __asm__("x0") = fc_generic->as_in.cmd;
		register u64 reg0 __asm__("x0") = fc_generic->as_in.cmd;
@@ -158,12 +164,13 @@ static inline long _smc(void *data)
			: "+r"(reg0), "+r"(reg1), "+r"(reg2), "+r"(reg3)
			: "+r"(reg0), "+r"(reg1), "+r"(reg2), "+r"(reg3)
		);
		);



		/* set response */
		/* set response */
		fc_generic->as_out.resp     = reg0;
		fc_generic->as_out.resp     = reg0;
		fc_generic->as_out.ret      = reg1;
		fc_generic->as_out.ret      = reg1;
		fc_generic->as_out.param[0] = reg2;
		fc_generic->as_out.param[0] = reg2;
		fc_generic->as_out.param[1] = reg3;
		fc_generic->as_out.param[1] = reg3;
	}
	#endif
	return ret;
	return ret;
}
}


+18 −0
Original line number Original line Diff line number Diff line
@@ -449,10 +449,20 @@ static int map_buffer(struct task_struct *task, void *wsm_buffer,
	 * - or fails and used_mmutable->table contains the list of page
	 * - or fails and used_mmutable->table contains the list of page
	 * pointers.
	 * pointers.
	 * Any mixed contents will make cleanup difficult.
	 * Any mixed contents will make cleanup difficult.
	 */
#if defined(CONFIG_ARM64) && !defined(LPAE_SUPPORT)
	/*
	 * When NWd pointers are 64bits and SWd pte 32bits we need to fill the
	 * table from 0.
	 */
	i = 0;
#else
	/*
	 * Fill the table in reverse order as the table is used as input and
	 * Fill the table in reverse order as the table is used as input and
	 * output.
	 * output.
	 */
	 */
	i = MC_ARM_MMU_TABLE_ENTRIES-1;
	i = MC_ARM_MMU_TABLE_ENTRIES-1;
#endif
	do {
	do {
		if (i < nr_of_pages) {
		if (i < nr_of_pages) {
#ifdef LPAE_SUPPORT
#ifdef LPAE_SUPPORT
@@ -462,6 +472,10 @@ static int map_buffer(struct task_struct *task, void *wsm_buffer,
#endif
#endif
			page = mmutable_as_array_of_pointers_to_page[i];
			page = mmutable_as_array_of_pointers_to_page[i];


			if (!page) {
				MCDRV_DBG_ERROR(mcd, "page address is null");
				return -EFAULT;
			}
			/*
			/*
			 * create MMU table entry, see ARM MMU docu for details
			 * create MMU table entry, see ARM MMU docu for details
			 * about flags stored in the lowest 12 bits.
			 * about flags stored in the lowest 12 bits.
@@ -507,7 +521,11 @@ static int map_buffer(struct task_struct *task, void *wsm_buffer,
			/* ensure rest of table is empty */
			/* ensure rest of table is empty */
			mmutable->table_entries[i] = 0;
			mmutable->table_entries[i] = 0;
		}
		}
#if defined(CONFIG_ARM64) && !defined(LPAE_SUPPORT)
	} while (++i < MC_ARM_MMU_TABLE_ENTRIES);
#else
	} while (i-- != 0);
	} while (i-- != 0);
#endif


	return ret;
	return ret;
}
}
+45 −3
Original line number Original line Diff line number Diff line
@@ -20,8 +20,6 @@
 * Header file the MobiCore Driver Kernel Module,
 * Header file the MobiCore Driver Kernel Module,
 * its internal structures and defines.
 * its internal structures and defines.
 */
 */


#ifndef _MC_PLATFORM_H_
#ifndef _MC_PLATFORM_H_
#define _MC_PLATFORM_H_
#define _MC_PLATFORM_H_


@@ -33,18 +31,62 @@


/*--------------- Implementation -------------- */
/*--------------- Implementation -------------- */
#include <soc/qcom/scm.h>
#include <soc/qcom/scm.h>

/* from following file */
/* from following file */
#define SCM_SVC_MOBICORE		250
#define SCM_SVC_MOBICORE		250
#define SCM_CMD_MOBICORE		1
#define SCM_CMD_MOBICORE		1


#ifdef CONFIG_ARM64

	#include <soc/qcom/qseecomi.h>
	#include <linux/slab.h>
	#include <linux/io.h>
	#include <linux/mm.h>
	#include <asm/cacheflush.h>
	#include <linux/errno.h>

	#define SCM_MOBIOS_FNID(s, c) (((((s) & 0xFF) << 8) | ((c) & 0xFF)) | 0x33000000)

	#define TZ_EXECUTIVE_EXT_ID_PARAM_ID \
		TZ_SYSCALL_CREATE_PARAM_ID_4( \
			TZ_SYSCALL_PARAM_TYPE_BUF_RW, TZ_SYSCALL_PARAM_TYPE_VAL, \
			TZ_SYSCALL_PARAM_TYPE_BUF_RW, TZ_SYSCALL_PARAM_TYPE_VAL)

#endif

extern int scm_call(u32 svc_id, u32 cmd_id, const void *cmd_buf, size_t cmd_len,
extern int scm_call(u32 svc_id, u32 cmd_id, const void *cmd_buf, size_t cmd_len,
		    void *resp_buf, size_t resp_len);
		    void *resp_buf, size_t resp_len);


static inline int smc_fastcall(void *fc_generic, size_t size)
static inline int smc_fastcall(void *fc_generic, size_t size)
{
{
#ifdef CONFIG_ARM64
	struct scm_desc desc = {0};
	int ret;
	void* scm_buf = NULL;

	scm_buf = kzalloc(PAGE_ALIGN(size), GFP_KERNEL);
	if (!scm_buf)
		return -ENOMEM;
	memcpy(scm_buf, fc_generic, size);
	dmac_flush_range(scm_buf, scm_buf + size);

	desc.arginfo = TZ_EXECUTIVE_EXT_ID_PARAM_ID;
	desc.args[0] = virt_to_phys(scm_buf);
	desc.args[1] = (u32)size;
	desc.args[2] = virt_to_phys(scm_buf);
	desc.args[3] = (u32)size;
	ret = scm_call2(
		SCM_MOBIOS_FNID(SCM_SVC_MOBICORE, SCM_CMD_MOBICORE),
		&desc);
	
	memcpy(fc_generic, scm_buf, size);
	kfree(scm_buf);
	return ret;
#else
	return scm_call(SCM_SVC_MOBICORE, SCM_CMD_MOBICORE,
	return scm_call(SCM_SVC_MOBICORE, SCM_CMD_MOBICORE,
			fc_generic, size,
			fc_generic, size,
			fc_generic, size);
			fc_generic, size);
#endif
}
}


/* Enable mobicore mem traces */
/* Enable mobicore mem traces */
@@ -58,7 +100,7 @@ static inline int smc_fastcall(void *fc_generic, size_t size)
/*
/*
 *  Perform crypto clock enable/disable
 *  Perform crypto clock enable/disable
 */
 */
#ifndef CONFIG_ARCH_MSM8960
#if !defined(CONFIG_ARCH_MSM8960) && !defined(CONFIG_ARCH_MSM8994)
#define MC_CRYPTO_CLOCK_MANAGEMENT
#define MC_CRYPTO_CLOCK_MANAGEMENT
#endif
#endif