This is not necessary. It's only used for /proc/cpuinfo (delays are done
using tb_ticks_per_usec), and it'll be overwritten by the generic
calibrate_delay() anyway.
We should be removing this from board files that have it, not adding it
to ones that don't.
+#if defined (CONFIG_SENSORS_DS1337) && defined (CONFIG_I2C)
+
+extern int ds1337_do_command(int id, int cmd, void *arg);
+extern spinlock_t rtc_lock;
+#define DS1337_GET_DATE 0
+#define DS1337_SET_DATE 1
+
+static void mpc8313rdb_get_rtc_time(struct rtc_time *tm)
+{
+ int result;
+
+ result = ds1337_do_command(0, DS1337_GET_DATE, tm);
+
+ if (result == 0)
+ result = mktime(tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
+}
+
+static int mpc8313rdb_set_rtc_time(struct rtc_time *tm)
+{
+ int result;
+
+ result = ds1337_do_command(0, DS1337_SET_DATE, tm);
+
+ return result;
+}
+
+static int __init rtc_hookup(void)
+{
+ ppc_md.get_rtc_time = mpc8313rdb_get_rtc_time;
+ ppc_md.set_rtc_time = mpc8313rdb_set_rtc_time;
+ return 0;
+}
+late_initcall(rtc_hookup);
+#endif
Please don't do this; drivers/i2c/chips/ds1337.c is deprecated. You
should be using the RTC-class driver in drivers/rtc/rtc-ds1307.c, which
has a non-device-specific API that can be used.
The ppc_md RTC functions should really just go away, though -- setting
the clock on bootup can be done by generic code, and periodically
updating the RTC when using NTP can be done from userspace.
-Scott
This is not necessary. It's only used for /proc/cpuinfo (delays are done
using tb_ticks_per_usec), and it'll be overwritten by the generic
calibrate_delay() anyway.
We should be removing this from board files that have it, not adding it
to ones that don't.
Yet many boards still have this stuff (like pretty recent 86xx) - should
we at least add some comments or clean that up?
quoted
+#if defined (CONFIG_SENSORS_DS1337) && defined (CONFIG_I2C)
+
+extern int ds1337_do_command(int id, int cmd, void *arg);
+extern spinlock_t rtc_lock;
+#define DS1337_GET_DATE 0
+#define DS1337_SET_DATE 1
+
+static void mpc8313rdb_get_rtc_time(struct rtc_time *tm)
+{
+ int result;
+
+ result = ds1337_do_command(0, DS1337_GET_DATE, tm);
+
+ if (result == 0)
+ result = mktime(tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
+}
+
+static int mpc8313rdb_set_rtc_time(struct rtc_time *tm)
+{
+ int result;
+
+ result = ds1337_do_command(0, DS1337_SET_DATE, tm);
+
+ return result;
+}
+
+static int __init rtc_hookup(void)
+{
+ ppc_md.get_rtc_time = mpc8313rdb_get_rtc_time;
+ ppc_md.set_rtc_time = mpc8313rdb_set_rtc_time;
+ return 0;
+}
+late_initcall(rtc_hookup);
+#endif
Please don't do this; drivers/i2c/chips/ds1337.c is deprecated. You
should be using the RTC-class driver in drivers/rtc/rtc-ds1307.c, which
has a non-device-specific API that can be used.
The ppc_md RTC functions should really just go away, though -- setting
the clock on bootup can be done by generic code, and periodically
updating the RTC when using NTP can be done from userspace.
If those ppc_md hookups would be declared deprecated, there's no much sense in the upper,
apparently. But I am not sure they will be... I'm inclined to let this patch floating since
interacting with rtc class from within BSP code just does not worth it.
--
Sincerely,
Vitaly
From: Scott Wood <hidden> Date: 2007-07-17 17:53:18
Vitaly Bordug wrote:
On Tue, 17 Jul 2007 11:36:45 -0500
Scott Wood [off-list ref] wrote:
quoted
We should be removing this from board files that have it, not adding it
to ones that don't.
Yet many boards still have this stuff (like pretty recent 86xx) - should
we at least add some comments or clean that up?
See above. :-)
AFAICT, it's just copied from board to board without thought. It should
be removed.
quoted
The ppc_md RTC functions should really just go away, though -- setting
the clock on bootup can be done by generic code, and periodically
updating the RTC when using NTP can be done from userspace.
If those ppc_md hookups would be declared deprecated, there's no much sense in the upper,
apparently. But I am not sure they will be... I'm inclined to let this patch floating since
interacting with rtc class from within BSP code just does not worth it.
I'm not sure they will either; I just wish they would be. :-)
In the meantime, some sort of workqueue-based hookup to the RTC class
API should be used. I believe there have been patches along those lines
posted in the past.
-Scott
From: Jon Loeliger <hidden> Date: 2007-07-17 18:13:04
On Tue, 2007-07-17 at 12:48, Vitaly Bordug wrote:
't.
quoted
Yet many boards still have this stuff (like pretty recent 86xx) - should
we at least add some comments or clean that up?
Hrm. Alright. I'm on deck for a patch here, I see... :-)
But you might notice that the most recent board port
that I added, mpc8544_ds.c, does NOT have it:
static void __init mpc8544_ds_setup_arch(void)
{
if (ppc_md.progress)
ppc_md.progress("mpc8544_ds_setup_arch()", 0);
printk("MPC8544 DS board from Freescale Semiconductor\n");
}
Thanks,
jdl
Please don't do this; drivers/i2c/chips/ds1337.c is deprecated. You
should be using the RTC-class driver in drivers/rtc/rtc-ds1307.c, which
has a non-device-specific API that can be used.
The ppc_md RTC functions should really just go away, though -- setting
the clock on bootup can be done by generic code, and periodically
updating the RTC when using NTP can be done from userspace.
If those ppc_md hookups would be declared deprecated, there's no much sense in the upper,
apparently. But I am not sure they will be... I'm inclined to let this patch floating since
interacting with rtc class from within BSP code just does not worth it.
Exactly! Don't interact with it. Just leave it alone. No need to re-write
[sg]et_rtc_time, bother with setting system time on bootup... Just let the
rtc driver and framework do it for you.
Thanks
Guennadi
---
Guennadi Liakhovetski