static void tf_clock_timer_cb(unsigned long data)
{
	unsigned long flags;
	u32 ret = 0;

	dprintk(KERN_INFO "%s called...\n", __func__);

	spin_lock_irqsave(&clk_timer_lock, flags);

	/*
	 * If one of the HWA is used (by secure or public) the timer
	 * function cuts all the HWA clocks
	 */
	if (tf_crypto_clock_enabled) {
		dprintk(KERN_INFO "%s; tf_crypto_clock_enabled = %d\n",
			__func__, tf_crypto_clock_enabled);
		goto restart;
	}

	ret = tf_crypto_turn_off_clocks();

	/*
	 * From MShield-DK 1.3.3 sources:
	 *
	 * Digest: 1 << 0
	 * DES   : 1 << 1
	 * AES1  : 1 << 2
	 * AES2  : 1 << 3
	 * RNG   : 1 << 4
	 * PKA   : 1 << 5
	 *
	 * Clock patch active: 1 << 7
	 */
	if (ret & 0x3f)
		goto restart;

	wake_unlock(&g_tf_wake_lock);
	clkdm_allow_idle(smc_l4_sec_clkdm);

	spin_unlock_irqrestore(&clk_timer_lock, flags);

	dprintk(KERN_INFO "%s success\n", __func__);
	return;

restart:
	dprintk("%s: will wait one more time ret=0x%x\n", __func__, ret);
	mod_timer(&tf_crypto_clock_timer,
		jiffies + msecs_to_jiffies(INACTIVITY_TIMER_TIMEOUT));

	spin_unlock_irqrestore(&clk_timer_lock, flags);
}
Exemple #2
0
/*
 * Function responsible for formatting parameters to pass from NS world to
 * S world
 */
u32 omap4_secure_dispatcher(u32 app_id, u32 flags, u32 nargs,
	u32 arg1, u32 arg2, u32 arg3, u32 arg4)
{
	u32 ret;
	unsigned long iflags;
	u32 pub2sec_args[5] = {0, 0, 0, 0, 0};

	/*dpr_info("%s: app_id=0x%08x, flags=0x%08x, nargs=%u\n",
		__func__, app_id, flags, nargs);*/

	/*if (nargs != 0)
		dpr_info("%s: args=%08x, %08x, %08x, %08x\n",
			__func__, arg1, arg2, arg3, arg4);*/

	pub2sec_args[0] = nargs;
	pub2sec_args[1] = arg1;
	pub2sec_args[2] = arg2;
	pub2sec_args[3] = arg3;
	pub2sec_args[4] = arg4;

	/* Make sure parameters are visible to the secure world */
	dmac_flush_range((void *)pub2sec_args,
		(void *)(((u32)(pub2sec_args)) + 5*sizeof(u32)));
	outer_clean_range(__pa(pub2sec_args),
		__pa(pub2sec_args) + 5*sizeof(u32));
	wmb();

	/*
	 * Put L4 Secure clock domain to SW_WKUP so that modules are accessible
	 */
	clkdm_wakeup(smc_l4_sec_clkdm);

	local_irq_save(iflags);

	/* proc_id is always 0 */
	ret = schedule_secure_world(app_id, 0, flags, __pa(pub2sec_args));
	local_irq_restore(iflags);

	/* Restore the HW_SUP on L4 Sec clock domain so hardware can idle */
	if ((app_id != API_HAL_HWATURNOFF_INDEX) &&
	    (!timer_pending(&tf_crypto_clock_timer))) {
		(void) tf_crypto_turn_off_clocks();
		clkdm_allow_idle(smc_l4_sec_clkdm);
	}

	/*dpr_info("%s()\n", __func__);*/

	return ret;
}