Exemplo n.º 1
0
static int
msmrtc_suspend(struct platform_device *dev, pm_message_t state)
{
	unsigned secs;
	struct msm_dex_command dex;
	if (rtcalarm_time) {
		unsigned long now = msmrtc_get_seconds();
		int diff = rtcalarm_time - now;
		if (diff <= 0) {
			msmrtc_alarmtimer_expired(1);
			return 0;
		}

		if(max_diff)
			diff = max_diff;

		dex.cmd = PCOM_READ_RTC;
		msm_proc_comm_wince(&dex, &secs);

		printk("Wake up in %d seconds\n",diff);

		dex.cmd = PCOM_SET_ALARM_RTC;
		dex.has_data = 1;
		dex.data = secs + diff;
		msm_proc_comm_wince(&dex, 0);
	}

	return 0;
}
Exemplo n.º 2
0
static int
msmrtc_virtual_alarm_set(struct device *dev, struct rtc_wkalrm *a)
{
	int rc;
	unsigned long now;

	if (!a->enabled) {
		rtcalarm_time = 0;
		return 0;
	} else
		rtc_tm_to_time(&a->time, &rtcalarm_time);

	rc = msmrtc_get_seconds(&now);
	if (rc) {
		pr_err("%s: Unable to read from RTC\n", __func__);
		return rc;
	}

	if (now > rtcalarm_time) {
		pr_err("%s: Attempt to set alarm in the past\n",
		       __func__);
		rtcalarm_time = 0;
		return -EINVAL;
	}

	return 0;
}
Exemplo n.º 3
0
static int
msmrtc_resume(struct platform_device *dev)
{
	if (rtcalarm_time) {
		unsigned long now = msmrtc_get_seconds();
		int diff = rtcalarm_time - now;
		if (diff <= 0)
			msmrtc_alarmtimer_expired(2);
	}
	return 0;
}
Exemplo n.º 4
0
int msmrtc_check(void)
{
	//Force complete resume is rtc alarm time has passed
	unsigned long int secs = msmrtc_get_seconds();
	if(rtcalarm_time && rtcalarm_time <= secs)
	{
//		printk("msmrtc: alarm went off: %d, %d\n", rtcalarm_time, secs);
		return 1;
	}
//	printk("msmrtc: alarm not yet: %d, %d\n", rtcalarm_time, secs);
	return 0;
}
Exemplo n.º 5
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;
}