linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Generic RTC class support for ppc_md.[gs]et_rtc_time
@ 2007-12-03 17:04 David Woodhouse
  2007-12-03 20:45 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 5+ messages in thread
From: David Woodhouse @ 2007-12-03 17:04 UTC (permalink / raw)
  To: linuxppc-dev

It would be good to migrate the platform code to register RTC devices
directly, but for now this will make them functional enough for most
purposes...

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");

-- 
dwmw2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Generic RTC class support for ppc_md.[gs]et_rtc_time
  2007-12-03 17:04 [PATCH] Generic RTC class support for ppc_md.[gs]et_rtc_time David Woodhouse
@ 2007-12-03 20:45 ` Benjamin Herrenschmidt
  2007-12-03 21:06   ` David Woodhouse
  0 siblings, 1 reply; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2007-12-03 20:45 UTC (permalink / raw)
  To: David Woodhouse; +Cc: linuxppc-dev


On Mon, 2007-12-03 at 17:04 +0000, David Woodhouse wrote:
> It would be good to migrate the platform code to register RTC devices
> directly, but for now this will make them functional enough for most
> purposes...

Wouldn't it be best to do the other way around at some stage ?

We need to solve the problem of ppc_md. stuff being called by the core
in atomic contexts first though.

Ben.
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Generic RTC class support for ppc_md.[gs]et_rtc_time
  2007-12-03 20:45 ` Benjamin Herrenschmidt
@ 2007-12-03 21:06   ` David Woodhouse
  2007-12-03 22:36     ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 5+ messages in thread
From: David Woodhouse @ 2007-12-03 21:06 UTC (permalink / raw)
  To: benh; +Cc: linuxppc-dev

On Tue, 2007-12-04 at 07:45 +1100, Benjamin Herrenschmidt wrote:
> On Mon, 2007-12-03 at 17:04 +0000, David Woodhouse wrote:
> > It would be good to migrate the platform code to register RTC devices
> > directly, but for now this will make them functional enough for most
> > purposes...
> 
> Wouldn't it be best to do the other way around at some stage ?

Yes, definitely. We can migrate them one at a time to the RTC class.

> We need to solve the problem of ppc_md. stuff being called by the core
> in atomic contexts first though.

Where from?

-- 
dwmw2

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Generic RTC class support for ppc_md.[gs]et_rtc_time
  2007-12-03 21:06   ` David Woodhouse
@ 2007-12-03 22:36     ` Benjamin Herrenschmidt
  2007-12-03 22:44       ` David Woodhouse
  0 siblings, 1 reply; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2007-12-03 22:36 UTC (permalink / raw)
  To: David Woodhouse; +Cc: linuxppc-dev


On Mon, 2007-12-03 at 21:06 +0000, David Woodhouse wrote:
> On Tue, 2007-12-04 at 07:45 +1100, Benjamin Herrenschmidt wrote:
> > On Mon, 2007-12-03 at 17:04 +0000, David Woodhouse wrote:
> > > It would be good to migrate the platform code to register RTC devices
> > > directly, but for now this will make them functional enough for most
> > > purposes...
> > 
> > Wouldn't it be best to do the other way around at some stage ?
> 
> Yes, definitely. We can migrate them one at a time to the RTC class.
> 
> > We need to solve the problem of ppc_md. stuff being called by the core
> > in atomic contexts first though.
> 
> Where from?

Worst one is time_init :-) Way too early to do any i2c babbling. Then
there used to be something with the NTP writeback, dunno if it's
changed.

Ben.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Generic RTC class support for ppc_md.[gs]et_rtc_time
  2007-12-03 22:36     ` Benjamin Herrenschmidt
@ 2007-12-03 22:44       ` David Woodhouse
  0 siblings, 0 replies; 5+ messages in thread
From: David Woodhouse @ 2007-12-03 22:44 UTC (permalink / raw)
  To: benh; +Cc: linuxppc-dev

On Tue, 2007-12-04 at 09:36 +1100, Benjamin Herrenschmidt wrote:
> Worst one is time_init :-) Way too early to do any i2c babbling. Then
> there used to be something with the NTP writeback, dunno if it's
> changed.

Setting the system time seems to be done in the new RTC class by a
late_initcall() in drivers/rtc/hctosys.c. In fact, it could even be done
in userspace.

NTP uses update_persistent_clock() and doesn't seem to have been
'solved' yet for the new RTC class. I don't think there's any particular
reason for it to do i2c stuff in that context though.

-- 
dwmw2

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-12-03 22:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-03 17:04 [PATCH] Generic RTC class support for ppc_md.[gs]et_rtc_time David Woodhouse
2007-12-03 20:45 ` Benjamin Herrenschmidt
2007-12-03 21:06   ` David Woodhouse
2007-12-03 22:36     ` Benjamin Herrenschmidt
2007-12-03 22:44       ` David Woodhouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).