From patchwork Fri Apr 23 08:00:35 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 50794 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-ww0-f56.google.com (mail-ww0-f56.google.com [74.125.82.56]) by ozlabs.org (Postfix) with ESMTP id 2C730B7D1F for ; Fri, 23 Apr 2010 18:00:43 +1000 (EST) Received: by wwa36 with SMTP id 36sf354822wwa.11 for ; Fri, 23 Apr 2010 01:00:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:mime-version:x-beenthere:received :received:received:received:received-spf:received:received:from:to :cc:subject:date:message-id:x-mailer:in-reply-to:references :x-original-authentication-results:x-original-sender:reply-to :precedence:mailing-list:list-id:list-post:list-help:list-archive :sender:list-subscribe:list-unsubscribe:content-type; bh=CijkP9xsvBEDLZ4TrQ6+t99Syo8bwQOJClWkS/JZu4M=; b=xofeY4y3vpXWyqzeaplBtEZ3UdhmiFdsintn1OLAGoi4IHCtjj6RkfZc2Wov2BC/8n ftAF7TlFVUVMxaaDtN68qiRAucZImYpxeITb8zdhIcpn8zKbD5ThOUPJiBcsGVTO2KkW bT8/fSPss4R04gJiEqapH/7fmzEIzzp/v8dr8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=mime-version:x-beenthere:received-spf:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references :x-original-authentication-results:x-original-sender:reply-to :precedence:mailing-list:list-id:list-post:list-help:list-archive :sender:list-subscribe:list-unsubscribe:content-type; b=FdXxtkgmVnaffQQaAYQxU/s8d6QXemAYwIFA9bs/3ruzn+N2ngtC4pUdg85nz/bbpR GoG1oZRTQ4L5qiGZ+JLaTKC2YI28BLjQi4jayXnT4oeB+ytzoAnk+JiLBHuxXabmZ6Zi wfi/kpmUdinQLAmvcYIH5i2d5qNwbOsmqxfC0= Received: by 10.223.6.193 with SMTP id a1mr119877faa.21.1272009641094; Fri, 23 Apr 2010 01:00:41 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.213.70.78 with SMTP id c14ls7321442ebj.2.p; Fri, 23 Apr 2010 01:00:39 -0700 (PDT) Received: by 10.213.52.207 with SMTP id j15mr1158801ebg.3.1272009639184; Fri, 23 Apr 2010 01:00:39 -0700 (PDT) Received: by 10.213.52.207 with SMTP id j15mr1158800ebg.3.1272009639139; Fri, 23 Apr 2010 01:00:39 -0700 (PDT) Received: from georges.telenet-ops.be (georges.telenet-ops.be [195.130.137.68]) by gmr-mx.google.com with ESMTP id 11si39411ewy.1.2010.04.23.01.00.39; Fri, 23 Apr 2010 01:00:39 -0700 (PDT) Received-SPF: neutral (google.com: 195.130.137.68 is neither permitted nor denied by best guess record for domain of geert@linux-m68k.org) client-ip=195.130.137.68; Received: from ayla.of.borg ([94.224.189.190]) by georges.telenet-ops.be with bizsmtp id 8w0c1e00F46vLmN06w0cLF; Fri, 23 Apr 2010 10:00:38 +0200 Received: from geert by ayla.of.borg with local (Exim 4.69) (envelope-from ) id 1O5DoS-0001vR-A5; Fri, 23 Apr 2010 10:00:36 +0200 From: Geert Uytterhoeven To: linux-m68k@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Geert Uytterhoeven , rtc-linux@googlegroups.com Subject: [rtc-linux] [PATCH 14/14] m68k: amiga - RTC platform device conversion Date: Fri, 23 Apr 2010 10:00:35 +0200 Message-Id: <1272009635-6504-15-git-send-email-geert@linux-m68k.org> X-Mailer: git-send-email 1.6.0.4 In-Reply-To: <1272009635-6504-14-git-send-email-geert@linux-m68k.org> References: <1272009635-6504-1-git-send-email-geert@linux-m68k.org> <1272009635-6504-2-git-send-email-geert@linux-m68k.org> <1272009635-6504-3-git-send-email-geert@linux-m68k.org> <1272009635-6504-4-git-send-email-geert@linux-m68k.org> <1272009635-6504-5-git-send-email-geert@linux-m68k.org> <1272009635-6504-6-git-send-email-geert@linux-m68k.org> <1272009635-6504-7-git-send-email-geert@linux-m68k.org> <1272009635-6504-8-git-send-email-geert@linux-m68k.org> <1272009635-6504-9-git-send-email-geert@linux-m68k.org> <1272009635-6504-10-git-send-email-geert@linux-m68k.org> <1272009635-6504-11-git-send-email-geert@linux-m68k.org> <1272009635-6504-12-git-send-email-geert@linux-m68k.org> <1272009635-6504-13-git-send-email-geert@linux-m68k.org> <1272009635-6504-14-git-send-email-geert@linux-m68k.org> X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 195.130.137.68 is neither permitted nor denied by best guess record for domain of geert@linux-m68k.org) smtp.mail=geert@linux-m68k.org X-Original-Sender: geert@linux-m68k.org Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , The A2000 TOD is an Oki MSM6242B, while the A3000 TOD is a Ricoh RP5C01. Signed-off-by: Geert Uytterhoeven Cc: rtc-linux@googlegroups.com --- arch/m68k/amiga/config.c | 174 -------------------------------------------- arch/m68k/amiga/platform.c | 17 ++++ 2 files changed, 17 insertions(+), 174 deletions(-) diff --git a/arch/m68k/amiga/config.c b/arch/m68k/amiga/config.c index a50e8ab..abe0c38 100644 --- a/arch/m68k/amiga/config.c +++ b/arch/m68k/amiga/config.c @@ -97,10 +97,6 @@ static void amiga_get_model(char *model); static void amiga_get_hardware_list(struct seq_file *m); /* amiga specific timer functions */ static unsigned long amiga_gettimeoffset(void); -static int a3000_hwclk(int, struct rtc_time *); -static int a2000_hwclk(int, struct rtc_time *); -static int amiga_set_clock_mmss(unsigned long); -static unsigned int amiga_get_ss(void); extern void amiga_mksound(unsigned int count, unsigned int ticks); static void amiga_reset(void); extern void amiga_init_sound(void); @@ -141,10 +137,6 @@ static struct { } }; -static struct resource rtc_resource = { - .start = 0x00dc0000, .end = 0x00dcffff -}; - static struct resource ram_resource[NUM_MEMINFO]; @@ -390,15 +382,6 @@ void __init config_amiga(void) mach_get_model = amiga_get_model; mach_get_hardware_list = amiga_get_hardware_list; mach_gettimeoffset = amiga_gettimeoffset; - if (AMIGAHW_PRESENT(A3000_CLK)) { - mach_hwclk = a3000_hwclk; - rtc_resource.name = "A3000 RTC"; - request_resource(&iomem_resource, &rtc_resource); - } else /* if (AMIGAHW_PRESENT(A2000_CLK)) */ { - mach_hwclk = a2000_hwclk; - rtc_resource.name = "A2000 RTC"; - request_resource(&iomem_resource, &rtc_resource); - } /* * default MAX_DMA=0xffffffff on all machines. If we don't do so, the SCSI @@ -407,8 +390,6 @@ void __init config_amiga(void) */ mach_max_dma_address = 0xffffffff; - mach_set_clock_mmss = amiga_set_clock_mmss; - mach_get_ss = amiga_get_ss; mach_reset = amiga_reset; #if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE) mach_beep = amiga_mksound; @@ -536,161 +517,6 @@ static unsigned long amiga_gettimeoffset(void) return ticks + offset; } -static int a3000_hwclk(int op, struct rtc_time *t) -{ - tod_3000.cntrl1 = TOD3000_CNTRL1_HOLD; - - if (!op) { /* read */ - t->tm_sec = tod_3000.second1 * 10 + tod_3000.second2; - t->tm_min = tod_3000.minute1 * 10 + tod_3000.minute2; - t->tm_hour = tod_3000.hour1 * 10 + tod_3000.hour2; - t->tm_mday = tod_3000.day1 * 10 + tod_3000.day2; - t->tm_wday = tod_3000.weekday; - t->tm_mon = tod_3000.month1 * 10 + tod_3000.month2 - 1; - t->tm_year = tod_3000.year1 * 10 + tod_3000.year2; - if (t->tm_year <= 69) - t->tm_year += 100; - } else { - tod_3000.second1 = t->tm_sec / 10; - tod_3000.second2 = t->tm_sec % 10; - tod_3000.minute1 = t->tm_min / 10; - tod_3000.minute2 = t->tm_min % 10; - tod_3000.hour1 = t->tm_hour / 10; - tod_3000.hour2 = t->tm_hour % 10; - tod_3000.day1 = t->tm_mday / 10; - tod_3000.day2 = t->tm_mday % 10; - if (t->tm_wday != -1) - tod_3000.weekday = t->tm_wday; - tod_3000.month1 = (t->tm_mon + 1) / 10; - tod_3000.month2 = (t->tm_mon + 1) % 10; - if (t->tm_year >= 100) - t->tm_year -= 100; - tod_3000.year1 = t->tm_year / 10; - tod_3000.year2 = t->tm_year % 10; - } - - tod_3000.cntrl1 = TOD3000_CNTRL1_FREE; - - return 0; -} - -static int a2000_hwclk(int op, struct rtc_time *t) -{ - int cnt = 5; - - tod_2000.cntrl1 = TOD2000_CNTRL1_HOLD; - - while ((tod_2000.cntrl1 & TOD2000_CNTRL1_BUSY) && cnt) { - tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD; - udelay(70); - tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD; - --cnt; - } - - if (!cnt) - printk(KERN_INFO "hwclk: timed out waiting for RTC (0x%x)\n", - tod_2000.cntrl1); - - if (!op) { /* read */ - t->tm_sec = tod_2000.second1 * 10 + tod_2000.second2; - t->tm_min = tod_2000.minute1 * 10 + tod_2000.minute2; - t->tm_hour = (tod_2000.hour1 & 3) * 10 + tod_2000.hour2; - t->tm_mday = tod_2000.day1 * 10 + tod_2000.day2; - t->tm_wday = tod_2000.weekday; - t->tm_mon = tod_2000.month1 * 10 + tod_2000.month2 - 1; - t->tm_year = tod_2000.year1 * 10 + tod_2000.year2; - if (t->tm_year <= 69) - t->tm_year += 100; - - if (!(tod_2000.cntrl3 & TOD2000_CNTRL3_24HMODE)) { - if (!(tod_2000.hour1 & TOD2000_HOUR1_PM) && t->tm_hour == 12) - t->tm_hour = 0; - else if ((tod_2000.hour1 & TOD2000_HOUR1_PM) && t->tm_hour != 12) - t->tm_hour += 12; - } - } else { - tod_2000.second1 = t->tm_sec / 10; - tod_2000.second2 = t->tm_sec % 10; - tod_2000.minute1 = t->tm_min / 10; - tod_2000.minute2 = t->tm_min % 10; - if (tod_2000.cntrl3 & TOD2000_CNTRL3_24HMODE) - tod_2000.hour1 = t->tm_hour / 10; - else if (t->tm_hour >= 12) - tod_2000.hour1 = TOD2000_HOUR1_PM + - (t->tm_hour - 12) / 10; - else - tod_2000.hour1 = t->tm_hour / 10; - tod_2000.hour2 = t->tm_hour % 10; - tod_2000.day1 = t->tm_mday / 10; - tod_2000.day2 = t->tm_mday % 10; - if (t->tm_wday != -1) - tod_2000.weekday = t->tm_wday; - tod_2000.month1 = (t->tm_mon + 1) / 10; - tod_2000.month2 = (t->tm_mon + 1) % 10; - if (t->tm_year >= 100) - t->tm_year -= 100; - tod_2000.year1 = t->tm_year / 10; - tod_2000.year2 = t->tm_year % 10; - } - - tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD; - - return 0; -} - -static int amiga_set_clock_mmss(unsigned long nowtime) -{ - short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60; - - if (AMIGAHW_PRESENT(A3000_CLK)) { - tod_3000.cntrl1 = TOD3000_CNTRL1_HOLD; - - tod_3000.second1 = real_seconds / 10; - tod_3000.second2 = real_seconds % 10; - tod_3000.minute1 = real_minutes / 10; - tod_3000.minute2 = real_minutes % 10; - - tod_3000.cntrl1 = TOD3000_CNTRL1_FREE; - } else /* if (AMIGAHW_PRESENT(A2000_CLK)) */ { - int cnt = 5; - - tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD; - - while ((tod_2000.cntrl1 & TOD2000_CNTRL1_BUSY) && cnt) { - tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD; - udelay(70); - tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD; - --cnt; - } - - if (!cnt) - printk(KERN_INFO "set_clock_mmss: timed out waiting for RTC (0x%x)\n", tod_2000.cntrl1); - - tod_2000.second1 = real_seconds / 10; - tod_2000.second2 = real_seconds % 10; - tod_2000.minute1 = real_minutes / 10; - tod_2000.minute2 = real_minutes % 10; - - tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD; - } - - return 0; -} - -static unsigned int amiga_get_ss(void) -{ - unsigned int s; - - if (AMIGAHW_PRESENT(A3000_CLK)) { - tod_3000.cntrl1 = TOD3000_CNTRL1_HOLD; - s = tod_3000.second1 * 10 + tod_3000.second2; - tod_3000.cntrl1 = TOD3000_CNTRL1_FREE; - } else /* if (AMIGAHW_PRESENT(A2000_CLK)) */ { - s = tod_2000.second1 * 10 + tod_2000.second2; - } - return s; -} - static NORET_TYPE void amiga_reset(void) ATTRIB_NORET; diff --git a/arch/m68k/amiga/platform.c b/arch/m68k/amiga/platform.c index c985db0..7fd8b41 100644 --- a/arch/m68k/amiga/platform.c +++ b/arch/m68k/amiga/platform.c @@ -116,6 +116,13 @@ static const struct gayle_ide_platform_data a4000_ide_pdata __initconst = { }; +static const struct resource amiga_rtc_resource __initconst = { + .start = 0x00dc0000, + .end = 0x00dcffff, + .flags = IORESOURCE_MEM, +}; + + static int __init amiga_init_devices(void) { struct platform_device *pdev; @@ -174,6 +181,16 @@ static int __init amiga_init_devices(void) if (AMIGAHW_PRESENT(AMI_PARALLEL)) platform_device_register_simple("amiga-parallel", -1, NULL, 0); + + /* real time clocks */ + if (AMIGAHW_PRESENT(A2000_CLK)) + platform_device_register_simple("rtc-msm6242", -1, + &amiga_rtc_resource, 1); + + if (AMIGAHW_PRESENT(A3000_CLK)) + platform_device_register_simple("rtc-rp5c01", -1, + &amiga_rtc_resource, 1); + return 0; }