* [PATCH] Add powerpc get/set_rtc_time interface to new generic rtc class
@ 2006-09-26 2:55 Kim Phillips
2006-09-26 3:13 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 4+ messages in thread
From: Kim Phillips @ 2006-09-26 2:55 UTC (permalink / raw)
To: linuxppc-dev
Add powerpc get/set_rtc_time interface to new generic rtc class. This
abstracts rtc chip specific code from the platform code for rtc-over-i2c
platforms. Specific RTC chip support is now configured under
Device Drivers -> Real Time Clock. Setting time of day from the RTC
on startup is also configurable.
Currently, the only default config in powerpc arch is the 8349 itx.
Other platforms wanting to consolidate code may also use this.
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
arch/powerpc/kernel/time.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 7a3c3f7..a231b6d 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -1048,6 +1048,50 @@ void __init time_init(void)
set_dec(tb_ticks_per_jiffy);
}
+#ifdef CONFIG_RTC_CLASS
+int set_rtc_class_time(struct rtc_time *tm)
+{
+ int err;
+ struct class_device *class_dev =
+ rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
+
+ if (class_dev == NULL)
+ return -ENODEV;
+
+ err = rtc_set_time(class_dev, tm);
+
+ rtc_class_close(class_dev);
+
+ return 0;
+}
+
+void get_rtc_class_time(struct rtc_time *tm)
+{
+ int err;
+ struct class_device *class_dev =
+ rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
+
+ if (class_dev == NULL)
+ return;
+
+ err = rtc_read_time(class_dev, tm);
+
+ rtc_class_close(class_dev);
+
+ return;
+}
+
+static int __init rtc_class_hookup(void)
+{
+ ppc_md.get_rtc_time = get_rtc_class_time;
+ ppc_md.set_rtc_time = set_rtc_class_time;
+
+ return 0;
+}
+
+late_initcall(rtc_class_hookup);
+#endif /* CONFIG_RTC_CLASS */
+
#define FEBRUARY 2
#define STARTOFTIME 1970
--
1.4.2.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Add powerpc get/set_rtc_time interface to new generic rtc class
2006-09-26 2:55 [PATCH] Add powerpc get/set_rtc_time interface to new generic rtc class Kim Phillips
@ 2006-09-26 3:13 ` Benjamin Herrenschmidt
2006-09-26 14:14 ` Kumar Gala
0 siblings, 1 reply; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2006-09-26 3:13 UTC (permalink / raw)
To: Kim Phillips; +Cc: linuxppc-dev
On Mon, 2006-09-25 at 21:55 -0500, Kim Phillips wrote:
> Add powerpc get/set_rtc_time interface to new generic rtc class. This
> abstracts rtc chip specific code from the platform code for rtc-over-i2c
> platforms. Specific RTC chip support is now configured under
> Device Drivers -> Real Time Clock. Setting time of day from the RTC
> on startup is also configurable.
>
> Currently, the only default config in powerpc arch is the 8349 itx.
> Other platforms wanting to consolidate code may also use this.
>
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
I think we should only get that in if we also adapt the various platform
RTC code to be in drivers/rtc ... right now, enabling that option will
just break everybody.
> ---
> arch/powerpc/kernel/time.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 44 insertions(+), 0 deletions(-)
>
> diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
> index 7a3c3f7..a231b6d 100644
> --- a/arch/powerpc/kernel/time.c
> +++ b/arch/powerpc/kernel/time.c
> @@ -1048,6 +1048,50 @@ void __init time_init(void)
> set_dec(tb_ticks_per_jiffy);
> }
>
> +#ifdef CONFIG_RTC_CLASS
> +int set_rtc_class_time(struct rtc_time *tm)
> +{
> + int err;
> + struct class_device *class_dev =
> + rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
> +
> + if (class_dev == NULL)
> + return -ENODEV;
> +
> + err = rtc_set_time(class_dev, tm);
> +
> + rtc_class_close(class_dev);
> +
> + return 0;
> +}
> +
> +void get_rtc_class_time(struct rtc_time *tm)
> +{
> + int err;
> + struct class_device *class_dev =
> + rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
> +
> + if (class_dev == NULL)
> + return;
> +
> + err = rtc_read_time(class_dev, tm);
> +
> + rtc_class_close(class_dev);
> +
> + return;
> +}
> +
> +static int __init rtc_class_hookup(void)
> +{
> + ppc_md.get_rtc_time = get_rtc_class_time;
> + ppc_md.set_rtc_time = set_rtc_class_time;
> +
> + return 0;
> +}
> +
> +late_initcall(rtc_class_hookup);
> +#endif /* CONFIG_RTC_CLASS */
> +
>
> #define FEBRUARY 2
> #define STARTOFTIME 1970
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Add powerpc get/set_rtc_time interface to new generic rtc class
2006-09-26 3:13 ` Benjamin Herrenschmidt
@ 2006-09-26 14:14 ` Kumar Gala
2006-09-26 22:01 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 4+ messages in thread
From: Kumar Gala @ 2006-09-26 14:14 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: linuxppc-dev
On Sep 25, 2006, at 10:13 PM, Benjamin Herrenschmidt wrote:
> On Mon, 2006-09-25 at 21:55 -0500, Kim Phillips wrote:
>> Add powerpc get/set_rtc_time interface to new generic rtc class. This
>> abstracts rtc chip specific code from the platform code for rtc-
>> over-i2c
>> platforms. Specific RTC chip support is now configured under
>> Device Drivers -> Real Time Clock. Setting time of day from the RTC
>> on startup is also configurable.
>>
>> Currently, the only default config in powerpc arch is the 8349 itx.
>> Other platforms wanting to consolidate code may also use this.
>>
>> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
>
> I think we should only get that in if we also adapt the various
> platform
> RTC code to be in drivers/rtc ... right now, enabling that option will
> just break everybody.
Maybe just drop the init call for now and let people migrate over to
using this and moving the drivers over to drivers/rtc which aren't
supported there.
- k
>> ---
>> arch/powerpc/kernel/time.c | 44 ++++++++++++++++++++++++++++++++
>> ++++++++++++
>> 1 files changed, 44 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
>> index 7a3c3f7..a231b6d 100644
>> --- a/arch/powerpc/kernel/time.c
>> +++ b/arch/powerpc/kernel/time.c
>> @@ -1048,6 +1048,50 @@ void __init time_init(void)
>> set_dec(tb_ticks_per_jiffy);
>> }
>>
>> +#ifdef CONFIG_RTC_CLASS
>> +int set_rtc_class_time(struct rtc_time *tm)
>> +{
>> + int err;
>> + struct class_device *class_dev =
>> + rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
>> +
>> + if (class_dev == NULL)
>> + return -ENODEV;
>> +
>> + err = rtc_set_time(class_dev, tm);
>> +
>> + rtc_class_close(class_dev);
>> +
>> + return 0;
>> +}
>> +
>> +void get_rtc_class_time(struct rtc_time *tm)
>> +{
>> + int err;
>> + struct class_device *class_dev =
>> + rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
>> +
>> + if (class_dev == NULL)
>> + return;
>> +
>> + err = rtc_read_time(class_dev, tm);
>> +
>> + rtc_class_close(class_dev);
>> +
>> + return;
>> +}
>> +
>> +static int __init rtc_class_hookup(void)
>> +{
>> + ppc_md.get_rtc_time = get_rtc_class_time;
>> + ppc_md.set_rtc_time = set_rtc_class_time;
>> +
>> + return 0;
>> +}
>> +
>> +late_initcall(rtc_class_hookup);
>> +#endif /* CONFIG_RTC_CLASS */
>> +
>>
>> #define FEBRUARY 2
>> #define STARTOFTIME 1970
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Add powerpc get/set_rtc_time interface to new generic rtc class
2006-09-26 14:14 ` Kumar Gala
@ 2006-09-26 22:01 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2006-09-26 22:01 UTC (permalink / raw)
To: Kumar Gala; +Cc: linuxppc-dev
On Tue, 2006-09-26 at 09:14 -0500, Kumar Gala wrote:
> On Sep 25, 2006, at 10:13 PM, Benjamin Herrenschmidt wrote:
>
> > On Mon, 2006-09-25 at 21:55 -0500, Kim Phillips wrote:
> >> Add powerpc get/set_rtc_time interface to new generic rtc class. This
> >> abstracts rtc chip specific code from the platform code for rtc-
> >> over-i2c
> >> platforms. Specific RTC chip support is now configured under
> >> Device Drivers -> Real Time Clock. Setting time of day from the RTC
> >> on startup is also configurable.
> >>
> >> Currently, the only default config in powerpc arch is the 8349 itx.
> >> Other platforms wanting to consolidate code may also use this.
> >>
> >> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
> >
> > I think we should only get that in if we also adapt the various
> > platform
> > RTC code to be in drivers/rtc ... right now, enabling that option will
> > just break everybody.
>
> Maybe just drop the init call for now and let people migrate over to
> using this and moving the drivers over to drivers/rtc which aren't
> supported there.
Yup. We shouldn't change ppc_md from an initcall that way for something
that may not be supported by a platform. The platform code shall set
ppc_md. (maybe calling some init function for doing it) if the platform
supports the new class mecanism.
Ben.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-09-26 22:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-26 2:55 [PATCH] Add powerpc get/set_rtc_time interface to new generic rtc class Kim Phillips
2006-09-26 3:13 ` Benjamin Herrenschmidt
2006-09-26 14:14 ` Kumar Gala
2006-09-26 22:01 ` Benjamin Herrenschmidt
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).