diff options
-rw-r--r-- | arch/sparc64/kernel/time.c | 79 | ||||
-rw-r--r-- | drivers/char/Kconfig | 2 | ||||
-rw-r--r-- | drivers/char/rtc.c | 30 |
3 files changed, 86 insertions, 25 deletions
diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c index 592ffcd57605..e340eb401fb9 100644 --- a/arch/sparc64/kernel/time.c +++ b/arch/sparc64/kernel/time.c | |||
@@ -1434,6 +1434,78 @@ static int bq4802_set_rtc_time(struct rtc_time *time) | |||
1434 | 1434 | ||
1435 | return 0; | 1435 | return 0; |
1436 | } | 1436 | } |
1437 | |||
1438 | static void cmos_get_rtc_time(struct rtc_time *rtc_tm) | ||
1439 | { | ||
1440 | unsigned char ctrl; | ||
1441 | |||
1442 | rtc_tm->tm_sec = CMOS_READ(RTC_SECONDS); | ||
1443 | rtc_tm->tm_min = CMOS_READ(RTC_MINUTES); | ||
1444 | rtc_tm->tm_hour = CMOS_READ(RTC_HOURS); | ||
1445 | rtc_tm->tm_mday = CMOS_READ(RTC_DAY_OF_MONTH); | ||
1446 | rtc_tm->tm_mon = CMOS_READ(RTC_MONTH); | ||
1447 | rtc_tm->tm_year = CMOS_READ(RTC_YEAR); | ||
1448 | rtc_tm->tm_wday = CMOS_READ(RTC_DAY_OF_WEEK); | ||
1449 | |||
1450 | ctrl = CMOS_READ(RTC_CONTROL); | ||
1451 | if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { | ||
1452 | BCD_TO_BIN(rtc_tm->tm_sec); | ||
1453 | BCD_TO_BIN(rtc_tm->tm_min); | ||
1454 | BCD_TO_BIN(rtc_tm->tm_hour); | ||
1455 | BCD_TO_BIN(rtc_tm->tm_mday); | ||
1456 | BCD_TO_BIN(rtc_tm->tm_mon); | ||
1457 | BCD_TO_BIN(rtc_tm->tm_year); | ||
1458 | BCD_TO_BIN(rtc_tm->tm_wday); | ||
1459 | } | ||
1460 | |||
1461 | if (rtc_tm->tm_year <= 69) | ||
1462 | rtc_tm->tm_year += 100; | ||
1463 | |||
1464 | rtc_tm->tm_mon--; | ||
1465 | } | ||
1466 | |||
1467 | static int cmos_set_rtc_time(struct rtc_time *rtc_tm) | ||
1468 | { | ||
1469 | unsigned char mon, day, hrs, min, sec; | ||
1470 | unsigned char save_control, save_freq_select; | ||
1471 | unsigned int yrs; | ||
1472 | |||
1473 | yrs = rtc_tm->tm_year; | ||
1474 | mon = rtc_tm->tm_mon + 1; | ||
1475 | day = rtc_tm->tm_mday; | ||
1476 | hrs = rtc_tm->tm_hour; | ||
1477 | min = rtc_tm->tm_min; | ||
1478 | sec = rtc_tm->tm_sec; | ||
1479 | |||
1480 | if (yrs >= 100) | ||
1481 | yrs -= 100; | ||
1482 | |||
1483 | if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { | ||
1484 | BIN_TO_BCD(sec); | ||
1485 | BIN_TO_BCD(min); | ||
1486 | BIN_TO_BCD(hrs); | ||
1487 | BIN_TO_BCD(day); | ||
1488 | BIN_TO_BCD(mon); | ||
1489 | BIN_TO_BCD(yrs); | ||
1490 | } | ||
1491 | |||
1492 | save_control = CMOS_READ(RTC_CONTROL); | ||
1493 | CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL); | ||
1494 | save_freq_select = CMOS_READ(RTC_FREQ_SELECT); | ||
1495 | CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT); | ||
1496 | |||
1497 | CMOS_WRITE(yrs, RTC_YEAR); | ||
1498 | CMOS_WRITE(mon, RTC_MONTH); | ||
1499 | CMOS_WRITE(day, RTC_DAY_OF_MONTH); | ||
1500 | CMOS_WRITE(hrs, RTC_HOURS); | ||
1501 | CMOS_WRITE(min, RTC_MINUTES); | ||
1502 | CMOS_WRITE(sec, RTC_SECONDS); | ||
1503 | |||
1504 | CMOS_WRITE(save_control, RTC_CONTROL); | ||
1505 | CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT); | ||
1506 | |||
1507 | return 0; | ||
1508 | } | ||
1437 | #endif /* CONFIG_PCI */ | 1509 | #endif /* CONFIG_PCI */ |
1438 | 1510 | ||
1439 | struct mini_rtc_ops { | 1511 | struct mini_rtc_ops { |
@@ -1456,6 +1528,11 @@ static struct mini_rtc_ops bq4802_rtc_ops = { | |||
1456 | .get_rtc_time = bq4802_get_rtc_time, | 1528 | .get_rtc_time = bq4802_get_rtc_time, |
1457 | .set_rtc_time = bq4802_set_rtc_time, | 1529 | .set_rtc_time = bq4802_set_rtc_time, |
1458 | }; | 1530 | }; |
1531 | |||
1532 | static struct mini_rtc_ops cmos_rtc_ops = { | ||
1533 | .get_rtc_time = cmos_get_rtc_time, | ||
1534 | .set_rtc_time = cmos_set_rtc_time, | ||
1535 | }; | ||
1459 | #endif /* CONFIG_PCI */ | 1536 | #endif /* CONFIG_PCI */ |
1460 | 1537 | ||
1461 | static struct mini_rtc_ops *mini_rtc_ops; | 1538 | static struct mini_rtc_ops *mini_rtc_ops; |
@@ -1583,6 +1660,8 @@ static int __init rtc_mini_init(void) | |||
1583 | #ifdef CONFIG_PCI | 1660 | #ifdef CONFIG_PCI |
1584 | else if (bq4802_regs) | 1661 | else if (bq4802_regs) |
1585 | mini_rtc_ops = &bq4802_rtc_ops; | 1662 | mini_rtc_ops = &bq4802_rtc_ops; |
1663 | else if (ds1287_regs) | ||
1664 | mini_rtc_ops = &cmos_rtc_ops; | ||
1586 | #endif /* CONFIG_PCI */ | 1665 | #endif /* CONFIG_PCI */ |
1587 | else | 1666 | else |
1588 | return -ENODEV; | 1667 | return -ENODEV; |
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 4373d7cdc5d2..c8dfd18bea44 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig | |||
@@ -726,7 +726,7 @@ config NVRAM | |||
726 | 726 | ||
727 | config RTC | 727 | config RTC |
728 | tristate "Enhanced Real Time Clock Support" | 728 | tristate "Enhanced Real Time Clock Support" |
729 | depends on !PPC && !PARISC && !IA64 && !M68K && (!SPARC || PCI) && !FRV && !ARM && !SUPERH && !S390 | 729 | depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC64 && (!SPARC32 || PCI) && !FRV && !ARM && !SUPERH && !S390 |
730 | ---help--- | 730 | ---help--- |
731 | If you say Y here and create a character special file /dev/rtc with | 731 | If you say Y here and create a character special file /dev/rtc with |
732 | major number 10 and minor number 135 using mknod ("man mknod"), you | 732 | major number 10 and minor number 135 using mknod ("man mknod"), you |
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c index 22cf7aa56cc4..30c3f54c7666 100644 --- a/drivers/char/rtc.c +++ b/drivers/char/rtc.c | |||
@@ -86,12 +86,9 @@ | |||
86 | #include <asm/hpet.h> | 86 | #include <asm/hpet.h> |
87 | #endif | 87 | #endif |
88 | 88 | ||
89 | #ifdef __sparc__ | 89 | #ifdef CONFIG_SPARC32 |
90 | #include <linux/pci.h> | 90 | #include <linux/pci.h> |
91 | #include <asm/ebus.h> | 91 | #include <asm/ebus.h> |
92 | #ifdef __sparc_v9__ | ||
93 | #include <asm/isa.h> | ||
94 | #endif | ||
95 | 92 | ||
96 | static unsigned long rtc_port; | 93 | static unsigned long rtc_port; |
97 | static int rtc_irq = PCI_IRQ_NONE; | 94 | static int rtc_irq = PCI_IRQ_NONE; |
@@ -930,13 +927,9 @@ static int __init rtc_init(void) | |||
930 | unsigned int year, ctrl; | 927 | unsigned int year, ctrl; |
931 | char *guess = NULL; | 928 | char *guess = NULL; |
932 | #endif | 929 | #endif |
933 | #ifdef __sparc__ | 930 | #ifdef CONFIG_SPARC32 |
934 | struct linux_ebus *ebus; | 931 | struct linux_ebus *ebus; |
935 | struct linux_ebus_device *edev; | 932 | struct linux_ebus_device *edev; |
936 | #ifdef __sparc_v9__ | ||
937 | struct sparc_isa_bridge *isa_br; | ||
938 | struct sparc_isa_device *isa_dev; | ||
939 | #endif | ||
940 | #else | 933 | #else |
941 | void *r; | 934 | void *r; |
942 | #ifdef RTC_IRQ | 935 | #ifdef RTC_IRQ |
@@ -944,7 +937,7 @@ static int __init rtc_init(void) | |||
944 | #endif | 937 | #endif |
945 | #endif | 938 | #endif |
946 | 939 | ||
947 | #ifdef __sparc__ | 940 | #ifdef CONFIG_SPARC32 |
948 | for_each_ebus(ebus) { | 941 | for_each_ebus(ebus) { |
949 | for_each_ebusdev(edev, ebus) { | 942 | for_each_ebusdev(edev, ebus) { |
950 | if(strcmp(edev->prom_node->name, "rtc") == 0) { | 943 | if(strcmp(edev->prom_node->name, "rtc") == 0) { |
@@ -954,17 +947,6 @@ static int __init rtc_init(void) | |||
954 | } | 947 | } |
955 | } | 948 | } |
956 | } | 949 | } |
957 | #ifdef __sparc_v9__ | ||
958 | for_each_isa(isa_br) { | ||
959 | for_each_isadev(isa_dev, isa_br) { | ||
960 | if (strcmp(isa_dev->prom_node->name, "rtc") == 0) { | ||
961 | rtc_port = isa_dev->resource.start; | ||
962 | rtc_irq = isa_dev->irq; | ||
963 | goto found; | ||
964 | } | ||
965 | } | ||
966 | } | ||
967 | #endif | ||
968 | rtc_has_irq = 0; | 950 | rtc_has_irq = 0; |
969 | printk(KERN_ERR "rtc_init: no PC rtc found\n"); | 951 | printk(KERN_ERR "rtc_init: no PC rtc found\n"); |
970 | return -EIO; | 952 | return -EIO; |
@@ -1020,7 +1002,7 @@ no_irq: | |||
1020 | 1002 | ||
1021 | #endif | 1003 | #endif |
1022 | 1004 | ||
1023 | #endif /* __sparc__ vs. others */ | 1005 | #endif /* CONFIG_SPARC32 vs. others */ |
1024 | 1006 | ||
1025 | if (misc_register(&rtc_dev)) { | 1007 | if (misc_register(&rtc_dev)) { |
1026 | #ifdef RTC_IRQ | 1008 | #ifdef RTC_IRQ |
@@ -1105,7 +1087,7 @@ static void __exit rtc_exit (void) | |||
1105 | remove_proc_entry ("driver/rtc", NULL); | 1087 | remove_proc_entry ("driver/rtc", NULL); |
1106 | misc_deregister(&rtc_dev); | 1088 | misc_deregister(&rtc_dev); |
1107 | 1089 | ||
1108 | #ifdef __sparc__ | 1090 | #ifdef CONFIG_SPARC32 |
1109 | if (rtc_has_irq) | 1091 | if (rtc_has_irq) |
1110 | free_irq (rtc_irq, &rtc_port); | 1092 | free_irq (rtc_irq, &rtc_port); |
1111 | #else | 1093 | #else |
@@ -1117,7 +1099,7 @@ static void __exit rtc_exit (void) | |||
1117 | if (rtc_has_irq) | 1099 | if (rtc_has_irq) |
1118 | free_irq (RTC_IRQ, NULL); | 1100 | free_irq (RTC_IRQ, NULL); |
1119 | #endif | 1101 | #endif |
1120 | #endif /* __sparc__ */ | 1102 | #endif /* CONFIG_SPARC32 */ |
1121 | } | 1103 | } |
1122 | 1104 | ||
1123 | module_init(rtc_init); | 1105 | module_init(rtc_init); |