summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2017-01-25 19:32:15 -0500
committerMichael Sevakis <jethead71@rockbox.org>2017-01-26 23:07:49 -0500
commit58b849c451ac1281c14bfc535ab7f411a0b736e0 (patch)
tree035026a62581900f72fa0d90bd694a8a92372c00 /firmware
parent783c77531c35e62dd754c510c4f2beefe6df4a9d (diff)
downloadrockbox-58b849c451ac1281c14bfc535ab7f411a0b736e0.tar.gz
rockbox-58b849c451ac1281c14bfc535ab7f411a0b736e0.tar.bz2
rockbox-58b849c451ac1281c14bfc535ab7f411a0b736e0.zip
Move intrinsic RTC implmentation differences to driver files
Some drivers set tm_wday just fine and do not need it coerced to be correct. Others set tm_yday, so don't overwrite what the driver sets; just zero it inside if it can't fill the field. Move calls to set_day_of_week() to the sorts of drivers that presumably required the hammer (FS#11814) in get_time() where the weekday isn't locked to the date. Change-Id: Idd0ded6bfc9d9f48fcc1a6074068164c42fcf24a
Diffstat (limited to 'firmware')
-rw-r--r--firmware/common/timefuncs.c3
-rw-r--r--firmware/drivers/rtc/rtc_d2.c5
-rw-r--r--firmware/drivers/rtc/rtc_ds1339_ds3231.c5
-rw-r--r--firmware/drivers/rtc/rtc_e8564.c6
-rw-r--r--firmware/drivers/rtc/rtc_m41st84w.c8
-rw-r--r--firmware/drivers/rtc/rtc_mr100.c5
-rw-r--r--firmware/drivers/rtc/rtc_pcf50605.c6
-rw-r--r--firmware/drivers/rtc/rtc_pcf50606.c5
-rw-r--r--firmware/drivers/rtc/rtc_rx5x348ab.c5
-rw-r--r--firmware/drivers/rtc/rtc_s35380a.c5
-rw-r--r--firmware/drivers/rtc/rtc_s35390a.c5
-rw-r--r--firmware/drivers/rtc/rtc_s3c2440.c5
-rw-r--r--firmware/libc/gmtime.c3
-rw-r--r--firmware/target/arm/s5l8700/ipodnano2g/rtc-nano2g.c5
-rw-r--r--firmware/target/arm/s5l8702/ipod6g/rtc-ipod6g.c5
15 files changed, 54 insertions, 22 deletions
diff --git a/firmware/common/timefuncs.c b/firmware/common/timefuncs.c
index ffa6e2a0b3..c8819ea76e 100644
--- a/firmware/common/timefuncs.c
+++ b/firmware/common/timefuncs.c
@@ -71,9 +71,6 @@ struct tm *get_time(void)
/* Once per second, 1/10th of a second off */
timeout = HZ * (current_tick / HZ + 1) + HZ / 5;
rtc_read_datetime(&tm);
- set_day_of_week(&tm);
-
- tm.tm_yday = 0; /* Not implemented for now */
tm.tm_isdst = -1; /* Not implemented for now */
}
#else /* No RTC */
diff --git a/firmware/drivers/rtc/rtc_d2.c b/firmware/drivers/rtc/rtc_d2.c
index a2a40fe7ac..1d202410e2 100644
--- a/firmware/drivers/rtc/rtc_d2.c
+++ b/firmware/drivers/rtc/rtc_d2.c
@@ -23,6 +23,7 @@
#include "pcf50606.h"
#include "pcf50635.h"
#include "pmu-target.h"
+#include "timefuncs.h"
void rtc_init(void)
{
@@ -49,10 +50,12 @@ int rtc_read_datetime(struct tm *tm)
tm->tm_sec = buf[0];
tm->tm_min = buf[1];
tm->tm_hour = buf[2];
- tm->tm_wday = buf[3];
tm->tm_mday = buf[4];
tm->tm_mon = buf[5] - 1;
tm->tm_year = buf[6] + 100;
+ tm->tm_yday = 0; /* Not implemented for now */
+
+ set_day_of_week(tm);
return rc;
}
diff --git a/firmware/drivers/rtc/rtc_ds1339_ds3231.c b/firmware/drivers/rtc/rtc_ds1339_ds3231.c
index a813e8d999..8f2a531e5f 100644
--- a/firmware/drivers/rtc/rtc_ds1339_ds3231.c
+++ b/firmware/drivers/rtc/rtc_ds1339_ds3231.c
@@ -21,6 +21,7 @@
#include "rtc.h"
#include "logf.h"
#include "sw_i2c.h"
+#include "timefuncs.h"
#define RTC_ADDR 0xD0
@@ -122,10 +123,12 @@ int rtc_read_datetime(struct tm *tm)
tm->tm_sec = BCD2DEC(buf[0] & 0x7f);
tm->tm_min = BCD2DEC(buf[1] & 0x7f);
tm->tm_hour = BCD2DEC(buf[2] & 0x3f);
- tm->tm_wday = BCD2DEC(buf[3] & 0x7) - 1; /* timefuncs wants 0..6 for wday */
tm->tm_mday = BCD2DEC(buf[4] & 0x3f);
tm->tm_mon = BCD2DEC(buf[5] & 0x1f) - 1;
tm->tm_year = BCD2DEC(buf[6]) + 100;
+ tm->tm_yday = 0; /* Not implemented for now */
+
+ set_day_of_week(tm);
return rc;
}
diff --git a/firmware/drivers/rtc/rtc_e8564.c b/firmware/drivers/rtc/rtc_e8564.c
index 7a02ec6cdc..7837bbaa83 100644
--- a/firmware/drivers/rtc/rtc_e8564.c
+++ b/firmware/drivers/rtc/rtc_e8564.c
@@ -25,7 +25,7 @@
#include "kernel.h"
#include "system.h"
#include "i2c-pp.h"
-#include <stdbool.h>
+#include "timefuncs.h"
/*RTC_E8564's slave address is 0x51*/
#define RTC_ADDR 0x51
@@ -83,9 +83,11 @@ int rtc_read_datetime(struct tm *tm)
tm->tm_min = BCD2DEC(buf[1] & 0x7f);
tm->tm_hour = BCD2DEC(buf[2] & 0x3f);
tm->tm_mday = BCD2DEC(buf[3] & 0x3f);
- tm->tm_wday = BCD2DEC(buf[4] & 0x7);
tm->tm_mon = BCD2DEC(buf[5] & 0x1f) - 1;
tm->tm_year = BCD2DEC(buf[6]) + 100;
+ tm->tm_yday = 0; /* Not implemented for now */
+
+ set_day_of_week(tm);
return read;
}
diff --git a/firmware/drivers/rtc/rtc_m41st84w.c b/firmware/drivers/rtc/rtc_m41st84w.c
index 4cfa155bfb..621e650f68 100644
--- a/firmware/drivers/rtc/rtc_m41st84w.c
+++ b/firmware/drivers/rtc/rtc_m41st84w.c
@@ -23,7 +23,7 @@
#include "rtc.h"
#include "kernel.h"
#include "system.h"
-#include <stdbool.h>
+#include "timefuncs.h"
#define RTC_ADR 0xd0
#define RTC_DEV_WRITE (RTC_ADR | 0x00)
@@ -257,14 +257,12 @@ int rtc_read_datetime(struct tm *tm)
tm->tm_sec = BCD2DEC(buf[0] & 0x7f);
tm->tm_min = BCD2DEC(buf[1] & 0x7f);
tm->tm_hour = BCD2DEC(buf[2] & 0x3f);
- tm->tm_wday = BCD2DEC(buf[3] & 0x7);
tm->tm_mday = BCD2DEC(buf[4] & 0x3f);
tm->tm_mon = BCD2DEC(buf[5] & 0x1f) - 1;
tm->tm_year = BCD2DEC(buf[6]) + 100;
+ tm->tm_yday = 0; /* Not implemented for now */
- /* Adjust weekday */
- if (tm->tm_wday == 7)
- tm->tm_wday = 0;
+ set_day_of_week(tm);
return rc;
}
diff --git a/firmware/drivers/rtc/rtc_mr100.c b/firmware/drivers/rtc/rtc_mr100.c
index 209845cea8..6e1b0b5f40 100644
--- a/firmware/drivers/rtc/rtc_mr100.c
+++ b/firmware/drivers/rtc/rtc_mr100.c
@@ -22,6 +22,7 @@
#include "logf.h"
#include "sw_i2c.h"
#include "i2c-pp.h"
+#include "timefuncs.h"
/* The RTC chip is unknown, the information about it was gathered by
* reverse engineering the bootloader.
@@ -140,10 +141,12 @@ int rtc_read_datetime(struct tm *tm)
tm->tm_sec = buf[6];
tm->tm_min = buf[5];
tm->tm_hour = buf[4];
- tm->tm_wday = buf[3];
tm->tm_mday = buf[2];
tm->tm_mon = buf[1] - 1;
tm->tm_year = buf[0] + 100;
+ tm->tm_yday = 0; /* Not implemented for now */
+
+ set_day_of_week(tm);
return rc;
}
diff --git a/firmware/drivers/rtc/rtc_pcf50605.c b/firmware/drivers/rtc/rtc_pcf50605.c
index 8c54a590c6..daa35fb13f 100644
--- a/firmware/drivers/rtc/rtc_pcf50605.c
+++ b/firmware/drivers/rtc/rtc_pcf50605.c
@@ -24,7 +24,7 @@
#include "kernel.h"
#include "system.h"
#include "pcf50605.h"
-#include <stdbool.h>
+#include "timefuncs.h"
/* Values which each disable one alarm time register */
static const char alarm_disable[] = {
@@ -49,10 +49,12 @@ int rtc_read_datetime(struct tm *tm)
tm->tm_sec = buf[0];
tm->tm_min = buf[1];
tm->tm_hour = buf[2];
- tm->tm_wday = buf[3];
tm->tm_mday = buf[4];
tm->tm_mon = buf[5] - 1;
tm->tm_year = buf[6] + 100;
+ tm->tm_yday = 0; /* Not implemented for now */
+
+ set_day_of_week(tm);
return rc;
}
diff --git a/firmware/drivers/rtc/rtc_pcf50606.c b/firmware/drivers/rtc/rtc_pcf50606.c
index cb6697207b..2c751e5b01 100644
--- a/firmware/drivers/rtc/rtc_pcf50606.c
+++ b/firmware/drivers/rtc/rtc_pcf50606.c
@@ -24,6 +24,7 @@
#include "kernel.h"
#include "system.h"
#include "pcf50606.h"
+#include "timefuncs.h"
void rtc_init(void)
{
@@ -47,9 +48,9 @@ int rtc_read_datetime(struct tm *tm)
tm->tm_sec = buf[0];
tm->tm_min = buf[1];
tm->tm_hour = buf[2];
- tm->tm_wday = buf[3];
tm->tm_mday = buf[4];
tm->tm_mon = buf[5] - 1;
+ tm->tm_yday = 0; /* Not implemented for now */
#ifdef IRIVER_H300_SERIES
/* Special kludge to coexist with the iriver firmware. The iriver firmware
stores the date as 1965+nn, and allows a range of 1980..2064. We use
@@ -60,6 +61,8 @@ int rtc_read_datetime(struct tm *tm)
tm->tm_year = buf[6] + 100;
#endif /* IRIVER_H300_SERIES */
+ set_day_of_week(tm);
+
return rc;
}
diff --git a/firmware/drivers/rtc/rtc_rx5x348ab.c b/firmware/drivers/rtc/rtc_rx5x348ab.c
index f31ab5623e..6d7b78b281 100644
--- a/firmware/drivers/rtc/rtc_rx5x348ab.c
+++ b/firmware/drivers/rtc/rtc_rx5x348ab.c
@@ -22,6 +22,7 @@
#include "config.h"
#include "spi.h"
#include "rtc.h"
+#include "timefuncs.h"
/* Choose one of: */
#define ADDR_READ 0x04
@@ -48,10 +49,12 @@ int rtc_read_datetime(struct tm *tm)
tm->tm_sec = buf[0];
tm->tm_min = buf[1];
tm->tm_hour = buf[2];
- tm->tm_wday = buf[3];
tm->tm_mday = buf[4];
tm->tm_mon = buf[5] - 1;
tm->tm_year = buf[6] + 100;
+ tm->tm_yday = 0; /* Not implemented for now */
+
+ set_day_of_week(tm);
return 1;
}
diff --git a/firmware/drivers/rtc/rtc_s35380a.c b/firmware/drivers/rtc/rtc_s35380a.c
index a45924d725..f32c431990 100644
--- a/firmware/drivers/rtc/rtc_s35380a.c
+++ b/firmware/drivers/rtc/rtc_s35380a.c
@@ -23,6 +23,7 @@
#include "config.h"
#include "rtc.h"
#include "i2c-coldfire.h"
+#include "timefuncs.h"
/* Driver for the Seiko S35380A real-time clock chip with i2c interface
@@ -188,10 +189,12 @@ int rtc_read_datetime(struct tm *tm)
tm->tm_sec = buf[TIME_SECOND];
tm->tm_min = buf[TIME_MINUTE];
tm->tm_hour = buf[TIME_HOUR];
- tm->tm_wday = buf[TIME_WEEKDAY];
tm->tm_mday = buf[TIME_DAY];
tm->tm_mon = buf[TIME_MONTH] - 1;
tm->tm_year = buf[TIME_YEAR] + 100;
+ tm->tm_yday = 0; /* Not implemented for now */
+
+ set_day_of_week(tm);
return ret;
}
diff --git a/firmware/drivers/rtc/rtc_s35390a.c b/firmware/drivers/rtc/rtc_s35390a.c
index 13027d31a2..b82029a114 100644
--- a/firmware/drivers/rtc/rtc_s35390a.c
+++ b/firmware/drivers/rtc/rtc_s35390a.c
@@ -22,6 +22,7 @@
#include "config.h"
#include "rtc.h"
#include "i2c-s5l8700.h"
+#include "timefuncs.h"
/* Driver for the Seiko S35390A real-time clock chip with i2c interface
@@ -75,10 +76,12 @@ int rtc_read_datetime(struct tm *tm)
tm->tm_sec = buf[6];
tm->tm_min = buf[5];
tm->tm_hour = buf[4];
- tm->tm_wday = buf[3];
tm->tm_mday = buf[2];
tm->tm_mon = buf[1] - 1;
tm->tm_year = buf[0] + 100;
+ tm->tm_yday = 0; /* Not implemented for now */
+
+ set_day_of_week(tm);
return ret;
}
diff --git a/firmware/drivers/rtc/rtc_s3c2440.c b/firmware/drivers/rtc/rtc_s3c2440.c
index a8787e3f8f..6cd34f0e23 100644
--- a/firmware/drivers/rtc/rtc_s3c2440.c
+++ b/firmware/drivers/rtc/rtc_s3c2440.c
@@ -23,6 +23,7 @@
#include "rtc.h"
#include "kernel.h"
#include "system.h"
+#include "timefuncs.h"
void rtc_init(void)
{
@@ -35,10 +36,12 @@ int rtc_read_datetime(struct tm *tm)
tm->tm_sec = BCD2DEC(BCDSEC);
tm->tm_min = BCD2DEC(BCDMIN);
tm->tm_hour = BCD2DEC(BCDHOUR);
- tm->tm_wday = BCD2DEC(BCDDAY) - 1; /* timefuncs wants 0..6 for wday */
tm->tm_mday = BCD2DEC(BCDDATE);
tm->tm_mon = BCD2DEC(BCDMON) - 1;
tm->tm_year = BCD2DEC(BCDYEAR) + 100;
+ tm->tm_yday = 0; /* Not implemented for now */
+
+ set_day_of_week(tm);
return 1;
}
diff --git a/firmware/libc/gmtime.c b/firmware/libc/gmtime.c
index e7ebdf0d90..c5deb593cd 100644
--- a/firmware/libc/gmtime.c
+++ b/firmware/libc/gmtime.c
@@ -108,6 +108,9 @@ struct tm *gmtime_r(const time_t *timep, struct tm *tm)
/* Second */
tm->tm_sec = seconds;
+ tm->tm_yday = 0; /* Not implemented for now */
+ tm->tm_isdst = -1; /* Not implemented for now */
+
return tm;
}
diff --git a/firmware/target/arm/s5l8700/ipodnano2g/rtc-nano2g.c b/firmware/target/arm/s5l8700/ipodnano2g/rtc-nano2g.c
index 39cecc5291..6f6b58ca35 100644
--- a/firmware/target/arm/s5l8700/ipodnano2g/rtc-nano2g.c
+++ b/firmware/target/arm/s5l8700/ipodnano2g/rtc-nano2g.c
@@ -23,6 +23,7 @@
#include "kernel.h"
#include "system.h"
#include "pmu-target.h"
+#include "timefuncs.h"
void rtc_init(void)
{
@@ -41,10 +42,12 @@ int rtc_read_datetime(struct tm *tm)
tm->tm_sec = buf[0];
tm->tm_min = buf[1];
tm->tm_hour = buf[2];
- tm->tm_wday = buf[3];
tm->tm_mday = buf[4];
tm->tm_mon = buf[5] - 1;
tm->tm_year = buf[6] + 100;
+ tm->tm_yday = 0; /* Not implemented for now */
+
+ set_day_of_week(tm);
return 0;
}
diff --git a/firmware/target/arm/s5l8702/ipod6g/rtc-ipod6g.c b/firmware/target/arm/s5l8702/ipod6g/rtc-ipod6g.c
index 76ef8ecb00..384cded758 100644
--- a/firmware/target/arm/s5l8702/ipod6g/rtc-ipod6g.c
+++ b/firmware/target/arm/s5l8702/ipod6g/rtc-ipod6g.c
@@ -23,6 +23,7 @@
#include "kernel.h"
#include "system.h"
#include "pmu-target.h"
+#include "timefuncs.h"
void rtc_init(void)
{
@@ -41,10 +42,12 @@ int rtc_read_datetime(struct tm *tm)
tm->tm_sec = buf[0];
tm->tm_min = buf[1];
tm->tm_hour = buf[2];
- tm->tm_wday = buf[3];
tm->tm_mday = buf[4];
tm->tm_mon = buf[5] - 1;
tm->tm_year = buf[6] + 100;
+ tm->tm_yday = 0; /* Not implemented for now */
+
+ set_day_of_week(tm);
return 0;
}