Exemple #1
0
static int tegra_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
	NvU32 now;
#if SYNC_EXTERNAL_RTC_TO_INTERNAL_RTC
        struct rtc_time iner_rtc_tm;
        unsigned long iner_now;
        int ret = 0;
#endif

	if (hPmu == NULL)
		return -1;

	if (!NvOdmPmuReadRtc(hPmu, &now)) {
		printk("NvOdmPmuReadRtc failed\n");
		return -1;
	}

	rtc_time_to_tm(now, tm);

#if SYNC_EXTERNAL_RTC_TO_INTERNAL_RTC
        /* Read internal RTC time, if there are different, set internal rtc with external rtc time */
        ret = internal_tegra_rtc_read_time(&iner_rtc_tm);
        if(ret) return ret;
        
        ret = rtc_tm_to_time(&iner_rtc_tm, &iner_now);
        if((ret == 0) && (now != iner_now)) {
                ret = internal_tegra_rtc_set_time(tm); /* Set internal rtc with external rtc time */
        }

        return ret;
#else
	return 0;
#endif
}
static int tegra_rtc_set_time(struct device *dev, struct rtc_time *tm)
{
	unsigned long now;
	int ret;

	if (hPmu == NULL)
		return -1;

	ret = rtc_tm_to_time(tm, &now);
	if (ret != 0)
		return -1;

	if (!NvOdmPmuWriteRtc(hPmu, (NvU32)now)) {
		printk("NvOdmPmuWriteRtc failed\n");
		return -1;
	}
#if SYNC_EXTERNAL_RTC_TO_INTERNAL_RTC
        return internal_tegra_rtc_set_time(tm);
#else
	return 0;
#endif
}