diff mbox

Re: mfd: tps6586x: add RTC driver for TI TPS6586x

Message ID 0b35872f-1965-48e3-903e-37aac37f14ae@r19g2000prm.googlegroups.com
State Superseded
Headers show

Commit Message

Wei Ni March 17, 2011, 10:56 a.m. UTC
Hi, Varun
As comments in https://code.google.com/p/chrome-os-partner/issues/detail?id=1937#makechanges,
I update the rtc-tps6586x.c as following:
1. add OSC_SRC_SEL to select external crystal clock
2. there have some error when using the function tps6586x_update(), we
should set the right value and mask
3. set alrm->enabled, 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 disable/enable_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");
diff mbox

Patch

--- rtc-tps6586x.c-orig	2011-03-17 18:19:37.783627510 +0800
+++ rtc-tps6586x.c	2011-03-17 18:43:51.293624552 +0800
@@ -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 = {