diff options
author | Stas Sergeev <stsp@aknet.ru> | 2008-06-12 18:21:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-06-12 21:05:42 -0400 |
commit | 1da2e3d679a8ea2d9e82040359a706da0bd3bef6 (patch) | |
tree | 1ce5966c9310366ed911fb0c6b7b514186a7af00 | |
parent | 643b52b9c0b4e959436b4b551ebf4060d06d5ae8 (diff) |
provide rtc_cmos platform device
Recently (around 2.6.25) I've noticed that RTC no longer works for me. It
turned out this is because I use pnpacpi=off kernel option to work around
the parport_pc bugs. I always did so, but RTC used to work fine in the
past, and now it have regressed.
The patch fixes the problem by creating the platform device for the RTC
when PNP is disabled. This may also help running the PNP-enabled kernel
on an older PCs.
Signed-off-by: Stas Sergeev <stsp@aknet.ru>
Cc: David Brownell <david-b@pacbell.net>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: Adam Belay <ambx1@neo.rr.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | arch/x86/kernel/rtc.c | 34 | ||||
-rw-r--r-- | drivers/rtc/rtc-cmos.c | 31 |
2 files changed, 50 insertions, 15 deletions
diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c index 9615eee9b775..05191bbc68b8 100644 --- a/arch/x86/kernel/rtc.c +++ b/arch/x86/kernel/rtc.c | |||
@@ -4,6 +4,8 @@ | |||
4 | #include <linux/acpi.h> | 4 | #include <linux/acpi.h> |
5 | #include <linux/bcd.h> | 5 | #include <linux/bcd.h> |
6 | #include <linux/mc146818rtc.h> | 6 | #include <linux/mc146818rtc.h> |
7 | #include <linux/platform_device.h> | ||
8 | #include <linux/pnp.h> | ||
7 | 9 | ||
8 | #include <asm/time.h> | 10 | #include <asm/time.h> |
9 | #include <asm/vsyscall.h> | 11 | #include <asm/vsyscall.h> |
@@ -197,3 +199,35 @@ unsigned long long native_read_tsc(void) | |||
197 | } | 199 | } |
198 | EXPORT_SYMBOL(native_read_tsc); | 200 | EXPORT_SYMBOL(native_read_tsc); |
199 | 201 | ||
202 | |||
203 | static struct resource rtc_resources[] = { | ||
204 | [0] = { | ||
205 | .start = RTC_PORT(0), | ||
206 | .end = RTC_PORT(1), | ||
207 | .flags = IORESOURCE_IO, | ||
208 | }, | ||
209 | [1] = { | ||
210 | .start = RTC_IRQ, | ||
211 | .end = RTC_IRQ, | ||
212 | .flags = IORESOURCE_IRQ, | ||
213 | } | ||
214 | }; | ||
215 | |||
216 | static struct platform_device rtc_device = { | ||
217 | .name = "rtc_cmos", | ||
218 | .id = -1, | ||
219 | .resource = rtc_resources, | ||
220 | .num_resources = ARRAY_SIZE(rtc_resources), | ||
221 | }; | ||
222 | |||
223 | static __init int add_rtc_cmos(void) | ||
224 | { | ||
225 | #ifdef CONFIG_PNP | ||
226 | if (!pnp_platform_devices) | ||
227 | platform_device_register(&rtc_device); | ||
228 | #else | ||
229 | platform_device_register(&rtc_device); | ||
230 | #endif /* CONFIG_PNP */ | ||
231 | return 0; | ||
232 | } | ||
233 | device_initcall(add_rtc_cmos); | ||
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index d060a06ce05b..d7bb9bac71df 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c | |||
@@ -905,19 +905,7 @@ static struct pnp_driver cmos_pnp_driver = { | |||
905 | .resume = cmos_pnp_resume, | 905 | .resume = cmos_pnp_resume, |
906 | }; | 906 | }; |
907 | 907 | ||
908 | static int __init cmos_init(void) | 908 | #endif /* CONFIG_PNP */ |
909 | { | ||
910 | return pnp_register_driver(&cmos_pnp_driver); | ||
911 | } | ||
912 | module_init(cmos_init); | ||
913 | |||
914 | static void __exit cmos_exit(void) | ||
915 | { | ||
916 | pnp_unregister_driver(&cmos_pnp_driver); | ||
917 | } | ||
918 | module_exit(cmos_exit); | ||
919 | |||
920 | #else /* no PNP */ | ||
921 | 909 | ||
922 | /*----------------------------------------------------------------*/ | 910 | /*----------------------------------------------------------------*/ |
923 | 911 | ||
@@ -958,20 +946,33 @@ static struct platform_driver cmos_platform_driver = { | |||
958 | 946 | ||
959 | static int __init cmos_init(void) | 947 | static int __init cmos_init(void) |
960 | { | 948 | { |
949 | #ifdef CONFIG_PNP | ||
950 | if (pnp_platform_devices) | ||
951 | return pnp_register_driver(&cmos_pnp_driver); | ||
952 | else | ||
953 | return platform_driver_probe(&cmos_platform_driver, | ||
954 | cmos_platform_probe); | ||
955 | #else | ||
961 | return platform_driver_probe(&cmos_platform_driver, | 956 | return platform_driver_probe(&cmos_platform_driver, |
962 | cmos_platform_probe); | 957 | cmos_platform_probe); |
958 | #endif /* CONFIG_PNP */ | ||
963 | } | 959 | } |
964 | module_init(cmos_init); | 960 | module_init(cmos_init); |
965 | 961 | ||
966 | static void __exit cmos_exit(void) | 962 | static void __exit cmos_exit(void) |
967 | { | 963 | { |
964 | #ifdef CONFIG_PNP | ||
965 | if (pnp_platform_devices) | ||
966 | pnp_unregister_driver(&cmos_pnp_driver); | ||
967 | else | ||
968 | platform_driver_unregister(&cmos_platform_driver); | ||
969 | #else | ||
968 | platform_driver_unregister(&cmos_platform_driver); | 970 | platform_driver_unregister(&cmos_platform_driver); |
971 | #endif /* CONFIG_PNP */ | ||
969 | } | 972 | } |
970 | module_exit(cmos_exit); | 973 | module_exit(cmos_exit); |
971 | 974 | ||
972 | 975 | ||
973 | #endif /* !PNP */ | ||
974 | |||
975 | MODULE_AUTHOR("David Brownell"); | 976 | MODULE_AUTHOR("David Brownell"); |
976 | MODULE_DESCRIPTION("Driver for PC-style 'CMOS' RTCs"); | 977 | MODULE_DESCRIPTION("Driver for PC-style 'CMOS' RTCs"); |
977 | MODULE_LICENSE("GPL"); | 978 | MODULE_LICENSE("GPL"); |