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; }
void soc_sleep(device_sleep_t dev) { save_my_context(dev); if (dev == SOC_SLEEP) { start_rtc(); QM_PUTS("SoC going to sleep"); POWER_SOC_DEEP_SLEEP(); } else { QM_PUTS("Core going to sleep"); POWER_SLEEP_WAIT(); } restore_my_context(dev); clear_flags(); #if !QM_SENSOR if (other_core_sleep_flag()) { sensor_activation(); } #endif }
int main(void) { bool do_soc_sleep, sleep_ready; int current_state = 0; QM_PRINTF("Starting: Sleep multicore %s\n", MYNAME); #if !QM_SENSOR sensor_activation(); #endif init_mailbox(); while (current_state < 5) { clk_sys_udelay(DELAY_1_SECOND); state_machine(current_state, &sleep_ready, &do_soc_sleep); /* * In that order, we can force the race condition when both * request sleep. */ if (do_soc_sleep) { request_soc_sleep(); current_state++; } else if (mbox_cb_fired) { mbox_cb_fired = false; qm_mbox_ch_read(mbox_rx, &rx_data); if (rx_data.ctrl == SLEEP_REQ) { soc_sleep_requested(sleep_ready); current_state++; } } } QM_PRINTF("Finished: Sleep multicore %s\n", MYNAME); return 0; }