In order to use the RTC CMOS driver, each architecture must register a
platform device for the RTC.
This creates a function to register the platform device based on the RTC
device node and verifies that the RTC port against the hard-coded value
in asm/mc146818rtc.h. It also sets the RTC to 24-hr mode as 12-hr mode
is not currently supported by the driver.
Signed-off-by: Wade Farnsworth <redacted>
---
arch/powerpc/sysdev/Makefile | 1
arch/powerpc/sysdev/rtc_cmos_setup.c | 54 +++++++++++++++++++++++++
2 files changed, 55 insertions(+)
Index: linux-2.6-powerpc-8641/arch/powerpc/sysdev/Makefile
===================================================================
@@ -18,6 +18,7 @@ obj-$(CONFIG_TSI108_BRIDGE) += tsi108_pcobj-$(CONFIG_QUICC_ENGINE)+=qe_lib/mv64x60-$(CONFIG_PCI)+=mv64x60_pci.oobj-$(CONFIG_MV64X60)+=$(mv64x60-y)mv64x60_pic.omv64x60_dev.o+obj-$(CONFIG_RTC_DRV_CMOS)+=rtc_cmos_setup.o# contains only the suspend handler for timeobj-$(CONFIG_PM)+=timer.o
This creates a function to register the platform device based on the
RTC
device node and verifies that the RTC port against the hard-coded value
in asm/mc146818rtc.h. It also sets the RTC to 24-hr mode as 12-hr mode
is not currently supported by the driver.
The 24h thing should be set in the driver itself. Does the
driver handle binary vs. decimal mode btw? If not, you'll
want to do the analogue thing for that.
Segher
On Wed, 2007-06-20 at 12:06 +0200, Segher Boessenkool wrote:
quoted
This creates a function to register the platform device based on the
RTC
device node and verifies that the RTC port against the hard-coded value
in asm/mc146818rtc.h. It also sets the RTC to 24-hr mode as 12-hr mode
is not currently supported by the driver.
The 24h thing should be set in the driver itself. Does the
driver handle binary vs. decimal mode btw? If not, you'll
want to do the analogue thing for that.
OK, I'll look into putting the 24h fix into the driver.
It looks like binary mode is also not supported, so I'll add a fix for
that as well.
Thanks,
--Wade
In order to use the RTC CMOS driver, each architecture must register a
platform device for the RTC.
This creates a function to register the platform device based on the RTC
device node and verifies that the RTC port against the hard-coded value
in asm/mc146818rtc.h.
Signed-off-by: Wade Farnsworth <redacted>
---
arch/powerpc/sysdev/Makefile | 1
arch/powerpc/sysdev/rtc_cmos_setup.c | 51 +++++++++++++++++++++++++
2 files changed, 52 insertions(+)
Index: linux-2.6-powerpc-8641/arch/powerpc/sysdev/Makefile
===================================================================
@@ -18,6 +18,7 @@ obj-$(CONFIG_TSI108_BRIDGE) += tsi108_pcobj-$(CONFIG_QUICC_ENGINE)+=qe_lib/mv64x60-$(CONFIG_PCI)+=mv64x60_pci.oobj-$(CONFIG_MV64X60)+=$(mv64x60-y)mv64x60_pic.omv64x60_dev.o+obj-$(CONFIG_RTC_DRV_CMOS)+=rtc_cmos_setup.o# contains only the suspend handler for timeobj-$(CONFIG_PM)+=timer.o
From: David Gibson <hidden> Date: 2007-06-22 03:31:58
On Wed, Jun 20, 2007 at 09:59:32AM -0700, Wade Farnsworth wrote:
In order to use the RTC CMOS driver, each architecture must register a
platform device for the RTC.
This creates a function to register the platform device based on the RTC
device node and verifies that the RTC port against the hard-coded value
in asm/mc146818rtc.h.
Signed-off-by: Wade Farnsworth <redacted>
Hrm. It seems rather specific. Can we do this more generally, by
creating an of_platform device which binds to rtc nodes, then
registers an appropriate platform device for each so that the generic
rtc drivers pick them up. Obviously we'd need some sort of table
mapping the device node compatible properties to the appropriate
platform device names.
@@ -18,6 +18,7 @@ obj-$(CONFIG_TSI108_BRIDGE) += tsi108_pcobj-$(CONFIG_QUICC_ENGINE)+=qe_lib/mv64x60-$(CONFIG_PCI)+=mv64x60_pci.oobj-$(CONFIG_MV64X60)+=$(mv64x60-y)mv64x60_pic.omv64x60_dev.o+obj-$(CONFIG_RTC_DRV_CMOS)+=rtc_cmos_setup.o# contains only the suspend handler for timeobj-$(CONFIG_PM)+=timer.o
express
+ * or implied.
+ */
+
+#include <linux/platform_device.h>
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/mc146818rtc.h>
+
+#include <asm/prom.h>
+
+static int __init add_rtc(void)
+{
+ struct device_node *np;
+ struct platform_device *pd;
+ struct resource res;
+
+ np = of_find_compatible_node(NULL, NULL, "pnpPNP,b00");
+ if (!np)
+ return -ENODEV;
+
+ if (of_address_to_resource(np, 0, &res)) {
+ of_node_put(np);
+ return -ENODEV;
+ }
+
+ /*
+ * RTC_PORT(x) is hardcoded in asm/mc146818rtc.h. Verify that the
+ * address provided by the device node matches.
+ */
+ if (res.start != RTC_PORT(0)) {
+ of_node_put(np);
+ return -ENODEV;
+ }
This looks totally bogus. If we have a device tree we should be using
the address information from there, not using hardcoded magic. Sounds
like asm/mc146818rtc.h needs some serious fixing.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
Hrm. It seems rather specific. Can we do this more generally, by
creating an of_platform device which binds to rtc nodes, then
registers an appropriate platform device for each so that the generic
rtc drivers pick them up. Obviously we'd need some sort of table
mapping the device node compatible properties to the appropriate
platform device names.
quoted
+ * RTC_PORT(x) is hardcoded in asm/mc146818rtc.h. Verify that the
+ * address provided by the device node matches.
+ */
+ if (res.start != RTC_PORT(0)) {
+ of_node_put(np);
+ return -ENODEV;
+ }
This looks totally bogus. If we have a device tree we should be using
the address information from there, not using hardcoded magic. Sounds
like asm/mc146818rtc.h needs some serious fixing.
Both of your comments would be nice extensions (and the right
way forwards), but Wade's patch is good as-is already.
Segher
From: David Gibson <hidden> Date: 2007-06-25 03:33:48
On Fri, Jun 22, 2007 at 09:56:24AM +0200, Segher Boessenkool wrote:
quoted
Hrm. It seems rather specific. Can we do this more generally, by
creating an of_platform device which binds to rtc nodes, then
registers an appropriate platform device for each so that the generic
rtc drivers pick them up. Obviously we'd need some sort of table
mapping the device node compatible properties to the appropriate
platform device names.
quoted
quoted
+ * RTC_PORT(x) is hardcoded in asm/mc146818rtc.h. Verify that the
+ * address provided by the device node matches.
+ */
+ if (res.start != RTC_PORT(0)) {
+ of_node_put(np);
+ return -ENODEV;
+ }
This looks totally bogus. If we have a device tree we should be using
the address information from there, not using hardcoded magic. Sounds
like asm/mc146818rtc.h needs some serious fixing.
Both of your comments would be nice extensions (and the right
way forwards), but Wade's patch is good as-is already.
True enough.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
From: Paul Mackerras <hidden> Date: 2007-07-10 11:54:58
Wade Farnsworth writes:
In order to use the RTC CMOS driver, each architecture must register a
platform device for the RTC.
This creates a function to register the platform device based on the RTC
device node and verifies that the RTC port against the hard-coded value
in asm/mc146818rtc.h.
The patch appears to be line-wrapped. Please re-send.
Paul.
In order to use the RTC CMOS driver, each architecture must register a
platform device for the RTC.
This creates a function to register the platform device based on the RTC
device node and verifies that the RTC port against the hard-coded value
in asm/mc146818rtc.h.
Signed-off-by: Wade Farnsworth <redacted>
---
Fixed line wrapping.
arch/powerpc/sysdev/Makefile | 1
arch/powerpc/sysdev/rtc_cmos_setup.c | 49 +++++++++++++++++++++++++
2 files changed, 50 insertions(+)