From patchwork Wed May 20 21:52:39 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 27473 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from wf-out-1516.google.com (wf-out-1516.google.com [209.85.200.162]) by bilbo.ozlabs.org (Postfix) with ESMTP id 9A47BB7067 for ; Thu, 21 May 2009 07:53:00 +1000 (EST) Received: by wf-out-1516.google.com with SMTP id u12so101312wfc.41 for ; Wed, 20 May 2009 14:52:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:received:x-sender:x-apparently-to :received:received:received-spf:authentication-results:received :dkim-signature:domainkey-signature:received:received:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references:reply-to :sender:precedence:x-google-loop:mailing-list:list-id:list-post :list-help:list-unsubscribe:x-beenthere-env:x-beenthere; bh=ChRMMVFwls9ahCbGpl4wxVf/0eHtITXeDSvSb/8e9Hc=; b=10wKZ75nxVTTK/1ytZmOl6t/CG0V5kxe1NyS3v4RYiZ39jBdehJEcbRubAVGUN1q/q 4ga3oy11DJlnI3kGLpb8Hil+DJZ88rZAh+0b8ckMP4SFKfBezGQLPuZ0N3KwqW0SUGbl /vQCpkP2LL6flGIzsGndTyDJhHR/VUSyj+EVU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-sender:x-apparently-to:received-spf:authentication-results :dkim-signature:domainkey-signature:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references:reply-to:sender :precedence:x-google-loop:mailing-list:list-id:list-post:list-help :list-unsubscribe:x-beenthere-env:x-beenthere; b=m4djZ3/oPnrbVg+O4DhOPNXTlEwVkDCz0BCTQpYKLc3FVqgZoWms7FoHT/zErgowhE 9xkK77lpXByrECH+MKHohqp9w+ZzaAeg9AoPbQc81Ctki4TzJO4kWhMM6uRH+AaQgA9v KaG0P9Mm6nr5gMSY9t2Us2cuPb4lCJYaAPb5M= Received: by 10.143.156.17 with SMTP id i17mr305076wfo.28.1242856375362; Wed, 20 May 2009 14:52:55 -0700 (PDT) Received: by 10.106.168.10 with SMTP id q10gr2391pre.0; Wed, 20 May 2009 14:52:55 -0700 (PDT) X-Sender: wuzhangjin@gmail.com X-Apparently-To: rtc-linux@googlegroups.com Received: by 10.140.247.13 with SMTP id u13mr297693rvh.21.1242856374214; Wed, 20 May 2009 14:52:54 -0700 (PDT) Received: from mail-pz0-f191.google.com (mail-pz0-f191.google.com [209.85.222.191]) by gmr-mx.google.com with ESMTP id 24si88796pzk.5.2009.05.20.14.52.53; Wed, 20 May 2009 14:52:53 -0700 (PDT) Received-SPF: pass (google.com: domain of wuzhangjin@gmail.com designates 209.85.222.191 as permitted sender) client-ip=209.85.222.191; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of wuzhangjin@gmail.com designates 209.85.222.191 as permitted sender) smtp.mail=wuzhangjin@gmail.com; dkim=pass (test mode) header.i=@gmail.com Received: by pzk29 with SMTP id 29so567643pzk.26 for ; Wed, 20 May 2009 14:52:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=DEBRdaL0wPcLwCuexPQ3i37tPY2Ljg5qz8DcVgYBqT4=; b=OYZFP25r6DI7hIQ49LTJ7VJv9Y3hrw7qYE15hvJMGk/wvpmIP4EPMRBesy/ShwOchJ 1yCuuvyyJ80IZM31oCRSyT3buKXgurpjhYaU2QX9bDlYSGApi1CF8SxPaSy3cy1y6gmY o3Jp+eAutlca6XRhuRT1vZD2vz4XDpBX/SWaI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=dzylfglyFtsQnPbTyY/5J9rXl7sTYUPIqvlLJ4Iekpi4OPG0xZSmZ9/bRg9QBscoST ZMMLPBCqinnRbnx9pJdSfxRTvmLAYpcmGGT8QSnozmCV3a3dv15IjVyaWDgYld09gu+a ye/XjS7VnhvXvPiBPTdzADOcVhtgdC5/zA6Vk= Received: by 10.114.208.20 with SMTP id f20mr3604099wag.46.1242856373108; Wed, 20 May 2009 14:52:53 -0700 (PDT) Received: from localhost.localdomain ([222.92.8.142]) by mx.google.com with ESMTPS id d20sm3341671waa.47.2009.05.20.14.52.46 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 20 May 2009 14:52:52 -0700 (PDT) From: wuzhangjin@gmail.com To: linux-mips@linux-mips.org, Ralf Baechle , rtc-linux@googlegroups.com Cc: Wu Zhangjin , Yan hua , Philippe Vachon , Zhang Le , Zhang Fuxin , Arnaud Patard , loongson-dev@googlegroups.com, gnewsense-dev@nongnu.org, Nicholas Mc Guire , Liu Junliang , Erwan Lerale Subject: [rtc-linux] [loongson-PATCH-v1 09/27] enable Real Time Clock Support for fuloong(2e) Date: Thu, 21 May 2009 05:52:39 +0800 Message-Id: <3d13efa122929c5de37175a6da07b3bd856ab226.1242855716.git.wuzhangjin@gmail.com> X-Mailer: git-send-email 1.6.2.1 In-Reply-To: References: Reply-To: rtc-linux@googlegroups.com Sender: rtc-linux@googlegroups.com Precedence: bulk X-Google-Loop: groups Mailing-List: list rtc-linux@googlegroups.com; contact rtc-linux+owner@googlegroups.com List-Id: List-Post: List-Help: List-Unsubscribe: , X-BeenThere-Env: rtc-linux@googlegroups.com X-BeenThere: rtc-linux@googlegroups.com From: Wu Zhangjin by default, RTC_LIB is selected by MIPS, but if RTC_LIB is enabled, Enhanced Real Time Clock Support(RTC) will be disabled, so, to enable it, not select RTC_LIB in LEMOTE_FULOONG2E will fix this problem. RTC support is needed by some tools like hwclock, if you want hwclock work well, these two jobs need to do: kernel configuration: Device Drivers ---> Character devices ---> <*> Enhanced Real Time Clock Support (legacy PC RTC driver) user-space configuration: $ mknod /dev/rtc c 10 135 and there is another RTC support in linux, whose kernel option is RTC_CLASS, it should be fixed for fuloong(2e) via enabling the binary mode in driver/rtc/rtc-cmos.c and register the RTC device resource in a machine specific rtc.c 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. Signed-off-by: Wu Zhangjin --- arch/mips/Kconfig | 2 +- arch/mips/loongson/fuloong-2e/Makefile | 7 ++++ arch/mips/loongson/fuloong-2e/rtc.c | 55 ++++++++++++++++++++++++++++++++ drivers/rtc/rtc-cmos.c | 8 ++-- 4 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 arch/mips/loongson/fuloong-2e/rtc.c diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index d9ecb44..974ce41 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -6,7 +6,7 @@ config MIPS select HAVE_ARCH_KGDB # Horrible source of confusion. Die, die, die ... select EMBEDDED - select RTC_LIB + select RTC_LIB if !LEMOTE_FULOONG2E mainmenu "Linux/MIPS Kernel Configuration" diff --git a/arch/mips/loongson/fuloong-2e/Makefile b/arch/mips/loongson/fuloong-2e/Makefile index 035e04c..76904da 100644 --- a/arch/mips/loongson/fuloong-2e/Makefile +++ b/arch/mips/loongson/fuloong-2e/Makefile @@ -10,4 +10,11 @@ obj-y += setup.o init.o cmdline.o time.o reset.o irq.o \ # obj-$(CONFIG_EARLY_PRINTK) += early_printk.o +# +# Enable RTC Class support +# +# please enable CONFIG_RTC_DRV_CMOS +# +obj-$(CONFIG_RTC_DRV_CMOS) += rtc.o + EXTRA_CFLAGS += -Werror diff --git a/arch/mips/loongson/fuloong-2e/rtc.c b/arch/mips/loongson/fuloong-2e/rtc.c new file mode 100644 index 0000000..469ada8 --- /dev/null +++ b/arch/mips/loongson/fuloong-2e/rtc.c @@ -0,0 +1,55 @@ +/* + * Registration of Cobalt RTC platform device. + * + * Copyright (C) 2007 Yoichi Yuasa + * Copyright (C) 2009 Wu Zhangjin + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include +#include +#include +#include + +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) +{ + platform_device_register(&rtc_cmos_device); + + return 0; +} + +device_initcall(rtc_cmos_init); diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index b6d35f5..b24181e 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c @@ -691,7 +691,8 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) */ #if defined(CONFIG_ATARI) address_space = 64; -#elif defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__sparc__) +#elif defined(__i386__) || defined(__x86_64__) || defined(__arm__) \ + || defined(__sparc__) || defined(__mips__) address_space = 128; #else #warning Assuming 128 bytes of RTC+NVRAM address space, not 64 bytes. @@ -756,9 +757,8 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) /* FIXME teach the alarm code how to handle binary mode; * doesn't know 12-hour mode either. */ - if (is_valid_irq(rtc_irq) && - (!(rtc_control & RTC_24H) || (rtc_control & (RTC_DM_BINARY)))) { - dev_dbg(dev, "only 24-hr BCD mode supported\n"); + if (is_valid_irq(rtc_irq) && !(rtc_control & RTC_24H)) { + dev_dbg(dev, "only 24-hr supported\n"); retval = -ENXIO; goto cleanup1; }