Skip to content

Commit a0574e0

Browse files
atsushi-nemotoralfbaechle
authored andcommitted
[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>
1 parent 148171b commit a0574e0

12 files changed

Lines changed: 86 additions & 339 deletions

File tree

‎arch/mips/Kconfig‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,10 +1895,6 @@ config HZ
18951895

18961896
source "kernel/Kconfig.preempt"
18971897

1898-
config RTC_DS1742
1899-
bool "DS1742 BRAM/RTC support"
1900-
depends on TOSHIBA_JMR3927 || TOSHIBA_RBTX4927
1901-
19021898
config MIPS_INSANE_LARGE
19031899
bool "Support for large 64-bit configurations"
19041900
depends on CPU_R10000 && 64BIT

‎arch/mips/configs/jmr3927_defconfig‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ CONFIG_HZ=1000
148148
CONFIG_PREEMPT_NONE=y
149149
# CONFIG_PREEMPT_VOLUNTARY is not set
150150
# CONFIG_PREEMPT is not set
151-
CONFIG_RTC_DS1742=y
152151
# CONFIG_KEXEC is not set
153152
CONFIG_LOCKDEP_SUPPORT=y
154153
CONFIG_STACKTRACE_SUPPORT=y
@@ -802,7 +801,28 @@ CONFIG_USB_ARCH_HAS_EHCI=y
802801
#
803802
# Real Time Clock
804803
#
805-
# CONFIG_RTC_CLASS is not set
804+
CONFIG_RTC_LIB=y
805+
CONFIG_RTC_CLASS=y
806+
CONFIG_RTC_HCTOSYS=y
807+
CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
808+
# CONFIG_RTC_DEBUG is not set
809+
810+
#
811+
# RTC interfaces
812+
#
813+
CONFIG_RTC_INTF_SYSFS=y
814+
CONFIG_RTC_INTF_PROC=y
815+
CONFIG_RTC_INTF_DEV=y
816+
# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
817+
818+
#
819+
# RTC drivers
820+
#
821+
# CONFIG_RTC_DRV_DS1553 is not set
822+
CONFIG_RTC_DRV_DS1742=y
823+
# CONFIG_RTC_DRV_M48T86 is not set
824+
# CONFIG_RTC_DRV_TEST is not set
825+
# CONFIG_RTC_DRV_V3020 is not set
806826

807827
#
808828
# DMA Engine support

‎arch/mips/jmr3927/common/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# Makefile for the common code of TOSHIBA JMR-TX3927 board
33
#
44

5-
obj-y += prom.o puts.o rtc_ds1742.o
5+
obj-y += prom.o puts.o

‎arch/mips/jmr3927/common/rtc_ds1742.c‎

Lines changed: 0 additions & 171 deletions
This file was deleted.

‎arch/mips/jmr3927/rbhma3100/setup.c‎

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include <linux/param.h> /* for HZ */
4646
#include <linux/delay.h>
4747
#include <linux/pm.h>
48+
#include <linux/platform_device.h>
4849
#ifdef CONFIG_SERIAL_TXX9
4950
#include <linux/tty.h>
5051
#include <linux/serial.h>
@@ -172,19 +173,10 @@ static cycle_t jmr3927_hpt_read(void)
172173
return jiffies * (JMR3927_TIMER_CLK / HZ) + jmr3927_tmrptr->trr;
173174
}
174175

175-
#define USE_RTC_DS1742
176-
#ifdef USE_RTC_DS1742
177-
extern void rtc_ds1742_init(unsigned long base);
178-
#endif
179176
static void __init jmr3927_time_init(void)
180177
{
181178
clocksource_mips.read = jmr3927_hpt_read;
182179
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
188180
}
189181

190182
void __init plat_timer_setup(struct irqaction *irq)
@@ -540,3 +532,32 @@ void __init tx3927_setup(void)
540532
printk("TX3927 D-Cache WriteBack (CWF) .\n");
541533
}
542534
}
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);

‎arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,6 @@ JP7 is not bus master -- do NOT use -- only 4 pci bus master's allowed -- SouthB
132132
#include <asm/wbflush.h>
133133
#include <linux/bootmem.h>
134134
#include <linux/blkdev.h>
135-
#ifdef CONFIG_RTC_DS1742
136-
#include <linux/ds1742rtc.h>
137-
#endif
138135
#ifdef CONFIG_TOSHIBA_FPCIB0
139136
#include <asm/tx4927/smsc_fdc37m81x.h>
140137
#endif

0 commit comments

Comments
 (0)