示例#1
0
文件: mpm.c 项目: AKToronto/IronBorn2
void msm_mpm_exit_sleep(bool from_idle)
{
	unsigned long pending;
	int i;
	int k;

	for (i = 0; i < MSM_MPM_REG_WIDTH; i++) {
		pending = msm_mpm_read(MSM_MPM_STATUS_REG_PENDING, i);

		if (MSM_MPM_DEBUG_PENDING_IRQ & msm_mpm_debug_mask)
			pr_info("%s: pending.%d: 0x%08lx", __func__,
					i, pending);

		k = find_first_bit(&pending, 32);
		while (k < 32) {
			unsigned int mpm_irq = 32 * i + k;
			unsigned int apps_irq = msm_mpm_get_irq_m2a(mpm_irq);
			struct irq_desc *desc = apps_irq ?
				irq_to_desc(apps_irq) : NULL;

			if (desc && !irqd_is_level_type(&desc->irq_data)) {
				irq_set_pending(apps_irq);
				if (from_idle)
					check_irq_resend(desc, apps_irq);
			}

			k = find_next_bit(&pending, 32, k + 1);
		}
	}

	msm_mpm_clear();
}
 /*
  * Restore interrupt subsystem from sleep -- phase 2
  * Poke the specified pending interrupts into interrupt hardware.
  */
void msm_gic_irq_exit_sleep2(uint32_t irq_mask, uint32_t wakeup_reason,
			uint32_t pending)
{
	int i, smsm_irq, smsm_mask;
	struct irq_desc *desc;

	if (msm_gic_irq_debug_mask & IRQ_DEBUG_SLEEP)
		pr_info("%s %x %x %x now\n", __func__, irq_mask,
				 pending, wakeup_reason);

	for (i = 0; pending && i < ARRAY_SIZE(msm_gic_irq_to_smsm); i++) {
		smsm_irq = msm_gic_irq_to_smsm[i];

		if (smsm_irq == 0)
			continue;

		smsm_mask = BIT(smsm_irq - 1);
		if (!(pending & smsm_mask))
			continue;

		pending &= ~smsm_mask;

		if (msm_gic_irq_debug_mask & IRQ_DEBUG_SLEEP_INT)
			pr_info("%s, irq %d, still pending %x now\n",
					__func__, i, pending);
		/* Peding IRQ */
		desc = i ? irq_to_desc(i) : NULL;

		/* Check if the pending */
		if (desc && !irqd_is_level_type(&desc->irq_data)) {
			/* Mark the IRQ as pending, if not Level */
			irq_set_pending(i);
			check_irq_resend(desc, i);
		}
	}
}
void msm_mpm_exit_sleep(bool from_idle)
{
#ifndef CONFIG_PM_LOG_SIM_TEST
	unsigned long pending;
	int i;
	int k;

	for (i = 0; i < MSM_MPM_REG_WIDTH; i++) {
		pending = msm_mpm_read(MSM_MPM_STATUS_REG_PENDING, i);

		if (MSM_MPM_DEBUG_PENDING_IRQ & msm_mpm_debug_mask)
			pr_info("%s: pending.%d: 0x%08lx", __func__,
					i, pending);

#ifdef CONFIG_PM_LOG
		pmlog_update_status(i, pending);
#endif //CONFIG_PM_LOG
		k = find_first_bit(&pending, 32);
		while (k < 32) {
			unsigned int mpm_irq = 32 * i + k;
			unsigned int apps_irq = msm_mpm_get_irq_m2a(mpm_irq);
			struct irq_desc *desc = apps_irq ?
				irq_to_desc(apps_irq) : NULL;
			//Print wake up irq to debug power consumption
			/* Terry Cheng, 20120607, Needn't show wake up reason when waking from idle thread {*/
			if(!from_idle)
				printk("mpm_irq = %d, apps_irq = %d\n", mpm_irq, apps_irq);
			/* } Terry Cheng, 20120607, Needn't show wake up reason when waking from idle thread */
			if (desc && !irqd_is_level_type(&desc->irq_data)) {
				irq_set_pending(apps_irq);
				if (from_idle)
					check_irq_resend(desc, apps_irq);
			}

			k = find_next_bit(&pending, 32, k + 1);
		}
	}

	msm_mpm_clear();
#else
	unsigned long pending;
	int i;
	uint rand_interrupt;
	uint rand_which;

	srandom32((uint)jiffies);
	rand_interrupt = random32();
	rand_which = random32();

	//update wake up source
	pending = rand_interrupt % 32;
	pending = 1 << pending;
	i = rand_which % 2;
	//pending = pending % 31;
	
	pr_info("%s: pending.%d: 0x%08lx", __func__, i, pending);		
#ifdef CONFIG_PM_LOG
	pmlog_update_status(i, pending);
#endif	//CONFIG_PM_LOG
	return;	
#endif //CONFIG_PM_LOG_SIM_TEST	
}
void touch_set_irq_pending(unsigned int irq)
{
	TOUCH_D(BASE_INFO, "%s : irq=%d\n", __func__, irq);
	irq_set_pending(irq);
}