summaryrefslogtreecommitdiff
path: root/drivers/rtc
diff options
context:
space:
mode:
authorMarcel Ziswiler <marcel.ziswiler@toradex.com>2012-11-12 15:28:39 +0100
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2012-11-12 15:28:39 +0100
commitf987e832a9e79d2ce8009a5ea9c7b677624b3b30 (patch)
tree0dd09a5e6b4c60ee0a9916907dfc2cda83f3e496 /drivers/rtc
parentf737b7f46a72c099cf8ac88baff02fbf61b1a47c (diff)
parentfc993d9bc48f772133d8cd156c67c296477db070 (diff)
Merge branch 'l4t/l4t-r16-r2' into colibri
Conflicts: arch/arm/mach-tegra/tegra3_usb_phy.c arch/arm/mach-tegra/usb_phy.c drivers/usb/gadget/tegra_udc.c drivers/usb/otg/Makefile drivers/video/tegra/fb.c sound/soc/tegra/tegra_pcm.c
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/Makefile1
-rw-r--r--drivers/rtc/alarm.c1
-rw-r--r--drivers/rtc/rtc-max77663.c11
-rw-r--r--drivers/rtc/rtc-tps6591x.c28
-rw-r--r--drivers/rtc/rtc-tps80031.c12
5 files changed, 42 insertions, 11 deletions
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index be5b16284db0..249c25d2df88 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -102,6 +102,7 @@ obj-$(CONFIG_RTC_DRV_STARFIRE) += rtc-starfire.o
obj-$(CONFIG_RTC_DRV_STK17TA8) += rtc-stk17ta8.o
obj-$(CONFIG_RTC_DRV_STMP) += rtc-stmp3xxx.o
obj-$(CONFIG_RTC_DRV_SUN4V) += rtc-sun4v.o
+CFLAGS_rtc-tegra.o = -Werror
obj-$(CONFIG_RTC_DRV_TEGRA) += rtc-tegra.o
obj-$(CONFIG_RTC_DRV_TEST) += rtc-test.o
obj-$(CONFIG_RTC_DRV_TILE) += rtc-tile.o
diff --git a/drivers/rtc/alarm.c b/drivers/rtc/alarm.c
index 28b0df836a30..12e6f3c8acfb 100644
--- a/drivers/rtc/alarm.c
+++ b/drivers/rtc/alarm.c
@@ -33,6 +33,7 @@
#define ANDROID_ALARM_PRINT_FLOW (1U << 6)
static int debug_mask = ANDROID_ALARM_PRINT_ERROR | \
+ ANDROID_ALARM_PRINT_SUSPEND | \
ANDROID_ALARM_PRINT_INIT_STATUS;
module_param_named(debug_mask, debug_mask, int, S_IRUGO | S_IWUSR | S_IWGRP);
diff --git a/drivers/rtc/rtc-max77663.c b/drivers/rtc/rtc-max77663.c
index 13d8062e1def..d6dac76944d6 100644
--- a/drivers/rtc/rtc-max77663.c
+++ b/drivers/rtc/rtc-max77663.c
@@ -227,9 +227,10 @@ static inline int max77663_rtc_tm_to_reg(struct max77663_rtc *rtc, u8 *buf,
/* The wday is configured only when disabled alarm. */
if (!alarm)
buf[RTC_WEEKDAY] = (1 << tm->tm_wday);
- else
- buf[RTC_WEEKDAY] = 0;
-
+ else {
+ /* Configure its default reset value 0x01, and not enable it. */
+ buf[RTC_WEEKDAY] = 0x01;
+ }
return 0;
}
@@ -431,9 +432,9 @@ static int max77663_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
alrm->time.tm_wday);
if (rtc->irq_mask & RTC_IRQ_ALARM1_MASK)
- alrm->enabled = 1;
- else
alrm->enabled = 0;
+ else
+ alrm->enabled = 1;
return 0;
}
diff --git a/drivers/rtc/rtc-tps6591x.c b/drivers/rtc/rtc-tps6591x.c
index ebc46b4cf46e..9644dc4afb42 100644
--- a/drivers/rtc/rtc-tps6591x.c
+++ b/drivers/rtc/rtc-tps6591x.c
@@ -106,6 +106,7 @@ static int tps6591x_write_regs(struct device *dev, int reg, int len,
static int tps6591x_rtc_valid_tm(struct rtc_time *tm)
{
if (tm->tm_year >= (RTC_YEAR_OFFSET + 99)
+ || tm->tm_year < (RTC_YEAR_OFFSET)
|| tm->tm_mon >= 12
|| tm->tm_mday < 1
|| tm->tm_mday > rtc_month_days(tm->tm_mon, tm->tm_year + OS_REF_YEAR)
@@ -245,6 +246,12 @@ static int tps6591x_rtc_set_time(struct device *dev, struct rtc_time *tm)
u8 buff[7];
int err;
+ err = tps6591x_rtc_valid_tm(tm);
+ if (err < 0) {
+ dev_err(dev->parent, "\n Invalid Time\n");
+ return err;
+ }
+
buff[0] = tm->tm_sec;
buff[1] = tm->tm_min;
buff[2] = tm->tm_hour;
@@ -323,6 +330,12 @@ static int tps6591x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
if (rtc->irq == -1)
return -EIO;
+ err = tps6591x_rtc_valid_tm(&alrm->time);
+ if (err < 0) {
+ dev_err(dev->parent, "\n Invalid alarm time\n");
+ return err;
+ }
+
dev_info(dev->parent, "\n setting alarm to requested time::\n");
print_time(dev->parent, &alrm->time);
rtc_tm_to_time(&alrm->time, &seconds);
@@ -461,13 +474,20 @@ static int __devinit tps6591x_rtc_probe(struct platform_device *pdev)
return -EBUSY;
}
+ err = tps6591x_rtc_start(&pdev->dev);
+ if (err) {
+ dev_err(&pdev->dev, "unable to start RTC\n");
+ return -EBUSY;
+ }
+
tps6591x_rtc_read_time(&pdev->dev, &tm);
- if ((tm.tm_year < RTC_YEAR_OFFSET || tm.tm_year > (RTC_YEAR_OFFSET + 99))){
- if (pdata->time.tm_year < 2000 || pdata->time.tm_year > 2100) {
+
+ if (tps6591x_rtc_valid_tm(&tm) < 0) {
+ if (pdata->time.tm_year < 2000 || pdata->time.tm_year >= 2100) {
memset(&pdata->time, 0, sizeof(pdata->time));
- pdata->time.tm_year = RTC_YEAR_OFFSET;
+ pdata->time.tm_year = 2000;
pdata->time.tm_mday = 1;
- } else
+ }
pdata->time.tm_year -= OS_REF_YEAR;
tps6591x_rtc_set_time(&pdev->dev, &pdata->time);
}
diff --git a/drivers/rtc/rtc-tps80031.c b/drivers/rtc/rtc-tps80031.c
index b2b9d04171c5..44013e13fe43 100644
--- a/drivers/rtc/rtc-tps80031.c
+++ b/drivers/rtc/rtc-tps80031.c
@@ -349,12 +349,20 @@ static irqreturn_t tps80031_rtc_irq(int irq, void *data)
static int __devinit tps80031_rtc_probe(struct platform_device *pdev)
{
- struct tps80031_rtc_platform_data *pdata = pdev->dev.platform_data;
+ struct tps80031_platform_data *tps80031_pdata;
+ struct tps80031_rtc_platform_data *pdata;
struct tps80031_rtc *rtc;
struct rtc_time tm;
int err;
u8 reg;
+ tps80031_pdata = dev_get_platdata(pdev->dev.parent);
+ if (!tps80031_pdata) {
+ dev_err(&pdev->dev, "no tps80031 platform_data specified\n");
+ return -EINVAL;
+ }
+
+ pdata = tps80031_pdata->rtc_pdata;
if (!pdata) {
dev_err(&pdev->dev, "no platform_data specified\n");
return -EINVAL;
@@ -469,7 +477,7 @@ static int __devexit tps80031_rtc_remove(struct platform_device *pdev)
static struct platform_driver tps80031_rtc_driver = {
.driver = {
- .name = "rtc_tps80031",
+ .name = "tps80031-rtc",
.owner = THIS_MODULE,
},
.probe = tps80031_rtc_probe,