Received: from mail.onstor.com (66.201.51.107) by exch1.onstor.net
 (10.0.0.225) with Microsoft SMTP Server id 8.1.311.2; Tue, 25 Nov 2008
 00:36:18 -0800
Received: from chiesmta2-3.messageone.com ([216.203.30.55]) by mail.onstor.com
 with Microsoft SMTPSVC(6.0.3790.3959);	 Tue, 25 Nov 2008 00:36:18 -0800
Received: from ftp.linux-mips.org (ftp.linux-mips.org [213.58.128.207])	by
 chiesmta2-3.messageone.com (8.13.8/8.13.8) with ESMTP id mAP8aG2N030268	for
 <andy.sharp@onstor.com>; Tue, 25 Nov 2008 02:36:17 -0600
Received: from localhost.localdomain ([127.0.0.1]:20693 "EHLO
	ftp.linux-mips.org") by ftp.linux-mips.org with ESMTP	id S23901483AbYKYIc3
 (ORCPT <rfc822;andy.sharp@onstor.com>);	Tue, 25 Nov 2008 08:32:29 +0000
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 25 Nov 2008 08:32:12
 +0000 (GMT)
Received: from mail.windriver.com ([147.11.1.11]:26325 "EHLO mail.wrs.com")	by
 ftp.linux-mips.org with ESMTP id S23901478AbYKYIcB (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Tue, 25 Nov 2008 08:32:01 +0000
Received: from ALA-MAIL03.corp.ad.wrs.com (ala-mail03 [147.11.57.144])	by
 mail.wrs.com (8.13.6/8.13.6) with ESMTP id mAP8VroU020053;	Tue, 25 Nov 2008
 00:31:53 -0800 (PST)
Received: from localhost.localdomain ([128.224.162.71]) by
 ALA-MAIL03.corp.ad.wrs.com with Microsoft SMTPSVC(6.0.3790.1830);	 Tue, 25
 Nov 2008 00:31:52 -0800
From: Tiejun Chen <tiejun.chen@windriver.com>
To: "ralf@linux-mips.org" <ralf@linux-mips.org>, "linux-mips@linux-mips.org"
	<linux-mips@linux-mips.org>
CC: Tiejun Chen <tiejun.chen@windriver.com>
Sender: "linux-mips-bounce@linux-mips.org" <linux-mips-bounce@linux-mips.org>
Date: Tue, 25 Nov 2008 00:33:20 -0800
Subject: [PATCH v2] Support RTC on Malta
Thread-Topic: [PATCH v2] Support RTC on Malta
Thread-Index: AclO2OMsvSw0Pz7dRrCGGURAWcfVIw==
Message-ID: <1227602000-11618-1-git-send-email-tiejun.chen@windriver.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 0b
X-MS-Exchange-Organization-AuthSource: exch1.onstor.net
X-MS-Has-Attach:
X-Auto-Response-Suppress: All
X-MS-TNEF-Correlator:
x-originalarrivaltime: 25 Nov 2008 08:31:52.0711 (UTC)
 FILETIME=[44924970:01C94ED8]
errors-to: linux-mips-bounce@linux-mips.org
x-ems-proccessed: 2K3Xl1OQTInXD6xxuA8z3Q==
x-ems-stamp: LzvtgMZr1H+vzJnMTfOCjg==
x-messageone-virus-version: vendor=fsecure
 engine=4.65.7400:2.4.4,1.2.40,4.0.164
 definitions=2008-11-25_02:2008-11-24,2008-11-25,2008-11-25 signatures=0
x-messageone-virus-scanned: Clean
x-messageone-envelope-sender: linux-mips-bounce@linux-mips.org
x-messageone-spam-details: rule=m773emszm_notspam policy=m773emszm score=0
 spamscore=0 ipscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam
 adjust=0 reason=mlx engine=3.1.0-0810130000 definitions=main-0811250002
x-messageone-spam-score: 0
x-messageone-spam-bar:
x-list: linux-mips
x-archive-position: 21413
x-ecartis-version: Ecartis v1.0.0
x-original-sender: tiejun.chen@windriver.com
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

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_de=
fconfig
index 74daa0c..aec64d0 100644
--- a/arch/mips/configs/malta_defconfig
+++ b/arch/mips/configs/malta_defconfig
@@ -1126,7 +1126,6 @@ CONFIG_LEGACY_PTY_COUNT=3D256
 # CONFIG_IPMI_HANDLER is not set
 # CONFIG_WATCHDOG is not set
 CONFIG_HW_RANDOM=3Dm
-CONFIG_RTC=3Dy
 # CONFIG_R3964 is not set
 # CONFIG_APPLICOM is not set
 # CONFIG_DRM is not set
@@ -1199,7 +1198,12 @@ CONFIG_USB_ARCH_HAS_EHCI=3Dy
 # 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=3Dy
+
+#
+# Platform RTC drivers
+#
+CONFIG_RTC_DRV_CMOS=3Dy
=20
 #
 # DMA Engine support
diff --git a/arch/mips/mti-malta/malta-platform.c b/arch/mips/mti-malta/mal=
ta-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.=20
+ *   updated by Tiejun Chen <tiejun.chen@windriver.com>=20
+ *
+ * 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 us=
ed
@@ -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>
=20
 #define SMC_PORT(base, int)						\
 {									\
@@ -53,13 +60,41 @@ static struct platform_device uart8250_device =3D {
 	},
 };
=20
-static int __init uart8250_init(void)
+static int __init malta_uart8250_init(void)
 {
 	return platform_device_register(&uart8250_device);
 }
=20
-module_init(uart8250_init);
+struct resource malta_rtc_resource[] =3D {
+	{
+		.start	=3D RTC_PORT(0),		=09
+		.end	=3D RTC_PORT(7),
+		.flags	=3D IORESOURCE_IO,
+	}, {
+		.start	=3D RTC_IRQ,
+		.end	=3D RTC_IRQ,
+		.flags	=3D IORESOURCE_IRQ,
+	}
+};
+
+static int __init malta_rtc_init(void)
+{
+	struct platform_device *pd;
+=09
+	pd =3D platform_device_register_simple("rtc_cmos", -1, malta_rtc_resource=
,=20
+						ARRAY_SIZE(malta_rtc_resource));
+
+	if (IS_ERR(pd))
+		return PTR_ERR(pd);
+=09
+	/* 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;
+}
=20
-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);
--=20
1.5.5.1


