[U-Boot] [PATCH] sntp: fix problems at setting RTC at multi-bus I2C systems

Wolfgang Denk wd at denx.de
Mon May 2 21:08:42 CEST 2011


Dear =?iso-8859-1?Q?Tr=FCbenbach=2C_Ralf?=,

In message <B578782695EC1545A6E9231C72F8ED2B09331A at MEN-EX2.intra.men.de> you wrote:
> 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 <ralf.truebenbach at men.de>
> ---
> I don't like that I have to include the I2C things into sntp.c.

Right, this is totally the wrong place.

> 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.

> index 76c10ec..7eee0db 100644
> --- a/net/sntp.c
> +++ b/net/sntp.c
> @@ -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?

> -	 * 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.

>  #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

-- 
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


More information about the U-Boot mailing list