This patch switches to the desired I2C bus when the SNTP network service is called. This can be configured using the CONFIG_SYS_RTC_BUS_NUM define.
In my eyes this is a bad and quick hack, but the same as was making for the date and dtt commands (commit: 0dc018e). The right way would be to move all the hardware specific i2c code down to the rtc driver layer. Signed-off-by: Stephan Linz <l...@li-pro.net> --- net/sntp.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/net/sntp.c b/net/sntp.c index 76c10ec..a4399a8 100644 --- a/net/sntp.c +++ b/net/sntp.c @@ -10,6 +10,12 @@ #include <net.h> #include <rtc.h> +#if defined(CONFIG_CMD_DATE) +/* FIXME: The i2c dependency should move into the RTC drivers itself. This higher + * network layer must not know about hardware specifics!!!!!!! */ +#include <i2c.h> +#endif + #include "sntp.h" #define SNTP_TIMEOUT 10000UL @@ -53,6 +59,9 @@ SntpHandler (uchar *pkt, unsigned dest, unsigned src, unsigned len) 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__); @@ -66,7 +75,14 @@ SntpHandler (uchar *pkt, unsigned dest, unsigned src, unsigned len) 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, -- 1.6.3.3 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot