Exemplo n.º 1
0
/**
@brief	interrupt handler for a wakeup interrupt

1) Reads the interrupt value\n
2) Performs interrupt handling\n

@param irq	the IRQ number
@param data	the pointer to a data
*/
static irqreturn_t ap_wakeup_interrupt(int irq, void *data)
{
    struct mem_link_device *mld = (struct mem_link_device *)data;
    int ap_wakeup = gpio_get_value(mld->gpio_ap_wakeup);
    int cp_wakeup = gpio_get_value(mld->gpio_cp_wakeup);
    int cpu = raw_smp_processor_id();

    change_irq_type(irq, ap_wakeup);

    if (work_pending(&mld->cp_sleep_dwork.work))
        cancel_delayed_work(&mld->cp_sleep_dwork);

    if (ap_wakeup) {
        mld->last_cp2ap_intr = cpu_clock(cpu);
        if (!cp_wakeup)
            gpio_set_value(mld->gpio_cp_wakeup, 1);

        if (!wake_lock_active(&mld->ap_wlock))
            wake_lock(&mld->ap_wlock);

        if (mipi_lli_get_link_status() == LLI_UNMOUNTED)
            mipi_lli_set_link_status(LLI_WAITFORMOUNT);

        if (!mipi_lli_suspended())
            gpio_set_value(mld->gpio_ap_status, 1);

    } else {
        if (wake_lock_active(&mld->ap_wlock))
            wake_unlock(&mld->ap_wlock);

        if (mipi_lli_get_link_status() & LLI_WAITFORMOUNT)
            mipi_lli_set_link_status(LLI_UNMOUNTED);
        queue_delayed_work(system_nrt_wq, &mld->cp_sleep_dwork,
                           msecs_to_jiffies(sleep_timeout));
    }

    print_pm_status(mld);

    return IRQ_HANDLED;
}
static bool lli_link_suspended(struct link_device *ld)
{
	return mipi_lli_suspended() ? true : false;
}