|
45 | 45 | #include <linux/param.h> /* for HZ */ |
46 | 46 | #include <linux/delay.h> |
47 | 47 | #include <linux/pm.h> |
| 48 | +#include <linux/platform_device.h> |
48 | 49 | #ifdef CONFIG_SERIAL_TXX9 |
49 | 50 | #include <linux/tty.h> |
50 | 51 | #include <linux/serial.h> |
@@ -172,19 +173,10 @@ static cycle_t jmr3927_hpt_read(void) |
172 | 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 | 176 | static void __init jmr3927_time_init(void) |
180 | 177 | { |
181 | 178 | clocksource_mips.read = jmr3927_hpt_read; |
182 | 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 | 182 | void __init plat_timer_setup(struct irqaction *irq) |
@@ -540,3 +532,32 @@ void __init tx3927_setup(void) |
540 | 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); |
0 commit comments