David Howells | b920de1 | 2008-02-08 04:19:31 -0800 | [diff] [blame] | 1 | /* MN10300 RTC management |
| 2 | * |
| 3 | * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. |
| 4 | * Written by David Howells (dhowells@redhat.com) |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public Licence |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the Licence, or (at your option) any later version. |
| 10 | */ |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/module.h> |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/mc146818rtc.h> |
Arnd Bergmann | 5ee98ab | 2016-06-01 16:46:22 +0200 | [diff] [blame] | 15 | #include <linux/ioport.h> |
| 16 | #include <linux/platform_device.h> |
| 17 | |
David Howells | b920de1 | 2008-02-08 04:19:31 -0800 | [diff] [blame] | 18 | #include <asm/rtc-regs.h> |
| 19 | #include <asm/rtc.h> |
| 20 | |
| 21 | DEFINE_SPINLOCK(rtc_lock); |
| 22 | EXPORT_SYMBOL(rtc_lock); |
| 23 | |
Arnd Bergmann | 5ee98ab | 2016-06-01 16:46:22 +0200 | [diff] [blame] | 24 | static const __initdata struct resource res[] = { |
| 25 | DEFINE_RES_IO(RTC_PORT(0), RTC_IO_EXTENT), |
| 26 | DEFINE_RES_IRQ(RTC_IRQ), |
| 27 | }; |
David Howells | b920de1 | 2008-02-08 04:19:31 -0800 | [diff] [blame] | 28 | |
| 29 | /* |
| 30 | * calibrate the TSC clock against the RTC |
| 31 | */ |
| 32 | void __init calibrate_clock(void) |
| 33 | { |
David Howells | b920de1 | 2008-02-08 04:19:31 -0800 | [diff] [blame] | 34 | unsigned char status; |
| 35 | |
| 36 | /* make sure the RTC is running and is set to operate in 24hr mode */ |
| 37 | status = RTSRC; |
| 38 | RTCRB |= RTCRB_SET; |
| 39 | RTCRB |= RTCRB_TM_24HR; |
Akira Takeuchi | 368dd5a | 2010-10-27 17:28:55 +0100 | [diff] [blame] | 40 | RTCRB &= ~RTCRB_DM_BINARY; |
David Howells | b920de1 | 2008-02-08 04:19:31 -0800 | [diff] [blame] | 41 | RTCRA |= RTCRA_DVR; |
| 42 | RTCRA &= ~RTCRA_DVR; |
| 43 | RTCRB &= ~RTCRB_SET; |
Arnd Bergmann | 5ee98ab | 2016-06-01 16:46:22 +0200 | [diff] [blame] | 44 | |
| 45 | platform_device_register_simple("rtc_cmos", -1, res, ARRAY_SIZE(res)); |
David Howells | b920de1 | 2008-02-08 04:19:31 -0800 | [diff] [blame] | 46 | } |