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;
}
Ejemplo n.º 2
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;
}
Ejemplo n.º 3
0
static unsigned long msmrtc_get_seconds(void)
{
	struct rtc_time tm;
	unsigned long now;

	msmrtc_timeremote_read_time(NULL, &tm);
	rtc_tm_to_time(&tm, &now);
	return now;
}
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;
}
Ejemplo n.º 5
0
static int
msmrtc_resume(struct platform_device *dev)
{
	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(2);
	}
	return 0;
}
Ejemplo n.º 6
0
static int
msmrtc_get_seconds(unsigned long *ret_now)
{
	int rc;
	struct rtc_time tm;
	unsigned long now;

	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);

	if (ret_now) {
		*ret_now = now;
	}

	return 0;
}
Ejemplo n.º 7
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;
}
Ejemplo n.º 8
0
static int
msmrtc_resume(struct platform_device *dev)
{
	int rc, diff;
	struct rtc_time tm;
	unsigned long now;
	struct msm_rtc *rtc_pdata = platform_get_drvdata(dev);

	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(2 , rtc_pdata);
	}
	return 0;
}
Ejemplo n.º 9
0
static int
msmrtc_probe(struct platform_device *pdev)
{
	int rc;
	struct rpcsvr_platform_device *rdev =
		container_of(pdev, struct rpcsvr_platform_device, base);
	uint32_t prog_version;
#ifdef CONFIG_MACH_ACER_A4
	struct rtc_time tm;
#endif
	if (pdev->id == (TIMEREMOTE_PROG_VER_1 & RPC_VERSION_MAJOR_MASK))
		prog_version = TIMEREMOTE_PROG_VER_1;
	else if (pdev->id == (TIMEREMOTE_PROG_VER_2 &
			      RPC_VERSION_MAJOR_MASK))
		prog_version = TIMEREMOTE_PROG_VER_2;
	else
		return -EINVAL;

	rpc_client = msm_rpc_register_client("rtc", rdev->prog,
				prog_version, 1, msmrtc_cb_func);
	if (IS_ERR(rpc_client)) {
		pr_err("%s: init RPC failed! VERS = %x\n", __func__,
					prog_version);
		return PTR_ERR(rpc_client);
	}
#ifdef CONFIG_MACH_ACER_A4
	/* Set the default system time to 2010-10-01 00:00:00 UTC.
	 */
	msmrtc_timeremote_read_time(&pdev->dev, &tm);
	if (tm.tm_year < 90) {
		tm.tm_year = 110; /* RTC layer expects years to start at 1900 */
		tm.tm_mon  = 9;  /* RTC layer expects mons to be 0 based */
		tm.tm_mday = 1;
		tm.tm_hour = 0;
		tm.tm_min  = 0;
		tm.tm_sec  = 0;
		tm.tm_wday = 4;   /* 2010-10-01 is Fri. */
		msmrtc_timeremote_set_time(&pdev->dev, &tm);
	}
#endif
	/*
	 * Set up the callback client.
	 * For older targets this initialization will fail
	 */
	rc = msmrtc_setup_cb();
	if (rc)
		pr_debug("%s: Could not initialize RPC callback\n",
								__func__);

	rtc = rtc_device_register("msm_rtc",
				  &pdev->dev,
				  &msm_rtc_ops,
				  THIS_MODULE);
	if (IS_ERR(rtc)) {
		printk(KERN_ERR "%s: Can't register RTC device (%ld)\n",
		       pdev->name, PTR_ERR(rtc));
		rc = PTR_ERR(rtc);
		goto fail_cb_setup;
	}

#ifdef CONFIG_RTC_SECURE_TIME_SUPPORT
	rtcsecure = rtc_device_register("msm_rtc_secure",
				  &pdev->dev,
				  &msm_rtc_ops_secure,
				  THIS_MODULE);

	if (IS_ERR(rtcsecure)) {
		printk(KERN_ERR "%s: Can't register RTC Secure device (%ld)\n",
		       pdev->name, PTR_ERR(rtcsecure));
		rtc_device_unregister(rtc);
		rc = PTR_ERR(rtcsecure);
		goto fail_cb_setup;
	}
#endif

	return 0;

fail_cb_setup:
	msm_rpc_unregister_client(rpc_client);
	return rc;
}
Ejemplo n.º 10
0
static int __devinit
msmrtc_probe(struct platform_device *pdev)
{
	int rc;
	struct msm_rtc *rtc_pdata = NULL;
	struct rpcsvr_platform_device *rdev =
		container_of(pdev, struct rpcsvr_platform_device, base);
	uint32_t prog_version;
#if defined(CONFIG_MACH_ACER_A4) || defined(CONFIG_MACH_ACER_A5)
	struct rtc_time tm;
#endif


	if (pdev->id == (TIMEREMOTE_PROG_VER_1 & RPC_VERSION_MAJOR_MASK))
		prog_version = TIMEREMOTE_PROG_VER_1;
	else if (pdev->id == (TIMEREMOTE_PROG_VER_2 &
			      RPC_VERSION_MAJOR_MASK))
		prog_version = TIMEREMOTE_PROG_VER_2;
	else
		return -EINVAL;

	rtc_pdata = kzalloc(sizeof(*rtc_pdata), GFP_KERNEL);
	if (rtc_pdata == NULL) {
		dev_err(&pdev->dev,
			"%s: Unable to allocate memory\n", __func__);
		return -ENOMEM;
	}
	rtc_pdata->rpc_client = msm_rpc_register_client("rtc", rdev->prog,
				prog_version, 1, msmrtc_cb_func);
	if (IS_ERR(rtc_pdata->rpc_client)) {
		dev_err(&pdev->dev,
			 "%s: init RPC failed! VERS = %x\n", __func__,
					prog_version);
		rc = PTR_ERR(rtc_pdata->rpc_client);
		kfree(rtc_pdata);
		return rc;
	}

	/*
	 * Set up the callback client.
	 * For older targets this initialization will fail
	 */
	rc = msmrtc_setup_cb(rtc_pdata);
	if (rc)
		dev_dbg(&pdev->dev, "%s: Could not initialize RPC callback\n",
								__func__);

	rtc_pdata->rtcalarm_time = 0;
	platform_set_drvdata(pdev, rtc_pdata);

#if defined(CONFIG_MACH_ACER_A4) || defined(CONFIG_MACH_ACER_A5)
	/* Set the default system time to 2011-03-01 00:00:00 UTC.
	 */
	msmrtc_timeremote_read_time(&pdev->dev, &tm);
	if (tm.tm_year < 90) {
		tm.tm_year = 111; /* RTC layer expects years to start at 1900 */
		tm.tm_mon  = 2;   /* RTC layer expects mons to be 0 based */
		tm.tm_mday = 1;
		tm.tm_hour = 0;
		tm.tm_min  = 0;
		tm.tm_sec  = 0;
		tm.tm_wday = 1;   /* 2011-03-01 is Tuesday */
		msmrtc_timeremote_set_time(&pdev->dev, &tm);
	}
#endif

	rtc_pdata->rtc = rtc_device_register("msm_rtc",
				  &pdev->dev,
				  &msm_rtc_ops,
				  THIS_MODULE);
	if (IS_ERR(rtc_pdata->rtc)) {
		dev_err(&pdev->dev, "%s: Can't register RTC device (%ld)\n",
		       pdev->name, PTR_ERR(rtc_pdata->rtc));
		rc = PTR_ERR(rtc_pdata->rtc);
		goto fail_cb_setup;
	}

#ifdef CONFIG_RTC_SECURE_TIME_SUPPORT
	rtc_pdata->rtcsecure = rtc_device_register("msm_rtc_secure",
				  &pdev->dev,
				  &msm_rtc_ops_secure,
				  THIS_MODULE);

	if (IS_ERR(rtc_pdata->rtcsecure)) {
		dev_err(&pdev->dev,
			"%s: Can't register RTC Secure device (%ld)\n",
		       pdev->name, PTR_ERR(rtc_pdata->rtcsecure));
		rtc_device_unregister(rtc_pdata->rtc);
		rc = PTR_ERR(rtc_pdata->rtcsecure);
		goto fail_cb_setup;
	}
#endif

#ifdef CONFIG_RTC_ASYNC_MODEM_SUPPORT
	rtc_hctosys();
#endif

	return 0;

fail_cb_setup:
	msm_rpc_unregister_client(rtc_pdata->rpc_client);
	kfree(rtc_pdata);
	return rc;
}