static int msmrtc_suspend(struct platform_device *dev, pm_message_t state) { int rc, diff; struct rtc_time tm; unsigned long now; struct msm_rtc *rtc_pdata = platform_get_drvdata(dev); suspend_state.tick_at_suspend = msm_timer_get_sclk_time(NULL); if (rtc_pdata->rtcalarm_time) { rc = msmrtc_timeremote_read_time(&dev->dev, &tm); if (rc) { dev_err(&dev->dev, "%s: Unable to read from RTC\n", __func__); return rc; } rtc_tm_to_time(&tm, &now); diff = rtc_pdata->rtcalarm_time - now; if (diff <= 0) { msmrtc_alarmtimer_expired(1 , rtc_pdata); msm_pm_set_max_sleep_time(0); atomic_inc(&suspend_state.state); return 0; } msm_pm_set_max_sleep_time((int64_t) ((int64_t) diff * NSEC_PER_SEC)); } else msm_pm_set_max_sleep_time(0); atomic_inc(&suspend_state.state); return 0; }
static int msmrtc_suspend(struct platform_device *dev, pm_message_t state) { int rc, diff; struct rtc_time tm; unsigned long now; if (rtcalarm_time) { rc = msmrtc_timeremote_read_time(NULL, &tm); if (rc) { pr_err("%s: Unable to read from RTC\n", __func__); return rc; } rtc_tm_to_time(&tm, &now); diff = rtcalarm_time - now; if (diff <= 0) { msmrtc_alarmtimer_expired(1); msm_pm_set_max_sleep_time(0); return 0; } msm_pm_set_max_sleep_time((int64_t) ((int64_t) diff * NSEC_PER_SEC)); } else msm_pm_set_max_sleep_time(0); return 0; }
static int msmrtc_suspend(struct platform_device *dev, pm_message_t state) { int rc, diff; struct rtc_time tm; unsigned long now; struct msm_rtc *rtc_pdata = platform_get_drvdata(dev); suspend_state.tick_at_suspend = msm_timer_get_sclk_time(NULL); if (rtc_pdata->rtcalarm_time) { rc = msmrtc_timeremote_read_time(&dev->dev, &tm); if (rc) { dev_err(&dev->dev, "%s: Unable to read from RTC\n", __func__); return rc; } rtc_tm_to_time(&tm, &now); diff = rtc_pdata->rtcalarm_time - now; if (diff <= 0) { msmrtc_alarmtimer_expired(1 , rtc_pdata); msm_pm_set_max_sleep_time(0); /* CR 293735 - Function/Feature Failure (Partial) * When system was in suspend, could make invalid "elapsed system time" at AP side. * * Problem description * When system is in suspend mode and if more than one network time update * comes while system is in suspend mode then the uptime gets corrupted. * * Failure frequency: Occasionally * Scenario frequency: Uncommon * Change description * Added change to modify tick_at_suspend (variable that stores time tick * while entering suspend) after each update to the current time tick. * Setting the suspend mode variable in case alarm time expires the current * RTC time as in thic case also system enters suspend mode. * to sdcc irq handlers returning IRQ_NONE without handling the interrupt. * When interrupt is disabled the communication between the SDIO client and * SDCC host controller is stopped while a pending command is in progress * and hence WLAN operation is stuck forever and LOGP recovery cannot be * processed. * Files affected * arch/arm/mach-msm/rpc_server_time_remote.c * drivers/rtc/rtc-msm.c * include/linux/rtc-msm.h */ #if 1 //QCT SBA 404017 atomic_inc(&suspend_state.state); #endif return 0; } msm_pm_set_max_sleep_time((int64_t) ((int64_t) diff * NSEC_PER_SEC)); } else msm_pm_set_max_sleep_time(0); atomic_inc(&suspend_state.state); return 0; }
static int msmrtc_suspend(struct platform_device *dev, pm_message_t state) { if (rtcalarm_time) { unsigned long now = msmrtc_get_seconds(); int diff = rtcalarm_time - now; if (diff <= 0) { msmrtc_alarmtimer_expired(1); msm_pm_set_max_sleep_time(0); return 0; } msm_pm_set_max_sleep_time((int64_t) ((int64_t) diff * NSEC_PER_SEC)); } else msm_pm_set_max_sleep_time(0); return 0; }
static int msmrtc_suspend(struct platform_device *dev, pm_message_t state) { int rc, diff; struct rtc_time tm; unsigned long now; if (rtcalarm_time) { rc = msmrtc_timeremote_read_time(NULL, &tm); if (rc) { pr_err("%s: Unable to read from RTC\n", __func__); return rc; } rtc_tm_to_time(&tm, &now); diff = rtcalarm_time - now; /* Div2-SW2-BSP-FBX-BATT { */ #ifdef CONFIG_BATTERY_FIH_MSM if (diff > RPC_wakeup_cycle_time && RPC_wakeup_cycle_time != 0) diff = RPC_wakeup_cycle_time; #endif /* } Div2-SW2-BSP-FBX-BATT */ if (diff <= 0) { msmrtc_alarmtimer_expired(1); msm_pm_set_max_sleep_time(0); return 0; } msm_pm_set_max_sleep_time((int64_t) ((int64_t) diff * NSEC_PER_SEC)); } else /* Div2-SW2-BSP-FBX-BATT { */ #ifdef CONFIG_BATTERY_FIH_MSM msm_pm_set_max_sleep_time((int64_t) ((int64_t) RPC_wakeup_cycle_time * NSEC_PER_SEC)); #else msm_pm_set_max_sleep_time(0); #endif /* } Div2-SW2-BSP-FBX-BATT */ return 0; }
static int max17040_suspend(struct i2c_client *client, pm_message_t state) { int time =0; int soc=max17040_data.soc; dbg_func_in(); /* If we are on battery, reduce our update rate until * we next resume. */ /*ps2 team shs : Runs only when the cable is not connected.*/ max17040_data.online=sky_get_plug_state(); max17040_data.slow_poll = Early_suspend; //ps1 team shs : cancel schedule_delayer_work cancel_delayed_work(&max17040_data.work); //ps1 team shs : set time time=max17040_sleep_time(soc); msm_pm_set_max_sleep_time((int64_t)((int64_t) time * NSEC_PER_SEC)); sleep_dbg("[SUSPEND] set time [%d] seconds : soc [%d] ]\n",time,soc); dbg_func_out(); return 0; }
/* * Suspend the Apps processor. * * Return value: * -EPERM: Suspend happened by a not permitted core * -EAGAIN: modem reset occurred or early exit from suspend * -EBUSY: modem not ready for our suspend * -EINVAL: invalid sleep mode * -EIO: could not ramp Apps processor clock * -ETIMEDOUT: timed out waiting for modem's handshake * 0: success */ static int msm_pm_enter(suspend_state_t state) { bool allow[MSM_PM_SLEEP_MODE_NR]; uint32_t sleep_limit = SLEEP_LIMIT_NONE; int ret = -EPERM; int i; int64_t period = 0; int64_t time = 0; /* Must executed by CORE0 */ if (smp_processor_id()) { __WARN(); goto suspend_exit; } time = msm_pm_timer_enter_suspend(&period); MSM_PM_DPRINTK(MSM_PM_DEBUG_SUSPEND, KERN_INFO, "%s(): sleep limit %u\n", __func__, sleep_limit); for (i = 0; i < ARRAY_SIZE(allow); i++) allow[i] = true; for (i = 0; i < ARRAY_SIZE(allow); i++) { struct msm_pm_platform_data *mode; mode = &msm_pm_modes[MSM_PM_MODE(0, i)]; if (!mode->suspend_supported || !mode->suspend_enabled) allow[i] = false; } if (allow[MSM_PM_SLEEP_MODE_POWER_COLLAPSE] || allow[MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN]) { enum msm_pm_time_stats_id id; clock_debug_print_enabled(); #ifdef CONFIG_MSM_SLEEP_TIME_OVERRIDE if (msm_pm_sleep_time_override > 0) { int64_t ns; ns = NSEC_PER_SEC * (int64_t)msm_pm_sleep_time_override; msm_pm_set_max_sleep_time(ns); msm_pm_sleep_time_override = 0; } #endif if (!allow[MSM_PM_SLEEP_MODE_POWER_COLLAPSE]) sleep_limit = SLEEP_LIMIT_NO_TCXO_SHUTDOWN; #if defined(CONFIG_MSM_MEMORY_LOW_POWER_MODE_SUSPEND_ACTIVE) sleep_limit |= SLEEP_RESOURCE_MEMORY_BIT1; #elif defined(CONFIG_MSM_MEMORY_LOW_POWER_MODE_SUSPEND_RETENTION) sleep_limit |= SLEEP_RESOURCE_MEMORY_BIT0; #elif defined(CONFIG_MSM_MEMORY_LOW_POWER_MODE_SUSPEND_DEEP_POWER_DOWN) if (get_msm_migrate_pages_status() != MEM_OFFLINE) sleep_limit |= SLEEP_RESOURCE_MEMORY_BIT0; #endif for (i = 0; i < 30 && msm_pm_modem_busy(); i++) udelay(500); ret = msm_pm_power_collapse( false, msm_pm_max_sleep_time, sleep_limit); if (ret) id = MSM_PM_STAT_FAILED_SUSPEND; else { id = MSM_PM_STAT_SUSPEND; msm_pm_sleep_limit = sleep_limit; } time = msm_pm_timer_exit_suspend(time, period); msm_pm_add_stat(id, time); } else if (allow[MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE]) { ret = msm_pm_power_collapse_standalone(false); } else if (allow[MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT]) { ret = msm_pm_swfi(true); if (ret) while (!msm_pm_irq_extns->irq_pending()) udelay(1); } else if (allow[MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT]) { msm_pm_swfi(false); } suspend_exit: MSM_PM_DPRINTK(MSM_PM_DEBUG_SUSPEND, KERN_INFO, "%s(): return %d\n", __func__, ret); return ret; }