Пример #1
0
void power_sleep_wait()
{
	/*
	 * Save x86 restore trap address.
	 * The first parameter in this macro represents the label defined in
	 * the qm_x86_restore_context() macro, which is actually the restore
	 * trap address.
	 */
	qm_x86_set_resume_vector(sleep_restore_trap, __x86_restore_info);

	/* Save x86 execution context. */
	qm_x86_save_context(sp_restore_storage);

	/* Set restore flags. */
	power_soc_set_x86_restore_flag();

	/* Enter C2 and stay in it until sleep and wake-up. */
	while (1) {
		power_cpu_c2();
	}

	/*
	 * Restore x86 execution context.
	 * The bootloader code will jump to this location after waking up from
	 * sleep. The restore trap address is the label defined in the macro.
	 * That label is exposed here through the first parameter.
	 */
	qm_x86_restore_context(sleep_restore_trap, sp_restore_storage);
}
Пример #2
0
int main(void)
{
    qm_gpio_port_config_t cfg;

    sensor_activation();

    QM_PUTS("Starting: Power LPSS");

    /* Set GPIO pin muxing. */
    qm_pmux_select(PIN_OUT, QM_PMUX_FN_0);
    qm_pmux_select(PIN_INTR, QM_PMUX_FN_0);

    /* Request IRQ and write GPIO port config. */
    cfg.direction = BIT(PIN_OUT);     /* Set PIN_OUT as output. */
    cfg.int_en = BIT(PIN_INTR);       /* Interrupt enabled. */
    cfg.int_type = BIT(PIN_INTR);     /* Edge sensitive interrupt. */
    cfg.int_polarity = BIT(PIN_INTR); /* Rising edge. */
    cfg.int_debounce = BIT(PIN_INTR); /* Debounce enabled. */
    cfg.int_bothedge = 0x0;		  /* Both edge disabled. */
    cfg.callback = NULL;
    cfg.callback_data = NULL;

    qm_irq_request(QM_IRQ_GPIO_0_INT, qm_gpio_0_isr);

    qm_gpio_set_config(QM_GPIO_0, &cfg);

    QM_PUTS("Go to LPSS with x86 core in C2.");

    /* Wait for the Sensor Subsystem to be ready to transition to LPSS. */
    while (!(QM_SCSS_GP->gps2 & QM_SCSS_GP_SENSOR_READY))
        ;

    /*
     * Go to C2. Sensor Subsystem will perform the transition to LPSS.
     * Once woken up, SS will wake up the x86 core with the GPIO interrupt.
     */
    power_cpu_c2();

    QM_PUTS("Wake up from LPSS.");

    QM_PUTS("Go to LPSS with x86 core in C2LP.");

    /* Wait for the Sensor Subsystem to be ready to transition to LPSS. */
    while (!(QM_SCSS_GP->gps2 & QM_SCSS_GP_SENSOR_READY))
        ;

    /*
     * Go to C2LP. Sensor Subsystem will perform the transition to LPSS.
     * Once woken up, SS will wake up the x86 core with the GPIO interrupt.
     */
    power_cpu_c2lp();

    QM_PUTS("Wake up from LPSS.");

    QM_PUTS("Finished: Power LPSS");

    return 0;
}