From: Wolfgang Denk Date: Wed, 20 Oct 2010 22:06:07 +0200 Subject: [U-Boot] [PATCH][v0] RTC driver for PT7C4338 chip. In-Reply-To: <1287564032-32198-1-git-send-email-Priyanka.Jain@freescale.com> References: <1287564032-32198-1-git-send-email-Priyanka.Jain@freescale.com> Message-ID: <20101020200607.6D6331359B3@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Priyanka Jain, In message <1287564032-32198-1-git-send-email-Priyanka.Jain@freescale.com> you wrote: > PT7C4338 chip is manufactured by Pericom Technology Inc. > It is a serial real-time clock which provides: > 1)Low-power clock/calendar. > 2)Programmable square-wave output. > It has 56 bytes of nonvolatile RAM. > > Freescale P1010RDB uses PT7C4338 as RTC. > > Signed-off-by: Priyanka Jain > Acked-by: Timur Tabi > --- > drivers/rtc/Makefile | 1 + > drivers/rtc/pt7c4338.c | 161 ++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 162 insertions(+), 0 deletions(-) > create mode 100644 drivers/rtc/pt7c4338.c ... > +/* Get the current time from the RTC */ > +int rtc_get(struct rtc_time *tmp) > +{ > + int ret = 0; > + u8 sec, min, hour, mday, wday, mon, year, ctl_stat; > + > + ctl_stat = rtc_read(RTC_CTL_STAT_REG_ADDR); > + sec = rtc_read(RTC_SEC_REG_ADDR); > + min = rtc_read(RTC_MIN_REG_ADDR); > + hour = rtc_read(RTC_HR_REG_ADDR); > + wday = rtc_read(RTC_DAY_REG_ADDR); > + mday = rtc_read(RTC_DATE_REG_ADDR); > + mon = rtc_read(RTC_MON_REG_ADDR); > + year = rtc_read(RTC_YR_REG_ADDR); > + debug("Get RTC year: %02x mon: %02x mday: %02x wday: %02x " > + "hr: %02x min: %02x sec: %02x control_status: %02x\n", > + year, mon, mday, wday, hour, min, sec, ctl_stat); > + > + if (ctl_stat & RTC_CTL_STAT_BIT_OSF) { > + printf("### Warning: RTC oscillator has stopped\n"); > + /* clear the OSF flag */ > + rtc_write(RTC_CTL_STAT_REG_ADDR, > + rtc_read(RTC_CTL_STAT_REG_ADDR)\ > + & ~RTC_CTL_STAT_BIT_OSF); > + ret = -1; I guess you want to return here, not fall through? > + } > + > + if (sec & RTC_SEC_BIT_CH) { > + printf("### Warning: RTC oscillator has stopped\n"); > + /* clear the CH flag */ > + rtc_write(RTC_SEC_REG_ADDR, > + rtc_read(RTC_SEC_REG_ADDR) & ~RTC_SEC_BIT_CH); > + ret = -1; I guess you want to return here, not fall through? Is it correct to have two different causes for the "Warning: RTC oscillator has stopped" message? I would be a bit connnnnnnnnnnfused what it means when I see this twice on a system. 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 Totally illogical, there was no chance. -- Spock, "The Galileo Seven", stardate 2822.3