diff mbox

[v1,3/3,loongson] RTC: Registration of Loongson RTC platform device

Message ID a597312c16b5cf32621a25e8444d15d23726727f.1257383766.git.wuzhangjin@gmail.com
State Changes Requested, archived
Headers show

Commit Message

Zhangjin Wu Nov. 5, 2009, 1:24 a.m. UTC
This patch add the RTC_LIB support for fuloong2e,fuloong2f.

To make hwclock work with it normally, please do:

kernel configuration:

Device Drivers --->
<*> Real Time Clock --->
	<*>   PC-style 'CMOS'

user-space configuration:

$ mknod /dev/rtc0 c 254 0

/dev/rtc0 is the default RTC device file.

Of course, if udevd installed, ignore the above user-space
configuration.

Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
 arch/mips/loongson/common/Makefile |    6 +++++
 arch/mips/loongson/common/rtc.c    |   43 ++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/loongson/common/rtc.c

Comments

Alessandro Zummo Dec. 3, 2009, 4:21 p.m. UTC | #1
On Thu,  5 Nov 2009 09:24:10 +0800
Wu Zhangjin <wuzhangjin@gmail.com> wrote:

> user-space configuration:
> 
> $ mknod /dev/rtc0 c 254 0

 That's not guaranteed.
Ralf Baechle Dec. 3, 2009, 5:11 p.m. UTC | #2
On Thu, Dec 03, 2009 at 05:21:10PM +0100, Alessandro Zummo wrote:

> > user-space configuration:
> > 
> > $ mknod /dev/rtc0 c 254 0
> 
>  That's not guaranteed. 

Thanks, I've fixed that comment.

  Ralf
diff mbox

Patch

diff --git a/arch/mips/loongson/common/Makefile b/arch/mips/loongson/common/Makefile
index d21d116..d1bd38c 100644
--- a/arch/mips/loongson/common/Makefile
+++ b/arch/mips/loongson/common/Makefile
@@ -10,3 +10,9 @@  obj-y += setup.o init.o cmdline.o env.o time.o reset.o irq.o \
 #
 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
 obj-$(CONFIG_SERIAL_8250) += serial.o
+
+# Enable RTC Class support
+#
+# please enable CONFIG_RTC_DRV_CMOS
+#
+obj-$(CONFIG_RTC_DRV_CMOS) += rtc.o
diff --git a/arch/mips/loongson/common/rtc.c b/arch/mips/loongson/common/rtc.c
new file mode 100644
index 0000000..1f88791
--- /dev/null
+++ b/arch/mips/loongson/common/rtc.c
@@ -0,0 +1,43 @@ 
+/*
+ *  Registration of Loongson RTC platform device.
+ *
+ *  Copyright (C) 2007  Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
+ *  Copyright (C) 2009  Wu Zhangjin <wuzj@lemote.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ */
+
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/mc146818rtc.h>
+#include <linux/platform_device.h>
+
+static struct resource rtc_cmos_resource[] = {
+	{
+		.start	= RTC_PORT(0),
+		.end	= RTC_PORT(1),
+		.flags	= IORESOURCE_IO,
+	},
+	{
+		.start	= RTC_IRQ,
+		.end	= RTC_IRQ,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device rtc_cmos_device = {
+	.name		= "rtc_cmos",
+	.id		= -1,
+	.num_resources	= ARRAY_SIZE(rtc_cmos_resource),
+	.resource	= rtc_cmos_resource
+};
+
+static __init int rtc_cmos_init(void)
+{
+	return platform_device_register(&rtc_cmos_device);
+}
+
+device_initcall(rtc_cmos_init);