diff options
author | Atsushi Nemoto <anemo@mba.ocn.ne.jp> | 2007-02-28 10:40:21 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2007-03-04 14:02:34 -0500 |
commit | a0574e04807608998d4d115c07b7bc12bb499a44 (patch) | |
tree | 41995893f58885097144c6d6908efa3bd4f7f735 /arch/mips/jmr3927/rbhma3100 | |
parent | 148171b2ac1fb6a1a9f987f8daedc146c810a8ae (diff) |
[MIPS] Convert to RTC-class ds1742 driver
The generic rtc-ds1742 driver can be used for RBTX4927 and JMR3927
(with __swizzle_addr trick). This patch also removes MIPS local
DS1742 stuff.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/jmr3927/rbhma3100')
-rw-r--r-- | arch/mips/jmr3927/rbhma3100/setup.c | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/arch/mips/jmr3927/rbhma3100/setup.c b/arch/mips/jmr3927/rbhma3100/setup.c index ecabe5b08489..fc523bda068f 100644 --- a/arch/mips/jmr3927/rbhma3100/setup.c +++ b/arch/mips/jmr3927/rbhma3100/setup.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <linux/param.h> /* for HZ */ | 45 | #include <linux/param.h> /* for HZ */ |
46 | #include <linux/delay.h> | 46 | #include <linux/delay.h> |
47 | #include <linux/pm.h> | 47 | #include <linux/pm.h> |
48 | #include <linux/platform_device.h> | ||
48 | #ifdef CONFIG_SERIAL_TXX9 | 49 | #ifdef CONFIG_SERIAL_TXX9 |
49 | #include <linux/tty.h> | 50 | #include <linux/tty.h> |
50 | #include <linux/serial.h> | 51 | #include <linux/serial.h> |
@@ -172,19 +173,10 @@ static cycle_t jmr3927_hpt_read(void) | |||
172 | return jiffies * (JMR3927_TIMER_CLK / HZ) + jmr3927_tmrptr->trr; | 173 | return jiffies * (JMR3927_TIMER_CLK / HZ) + jmr3927_tmrptr->trr; |
173 | } | 174 | } |
174 | 175 | ||
175 | #define USE_RTC_DS1742 | ||
176 | #ifdef USE_RTC_DS1742 | ||
177 | extern void rtc_ds1742_init(unsigned long base); | ||
178 | #endif | ||
179 | static void __init jmr3927_time_init(void) | 176 | static void __init jmr3927_time_init(void) |
180 | { | 177 | { |
181 | clocksource_mips.read = jmr3927_hpt_read; | 178 | clocksource_mips.read = jmr3927_hpt_read; |
182 | mips_hpt_frequency = JMR3927_TIMER_CLK; | 179 | mips_hpt_frequency = JMR3927_TIMER_CLK; |
183 | #ifdef USE_RTC_DS1742 | ||
184 | if (jmr3927_have_nvram()) { | ||
185 | rtc_ds1742_init(JMR3927_IOC_NVRAMB_ADDR); | ||
186 | } | ||
187 | #endif | ||
188 | } | 180 | } |
189 | 181 | ||
190 | void __init plat_timer_setup(struct irqaction *irq) | 182 | void __init plat_timer_setup(struct irqaction *irq) |
@@ -540,3 +532,32 @@ void __init tx3927_setup(void) | |||
540 | printk("TX3927 D-Cache WriteBack (CWF) .\n"); | 532 | printk("TX3927 D-Cache WriteBack (CWF) .\n"); |
541 | } | 533 | } |
542 | } | 534 | } |
535 | |||
536 | /* This trick makes rtc-ds1742 driver usable as is. */ | ||
537 | unsigned long __swizzle_addr_b(unsigned long port) | ||
538 | { | ||
539 | if ((port & 0xffff0000) != JMR3927_IOC_NVRAMB_ADDR) | ||
540 | return port; | ||
541 | port = (port & 0xffff0000) | (port & 0x7fff << 1); | ||
542 | #ifdef __BIG_ENDIAN | ||
543 | return port; | ||
544 | #else | ||
545 | return port | 1; | ||
546 | #endif | ||
547 | } | ||
548 | EXPORT_SYMBOL(__swizzle_addr_b); | ||
549 | |||
550 | static int __init jmr3927_rtc_init(void) | ||
551 | { | ||
552 | struct resource res = { | ||
553 | .start = JMR3927_IOC_NVRAMB_ADDR - IO_BASE, | ||
554 | .end = JMR3927_IOC_NVRAMB_ADDR - IO_BASE + 0x800 - 1, | ||
555 | .flags = IORESOURCE_MEM, | ||
556 | }; | ||
557 | struct platform_device *dev; | ||
558 | if (!jmr3927_have_nvram()) | ||
559 | return -ENODEV; | ||
560 | dev = platform_device_register_simple("ds1742", -1, &res, 1); | ||
561 | return IS_ERR(dev) ? PTR_ERR(dev) : 0; | ||
562 | } | ||
563 | device_initcall(jmr3927_rtc_init); | ||