From patchwork Mon May 2 14:57:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Tr=C3=BCbenbach=2C_Ralf?= X-Patchwork-Id: 93672 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 151131007D1 for ; Tue, 3 May 2011 00:57:24 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B1E5128129; Mon, 2 May 2011 16:57:22 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id h523xAfNtJsK; Mon, 2 May 2011 16:57:22 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B664F2812B; Mon, 2 May 2011 16:57:20 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 02C022812B for ; Mon, 2 May 2011 16:57:19 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7GEOfiw5uhcj for ; Mon, 2 May 2011 16:57:18 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail204.messagelabs.com (mail204.messagelabs.com [85.158.143.51]) by theia.denx.de (Postfix) with ESMTPS id 05F8128129 for ; Mon, 2 May 2011 16:57:14 +0200 (CEST) X-VirusChecked: Checked X-Env-Sender: Ralf.Truebenbach@men.de X-Msg-Ref: server-13.tower-204.messagelabs.com!1304348232!37276489!1 X-StarScan-Version: 6.2.9; banners=-,-,- X-Originating-IP: [195.127.220.122] Received: (qmail 21724 invoked from network); 2 May 2011 14:57:13 -0000 Received: from unknown (HELO keys.men.de) (195.127.220.122) by server-13.tower-204.messagelabs.com with AES128-SHA encrypted SMTP; 2 May 2011 14:57:13 -0000 Received: from men-exch1.intra.men.de ([192.168.1.1]) by keys.men.de (PGP Universal service); Mon, 02 May 2011 16:57:13 +0200 X-PGP-Universal: processed; by keys.men.de on Mon, 02 May 2011 16:57:13 +0200 Received: from MEN-EX1.intra.men.de ([192.168.1.2]) by men-exch1.intra.men.de with Microsoft SMTPSVC(6.0.3790.3959); Mon, 2 May 2011 16:57:13 +0200 Received: from MEN-EX2.intra.men.de ([fe80::cd66:369a:26d7:be00]) by MEN-EX1.intra.men.de ([fe80::116c:94db:44e4:2cfa%13]) with mapi id 14.01.0270.001; Mon, 2 May 2011 16:57:12 +0200 From: =?iso-8859-1?Q?Tr=FCbenbach=2C_Ralf?= To: "u-boot@lists.denx.de" Thread-Topic: [PATCH] sntp: fix problems at setting RTC at multi-bus I2C systems Thread-Index: AcwI2NqEv3seM2+aT6OeankQ3en0lQ== Date: Mon, 2 May 2011 14:57:11 +0000 Message-ID: Accept-Language: de-DE, en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.3.18] MIME-Version: 1.0 X-OriginalArrivalTime: 02 May 2011 14:57:13.0001 (UTC) FILETIME=[38289190:01CC08D9] Subject: [U-Boot] [PATCH] sntp: fix problems at setting RTC at multi-bus I2C systems X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Setting the RTC via SNTP did not work if the current I2C bus no. is --- 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@men.de www.men.de MEN Mikro Elektronik GmbH - Manfred Schmitz (CTO), Udo Fuchs (CFO) - Handelsregister/Trade Register AG Nürnberg HRB 5540 different from the bus no. the RTC is connected to. Signed-off-by: Ralf Trübenbach --- 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. diff --git a/net/sntp.c b/net/sntp.c index 76c10ec..7eee0db 100644 --- a/net/sntp.c +++ b/net/sntp.c @@ -9,6 +9,9 @@ #include #include #include +#if defined(CONFIG_CMD_DATE) +#include +#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,