diff options
author | Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> | 2009-02-24 08:04:20 -0500 |
---|---|---|
committer | Kyle McMartin <kyle@mcmartin.ca> | 2009-04-01 21:05:32 -0400 |
commit | 0b5f037a4dc495f9c40eed7f076fc6c23af3359b (patch) | |
tree | 0b4f3388c2ad47ba2310e3e8c1feafcd800f2e72 | |
parent | bcd68a70cb0eee556d86d93133aa150319bd9f53 (diff) |
powerpc/ps3: Add rtc-ps3
Create a real RTC driver for PS3, and unhook the deprecated
ppc_md.[gs]et_rtc_time.
Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Acked-by: Alessandro Zummo <a.zummo@towertech.it>
Acked-by: Geoff Levand <geoffrey.levand@am.sony.com>
Signed-off-by: Kyle McMartin <kyle@mcmartin.ca>
-rw-r--r-- | arch/powerpc/include/asm/ps3.h | 3 | ||||
-rw-r--r-- | arch/powerpc/platforms/ps3/os-area.c | 2 | ||||
-rw-r--r-- | arch/powerpc/platforms/ps3/platform.h | 2 | ||||
-rw-r--r-- | arch/powerpc/platforms/ps3/setup.c | 2 | ||||
-rw-r--r-- | arch/powerpc/platforms/ps3/time.c | 26 | ||||
-rw-r--r-- | drivers/rtc/Kconfig | 9 | ||||
-rw-r--r-- | drivers/rtc/Makefile | 1 | ||||
-rw-r--r-- | drivers/rtc/rtc-ps3.c | 104 |
8 files changed, 131 insertions, 18 deletions
diff --git a/arch/powerpc/include/asm/ps3.h b/arch/powerpc/include/asm/ps3.h index 67f1812698d2..cdb6fd814de8 100644 --- a/arch/powerpc/include/asm/ps3.h +++ b/arch/powerpc/include/asm/ps3.h | |||
@@ -50,6 +50,9 @@ enum ps3_param_av_multi_out { | |||
50 | 50 | ||
51 | enum ps3_param_av_multi_out ps3_os_area_get_av_multi_out(void); | 51 | enum ps3_param_av_multi_out ps3_os_area_get_av_multi_out(void); |
52 | 52 | ||
53 | extern u64 ps3_os_area_get_rtc_diff(void); | ||
54 | extern void ps3_os_area_set_rtc_diff(u64 rtc_diff); | ||
55 | |||
53 | /* dma routines */ | 56 | /* dma routines */ |
54 | 57 | ||
55 | enum ps3_dma_page_size { | 58 | enum ps3_dma_page_size { |
diff --git a/arch/powerpc/platforms/ps3/os-area.c b/arch/powerpc/platforms/ps3/os-area.c index e1c83c23b435..86e392b1b049 100644 --- a/arch/powerpc/platforms/ps3/os-area.c +++ b/arch/powerpc/platforms/ps3/os-area.c | |||
@@ -808,6 +808,7 @@ u64 ps3_os_area_get_rtc_diff(void) | |||
808 | { | 808 | { |
809 | return saved_params.rtc_diff; | 809 | return saved_params.rtc_diff; |
810 | } | 810 | } |
811 | EXPORT_SYMBOL(ps3_os_area_get_rtc_diff); | ||
811 | 812 | ||
812 | /** | 813 | /** |
813 | * ps3_os_area_set_rtc_diff - Set the rtc diff value. | 814 | * ps3_os_area_set_rtc_diff - Set the rtc diff value. |
@@ -823,6 +824,7 @@ void ps3_os_area_set_rtc_diff(u64 rtc_diff) | |||
823 | os_area_queue_work(); | 824 | os_area_queue_work(); |
824 | } | 825 | } |
825 | } | 826 | } |
827 | EXPORT_SYMBOL(ps3_os_area_set_rtc_diff); | ||
826 | 828 | ||
827 | /** | 829 | /** |
828 | * ps3_os_area_get_av_multi_out - Returns the default video mode. | 830 | * ps3_os_area_get_av_multi_out - Returns the default video mode. |
diff --git a/arch/powerpc/platforms/ps3/platform.h b/arch/powerpc/platforms/ps3/platform.h index 235c13ebacd9..136aa0637d9c 100644 --- a/arch/powerpc/platforms/ps3/platform.h +++ b/arch/powerpc/platforms/ps3/platform.h | |||
@@ -64,8 +64,6 @@ int ps3_set_rtc_time(struct rtc_time *time); | |||
64 | 64 | ||
65 | void __init ps3_os_area_save_params(void); | 65 | void __init ps3_os_area_save_params(void); |
66 | void __init ps3_os_area_init(void); | 66 | void __init ps3_os_area_init(void); |
67 | u64 ps3_os_area_get_rtc_diff(void); | ||
68 | void ps3_os_area_set_rtc_diff(u64 rtc_diff); | ||
69 | 67 | ||
70 | /* spu */ | 68 | /* spu */ |
71 | 69 | ||
diff --git a/arch/powerpc/platforms/ps3/setup.c b/arch/powerpc/platforms/ps3/setup.c index 3331ccbb8d38..66181821322a 100644 --- a/arch/powerpc/platforms/ps3/setup.c +++ b/arch/powerpc/platforms/ps3/setup.c | |||
@@ -270,8 +270,6 @@ define_machine(ps3) { | |||
270 | .init_IRQ = ps3_init_IRQ, | 270 | .init_IRQ = ps3_init_IRQ, |
271 | .panic = ps3_panic, | 271 | .panic = ps3_panic, |
272 | .get_boot_time = ps3_get_boot_time, | 272 | .get_boot_time = ps3_get_boot_time, |
273 | .set_rtc_time = ps3_set_rtc_time, | ||
274 | .get_rtc_time = ps3_get_rtc_time, | ||
275 | .set_dabr = ps3_set_dabr, | 273 | .set_dabr = ps3_set_dabr, |
276 | .calibrate_decr = ps3_calibrate_decr, | 274 | .calibrate_decr = ps3_calibrate_decr, |
277 | .progress = ps3_progress, | 275 | .progress = ps3_progress, |
diff --git a/arch/powerpc/platforms/ps3/time.c b/arch/powerpc/platforms/ps3/time.c index d0daf7d6d3b2..b178a1e66c91 100644 --- a/arch/powerpc/platforms/ps3/time.c +++ b/arch/powerpc/platforms/ps3/time.c | |||
@@ -19,6 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/platform_device.h> | ||
22 | 23 | ||
23 | #include <asm/rtc.h> | 24 | #include <asm/rtc.h> |
24 | #include <asm/lv1call.h> | 25 | #include <asm/lv1call.h> |
@@ -74,23 +75,20 @@ static u64 read_rtc(void) | |||
74 | return rtc_val; | 75 | return rtc_val; |
75 | } | 76 | } |
76 | 77 | ||
77 | int ps3_set_rtc_time(struct rtc_time *tm) | 78 | unsigned long __init ps3_get_boot_time(void) |
78 | { | 79 | { |
79 | u64 now = mktime(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, | 80 | return read_rtc() + ps3_os_area_get_rtc_diff(); |
80 | tm->tm_hour, tm->tm_min, tm->tm_sec); | ||
81 | |||
82 | ps3_os_area_set_rtc_diff(now - read_rtc()); | ||
83 | return 0; | ||
84 | } | 81 | } |
85 | 82 | ||
86 | void ps3_get_rtc_time(struct rtc_time *tm) | 83 | static int __init ps3_rtc_init(void) |
87 | { | 84 | { |
88 | to_tm(read_rtc() + ps3_os_area_get_rtc_diff(), tm); | 85 | struct platform_device *pdev; |
89 | tm->tm_year -= 1900; | ||
90 | tm->tm_mon -= 1; | ||
91 | } | ||
92 | 86 | ||
93 | unsigned long __init ps3_get_boot_time(void) | 87 | pdev = platform_device_register_simple("rtc-ps3", -1, NULL, 0); |
94 | { | 88 | if (IS_ERR(pdev)) |
95 | return read_rtc() + ps3_os_area_get_rtc_diff(); | 89 | return PTR_ERR(pdev); |
90 | |||
91 | return 0; | ||
96 | } | 92 | } |
93 | |||
94 | module_init(ps3_rtc_init); | ||
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index fa66d10dd5a0..b072826c9ee1 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -741,4 +741,13 @@ config RTC_DRV_MV | |||
741 | This driver can also be built as a module. If so, the module | 741 | This driver can also be built as a module. If so, the module |
742 | will be called rtc-mv. | 742 | will be called rtc-mv. |
743 | 743 | ||
744 | config RTC_DRV_PS3 | ||
745 | tristate "PS3 RTC" | ||
746 | depends on PPC_PS3 | ||
747 | help | ||
748 | If you say yes here you will get support for the RTC on PS3. | ||
749 | |||
750 | This driver can also be built as a module. If so, the module | ||
751 | will be called rtc-ps3. | ||
752 | |||
744 | endif # RTC_CLASS | 753 | endif # RTC_CLASS |
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 2b022f19a6ed..6c0639a14f09 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile | |||
@@ -76,3 +76,4 @@ obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o | |||
76 | obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o | 76 | obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o |
77 | obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o | 77 | obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o |
78 | obj-$(CONFIG_RTC_DRV_PCF50633) += rtc-pcf50633.o | 78 | obj-$(CONFIG_RTC_DRV_PCF50633) += rtc-pcf50633.o |
79 | obj-$(CONFIG_RTC_DRV_PS3) += rtc-ps3.o | ||
diff --git a/drivers/rtc/rtc-ps3.c b/drivers/rtc/rtc-ps3.c new file mode 100644 index 000000000000..968133ce1ee8 --- /dev/null +++ b/drivers/rtc/rtc-ps3.c | |||
@@ -0,0 +1,104 @@ | |||
1 | /* | ||
2 | * PS3 RTC Driver | ||
3 | * | ||
4 | * Copyright 2009 Sony Corporation | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; version 2 of the License. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program. | ||
17 | * If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | ||
19 | |||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/module.h> | ||
22 | #include <linux/platform_device.h> | ||
23 | #include <linux/rtc.h> | ||
24 | |||
25 | #include <asm/lv1call.h> | ||
26 | #include <asm/ps3.h> | ||
27 | |||
28 | |||
29 | static u64 read_rtc(void) | ||
30 | { | ||
31 | int result; | ||
32 | u64 rtc_val; | ||
33 | u64 tb_val; | ||
34 | |||
35 | result = lv1_get_rtc(&rtc_val, &tb_val); | ||
36 | BUG_ON(result); | ||
37 | |||
38 | return rtc_val; | ||
39 | } | ||
40 | |||
41 | static int ps3_get_time(struct device *dev, struct rtc_time *tm) | ||
42 | { | ||
43 | rtc_time_to_tm(read_rtc() + ps3_os_area_get_rtc_diff(), tm); | ||
44 | return rtc_valid_tm(tm); | ||
45 | } | ||
46 | |||
47 | static int ps3_set_time(struct device *dev, struct rtc_time *tm) | ||
48 | { | ||
49 | unsigned long now; | ||
50 | |||
51 | rtc_tm_to_time(tm, &now); | ||
52 | ps3_os_area_set_rtc_diff(now - read_rtc()); | ||
53 | return 0; | ||
54 | } | ||
55 | |||
56 | static const struct rtc_class_ops ps3_rtc_ops = { | ||
57 | .read_time = ps3_get_time, | ||
58 | .set_time = ps3_set_time, | ||
59 | }; | ||
60 | |||
61 | static int __init ps3_rtc_probe(struct platform_device *dev) | ||
62 | { | ||
63 | struct rtc_device *rtc; | ||
64 | |||
65 | rtc = rtc_device_register("rtc-ps3", &dev->dev, &ps3_rtc_ops, | ||
66 | THIS_MODULE); | ||
67 | if (IS_ERR(rtc)) | ||
68 | return PTR_ERR(rtc); | ||
69 | |||
70 | platform_set_drvdata(dev, rtc); | ||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | static int __exit ps3_rtc_remove(struct platform_device *dev) | ||
75 | { | ||
76 | rtc_device_unregister(platform_get_drvdata(dev)); | ||
77 | return 0; | ||
78 | } | ||
79 | |||
80 | static struct platform_driver ps3_rtc_driver = { | ||
81 | .driver = { | ||
82 | .name = "rtc-ps3", | ||
83 | .owner = THIS_MODULE, | ||
84 | }, | ||
85 | .remove = __exit_p(ps3_rtc_remove), | ||
86 | }; | ||
87 | |||
88 | static int __init ps3_rtc_init(void) | ||
89 | { | ||
90 | return platform_driver_probe(&ps3_rtc_driver, ps3_rtc_probe); | ||
91 | } | ||
92 | |||
93 | static void __exit ps3_rtc_fini(void) | ||
94 | { | ||
95 | platform_driver_unregister(&ps3_rtc_driver); | ||
96 | } | ||
97 | |||
98 | module_init(ps3_rtc_init); | ||
99 | module_exit(ps3_rtc_fini); | ||
100 | |||
101 | MODULE_AUTHOR("Sony Corporation"); | ||
102 | MODULE_LICENSE("GPL"); | ||
103 | MODULE_DESCRIPTION("ps3 RTC driver"); | ||
104 | MODULE_ALIAS("platform:rtc-ps3"); | ||