/**
 * omap_wakeupgen_check_interrupts() - sanity check for pending interrupts
 * @report_string:	what is used to report
 *
 * Return false if there are no pending interrupts, else, if there
 * are pending interrupts, return true.
 *
 * NOTE: if report_string is not NULL, then logic will search beyond
 * the first occurance and report all such pending events. if report_string
 * is NULL, search returns true at the very first occurance of event.
 */
bool omap_wakeupgen_check_interrupts(char *report_string)
{
	int i, k;
	u32 gica, wakea_c0, wakea_c1;
	int ret = false;

	for (i = 0; i < spi_irq_banks - 1; i++) {
		gica = gic_readl(GIC_DIST_PENDING_SET, i + 1);

		/*
		 * HACK: On OMAP4 GP devices 8th (secure) interrupt
		 * is constantly pending and thus preventing suspend.
		 * The source of this interrupt is CONTROL_CORE_SEC_STATUS
		 * register. This register can't be cleared on GP device
		 * because it is accessible for write only from secure
		 * privileged mode. So just ignore 8th interrupt in this check.
		 */
		if (i == 0 && cpu_is_omap44xx() &&
		    (omap_type() == OMAP2_DEVICE_TYPE_GP))
			gica &= ~(1 << 8);

		wakea_c0 = wakeupgen_readl(i, 0);
		wakea_c1 = wakeupgen_readl(i, 1);

		/* If there is nothing pending, nothing to report */
		if (!gica)
			continue;

		/* report register dump for debug */
		pr_debug("%s: %s: IRQ Bank = %d GIC Pending status=0x%08x "
		       "GIC Enable = 0x%08x Wakeupgen Config ="
		       "cpu0=0x%08x cpu1=0x%08x\n",
		       __func__, report_string, i, gica,
		       gic_readl(GIC_DIST_ENABLE_SET, i + 1),
		       wakea_c0, wakea_c1);

		k = 0;
		while (gica) {
			if (gica & 0x1) {
				struct irq_desc *desc;
				const char *name, *wc0, *wc1;
				int irq;

				/* Return true if pending interrupts */
				ret = true;

				/*
				 * we need to search for more ONLY if
				 * there is something to report
				 */
				if (!report_string)
					goto quit_search;

				/* Grab the current wakeup state for CPU0,1 */
				wc0 = (wakea_c0 & 0x1) ? "yes" : "no";
				wc1 = (wakea_c1 & 0x1) ? "yes" : "no";
				/* Since we skip GIC PPI and SGI, base 32 */
				irq = 32 + i * 32 + k;
				desc = irq_to_desc(irq);
				if (desc && desc->action &&
				    desc->action->name) {
					name = desc->action->name;
				} else if (irq == OMAP44XX_IRQ_PRCM) {
					name = NULL;
					print_prcm_wakeirq(irq, report_string);
				} else {
					name = "unknown";
				}

				if (name)
					pr_info("%s: IRQ %d(%s)(OMAP-IRQ=%d) "\
						"Pending! Wakeup Enable: "\
						"CPU0=%s,CPU1=%s\n",
						report_string, irq, name,
						(irq - 32), wc0, wc1);
			}
			k++;
			gica >>= 1;
			wakea_c0 >>= 1;
			wakea_c1 >>= 1;
		}
	}

quit_search:
	return ret;
}
Example #2
0
/**
 * omap_wakeupgen_check_interrupts() - sanity check for pending interrupts
 * @report_string:	what is used to report
 *
 * Return false if there are no pending interrupts, else, if there
 * are pending interrupts, return true.
 *
 * NOTE: if report_string is not NULL, then logic will search beyond
 * the first occurance and report all such pending events. if report_string
 * is NULL, search returns true at the very first occurance of event.
 */
bool omap_wakeupgen_check_interrupts(char *report_string)
{
	int i, k;
	u32 gica, wakea_c0, wakea_c1;
	int ret = false;

	for (i = 0; i < spi_irq_banks - 1; i++) {
		gica = gic_readl(GIC_DIST_PENDING_SET, i + 1);
		wakea_c0 = wakeupgen_readl(i, 0);
		wakea_c1 = wakeupgen_readl(i, 1);

		/* If there is nothing pending, nothing to report */
		if (!gica)
			continue;

		/* report register dump for debug */
		pr_debug("%s: %s: IRQ Bank = %d GIC Pending status=0x%08x "
		       "GIC Enable = 0x%08x Wakeupgen Config ="
		       "cpu0=0x%08x cpu1=0x%08x\n",
		       __func__, report_string, i, gica,
		       gic_readl(GIC_DIST_ENABLE_SET, i + 1),
		       wakea_c0, wakea_c1);

		k = 0;
		while (gica) {
			if (gica & 0x1) {
				struct irq_desc *desc;
				const char *name, *wc0, *wc1;
				int irq;

				/* Return true if pending interrupts */
				ret = true;

				/*
				 * we need to search for more ONLY if
				 * there is something to report
				 */
				if (!report_string)
					goto quit_search;

				/* Grab the current wakeup state for CPU0,1 */
				wc0 = (wakea_c0 & 0x1) ? "yes" : "no";
				wc1 = (wakea_c1 & 0x1) ? "yes" : "no";
				/* Since we skip GIC PPI and SGI, base 32 */
				irq = 32 + i * 32 + k;
				desc = irq_to_desc(irq);
				if (desc && desc->action &&
				    desc->action->name) {
					name = desc->action->name;
				} else if (irq == OMAP44XX_IRQ_PRCM) {
					name = NULL;
					print_prcm_wakeirq(irq, report_string);
				} else {
					name = "unknown";
				}

				if (name)
					pr_info("%s: IRQ %d(%s)(OMAP-IRQ=%d) "\
						"Pending! Wakeup Enable: "\
						"CPU0=%s,CPU1=%s\n",
						report_string, irq, name,
						(irq - 32), wc0, wc1);
			}
			k++;
			gica >>= 1;
			wakea_c0 >>= 1;
			wakea_c1 >>= 1;
		}
	}

quit_search:
	return ret;
}