Commit cdee99d7 authored by David S. Miller's avatar David S. Miller

[SPARC64]: Stop using drivers/char/rtc.c

The existing sparc64 mini_rtc driver can handle CMOS based
rtcs trivially with just a few lines of code and the simplifies
things tremendously.

Tested on SB1500.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0fe85d50
...@@ -1434,6 +1434,78 @@ static int bq4802_set_rtc_time(struct rtc_time *time) ...@@ -1434,6 +1434,78 @@ static int bq4802_set_rtc_time(struct rtc_time *time)
return 0; return 0;
} }
static void cmos_get_rtc_time(struct rtc_time *rtc_tm)
{
unsigned char ctrl;
rtc_tm->tm_sec = CMOS_READ(RTC_SECONDS);
rtc_tm->tm_min = CMOS_READ(RTC_MINUTES);
rtc_tm->tm_hour = CMOS_READ(RTC_HOURS);
rtc_tm->tm_mday = CMOS_READ(RTC_DAY_OF_MONTH);
rtc_tm->tm_mon = CMOS_READ(RTC_MONTH);
rtc_tm->tm_year = CMOS_READ(RTC_YEAR);
rtc_tm->tm_wday = CMOS_READ(RTC_DAY_OF_WEEK);
ctrl = CMOS_READ(RTC_CONTROL);
if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
BCD_TO_BIN(rtc_tm->tm_sec);
BCD_TO_BIN(rtc_tm->tm_min);
BCD_TO_BIN(rtc_tm->tm_hour);
BCD_TO_BIN(rtc_tm->tm_mday);
BCD_TO_BIN(rtc_tm->tm_mon);
BCD_TO_BIN(rtc_tm->tm_year);
BCD_TO_BIN(rtc_tm->tm_wday);
}
if (rtc_tm->tm_year <= 69)
rtc_tm->tm_year += 100;
rtc_tm->tm_mon--;
}
static int cmos_set_rtc_time(struct rtc_time *rtc_tm)
{
unsigned char mon, day, hrs, min, sec;
unsigned char save_control, save_freq_select;
unsigned int yrs;
yrs = rtc_tm->tm_year;
mon = rtc_tm->tm_mon + 1;
day = rtc_tm->tm_mday;
hrs = rtc_tm->tm_hour;
min = rtc_tm->tm_min;
sec = rtc_tm->tm_sec;
if (yrs >= 100)
yrs -= 100;
if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
BIN_TO_BCD(sec);
BIN_TO_BCD(min);
BIN_TO_BCD(hrs);
BIN_TO_BCD(day);
BIN_TO_BCD(mon);
BIN_TO_BCD(yrs);
}
save_control = CMOS_READ(RTC_CONTROL);
CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
save_freq_select = CMOS_READ(RTC_FREQ_SELECT);
CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
CMOS_WRITE(yrs, RTC_YEAR);
CMOS_WRITE(mon, RTC_MONTH);
CMOS_WRITE(day, RTC_DAY_OF_MONTH);
CMOS_WRITE(hrs, RTC_HOURS);
CMOS_WRITE(min, RTC_MINUTES);
CMOS_WRITE(sec, RTC_SECONDS);
CMOS_WRITE(save_control, RTC_CONTROL);
CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
return 0;
}
#endif /* CONFIG_PCI */ #endif /* CONFIG_PCI */
struct mini_rtc_ops { struct mini_rtc_ops {
...@@ -1456,6 +1528,11 @@ static struct mini_rtc_ops bq4802_rtc_ops = { ...@@ -1456,6 +1528,11 @@ static struct mini_rtc_ops bq4802_rtc_ops = {
.get_rtc_time = bq4802_get_rtc_time, .get_rtc_time = bq4802_get_rtc_time,
.set_rtc_time = bq4802_set_rtc_time, .set_rtc_time = bq4802_set_rtc_time,
}; };
static struct mini_rtc_ops cmos_rtc_ops = {
.get_rtc_time = cmos_get_rtc_time,
.set_rtc_time = cmos_set_rtc_time,
};
#endif /* CONFIG_PCI */ #endif /* CONFIG_PCI */
static struct mini_rtc_ops *mini_rtc_ops; static struct mini_rtc_ops *mini_rtc_ops;
...@@ -1583,6 +1660,8 @@ static int __init rtc_mini_init(void) ...@@ -1583,6 +1660,8 @@ static int __init rtc_mini_init(void)
#ifdef CONFIG_PCI #ifdef CONFIG_PCI
else if (bq4802_regs) else if (bq4802_regs)
mini_rtc_ops = &bq4802_rtc_ops; mini_rtc_ops = &bq4802_rtc_ops;
else if (ds1287_regs)
mini_rtc_ops = &cmos_rtc_ops;
#endif /* CONFIG_PCI */ #endif /* CONFIG_PCI */
else else
return -ENODEV; return -ENODEV;
......
...@@ -726,7 +726,7 @@ config NVRAM ...@@ -726,7 +726,7 @@ config NVRAM
config RTC config RTC
tristate "Enhanced Real Time Clock Support" tristate "Enhanced Real Time Clock Support"
depends on !PPC && !PARISC && !IA64 && !M68K && (!SPARC || PCI) && !FRV && !ARM && !SUPERH && !S390 depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC64 && (!SPARC32 || PCI) && !FRV && !ARM && !SUPERH && !S390
---help--- ---help---
If you say Y here and create a character special file /dev/rtc with If you say Y here and create a character special file /dev/rtc with
major number 10 and minor number 135 using mknod ("man mknod"), you major number 10 and minor number 135 using mknod ("man mknod"), you
......
...@@ -86,12 +86,9 @@ ...@@ -86,12 +86,9 @@
#include <asm/hpet.h> #include <asm/hpet.h>
#endif #endif
#ifdef __sparc__ #ifdef CONFIG_SPARC32
#include <linux/pci.h> #include <linux/pci.h>
#include <asm/ebus.h> #include <asm/ebus.h>
#ifdef __sparc_v9__
#include <asm/isa.h>
#endif
static unsigned long rtc_port; static unsigned long rtc_port;
static int rtc_irq = PCI_IRQ_NONE; static int rtc_irq = PCI_IRQ_NONE;
...@@ -930,13 +927,9 @@ static int __init rtc_init(void) ...@@ -930,13 +927,9 @@ static int __init rtc_init(void)
unsigned int year, ctrl; unsigned int year, ctrl;
char *guess = NULL; char *guess = NULL;
#endif #endif
#ifdef __sparc__ #ifdef CONFIG_SPARC32
struct linux_ebus *ebus; struct linux_ebus *ebus;
struct linux_ebus_device *edev; struct linux_ebus_device *edev;
#ifdef __sparc_v9__
struct sparc_isa_bridge *isa_br;
struct sparc_isa_device *isa_dev;
#endif
#else #else
void *r; void *r;
#ifdef RTC_IRQ #ifdef RTC_IRQ
...@@ -944,7 +937,7 @@ static int __init rtc_init(void) ...@@ -944,7 +937,7 @@ static int __init rtc_init(void)
#endif #endif
#endif #endif
#ifdef __sparc__ #ifdef CONFIG_SPARC32
for_each_ebus(ebus) { for_each_ebus(ebus) {
for_each_ebusdev(edev, ebus) { for_each_ebusdev(edev, ebus) {
if(strcmp(edev->prom_node->name, "rtc") == 0) { if(strcmp(edev->prom_node->name, "rtc") == 0) {
...@@ -954,17 +947,6 @@ static int __init rtc_init(void) ...@@ -954,17 +947,6 @@ static int __init rtc_init(void)
} }
} }
} }
#ifdef __sparc_v9__
for_each_isa(isa_br) {
for_each_isadev(isa_dev, isa_br) {
if (strcmp(isa_dev->prom_node->name, "rtc") == 0) {
rtc_port = isa_dev->resource.start;
rtc_irq = isa_dev->irq;
goto found;
}
}
}
#endif
rtc_has_irq = 0; rtc_has_irq = 0;
printk(KERN_ERR "rtc_init: no PC rtc found\n"); printk(KERN_ERR "rtc_init: no PC rtc found\n");
return -EIO; return -EIO;
...@@ -1020,7 +1002,7 @@ static int __init rtc_init(void) ...@@ -1020,7 +1002,7 @@ static int __init rtc_init(void)
#endif #endif
#endif /* __sparc__ vs. others */ #endif /* CONFIG_SPARC32 vs. others */
if (misc_register(&rtc_dev)) { if (misc_register(&rtc_dev)) {
#ifdef RTC_IRQ #ifdef RTC_IRQ
...@@ -1105,7 +1087,7 @@ static void __exit rtc_exit (void) ...@@ -1105,7 +1087,7 @@ static void __exit rtc_exit (void)
remove_proc_entry ("driver/rtc", NULL); remove_proc_entry ("driver/rtc", NULL);
misc_deregister(&rtc_dev); misc_deregister(&rtc_dev);
#ifdef __sparc__ #ifdef CONFIG_SPARC32
if (rtc_has_irq) if (rtc_has_irq)
free_irq (rtc_irq, &rtc_port); free_irq (rtc_irq, &rtc_port);
#else #else
...@@ -1117,7 +1099,7 @@ static void __exit rtc_exit (void) ...@@ -1117,7 +1099,7 @@ static void __exit rtc_exit (void)
if (rtc_has_irq) if (rtc_has_irq)
free_irq (RTC_IRQ, NULL); free_irq (RTC_IRQ, NULL);
#endif #endif
#endif /* __sparc__ */ #endif /* CONFIG_SPARC32 */
} }
module_init(rtc_init); module_init(rtc_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment