diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-08-05 09:48:22 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-08-05 09:48:22 -0400 |
commit | 6c84239d595dc6ffe39f0f03dae2f64ed200db95 (patch) | |
tree | 3aea4368a644be16e44612c964aa26152854e1ae /arch/mn10300 | |
parent | d4c06c708123c652025d04fe77b7e39448077395 (diff) | |
parent | 6f367788d6333a41fefd013975b0b160d5c0a1c8 (diff) |
Merge tag 'rtc-4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
Pull RTC updates from Alexandre Belloni:
"RTC for 4.8
Cleanups:
- huge cleanup of rtc-generic and char/genrtc this allowed to cleanup
rtc-cmos, rtc-sh, rtc-m68k, rtc-powerpc and rtc-parisc
- move mn10300 to rtc-cmos
Subsystem:
- fix wakealarms after hibernate
- multiples fixes for rctest
- simplify implementations of .read_alarm
New drivers:
- Maxim MAX6916
Drivers:
- ds1307: fix weekday
- m41t80: add wakeup support
- pcf85063: add support for PCF85063A variant
- rv8803: extend i2c fix and other fixes
- s35390a: fix alarm reading, this fixes instant reboot after
shutdown for QNAP TS-41x
- s3c: clock fixes"
* tag 'rtc-4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (65 commits)
rtc: rv8803: Clear V1F when setting the time
rtc: rv8803: Stop the clock while setting the time
rtc: rv8803: Always apply the I²C workaround
rtc: rv8803: Fix read day of week
rtc: rv8803: Remove the check for valid time
rtc: rv8803: Kconfig: Indicate rx8900 support
rtc: asm9260: remove .owner field for driver
rtc: at91sam9: Fix missing spin_lock_init()
rtc: m41t80: add suspend handlers for alarm IRQ
rtc: m41t80: make it a real error message
rtc: pcf85063: Add support for the PCF85063A device
rtc: pcf85063: fix year range
rtc: hym8563: in .read_alarm set .tm_sec to 0 to signal minute accuracy
rtc: explicitly set tm_sec = 0 for drivers with minute accurancy
rtc: s3c: Add s3c_rtc_{enable/disable}_clk in s3c_rtc_setfreq()
rtc: s3c: Remove unnecessary call to disable already disabled clock
rtc: abx80x: use devm_add_action_or_reset()
rtc: m41t80: use devm_add_action_or_reset()
rtc: fix a typo and reduce three empty lines to one
rtc: s35390a: improve two comments in .set_alarm
...
Diffstat (limited to 'arch/mn10300')
-rw-r--r-- | arch/mn10300/Kconfig | 4 | ||||
-rw-r--r-- | arch/mn10300/include/asm/rtc-regs.h | 4 | ||||
-rw-r--r-- | arch/mn10300/include/asm/rtc.h | 2 | ||||
-rw-r--r-- | arch/mn10300/kernel/rtc.c | 104 | ||||
-rw-r--r-- | arch/mn10300/proc-mn103e010/proc-init.c | 3 | ||||
-rw-r--r-- | arch/mn10300/proc-mn2ws0050/proc-init.c | 1 |
6 files changed, 18 insertions, 100 deletions
diff --git a/arch/mn10300/Kconfig b/arch/mn10300/Kconfig index 9627e81a6cbb..38e3494bfb63 100644 --- a/arch/mn10300/Kconfig +++ b/arch/mn10300/Kconfig | |||
@@ -236,7 +236,9 @@ source "kernel/Kconfig.hz" | |||
236 | config MN10300_RTC | 236 | config MN10300_RTC |
237 | bool "Using MN10300 RTC" | 237 | bool "Using MN10300 RTC" |
238 | depends on MN10300_PROC_MN103E010 || MN10300_PROC_MN2WS0050 | 238 | depends on MN10300_PROC_MN103E010 || MN10300_PROC_MN2WS0050 |
239 | select GENERIC_CMOS_UPDATE | 239 | select RTC_CLASS |
240 | select RTC_DRV_CMOS | ||
241 | select RTC_SYSTOHC | ||
240 | default n | 242 | default n |
241 | help | 243 | help |
242 | This option enables support for the RTC, thus enabling time to be | 244 | This option enables support for the RTC, thus enabling time to be |
diff --git a/arch/mn10300/include/asm/rtc-regs.h b/arch/mn10300/include/asm/rtc-regs.h index c42deefaec11..c81cacecb6e3 100644 --- a/arch/mn10300/include/asm/rtc-regs.h +++ b/arch/mn10300/include/asm/rtc-regs.h | |||
@@ -75,9 +75,9 @@ | |||
75 | #define RTC_PORT(x) 0xd8600000 | 75 | #define RTC_PORT(x) 0xd8600000 |
76 | #define RTC_ALWAYS_BCD 1 /* RTC operates in binary mode */ | 76 | #define RTC_ALWAYS_BCD 1 /* RTC operates in binary mode */ |
77 | 77 | ||
78 | #define CMOS_READ(addr) __SYSREG(0xd8600000 + (addr), u8) | 78 | #define CMOS_READ(addr) __SYSREG(0xd8600000 + (u32)(addr), u8) |
79 | #define CMOS_WRITE(val, addr) \ | 79 | #define CMOS_WRITE(val, addr) \ |
80 | do { __SYSREG(0xd8600000 + (addr), u8) = val; } while (0) | 80 | do { __SYSREG(0xd8600000 + (u32)(addr), u8) = val; } while (0) |
81 | 81 | ||
82 | #define RTC_IRQ RTIRQ | 82 | #define RTC_IRQ RTIRQ |
83 | 83 | ||
diff --git a/arch/mn10300/include/asm/rtc.h b/arch/mn10300/include/asm/rtc.h index 6c14bb1d0d9b..07dc87656197 100644 --- a/arch/mn10300/include/asm/rtc.h +++ b/arch/mn10300/include/asm/rtc.h | |||
@@ -25,6 +25,4 @@ static inline void calibrate_clock(void) | |||
25 | 25 | ||
26 | #endif /* !CONFIG_MN10300_RTC */ | 26 | #endif /* !CONFIG_MN10300_RTC */ |
27 | 27 | ||
28 | #include <asm-generic/rtc.h> | ||
29 | |||
30 | #endif /* _ASM_RTC_H */ | 28 | #endif /* _ASM_RTC_H */ |
diff --git a/arch/mn10300/kernel/rtc.c b/arch/mn10300/kernel/rtc.c index 48d7058b3295..f81f37025072 100644 --- a/arch/mn10300/kernel/rtc.c +++ b/arch/mn10300/kernel/rtc.c | |||
@@ -12,107 +12,19 @@ | |||
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/mc146818rtc.h> | 14 | #include <linux/mc146818rtc.h> |
15 | #include <linux/bcd.h> | 15 | #include <linux/ioport.h> |
16 | #include <linux/timex.h> | 16 | #include <linux/platform_device.h> |
17 | |||
17 | #include <asm/rtc-regs.h> | 18 | #include <asm/rtc-regs.h> |
18 | #include <asm/rtc.h> | 19 | #include <asm/rtc.h> |
19 | 20 | ||
20 | DEFINE_SPINLOCK(rtc_lock); | 21 | DEFINE_SPINLOCK(rtc_lock); |
21 | EXPORT_SYMBOL(rtc_lock); | 22 | EXPORT_SYMBOL(rtc_lock); |
22 | 23 | ||
23 | /* | 24 | static const __initdata struct resource res[] = { |
24 | * Read the current RTC time | 25 | DEFINE_RES_IO(RTC_PORT(0), RTC_IO_EXTENT), |
25 | */ | 26 | DEFINE_RES_IRQ(RTC_IRQ), |
26 | void read_persistent_clock(struct timespec *ts) | 27 | }; |
27 | { | ||
28 | struct rtc_time tm; | ||
29 | |||
30 | get_rtc_time(&tm); | ||
31 | |||
32 | ts->tv_nsec = 0; | ||
33 | ts->tv_sec = mktime(tm.tm_year, tm.tm_mon, tm.tm_mday, | ||
34 | tm.tm_hour, tm.tm_min, tm.tm_sec); | ||
35 | |||
36 | /* if rtc is way off in the past, set something reasonable */ | ||
37 | if (ts->tv_sec < 0) | ||
38 | ts->tv_sec = mktime(2009, 1, 1, 12, 0, 0); | ||
39 | } | ||
40 | |||
41 | /* | ||
42 | * In order to set the CMOS clock precisely, set_rtc_mmss has to be called 500 | ||
43 | * ms after the second nowtime has started, because when nowtime is written | ||
44 | * into the registers of the CMOS clock, it will jump to the next second | ||
45 | * precisely 500 ms later. Check the Motorola MC146818A or Dallas DS12887 data | ||
46 | * sheet for details. | ||
47 | * | ||
48 | * BUG: This routine does not handle hour overflow properly; it just | ||
49 | * sets the minutes. Usually you'll only notice that after reboot! | ||
50 | */ | ||
51 | static int set_rtc_mmss(unsigned long nowtime) | ||
52 | { | ||
53 | unsigned char save_control, save_freq_select; | ||
54 | int retval = 0; | ||
55 | int real_seconds, real_minutes, cmos_minutes; | ||
56 | |||
57 | /* gets recalled with irq locally disabled */ | ||
58 | spin_lock(&rtc_lock); | ||
59 | save_control = CMOS_READ(RTC_CONTROL); /* tell the clock it's being | ||
60 | * set */ | ||
61 | CMOS_WRITE(save_control | RTC_SET, RTC_CONTROL); | ||
62 | |||
63 | save_freq_select = CMOS_READ(RTC_FREQ_SELECT); /* stop and reset | ||
64 | * prescaler */ | ||
65 | CMOS_WRITE(save_freq_select | RTC_DIV_RESET2, RTC_FREQ_SELECT); | ||
66 | |||
67 | cmos_minutes = CMOS_READ(RTC_MINUTES); | ||
68 | if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) | ||
69 | cmos_minutes = bcd2bin(cmos_minutes); | ||
70 | |||
71 | /* | ||
72 | * since we're only adjusting minutes and seconds, | ||
73 | * don't interfere with hour overflow. This avoids | ||
74 | * messing with unknown time zones but requires your | ||
75 | * RTC not to be off by more than 15 minutes | ||
76 | */ | ||
77 | real_seconds = nowtime % 60; | ||
78 | real_minutes = nowtime / 60; | ||
79 | if (((abs(real_minutes - cmos_minutes) + 15) / 30) & 1) | ||
80 | /* correct for half hour time zone */ | ||
81 | real_minutes += 30; | ||
82 | real_minutes %= 60; | ||
83 | |||
84 | if (abs(real_minutes - cmos_minutes) < 30) { | ||
85 | if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { | ||
86 | real_seconds = bin2bcd(real_seconds); | ||
87 | real_minutes = bin2bcd(real_minutes); | ||
88 | } | ||
89 | CMOS_WRITE(real_seconds, RTC_SECONDS); | ||
90 | CMOS_WRITE(real_minutes, RTC_MINUTES); | ||
91 | } else { | ||
92 | printk_once(KERN_NOTICE | ||
93 | "set_rtc_mmss: can't update from %d to %d\n", | ||
94 | cmos_minutes, real_minutes); | ||
95 | retval = -1; | ||
96 | } | ||
97 | |||
98 | /* The following flags have to be released exactly in this order, | ||
99 | * otherwise the DS12887 (popular MC146818A clone with integrated | ||
100 | * battery and quartz) will not reset the oscillator and will not | ||
101 | * update precisely 500 ms later. You won't find this mentioned in | ||
102 | * the Dallas Semiconductor data sheets, but who believes data | ||
103 | * sheets anyway ... -- Markus Kuhn | ||
104 | */ | ||
105 | CMOS_WRITE(save_control, RTC_CONTROL); | ||
106 | CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT); | ||
107 | spin_unlock(&rtc_lock); | ||
108 | |||
109 | return retval; | ||
110 | } | ||
111 | |||
112 | int update_persistent_clock(struct timespec now) | ||
113 | { | ||
114 | return set_rtc_mmss(now.tv_sec); | ||
115 | } | ||
116 | 28 | ||
117 | /* | 29 | /* |
118 | * calibrate the TSC clock against the RTC | 30 | * calibrate the TSC clock against the RTC |
@@ -129,4 +41,6 @@ void __init calibrate_clock(void) | |||
129 | RTCRA |= RTCRA_DVR; | 41 | RTCRA |= RTCRA_DVR; |
130 | RTCRA &= ~RTCRA_DVR; | 42 | RTCRA &= ~RTCRA_DVR; |
131 | RTCRB &= ~RTCRB_SET; | 43 | RTCRB &= ~RTCRB_SET; |
44 | |||
45 | platform_device_register_simple("rtc_cmos", -1, res, ARRAY_SIZE(res)); | ||
132 | } | 46 | } |
diff --git a/arch/mn10300/proc-mn103e010/proc-init.c b/arch/mn10300/proc-mn103e010/proc-init.c index 27b97980dca4..102d86a6ae56 100644 --- a/arch/mn10300/proc-mn103e010/proc-init.c +++ b/arch/mn10300/proc-mn103e010/proc-init.c | |||
@@ -9,7 +9,10 @@ | |||
9 | * 2 of the Licence, or (at your option) any later version. | 9 | * 2 of the Licence, or (at your option) any later version. |
10 | */ | 10 | */ |
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | #include <linux/irq.h> | ||
13 | #include <asm/cacheflush.h> | ||
12 | #include <asm/fpu.h> | 14 | #include <asm/fpu.h> |
15 | #include <asm/irq.h> | ||
13 | #include <asm/rtc.h> | 16 | #include <asm/rtc.h> |
14 | #include <asm/busctl-regs.h> | 17 | #include <asm/busctl-regs.h> |
15 | 18 | ||
diff --git a/arch/mn10300/proc-mn2ws0050/proc-init.c b/arch/mn10300/proc-mn2ws0050/proc-init.c index ee6d03dbc8d8..950cc8dbb284 100644 --- a/arch/mn10300/proc-mn2ws0050/proc-init.c +++ b/arch/mn10300/proc-mn2ws0050/proc-init.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/delay.h> | 14 | #include <linux/delay.h> |
15 | #include <linux/interrupt.h> | 15 | #include <linux/interrupt.h> |
16 | 16 | ||
17 | #include <asm/cacheflush.h> | ||
17 | #include <asm/processor.h> | 18 | #include <asm/processor.h> |
18 | #include <asm/uaccess.h> | 19 | #include <asm/uaccess.h> |
19 | #include <asm/io.h> | 20 | #include <asm/io.h> |