diff options
author | Geert Uytterhoeven <geert@linux-m68k.org> | 2009-04-05 07:15:10 -0400 |
---|---|---|
committer | Geert Uytterhoeven <geert@linux-m68k.org> | 2010-05-26 13:51:10 -0400 |
commit | 0779c862e43e052c58a350a8bd2bf97e6908de04 (patch) | |
tree | 108eadd3625738e7ad0db1446a96ade7d8939cc5 /arch/m68k | |
parent | 6f8221c26be5d80f749b1b6c2e7c8456fefb5250 (diff) |
m68k: amiga - RTC platform device conversion
The A2000 TOD is an Oki MSM6242B, while the A3000 TOD is a Ricoh RP5C01.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Diffstat (limited to 'arch/m68k')
-rw-r--r-- | arch/m68k/amiga/config.c | 174 | ||||
-rw-r--r-- | arch/m68k/amiga/platform.c | 17 |
2 files changed, 17 insertions, 174 deletions
diff --git a/arch/m68k/amiga/config.c b/arch/m68k/amiga/config.c index d2cc35d98532..b1577f741fa8 100644 --- a/arch/m68k/amiga/config.c +++ b/arch/m68k/amiga/config.c | |||
@@ -97,10 +97,6 @@ static void amiga_get_model(char *model); | |||
97 | static void amiga_get_hardware_list(struct seq_file *m); | 97 | static void amiga_get_hardware_list(struct seq_file *m); |
98 | /* amiga specific timer functions */ | 98 | /* amiga specific timer functions */ |
99 | static unsigned long amiga_gettimeoffset(void); | 99 | static unsigned long amiga_gettimeoffset(void); |
100 | static int a3000_hwclk(int, struct rtc_time *); | ||
101 | static int a2000_hwclk(int, struct rtc_time *); | ||
102 | static int amiga_set_clock_mmss(unsigned long); | ||
103 | static unsigned int amiga_get_ss(void); | ||
104 | extern void amiga_mksound(unsigned int count, unsigned int ticks); | 100 | extern void amiga_mksound(unsigned int count, unsigned int ticks); |
105 | static void amiga_reset(void); | 101 | static void amiga_reset(void); |
106 | extern void amiga_init_sound(void); | 102 | extern void amiga_init_sound(void); |
@@ -138,10 +134,6 @@ static struct { | |||
138 | } | 134 | } |
139 | }; | 135 | }; |
140 | 136 | ||
141 | static struct resource rtc_resource = { | ||
142 | .start = 0x00dc0000, .end = 0x00dcffff | ||
143 | }; | ||
144 | |||
145 | static struct resource ram_resource[NUM_MEMINFO]; | 137 | static struct resource ram_resource[NUM_MEMINFO]; |
146 | 138 | ||
147 | 139 | ||
@@ -387,15 +379,6 @@ void __init config_amiga(void) | |||
387 | mach_get_model = amiga_get_model; | 379 | mach_get_model = amiga_get_model; |
388 | mach_get_hardware_list = amiga_get_hardware_list; | 380 | mach_get_hardware_list = amiga_get_hardware_list; |
389 | mach_gettimeoffset = amiga_gettimeoffset; | 381 | mach_gettimeoffset = amiga_gettimeoffset; |
390 | if (AMIGAHW_PRESENT(A3000_CLK)) { | ||
391 | mach_hwclk = a3000_hwclk; | ||
392 | rtc_resource.name = "A3000 RTC"; | ||
393 | request_resource(&iomem_resource, &rtc_resource); | ||
394 | } else /* if (AMIGAHW_PRESENT(A2000_CLK)) */ { | ||
395 | mach_hwclk = a2000_hwclk; | ||
396 | rtc_resource.name = "A2000 RTC"; | ||
397 | request_resource(&iomem_resource, &rtc_resource); | ||
398 | } | ||
399 | 382 | ||
400 | /* | 383 | /* |
401 | * default MAX_DMA=0xffffffff on all machines. If we don't do so, the SCSI | 384 | * default MAX_DMA=0xffffffff on all machines. If we don't do so, the SCSI |
@@ -404,8 +387,6 @@ void __init config_amiga(void) | |||
404 | */ | 387 | */ |
405 | mach_max_dma_address = 0xffffffff; | 388 | mach_max_dma_address = 0xffffffff; |
406 | 389 | ||
407 | mach_set_clock_mmss = amiga_set_clock_mmss; | ||
408 | mach_get_ss = amiga_get_ss; | ||
409 | mach_reset = amiga_reset; | 390 | mach_reset = amiga_reset; |
410 | #if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE) | 391 | #if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE) |
411 | mach_beep = amiga_mksound; | 392 | mach_beep = amiga_mksound; |
@@ -530,161 +511,6 @@ static unsigned long amiga_gettimeoffset(void) | |||
530 | return ticks + offset; | 511 | return ticks + offset; |
531 | } | 512 | } |
532 | 513 | ||
533 | static int a3000_hwclk(int op, struct rtc_time *t) | ||
534 | { | ||
535 | tod_3000.cntrl1 = TOD3000_CNTRL1_HOLD; | ||
536 | |||
537 | if (!op) { /* read */ | ||
538 | t->tm_sec = tod_3000.second1 * 10 + tod_3000.second2; | ||
539 | t->tm_min = tod_3000.minute1 * 10 + tod_3000.minute2; | ||
540 | t->tm_hour = tod_3000.hour1 * 10 + tod_3000.hour2; | ||
541 | t->tm_mday = tod_3000.day1 * 10 + tod_3000.day2; | ||
542 | t->tm_wday = tod_3000.weekday; | ||
543 | t->tm_mon = tod_3000.month1 * 10 + tod_3000.month2 - 1; | ||
544 | t->tm_year = tod_3000.year1 * 10 + tod_3000.year2; | ||
545 | if (t->tm_year <= 69) | ||
546 | t->tm_year += 100; | ||
547 | } else { | ||
548 | tod_3000.second1 = t->tm_sec / 10; | ||
549 | tod_3000.second2 = t->tm_sec % 10; | ||
550 | tod_3000.minute1 = t->tm_min / 10; | ||
551 | tod_3000.minute2 = t->tm_min % 10; | ||
552 | tod_3000.hour1 = t->tm_hour / 10; | ||
553 | tod_3000.hour2 = t->tm_hour % 10; | ||
554 | tod_3000.day1 = t->tm_mday / 10; | ||
555 | tod_3000.day2 = t->tm_mday % 10; | ||
556 | if (t->tm_wday != -1) | ||
557 | tod_3000.weekday = t->tm_wday; | ||
558 | tod_3000.month1 = (t->tm_mon + 1) / 10; | ||
559 | tod_3000.month2 = (t->tm_mon + 1) % 10; | ||
560 | if (t->tm_year >= 100) | ||
561 | t->tm_year -= 100; | ||
562 | tod_3000.year1 = t->tm_year / 10; | ||
563 | tod_3000.year2 = t->tm_year % 10; | ||
564 | } | ||
565 | |||
566 | tod_3000.cntrl1 = TOD3000_CNTRL1_FREE; | ||
567 | |||
568 | return 0; | ||
569 | } | ||
570 | |||
571 | static int a2000_hwclk(int op, struct rtc_time *t) | ||
572 | { | ||
573 | int cnt = 5; | ||
574 | |||
575 | tod_2000.cntrl1 = TOD2000_CNTRL1_HOLD; | ||
576 | |||
577 | while ((tod_2000.cntrl1 & TOD2000_CNTRL1_BUSY) && cnt) { | ||
578 | tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD; | ||
579 | udelay(70); | ||
580 | tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD; | ||
581 | --cnt; | ||
582 | } | ||
583 | |||
584 | if (!cnt) | ||
585 | printk(KERN_INFO "hwclk: timed out waiting for RTC (0x%x)\n", | ||
586 | tod_2000.cntrl1); | ||
587 | |||
588 | if (!op) { /* read */ | ||
589 | t->tm_sec = tod_2000.second1 * 10 + tod_2000.second2; | ||
590 | t->tm_min = tod_2000.minute1 * 10 + tod_2000.minute2; | ||
591 | t->tm_hour = (tod_2000.hour1 & 3) * 10 + tod_2000.hour2; | ||
592 | t->tm_mday = tod_2000.day1 * 10 + tod_2000.day2; | ||
593 | t->tm_wday = tod_2000.weekday; | ||
594 | t->tm_mon = tod_2000.month1 * 10 + tod_2000.month2 - 1; | ||
595 | t->tm_year = tod_2000.year1 * 10 + tod_2000.year2; | ||
596 | if (t->tm_year <= 69) | ||
597 | t->tm_year += 100; | ||
598 | |||
599 | if (!(tod_2000.cntrl3 & TOD2000_CNTRL3_24HMODE)) { | ||
600 | if (!(tod_2000.hour1 & TOD2000_HOUR1_PM) && t->tm_hour == 12) | ||
601 | t->tm_hour = 0; | ||
602 | else if ((tod_2000.hour1 & TOD2000_HOUR1_PM) && t->tm_hour != 12) | ||
603 | t->tm_hour += 12; | ||
604 | } | ||
605 | } else { | ||
606 | tod_2000.second1 = t->tm_sec / 10; | ||
607 | tod_2000.second2 = t->tm_sec % 10; | ||
608 | tod_2000.minute1 = t->tm_min / 10; | ||
609 | tod_2000.minute2 = t->tm_min % 10; | ||
610 | if (tod_2000.cntrl3 & TOD2000_CNTRL3_24HMODE) | ||
611 | tod_2000.hour1 = t->tm_hour / 10; | ||
612 | else if (t->tm_hour >= 12) | ||
613 | tod_2000.hour1 = TOD2000_HOUR1_PM + | ||
614 | (t->tm_hour - 12) / 10; | ||
615 | else | ||
616 | tod_2000.hour1 = t->tm_hour / 10; | ||
617 | tod_2000.hour2 = t->tm_hour % 10; | ||
618 | tod_2000.day1 = t->tm_mday / 10; | ||
619 | tod_2000.day2 = t->tm_mday % 10; | ||
620 | if (t->tm_wday != -1) | ||
621 | tod_2000.weekday = t->tm_wday; | ||
622 | tod_2000.month1 = (t->tm_mon + 1) / 10; | ||
623 | tod_2000.month2 = (t->tm_mon + 1) % 10; | ||
624 | if (t->tm_year >= 100) | ||
625 | t->tm_year -= 100; | ||
626 | tod_2000.year1 = t->tm_year / 10; | ||
627 | tod_2000.year2 = t->tm_year % 10; | ||
628 | } | ||
629 | |||
630 | tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD; | ||
631 | |||
632 | return 0; | ||
633 | } | ||
634 | |||
635 | static int amiga_set_clock_mmss(unsigned long nowtime) | ||
636 | { | ||
637 | short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60; | ||
638 | |||
639 | if (AMIGAHW_PRESENT(A3000_CLK)) { | ||
640 | tod_3000.cntrl1 = TOD3000_CNTRL1_HOLD; | ||
641 | |||
642 | tod_3000.second1 = real_seconds / 10; | ||
643 | tod_3000.second2 = real_seconds % 10; | ||
644 | tod_3000.minute1 = real_minutes / 10; | ||
645 | tod_3000.minute2 = real_minutes % 10; | ||
646 | |||
647 | tod_3000.cntrl1 = TOD3000_CNTRL1_FREE; | ||
648 | } else /* if (AMIGAHW_PRESENT(A2000_CLK)) */ { | ||
649 | int cnt = 5; | ||
650 | |||
651 | tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD; | ||
652 | |||
653 | while ((tod_2000.cntrl1 & TOD2000_CNTRL1_BUSY) && cnt) { | ||
654 | tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD; | ||
655 | udelay(70); | ||
656 | tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD; | ||
657 | --cnt; | ||
658 | } | ||
659 | |||
660 | if (!cnt) | ||
661 | printk(KERN_INFO "set_clock_mmss: timed out waiting for RTC (0x%x)\n", tod_2000.cntrl1); | ||
662 | |||
663 | tod_2000.second1 = real_seconds / 10; | ||
664 | tod_2000.second2 = real_seconds % 10; | ||
665 | tod_2000.minute1 = real_minutes / 10; | ||
666 | tod_2000.minute2 = real_minutes % 10; | ||
667 | |||
668 | tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD; | ||
669 | } | ||
670 | |||
671 | return 0; | ||
672 | } | ||
673 | |||
674 | static unsigned int amiga_get_ss(void) | ||
675 | { | ||
676 | unsigned int s; | ||
677 | |||
678 | if (AMIGAHW_PRESENT(A3000_CLK)) { | ||
679 | tod_3000.cntrl1 = TOD3000_CNTRL1_HOLD; | ||
680 | s = tod_3000.second1 * 10 + tod_3000.second2; | ||
681 | tod_3000.cntrl1 = TOD3000_CNTRL1_FREE; | ||
682 | } else /* if (AMIGAHW_PRESENT(A2000_CLK)) */ { | ||
683 | s = tod_2000.second1 * 10 + tod_2000.second2; | ||
684 | } | ||
685 | return s; | ||
686 | } | ||
687 | |||
688 | static NORET_TYPE void amiga_reset(void) | 514 | static NORET_TYPE void amiga_reset(void) |
689 | ATTRIB_NORET; | 515 | ATTRIB_NORET; |
690 | 516 | ||
diff --git a/arch/m68k/amiga/platform.c b/arch/m68k/amiga/platform.c index c985db029503..7fd8b41723ea 100644 --- a/arch/m68k/amiga/platform.c +++ b/arch/m68k/amiga/platform.c | |||
@@ -116,6 +116,13 @@ static const struct gayle_ide_platform_data a4000_ide_pdata __initconst = { | |||
116 | }; | 116 | }; |
117 | 117 | ||
118 | 118 | ||
119 | static const struct resource amiga_rtc_resource __initconst = { | ||
120 | .start = 0x00dc0000, | ||
121 | .end = 0x00dcffff, | ||
122 | .flags = IORESOURCE_MEM, | ||
123 | }; | ||
124 | |||
125 | |||
119 | static int __init amiga_init_devices(void) | 126 | static int __init amiga_init_devices(void) |
120 | { | 127 | { |
121 | struct platform_device *pdev; | 128 | struct platform_device *pdev; |
@@ -174,6 +181,16 @@ static int __init amiga_init_devices(void) | |||
174 | if (AMIGAHW_PRESENT(AMI_PARALLEL)) | 181 | if (AMIGAHW_PRESENT(AMI_PARALLEL)) |
175 | platform_device_register_simple("amiga-parallel", -1, NULL, 0); | 182 | platform_device_register_simple("amiga-parallel", -1, NULL, 0); |
176 | 183 | ||
184 | |||
185 | /* real time clocks */ | ||
186 | if (AMIGAHW_PRESENT(A2000_CLK)) | ||
187 | platform_device_register_simple("rtc-msm6242", -1, | ||
188 | &amiga_rtc_resource, 1); | ||
189 | |||
190 | if (AMIGAHW_PRESENT(A3000_CLK)) | ||
191 | platform_device_register_simple("rtc-rp5c01", -1, | ||
192 | &amiga_rtc_resource, 1); | ||
193 | |||
177 | return 0; | 194 | return 0; |
178 | } | 195 | } |
179 | 196 | ||