sntp: fix problems at setting RTC at multi-bus I2C systems
PATCH 1/1 sntp: fix problems at setting RTC at multi-bus I2C systems
Setting the RTC via SNTP did not work if the current I2C bus no. is different from the bus no. the RTC is connected to.
---
I don't like that I have to include the I2C things into sntp.c. But changing the rtc_set() function in 20 RTC drivers I don't like, too.
net/sntp.c +14 -1
@@ -9,6 +9,9 @@#include <command.h> #include <net.h> #include <rtc.h> +#if defined(CONFIG_CMD_DATE ) +#include <i2c.h> +#endif #include "sntp.h"
@@ -53,20 +56,30 @@struct sntp_pkt_t *rpktp = (struct sntp_pkt_t *)pkt;struct rtc_time tm;ulong seconds; +#if defined(CONFIG_CMD_DATE ) +int old_bus; +#endif debug ("%s\n" , __func__);if (dest != SntpOurPort)return ;/* -* As the RTC's used in U-Boot sepport second resolution only +* As the RTC's used in U-Boot support second resolution only * we simply ignore the sub-second field. */ memcpy (&seconds, &rpktp->transmit_timestamp,sizeof (ulong));to_tm (ntohl (seconds) -2208988800UL + NetTimeOffset, &tm);#if defined(CONFIG_CMD_DATE ) +/* switch to correct I2C bus */ + old_bus =I2C_GET_BUS (); +I2C_SET_BUS (CONFIG_SYS_RTC_BUS_NUM ); +rtc_set (&tm); + +/* switch back to original I2C bus */ +I2C_SET_BUS (old_bus);#endif printf ("Date: %4d-%02d-%02d Time: %2d:%02d:%02d\n", tm.tm_year, tm.tm_mon, tm.tm_mday,
--
Best Regards/Mit freundlichen Gruessen
Ralf Tr?benbach
------------------------------------------------------------------------
Ralf Tr?benbach, Software Design
MEN Mikro Elektronik GmbH
Neuwieder Stra?e 5-7
90411 N?rnberg, Germany
Phone +49-911-99 33 5-0
Fax +49-911-99 33 5-910
Ralf.Truebenbach at men.de
www.men.de
MEN Mikro Elektronik GmbH - Manfred Schmitz (CTO), Udo Fuchs (CFO)
- Handelsregister/Trade Register AG N?rnberg HRB 5540
PATCH 1/1 sntp: fix problems at setting RTC at multi-bus I2C systems
Quoted 8 lines · Ralf
Setting the RTC via SNTP did not work if the current I2C bus no. is different from the bus no. the RTC is connected to.
Signed-off-by Ralf Tr?benbach <[email protected]>---
I don't like that I have to include the I2C things intosntp.c. But changing thertc_set()function in 20 RTC drivers I don't like, too.
that would probably be the correct answer though. not all rtc devices are i2c, and binding i2c logic to the date command is wrong.
looks like when Stefan added this logic to cmd_date.c, he did it incorrectly -mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110502/a9df14d8/attachment.pgp
Wolfgang Denk
NAKPATCH 1/1 sntp: fix problems at setting RTC at multi-bus I2C systems
In reply to Trübenbach, RalfDear =?iso-8859-1?Q?Tr=FCbenbach=2C_Ralf?=,
Quoted 6 lines · In message <[email protected]> you…
Setting the RTC via SNTP did not work if the current I2C bus no. is different from the bus no. the RTC is connected to.
Signed-off-by Ralf Tr=FCbenbach <[email protected]>---
I don't like that I have to include the I2C things intosntp.c.
Right, this is totally the wrong place.
Quoted 2 lines
But changing the
rtc_set()function in 20 RTC drivers I don't like, too.
But that's where such code belongs - probably not into all of them, but into a single central locatioon.
net/sntp.c line 14
Quoted 10 lines
index 76c10ec..7eee0db 100644
net/sntp.c +3
-0@@ -9,6 +9,9 @@#include <command.h> #include <net.h> #include <rtc.h> +#if defined(CONFIG_CMD_DATE ) +#include <i2c.h> +#endif
This also makes little sense - what if the RTC is not I2C, but bus attached?
net/sntp.c line 68
Quoted 2 lines
net/sntp.c +1
-1-* As the RTC's used in U-Boot sepport second resolution only +* As the RTC's used in U-Boot support second resolution only
Unrelated changes must be submitted separately.
net/sntp.c line 83
Quoted 10 lines
net/sntp.c +7
-0#if defined(CONFIG_CMD_DATE ) +/* switch to correct I2C bus */ + old_bus =I2C_GET_BUS (); +I2C_SET_BUS (CONFIG_SYS_RTC_BUS_NUM ); +rtc_set (&tm); + +/* switch back to original I2C bus */ +I2C_SET_BUS (old_bus);#endif
Totally wrong: wrong place, wrong dependeny.
NAK.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de I often quote myself; it adds spice to my conversation. - G. B. Shaw