Comments
Patch
@@ -30,6 +30,7 @@
#include <linux/slab.h>
#define RTC_CTRL 0xc0
+#define OSC_SRC_SEL BIT(6) /* select internal or external clock */
#define RTC_ENABLE BIT(5) /* enables alarm */
#define RTC_HIRES BIT(4) /* 1Khz or 32Khz updates */
#define RTC_ALARM1_HI 0xc1
@@ -180,6 +181,7 @@
seconds += rtc->epoch_start;
rtc_time_to_tm(seconds, &alrm->time);
+ alrm->enabled = rtc->irq_en;
return 0;
}
@@ -286,7 +288,8 @@
/* disable high-res mode, enable tick counting */
err = tps6586x_update(tps_dev, RTC_CTRL,
- (RTC_ENABLE | RTC_HIRES), RTC_ENABLE);
+ (RTC_ENABLE | OSC_SRC_SEL), (RTC_ENABLE | OSC_SRC_SEL));
+
if (err < 0) {
dev_err(&pdev->dev, "unable to start counter\n");
goto fail;
@@ -303,7 +306,7 @@
rtc->irq = -1;
} else {
disable_irq(rtc->irq);
- enable_irq_wake(rtc->irq);
+ rtc->irq_en = false;
}
}
@@ -327,6 +330,24 @@
return 0;
}
+static int tps6586x_rtc_suspend(struct platform_device *pdev,
pm_message_t state)
+{
+ struct tps6586x_rtc *rtc = dev_get_drvdata(&pdev->dev);
+
+ if (device_may_wakeup(pdev))
+ enable_irq_wake(rtc->irq);
+ return 0;
+}
+
+static int tps6586x_rtc_resume(struct platform_device *pdev)
+{
+ struct tps6586x_rtc *rtc = dev_get_drvdata(&pdev->dev);
+
+ if (device_may_wakeup(pdev))
+ disable_irq_wake(rtc->irq);
+ return 0;
+}
+
static struct platform_driver tps6586x_rtc_driver = {
.driver = {
Hi, Varun As comments in https://code.google.com/p/chrome-os-partner/issues/detail?id=1937#makechanges, I update rtc-tps6586x.c as following: 1. set OSC_SRC_SEL to select external external crystal clock 2. there has some error when using the function tps6586x_update(), we should set right value and mask. 3. the alrm->enable should be set. this value didn't be set, but be used in some function. 4. init the rtc->irq_en in the probe callback 5. add suspend/resume callback, and call enable/disable_irq_wake in here Please check it, thanks .name = "tps6586x-rtc", @@ -334,6 +355,8 @@ }, .probe = tps6586x_rtc_probe, .remove = __devexit_p(tps6586x_rtc_remove), + .suspend = tps6586x_rtc_suspend, + .resume = tps6586x_rtc_resume, }; static int __init tps6586x_rtc_init(void) @@ -351,4 +374,4 @@ MODULE_DESCRIPTION("TI TPS6586x RTC driver"); MODULE_AUTHOR("NVIDIA Corporation"); MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:rtc-tps6586x") +MODULE_ALIAS("platform:rtc-tps6586x");