aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/jmr3927/rbhma3100/setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/jmr3927/rbhma3100/setup.c')
-rw-r--r--arch/mips/jmr3927/rbhma3100/setup.c39
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
177extern void rtc_ds1742_init(unsigned long base);
178#endif
179static void __init jmr3927_time_init(void) 176static 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
190void __init plat_timer_setup(struct irqaction *irq) 182void __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. */
537unsigned 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}
548EXPORT_SYMBOL(__swizzle_addr_b);
549
550static 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}
563device_initcall(jmr3927_rtc_init);