All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tiejun Chen <tiejun.chen@windriver.com>
To: ralf@linux-mips.org, linux-mips@linux-mips.org
Cc: Tiejun Chen <tiejun.chen@windriver.com>
Subject: [PATCH v2] Support RTC on Malta
Date: Tue, 25 Nov 2008 16:33:20 +0800	[thread overview]
Message-ID: <1227602000-11618-1-git-send-email-tiejun.chen@windriver.com> (raw)

To create platform device for RTC to call platform driver successfully.

Signed-off-by: Tiejun Chen <tiejun.chen@windriver.com>
---
 arch/mips/configs/malta_defconfig    |    8 ++++-
 arch/mips/mti-malta/malta-platform.c |   47 +++++++++++++++++++++++++++++----
 2 files changed, 47 insertions(+), 8 deletions(-)

diff --git a/arch/mips/configs/malta_defconfig b/arch/mips/configs/malta_defconfig
index 74daa0c..aec64d0 100644
--- a/arch/mips/configs/malta_defconfig
+++ b/arch/mips/configs/malta_defconfig
@@ -1126,7 +1126,6 @@ CONFIG_LEGACY_PTY_COUNT=256
 # CONFIG_IPMI_HANDLER is not set
 # CONFIG_WATCHDOG is not set
 CONFIG_HW_RANDOM=m
-CONFIG_RTC=y
 # CONFIG_R3964 is not set
 # CONFIG_APPLICOM is not set
 # CONFIG_DRM is not set
@@ -1199,7 +1198,12 @@ CONFIG_USB_ARCH_HAS_EHCI=y
 # CONFIG_MMC is not set
 # CONFIG_NEW_LEDS is not set
 # CONFIG_INFINIBAND is not set
-# CONFIG_RTC_CLASS is not set
+CONFIG_RTC_CLASS=y
+
+#
+# Platform RTC drivers
+#
+CONFIG_RTC_DRV_CMOS=y
 
 #
 # DMA Engine support
diff --git a/arch/mips/mti-malta/malta-platform.c b/arch/mips/mti-malta/malta-platform.c
index 83b9bab..039e6e6 100644
--- a/arch/mips/mti-malta/malta-platform.c
+++ b/arch/mips/mti-malta/malta-platform.c
@@ -6,7 +6,10 @@
  * Copyright (C) 2007 MIPS Technologies, Inc.
  *   written by Ralf Baechle (ralf@linux-mips.org)
  *
- * Probe driver for the Malta's UART ports:
+ * Copyright (C) 2008 Wind River Systems, Inc. 
+ *   updated by Tiejun Chen <tiejun.chen@windriver.com> 
+ *
+ * 1. Probe driver for the Malta's UART ports:
  *
  *   o 2 ports in the SMC SuperIO
  *   o 1 port in the CBUS UART, a discrete 16550 which normally is only used
@@ -14,10 +17,14 @@
  *
  * We don't use 8250_platform.c on Malta as it would result in the CBUS
  * UART becoming ttyS0.
+ *
+ * 2. Register RTC-CMOS platform device on Malta.
  */
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/serial_8250.h>
+#include <linux/mc146818rtc.h>
+#include <linux/platform_device.h>
 
 #define SMC_PORT(base, int)						\
 {									\
@@ -53,13 +60,41 @@ static struct platform_device uart8250_device = {
 	},
 };
 
-static int __init uart8250_init(void)
+static int __init malta_uart8250_init(void)
 {
 	return platform_device_register(&uart8250_device);
 }
 
-module_init(uart8250_init);
+struct resource malta_rtc_resource[] = {
+	{
+		.start	= RTC_PORT(0),			
+		.end	= RTC_PORT(7),
+		.flags	= IORESOURCE_IO,
+	}, {
+		.start	= RTC_IRQ,
+		.end	= RTC_IRQ,
+		.flags	= IORESOURCE_IRQ,
+	}
+};
+
+static int __init malta_rtc_init(void)
+{
+	struct platform_device *pd;
+	
+	pd = platform_device_register_simple("rtc_cmos", -1, malta_rtc_resource, 
+						ARRAY_SIZE(malta_rtc_resource));
+
+	if (IS_ERR(pd))
+		return PTR_ERR(pd);
+	
+	/* Try setting rtc as BCD mode to support
+	 * current alarm code if possible.
+	 */
+	if (!RTC_ALWAYS_BCD)
+		CMOS_WRITE(CMOS_READ(RTC_CONTROL) & ~RTC_DM_BINARY, RTC_CONTROL);
+
+	return 0;
+}
 
-MODULE_AUTHOR("Ralf Baechle <ralf@linux-mips.org>");
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("8250 UART probe driver for the Malta CBUS UART");
+device_initcall(malta_rtc_init);
+device_initcall(malta_uart8250_init);
-- 
1.5.5.1

                 reply	other threads:[~2008-11-25  8:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1227602000-11618-1-git-send-email-tiejun.chen@windriver.com \
    --to=tiejun.chen@windriver.com \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.