Bug#484693: linux-2.6: Add RTC class support for powerpc64 machines
Package: linux-2.6
Version: 2.6.25
Severity: normal
Tags: patch
The attached kernel and config.powerpc64 patches add a
new style RTC class driver that works with most powerpc64
platforms.
This driver, enabled with the CONFIG_RTC_DRV_PPC option,
replaces the old gen_rtc support that was enabled with
the CONFIG_GEN_RTC option. The old CONFIG_GEN_RTC option
is incompatible with the RTC class system and can no
longer be enabled in the Debian kernel config.
This patch has been submitted for mainline 2.6.27:
http://patchwork.ozlabs.org/linuxppc/patch?id=18139
Without this RTC class driver, the following error can
be seen at start up:
Setting the system clock.
Cannot access the Hardware Clock via any known method.
Use the --debug option to see the details of our search for an access method.
* Unable to set System Clock to: Fri May 30 20:33:06 UTC 2008
The problem can also be reproduced with these steps:
# hwclock --debug
hwclock from util-linux-ng 2.13.1.1
hwclock: Open of /dev/rtc failed, errno=2: No such file or directory.
No usable clock interface found.
Cannot access the Hardware Clock via any known method.
# ls -l /dev/rtc*
ls: cannot access /dev/rtc*: No such file or directory
-- System Information:
Debian Release: lenny/sid
APT prefers testing
APT policy: (500, 'testing')
Architecture: powerpc (ppc64)
Kernel: Linux 2.6.25-3-powerpc64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
--- a/debian/config/powerpc/config.powerpc64
+++ b/debian/config/powerpc/config.powerpc64
@@ -155,6 +155,11 @@ CONFIG_IBM_NEW_EMAC_RX_SKB_HEADROOM=0
##
# CONFIG_HOTPLUG_PCI is not set
+###
+### file: drivers/rtc/Kconfig
+###
+CONFIG_RTC_DRV_PPC=m
+
##
## file: drivers/scsi/Kconfig
##
>From dwmw2@infradead.org Fri Apr 25 19:29:12 2008
From: David Woodhouse <dwmw2@infradead.org>
Subject: [PATCH, RESEND] RTC class driver for ppc_md RTC functions
Date: Fri, 25 Apr 2008 19:29:12 +1000
X-Patchwork-ID: 18139
This hooks up the platform-specific [gs]et_rtc_time functions so that
kernels using CONFIG_RTC_CLASS have RTC support on most PowerPC
platforms.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
---
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 1e6715e..3e788b7 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -461,4 +461,12 @@ config RTC_DRV_RS5C313
help
If you say yes here you get support for the Ricoh RS5C313 RTC chips.
+config RTC_DRV_PPC
+ tristate "PowerPC machine dependent RTC support"
+ depends on PPC_MERGE
+ help
+ The PowerPC kernel has machine-specific functions for accessing
+ the RTC. This exposes that functionality through the generic RTC
+ class.
+
endif # RTC_CLASS
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 465db4d..e822e56 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -49,3 +49,4 @@ obj-$(CONFIG_RTC_DRV_TEST) += rtc-test.o
obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o
obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o
obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o
+obj-$(CONFIG_RTC_DRV_PPC) += rtc-ppc.o
--- /dev/null 2007-12-03 03:08:41.854157978 +0000
+++ b/drivers/rtc/rtc-ppc.c 2007-12-03 16:56:15.000000000 +0000
@@ -0,0 +1,69 @@
+/*
+ * RTC driver for ppc_md RTC functions
+ *
+ * © 2007 Red Hat, Inc.
+ *
+ * Author: David Woodhouse <dwmw2@infradead.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/rtc.h>
+#include <linux/platform_device.h>
+#include <asm/machdep.h>
+
+static int ppc_rtc_read_time(struct device *dev, struct rtc_time *tm)
+{
+ ppc_md.get_rtc_time(tm);
+ return 0;
+}
+
+static int ppc_rtc_set_time(struct device *dev, struct rtc_time *tm)
+{
+ return ppc_md.set_rtc_time(tm);
+}
+
+static const struct rtc_class_ops ppc_rtc_ops = {
+ .set_time = ppc_rtc_set_time,
+ .read_time = ppc_rtc_read_time,
+};
+
+static struct rtc_device *rtc;
+static struct platform_device *ppc_rtc_pdev;
+
+static int __init ppc_rtc_init(void)
+{
+ if (!ppc_md.get_rtc_time || !ppc_md.set_rtc_time)
+ return -ENODEV;
+
+ ppc_rtc_pdev = platform_device_register_simple("ppc-rtc", 0, NULL, 0);
+ if (IS_ERR(ppc_rtc_pdev))
+ return PTR_ERR(ppc_rtc_pdev);
+
+ rtc = rtc_device_register("ppc_md", &ppc_rtc_pdev->dev,
+ &ppc_rtc_ops, THIS_MODULE);
+ if (IS_ERR(rtc)) {
+ platform_device_unregister(ppc_rtc_pdev);
+ return PTR_ERR(rtc);
+ }
+
+ return 0;
+}
+
+static void __exit ppc_rtc_exit(void)
+{
+ rtc_device_unregister(rtc);
+ platform_device_unregister(ppc_rtc_pdev);
+}
+
+module_init(ppc_rtc_init);
+module_exit(ppc_rtc_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
+MODULE_DESCRIPTION("Generic RTC class driver for PowerPC");
Reply to: