diff mbox

[6/7] ARM: rtc: update CMOS RTC to support MMIO and private lock

Message ID 1398418275-9671-7-git-send-email-marc.zyngier@arm.com
State New
Headers show

Commit Message

Marc Zyngier April 25, 2014, 9:31 a.m. UTC
So far, the CMOS RTC (PC-style mc146818) has always been used
through an ISA I/O port of some sort, with each platform configuring
the address in a static way.

Some platforms (KVM with kvmtools, for example) offer a MMIO version
of the CMOS RTC, which requires a different access method.

This patch select the RTC_DRV_CMOS_MMIO configuration in order to
support MMIO accesses as well as the older IO port method.

While we're at it, switch to RTC_DRV_CMOS_PRIV_LOCK and remove the
ancient rtc_lock.

Tested on Cortex-A7 with KVM and kvmtools.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
 arch/arm/kernel/time.c | 7 -------
 drivers/rtc/Kconfig    | 2 ++
 2 files changed, 2 insertions(+), 7 deletions(-)

Comments

Russell King - ARM Linux April 25, 2014, 10:27 a.m. UTC | #1
On Fri, Apr 25, 2014 at 10:31:14AM +0100, Marc Zyngier wrote:
> So far, the CMOS RTC (PC-style mc146818) has always been used
> through an ISA I/O port of some sort, with each platform configuring
> the address in a static way.
> 
> Some platforms (KVM with kvmtools, for example) offer a MMIO version
> of the CMOS RTC, which requires a different access method.
> 
> This patch select the RTC_DRV_CMOS_MMIO configuration in order to
> support MMIO accesses as well as the older IO port method.
> 
> While we're at it, switch to RTC_DRV_CMOS_PRIV_LOCK and remove the
> ancient rtc_lock.

rtc_lock is there so that if you build the RTC driver and nvram driver
in, and load them, they will both want to access the RTC via its
indexed registers, and they need to share the lock to avoid trampling
on each others toes.

Yes, it should be handled in a more modern way, but I don't think you
can simply get rid of this in this manner.  We can have both these
drivers loaded on ARM platforms.
Marc Zyngier April 25, 2014, 12:32 p.m. UTC | #2
Hi Russell,

On 25/04/14 11:27, Russell King - ARM Linux wrote:
> On Fri, Apr 25, 2014 at 10:31:14AM +0100, Marc Zyngier wrote:
>> So far, the CMOS RTC (PC-style mc146818) has always been used
>> through an ISA I/O port of some sort, with each platform configuring
>> the address in a static way.
>>
>> Some platforms (KVM with kvmtools, for example) offer a MMIO version
>> of the CMOS RTC, which requires a different access method.
>>
>> This patch select the RTC_DRV_CMOS_MMIO configuration in order to
>> support MMIO accesses as well as the older IO port method.
>>
>> While we're at it, switch to RTC_DRV_CMOS_PRIV_LOCK and remove the
>> ancient rtc_lock.
> 
> rtc_lock is there so that if you build the RTC driver and nvram driver
> in, and load them, they will both want to access the RTC via its
> indexed registers, and they need to share the lock to avoid trampling
> on each others toes.

Ah, I completely missed that one. Note to self: never look at that kind
of code just after lunch...

> Yes, it should be handled in a more modern way, but I don't think you
> can simply get rid of this in this manner.  We can have both these
> drivers loaded on ARM platforms.

Agreed. I suppose that would have to be handled by some kind of module
dependency, but it is starting to look even uglier than I initially thought.

Back to the drawing board...

Thanks,

	M.
diff mbox

Patch

diff --git a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c
index 829a96d..38c8718 100644
--- a/arch/arm/kernel/time.c
+++ b/arch/arm/kernel/time.c
@@ -32,13 +32,6 @@ 
 #include <asm/stacktrace.h>
 #include <asm/thread_info.h>
 
-#if defined(CONFIG_RTC_DRV_CMOS) || defined(CONFIG_RTC_DRV_CMOS_MODULE) || \
-    defined(CONFIG_NVRAM) || defined(CONFIG_NVRAM_MODULE)
-/* this needs a better home */
-DEFINE_SPINLOCK(rtc_lock);
-EXPORT_SYMBOL(rtc_lock);
-#endif	/* pc-style 'CMOS' RTC support */
-
 /* change this if you have some constant time drift */
 #define USECS_PER_JIFFY	(1000000/HZ)
 
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 12bc27d..b2a512e 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -662,6 +662,8 @@  config RTC_DRV_CMOS
 	tristate "PC-style 'CMOS'"
 	depends on X86 || ARM || M32R || PPC || MIPS || SPARC64
 	default y if X86
+	select RTC_DRV_CMOS_MMIO if ARM
+	select RTC_DRV_CMOS_PRIV_LOCK if ARM
 	help
 	  Say "yes" here to get direct support for the real time clock
 	  found in every PC or ACPI-based system, and some other boards.