Enable RTC for Ebony and Walnut
Subsystems (3)
This patch extends the Ebony and Walnut platform code to instantiate the existing ds1742 RTC class driver for the DS1743 RTC/NVRAM chip found on both those boards. The patch uses a helper function to scan the device tree and instantiate the appropriate platform_device based on it, so it should be easy to extend for other boards which have mmio mapped RTC chips.
Along with this, the device tree binding for the ds1743 chips is tweaked, based on the existing DS1385 OF binding found at:
http://playground.sun.com/1275/proposals/Closed/Remanded/Accepted/346-it.txt
Although that document covers the NVRAM portion of the chip, whereas here we're interested in the RTC portion, so it's not entirely clear if that's a good model.
This implements only RTC class driver support - that is /dev/rtc0, not /dev/rtc, and the low-level get/set time callbacks remain unimplemented. That means in order to get at the clock you will either need a modified version of hwclock which will look at /dev/rtc0, or you'll need to configure udev to symlink rtc0 to rtc.
arch/powerpc/boot/dts/ebony.dts +3 -2
@@ -150,9 +150,10 @@ }; }; - ds1743@1,0 { + nvram@1,0 { /* NVRAM & RTC */ - compatible = "ds1743"; + compatible = "ds1743-nvram"; + #bytes = <2000>; reg = <1 0 2000>; };
arch/powerpc/platforms/44x/ebony.c +2 -0
@@ -18,6 +18,7 @@#include <linux/init.h> #include <linux/of_platform.h> +#include <linux/rtc.h> #include <asm/machdep.h> #include <asm/prom.h>
@@ -40,6 +41,7 @@ static int __init ebony_device_probe(voireturn 0 ;of_platform_bus_probe (NULL , ebony_of_bus,NULL ); +of_instantiate_rtc ();return 0 ; }
arch/powerpc/platforms/Kconfig +3 -0
@@ -315,6 +315,9 @@ config FSL_ULI1575 config CPM bool +config OF_RTC + bool + source "arch/powerpc/sysdev/bestcomm/Kconfig" endmenu
arch/powerpc/sysdev/Makefile +1 -0
@@ -27,6 +27,7 @@ obj-$(CONFIG_PPC_I8259) += i8259.o obj-$(CONFIG_PPC_83xx) += ipic.o obj-$(CONFIG_4xx) += uic.o obj-$(CONFIG_XILINX_VIRTEX) += xilinx_intc.o +obj-$(CONFIG_OF_RTC) += of_rtc.o endif # Temporary hack until we have migrated to asm-powerpc
arch/powerpc/sysdev/of_rtc.c new file +59 -0
59 lines not on this page · raw message
arch/powerpc/platforms/44x/Kconfig +1 -0
@@ -11,6 +11,7 @@ config EBONY depends on 44x default y select 440GP + select OF_RTC help This option enables support for the IBM PPC440GP evaluation board.
include/asm-powerpc/of_platform.h +2 -0
@@ -37,4 +37,6 @@ extern int of_platform_bus_probe(structextern struct of_device *of_find_device_by_phandle (phandle ph); +extern void of_instantiate_rtc (void ); +#endif /* _ASM_POWERPC_OF_PLATFORM_H */
arch/powerpc/boot/dts/walnut.dts +3 -2
@@ -168,9 +168,10 @@ }; }; - ds1743@1,0 { + nvram@1,0 { /* NVRAM and RTC */ - compatible = "ds1743"; + compatible = "ds1743-nvram"; + #bytes = <2000>; reg = <1 0 2000>; };
arch/powerpc/platforms/40x/walnut.c +1 -0
@@ -39,6 +39,7 @@ static int __init walnut_device_probe(vo/* FIXME: do bus probe here */ of_platform_bus_probe (NULL , walnut_of_bus,NULL ); +of_instantiate_rtc ();return 0 ; }
Signature · 4 lines
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
Quoted 3 lines · On Fri, 21 Dec 2007 13:21:30 +1100 David Gibson <[email protected]>…
+++
working-2.6/arch/powerpc/sysdev/of_rtc.c2007-12-21 13:11:34.000000000 +1100
+#include <asm/of_platform.h>
Use linux/of_platform.h, please.
arch/powerpc/sysdev/of_rtc.c line 16
Quoted 2 lines
arch/powerpc/sysdev/of_rtc.c new file +2
-0+ +static struct {
const or __initdata
arch/powerpc/sysdev/of_rtc.c line 17
Quoted 1 line
arch/powerpc/sysdev/of_rtc.c new file +1
-0+char *compatible;
const
arch/powerpc/sysdev/of_rtc.c line 18
Quoted 1 line
arch/powerpc/sysdev/of_rtc.c new file +1
-0+char *plat_name;
const (ok, no, thanks to platform_device_register_simple()).
arch/powerpc/sysdev/of_rtc.c line 30
Quoted 12 lines
arch/powerpc/sysdev/of_rtc.c new file +12
-0+} of_rtc_table[] = { + { "ds1743-nvram", "rtc-ds1742" }, +}; + +void __init of_instantiate_rtc(void) +{ + struct device_node *node; + int err; + int i; + + for (i = 0; i < ARRAY_SIZE(of_rtc_table); i++) { + char *compatible = of_rtc_table[i].compatible;
const (or maybe just use of_rtc_table[i].compatible directly in the one place it is used).
Signature · 3 lines
Cheers, Stephen Rothwell [email protected] http://www.canb.auug.org.au/~sfr/
Hi,
arch/powerpc/platforms/Kconfig config FSL_ULI1575 · line 320
Quoted 11 lines · David Gibson
Index: working-2.6/arch/powerpc/platforms/Kconfig
===================================================================arch/powerpc/platforms/Kconfig +3
-0@@ -315,6 +315,9 @@ config FSL_ULI1575 config CPM bool +config OF_RTC + bool +
New config options should have descriptions, even if they're silent ones.
Thanks,
-Olof
Quoted 11 lines · Olof Johansson
Hi,
Quoted 8 lines · David Gibson
Index: working-2.6/arch/powerpc/platforms/Kconfig
===================================================================arch/powerpc/platforms/Kconfig +0
-0@@ -315,6 +315,9 @@ config FSL_ULI1575 config CPM bool
Quoted 6 lines
arch/powerpc/platforms/Kconfig config FSL_ULI1575 · line 320
Quoted 3 lines
arch/powerpc/platforms/Kconfig +3
-0+config OF_RTC + bool +New config options should have descriptions, even if they're silent ones.
Uh.. but if there's a description, won't kconfig prompt for the option? This one should only ever be selected by the platform options.
Signature · 4 lines
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
Quoted 19 lines · David Gibson
Quoted 11 lines · Olof Johansson
Hi,
Quoted 8 lines · David Gibson
Index: working-2.6/arch/powerpc/platforms/Kconfig
===================================================================arch/powerpc/platforms/Kconfig +0
-0@@ -315,6 +315,9 @@ config FSL_ULI1575 config CPM boolQuoted 6 lines
arch/powerpc/platforms/Kconfig config FSL_ULI1575 · line 320
Quoted 3 lines
arch/powerpc/platforms/Kconfig +3
-0+config OF_RTC + bool +New config options should have descriptions, even if they're silent ones.
Quoted 3 lines
Uh.. but if there's a description, won't kconfig prompt for the option? This one should only ever be selected by the platform options.
Sorry, should have said "should have help texts to describe them". Yes, the one-line description will trigger a question, but adding a short help text describing what the config option is for does not.
-Olof
Enable RTC for Ebony and Walnut (v2)
In reply to David GibsonThis patch extends the Ebony and Walnut platform code to instantiate the existing ds1742 RTC class driver for the DS1743 RTC/NVRAM chip found on both those boards. The patch uses a helper function to scan the device tree and instantiate the appropriate platform_device based on it, so it should be easy to extend for other boards which have mmio mapped RTC chips.
Along with this, the device tree binding for the ds1743 chips is tweaked, based on the existing DS1385 OF binding found at:
http://playground.sun.com/1275/proposals/Closed/Remanded/Accepted/346-it.txt
Although that document covers the NVRAM portion of the chip, whereas here we're interested in the RTC portion, so it's not entirely clear if that's a good model.
This implements only RTC class driver support - that is /dev/rtc0, not /dev/rtc, and the low-level get/set time callbacks remain unimplemented. That means in order to get at the clock you will either need a modified version of hwclock which will look at /dev/rtc0, or you'll need to configure udev to symlink rtc0 to rtc.
---
Updated for kernel changes and feedback.
arch/powerpc/boot/dts/ebony.dts +3 -2
@@ -158,9 +158,10 @@ }; }; - ds1743@1,0 { + nvram@1,0 { /* NVRAM & RTC */ - compatible = "ds1743"; + compatible = "ds1743-nvram"; + #bytes = <2000>; reg = <1 0 2000>; };
arch/powerpc/platforms/44x/ebony.c +2 -0
@@ -18,6 +18,7 @@#include <linux/init.h> #include <linux/of_platform.h> +#include <linux/rtc.h> #include <asm/machdep.h> #include <asm/prom.h>
@@ -38,6 +39,7 @@ static __initdata struct of_device_id ebstatic int __init ebony_device_probe (void ) {of_platform_bus_probe (NULL , ebony_of_bus,NULL ); +of_instantiate_rtc ();return 0 ; }
arch/powerpc/platforms/Kconfig +6 -0
@@ -315,6 +315,12 @@ config FSL_ULI1575 config CPM bool +config OF_RTC + bool + help + Uses information from the OF or flattened device tree to instatiate + platform devices for direct mapped RTC chips like the DS1742 or DS1743. + source "arch/powerpc/sysdev/bestcomm/Kconfig" endmenu
arch/powerpc/sysdev/Makefile +1 -0
@@ -27,6 +27,7 @@ obj-$(CONFIG_PPC_I8259) += i8259.o obj-$(CONFIG_PPC_83xx) += ipic.o obj-$(CONFIG_4xx) += uic.o obj-$(CONFIG_XILINX_VIRTEX) += xilinx_intc.o +obj-$(CONFIG_OF_RTC) += of_rtc.o ifeq ($(CONFIG_PCI),y) obj-$(CONFIG_4xx) += ppc4xx_pci.o endif
arch/powerpc/sysdev/of_rtc.c new file +59 -0
59 lines not on this page · raw message
arch/powerpc/platforms/44x/Kconfig +1 -0
@@ -13,6 +13,7 @@ config EBONY default y select 440GP select PCI + select OF_RTC help This option enables support for the IBM PPC440GP evaluation board.
include/asm-powerpc/of_platform.h +2 -0
@@ -37,4 +37,6 @@ extern int of_platform_bus_probe(structextern struct of_device *of_find_device_by_phandle (phandle ph); +extern void of_instantiate_rtc (void ); +#endif /* _ASM_POWERPC_OF_PLATFORM_H */
arch/powerpc/boot/dts/walnut.dts +3 -2
@@ -175,9 +175,10 @@ }; }; - ds1743@1,0 { + nvram@1,0 { /* NVRAM and RTC */ - compatible = "ds1743"; + compatible = "ds1743-nvram"; + #bytes = <2000>; reg = <1 0 2000>; };
arch/powerpc/platforms/40x/walnut.c +1 -0
@@ -36,6 +36,7 @@ static __initdata struct of_device_id wastatic int __init walnut_device_probe (void ) {of_platform_bus_probe (NULL , walnut_of_bus,NULL ); +of_instantiate_rtc ();return 0 ; }
Signature · 4 lines
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
Re: Enable RTC for Ebony and Walnut (v2)
arch/powerpc/sysdev/of_rtc.c line 17
Quoted 5 lines · On Fri, 11 Jan 2008 14:25:34 +1100 David Gibson <[email protected]> wrote:
+++
working-2.6/arch/powerpc/sysdev/of_rtc.c2008-01-11 14:17:03.000000000 +1100arch/powerpc/sysdev/of_rtc.c new file +2
-0+static __initdata struct { + const char *compatible;
If you make this an array, then the string will become __initdata as well.
arch/powerpc/sysdev/of_rtc.c line 56
Quoted 6 lines
arch/powerpc/sysdev/of_rtc.c new file +5
-0+char *plat_name; +} of_rtc_table[] = { + { "ds1743-nvram", "rtc-ds1742" }, +}; + platform_device_register_simple(plat_name, -1, res, 1);
Do we care if this fails?
Signature · 3 lines
Cheers, Stephen Rothwell [email protected] http://www.canb.auug.org.au/~sfr/
Re: Enable RTC for Ebony and Walnut (v2)
Quoted 8 lines · Stephen Rothwell
arch/powerpc/sysdev/of_rtc.c line 17
Quoted 5 lines · On Fri, 11 Jan 2008 14:25:34 +1100 David Gibson <[email protected]> wrote:
+++
working-2.6/arch/powerpc/sysdev/of_rtc.c2008-01-11 14:17:03.000000000 +1100arch/powerpc/sysdev/of_rtc.c new file +2
-0+static __initdata struct { + const char *compatible;If you make this an array, then the string will become
__initdataas well.
Well, yes, but then I'd have to pick a specific size for the string. Since this is supposed to be a stopgap until I can build a more general constructor mechanism..
Quoted 8 lines
arch/powerpc/sysdev/of_rtc.c line 56
Quoted 6 lines
arch/powerpc/sysdev/of_rtc.c new file +5
-0+char *plat_name; +} of_rtc_table[] = { + { "ds1743-nvram", "rtc-ds1742" }, +}; + platform_device_register_simple(plat_name, -1, res, 1);Do we care if this fails?
Well.. sort of, but there's not really any sane way of reporting it. This will be called from early platform init code, failures shouldn't cause us not to boot, and failure to register one rtc shouldn't cause us not to attempt to register others if they're present.
Signature · 4 lines
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