[U-Boot] [PATCH] drivers: rtc: remove dead drivers

Masahiro Yamada yamada.m at jp.panasonic.com
Wed Jul 30 12:20:03 CEST 2014


The following configs are not defined at all:

 - CONFIG_RTC_DS1388
 - CONFIG_RTC_ISL1208
 - CONFIG_RTC_MX27
 - CONFIG_RTC_PL031
 - CONFIG_RTC_RS5C372A
 - CONFIG_SYS_DS1388_TCR_VAL

Signed-off-by: Masahiro Yamada <yamada.m at jp.panasonic.com>
---

 README                |   1 -
 drivers/rtc/Makefile  |   5 -
 drivers/rtc/ds1337.c  |  25 -----
 drivers/rtc/isl1208.c | 147 --------------------------
 drivers/rtc/mx27rtc.c |  70 -------------
 drivers/rtc/pl031.c   | 109 --------------------
 drivers/rtc/rs5c372.c | 281 --------------------------------------------------
 7 files changed, 638 deletions(-)
 delete mode 100644 drivers/rtc/isl1208.c
 delete mode 100644 drivers/rtc/mx27rtc.c
 delete mode 100644 drivers/rtc/pl031.c
 delete mode 100644 drivers/rtc/rs5c372.c

diff --git a/README b/README
index f704eb3..468a2bf 100644
--- a/README
+++ b/README
@@ -1153,7 +1153,6 @@ The following options need to be configured:
 		CONFIG_RTC_DS1337	- use Maxim, Inc. DS1337 RTC
 		CONFIG_RTC_DS1338	- use Maxim, Inc. DS1338 RTC
 		CONFIG_RTC_DS164x	- use Dallas DS164x RTC
-		CONFIG_RTC_ISL1208	- use Intersil ISL1208 RTC
 		CONFIG_RTC_MAX6900	- use Maxim, Inc. MAX6900 RTC
 		CONFIG_SYS_RTC_DS1337_NOOSC	- Turn off the OSC output for DS1337
 		CONFIG_SYS_RV3029_TCR	- enable trickle charger on
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 003d322..a3ce4d4 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -18,14 +18,12 @@ obj-$(CONFIG_RTC_DS1307) += ds1307.o
 obj-$(CONFIG_RTC_DS1338) += ds1307.o
 obj-$(CONFIG_RTC_DS1337) += ds1337.o
 obj-$(CONFIG_RTC_DS1374) += ds1374.o
-obj-$(CONFIG_RTC_DS1388) += ds1337.o
 obj-$(CONFIG_RTC_DS1556) += ds1556.o
 obj-$(CONFIG_RTC_DS164x) += ds164x.o
 obj-$(CONFIG_RTC_DS174x) += ds174x.o
 obj-$(CONFIG_RTC_DS3231) += ds3231.o
 obj-$(CONFIG_RTC_FTRTC010) += ftrtc010.o
 obj-$(CONFIG_RTC_IMXDI) += imxdi.o
-obj-$(CONFIG_RTC_ISL1208) += isl1208.o
 obj-$(CONFIG_RTC_M41T11) += m41t11.o
 obj-$(CONFIG_RTC_M41T60) += m41t60.o
 obj-$(CONFIG_RTC_M41T62) += m41t62.o
@@ -39,12 +37,9 @@ obj-$(CONFIG_RTC_MK48T59) += mk48t59.o
 obj-$(CONFIG_RTC_MPC5200) += mpc5xxx.o
 obj-$(CONFIG_RTC_MPC8xx) += mpc8xx.o
 obj-$(CONFIG_RTC_MV) += mvrtc.o
-obj-$(CONFIG_RTC_MX27) += mx27rtc.o
 obj-$(CONFIG_RTC_MXS) += mxsrtc.o
 obj-$(CONFIG_RTC_PCF8563) += pcf8563.o
-obj-$(CONFIG_RTC_PL031) += pl031.o
 obj-$(CONFIG_RTC_PT7C4338) += pt7c4338.o
-obj-$(CONFIG_RTC_RS5C372A) += rs5c372.o
 obj-$(CONFIG_RTC_RTC4543) += rtc4543.o
 obj-$(CONFIG_RTC_RV3029) += rv3029.o
 obj-$(CONFIG_RTC_RX8025) += rx8025.o
diff --git a/drivers/rtc/ds1337.c b/drivers/rtc/ds1337.c
index dae1b3c..550be90 100644
--- a/drivers/rtc/ds1337.c
+++ b/drivers/rtc/ds1337.c
@@ -21,7 +21,6 @@
 /*
  * RTC register addresses
  */
-#if defined CONFIG_RTC_DS1337
 #define RTC_SEC_REG_ADDR	0x0
 #define RTC_MIN_REG_ADDR	0x1
 #define RTC_HR_REG_ADDR		0x2
@@ -32,18 +31,6 @@
 #define RTC_CTL_REG_ADDR	0x0e
 #define RTC_STAT_REG_ADDR	0x0f
 #define RTC_TC_REG_ADDR		0x10
-#elif defined CONFIG_RTC_DS1388
-#define RTC_SEC_REG_ADDR	0x1
-#define RTC_MIN_REG_ADDR	0x2
-#define RTC_HR_REG_ADDR		0x3
-#define RTC_DAY_REG_ADDR	0x4
-#define RTC_DATE_REG_ADDR	0x5
-#define RTC_MON_REG_ADDR	0x6
-#define RTC_YR_REG_ADDR		0x7
-#define RTC_CTL_REG_ADDR	0x0c
-#define RTC_STAT_REG_ADDR	0x0b
-#define RTC_TC_REG_ADDR		0x0a
-#endif
 
 /*
  * RTC control register bits
@@ -84,11 +71,6 @@ int rtc_get (struct rtc_time *tmp)
 	mon_cent = rtc_read (RTC_MON_REG_ADDR);
 	year = rtc_read (RTC_YR_REG_ADDR);
 
-	/* No century bit, assume year 2000 */
-#ifdef CONFIG_RTC_DS1388
-	mon_cent |= 0x80;
-#endif
-
 	debug("Get RTC year: %02x mon/cent: %02x mday: %02x wday: %02x "
 		"hr: %02x min: %02x sec: %02x control: %02x status: %02x\n",
 		year, mon_cent, mday, wday, hour, min, sec, control, status);
@@ -162,17 +144,10 @@ int rtc_set (struct rtc_time *tmp)
 #endif
 void rtc_reset (void)
 {
-#ifdef CONFIG_SYS_RTC_DS1337
 	rtc_write (RTC_CTL_REG_ADDR, RTC_DS1337_RESET_VAL);
-#elif defined CONFIG_SYS_RTC_DS1388
-	rtc_write(RTC_CTL_REG_ADDR, 0x0); /* hw default */
-#endif
 #ifdef CONFIG_SYS_DS1339_TCR_VAL
 	rtc_write (RTC_TC_REG_ADDR, CONFIG_SYS_DS1339_TCR_VAL);
 #endif
-#ifdef CONFIG_SYS_DS1388_TCR_VAL
-	rtc_write(RTC_TC_REG_ADDR, CONFIG_SYS_DS1388_TCR_VAL);
-#endif
 }
 
 
diff --git a/drivers/rtc/isl1208.c b/drivers/rtc/isl1208.c
deleted file mode 100644
index 807e2e4..0000000
--- a/drivers/rtc/isl1208.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * (C) Copyright 2008
- * Tor Krill, Excito Elektronik i Skåne , tor at excito.com
- *
- * Modelled after the ds1337 driver
- *
- * SPDX-License-Identifier:	GPL-2.0+
- */
-
-/*
- * Date & Time support (no alarms) for Intersil
- * ISL1208 Real Time Clock (RTC).
- */
-
-#include <common.h>
-#include <command.h>
-#include <rtc.h>
-#include <i2c.h>
-
-/*---------------------------------------------------------------------*/
-#ifdef DEBUG_RTC
-#define DEBUGR(fmt,args...) printf(fmt ,##args)
-#else
-#define DEBUGR(fmt,args...)
-#endif
-/*---------------------------------------------------------------------*/
-
-/*
- * RTC register addresses
- */
-
-#define RTC_SEC_REG_ADDR	0x0
-#define RTC_MIN_REG_ADDR	0x1
-#define RTC_HR_REG_ADDR		0x2
-#define RTC_DATE_REG_ADDR	0x3
-#define RTC_MON_REG_ADDR	0x4
-#define RTC_YR_REG_ADDR		0x5
-#define RTC_DAY_REG_ADDR	0x6
-#define RTC_STAT_REG_ADDR	0x7
-/*
- * RTC control register bits
- */
-
-/*
- * RTC status register bits
- */
-#define RTC_STAT_BIT_ARST	0x80	/* AUTO RESET ENABLE BIT */
-#define RTC_STAT_BIT_XTOSCB	0x40	/* CRYSTAL OSCILLATOR ENABLE BIT */
-#define RTC_STAT_BIT_WRTC	0x10	/* WRITE RTC ENABLE BIT */
-#define RTC_STAT_BIT_ALM	0x04	/* ALARM BIT */
-#define RTC_STAT_BIT_BAT	0x02	/* BATTERY BIT */
-#define RTC_STAT_BIT_RTCF	0x01	/* REAL TIME CLOCK FAIL BIT */
-
-static uchar rtc_read (uchar reg);
-static void rtc_write (uchar reg, uchar val);
-
-/*
- * Get the current time from the RTC
- */
-
-int rtc_get (struct rtc_time *tmp)
-{
-	int rel = 0;
-	uchar sec, min, hour, mday, wday, mon, year, status;
-
-	status = rtc_read (RTC_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);
-
-	DEBUGR ("Get RTC year: %02x mon: %02x mday: %02x wday: %02x "
-		"hr: %02x min: %02x sec: %02x status: %02x\n",
-		year, mon, mday, wday, hour, min, sec, status);
-
-	if (status & RTC_STAT_BIT_RTCF) {
-		printf ("### Warning: RTC oscillator has stopped\n");
-		rtc_write(RTC_STAT_REG_ADDR,
-			rtc_read(RTC_STAT_REG_ADDR) &~ (RTC_STAT_BIT_BAT|RTC_STAT_BIT_RTCF));
-		rel = -1;
-	}
-
-	tmp->tm_sec  = bcd2bin (sec & 0x7F);
-	tmp->tm_min  = bcd2bin (min & 0x7F);
-	tmp->tm_hour = bcd2bin (hour & 0x3F);
-	tmp->tm_mday = bcd2bin (mday & 0x3F);
-	tmp->tm_mon  = bcd2bin (mon & 0x1F);
-	tmp->tm_year = bcd2bin (year)+2000;
-	tmp->tm_wday = bcd2bin (wday & 0x07);
-	tmp->tm_yday = 0;
-	tmp->tm_isdst= 0;
-
-	DEBUGR ("Get DATE: %4d-%02d-%02d (wday=%d)  TIME: %2d:%02d:%02d\n",
-		tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
-		tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
-
-	return rel;
-}
-
-/*
- * Set the RTC
- */
-int rtc_set (struct rtc_time *tmp)
-{
-	DEBUGR ("Set DATE: %4d-%02d-%02d (wday=%d)  TIME: %2d:%02d:%02d\n",
-		tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
-		tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
-
-	/* enable write */
-	rtc_write(RTC_STAT_REG_ADDR,
-		rtc_read(RTC_STAT_REG_ADDR) | RTC_STAT_BIT_WRTC);
-
-	rtc_write (RTC_YR_REG_ADDR, bin2bcd (tmp->tm_year % 100));
-	rtc_write (RTC_MON_REG_ADDR, bin2bcd (tmp->tm_mon));
-	rtc_write (RTC_DAY_REG_ADDR, bin2bcd (tmp->tm_wday));
-	rtc_write (RTC_DATE_REG_ADDR, bin2bcd (tmp->tm_mday));
-	rtc_write (RTC_HR_REG_ADDR, bin2bcd (tmp->tm_hour) | 0x80 ); /* 24h clock */
-	rtc_write (RTC_MIN_REG_ADDR, bin2bcd (tmp->tm_min));
-	rtc_write (RTC_SEC_REG_ADDR, bin2bcd (tmp->tm_sec));
-
-	/* disable write */
-	rtc_write(RTC_STAT_REG_ADDR,
-		rtc_read(RTC_STAT_REG_ADDR) & ~RTC_STAT_BIT_WRTC);
-
-	return 0;
-}
-
-void rtc_reset (void)
-{
-}
-
-/*
- * Helper functions
- */
-
-static uchar rtc_read (uchar reg)
-{
-	return (i2c_reg_read (CONFIG_SYS_I2C_RTC_ADDR, reg));
-}
-
-static void rtc_write (uchar reg, uchar val)
-{
-	i2c_reg_write (CONFIG_SYS_I2C_RTC_ADDR, reg, val);
-}
diff --git a/drivers/rtc/mx27rtc.c b/drivers/rtc/mx27rtc.c
deleted file mode 100644
index ae6595b..0000000
--- a/drivers/rtc/mx27rtc.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Freescale i.MX27 RTC Driver
- *
- * Copyright (C) 2012 Philippe Reynes <tremyfr at yahoo.fr>
- *
- * SPDX-License-Identifier:	GPL-2.0+
- */
-
-#include <common.h>
-#include <rtc.h>
-#include <asm/io.h>
-#include <asm/arch/imx-regs.h>
-
-#define HOUR_SHIFT 8
-#define HOUR_MASK  0x1f
-#define MIN_SHIFT  0
-#define MIN_MASK   0x3f
-
-int rtc_get(struct rtc_time *time)
-{
-	struct rtc_regs *rtc_regs = (struct rtc_regs *)IMX_RTC_BASE;
-	uint32_t day, hour, min, sec;
-
-	day  = readl(&rtc_regs->dayr);
-	hour = readl(&rtc_regs->hourmin);
-	sec  = readl(&rtc_regs->seconds);
-
-	min  = (hour >> MIN_SHIFT) & MIN_MASK;
-	hour = (hour >> HOUR_SHIFT) & HOUR_MASK;
-
-	sec += min * 60 + hour * 3600 + day * 24 * 3600;
-
-	to_tm(sec, time);
-
-	return 0;
-}
-
-int rtc_set(struct rtc_time *time)
-{
-	struct rtc_regs *rtc_regs = (struct rtc_regs *)IMX_RTC_BASE;
-	uint32_t day, hour, min, sec;
-
-	sec = mktime(time->tm_year, time->tm_mon, time->tm_mday,
-		time->tm_hour, time->tm_min, time->tm_sec);
-
-	day  = sec / (24 * 3600);
-	sec  = sec % (24 * 3600);
-	hour = sec / 3600;
-	sec  = sec % 3600;
-	min  = sec / 60;
-	sec  = sec % 60;
-
-	hour  = (hour & HOUR_MASK) << HOUR_SHIFT;
-	hour |= (min & MIN_MASK) << MIN_SHIFT;
-
-	writel(day, &rtc_regs->dayr);
-	writel(hour, &rtc_regs->hourmin);
-	writel(sec, &rtc_regs->seconds);
-
-	return 0;
-}
-
-void rtc_reset(void)
-{
-	struct rtc_regs *rtc_regs = (struct rtc_regs *)IMX_RTC_BASE;
-
-	writel(0, &rtc_regs->dayr);
-	writel(0, &rtc_regs->hourmin);
-	writel(0, &rtc_regs->seconds);
-}
diff --git a/drivers/rtc/pl031.c b/drivers/rtc/pl031.c
deleted file mode 100644
index c4d1259..0000000
--- a/drivers/rtc/pl031.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * (C) Copyright 2008
- * Gururaja Hebbar gururajakr at sanyo.co.in
- *
- * reference linux-2.6.20.6/drivers/rtc/rtc-pl031.c
- *
- * SPDX-License-Identifier:	GPL-2.0+
- */
-
-#include <common.h>
-#include <command.h>
-#include <rtc.h>
-
-#if defined(CONFIG_CMD_DATE)
-
-#ifndef CONFIG_SYS_RTC_PL031_BASE
-#error CONFIG_SYS_RTC_PL031_BASE is not defined!
-#endif
-
-/*
- * Register definitions
- */
-#define	RTC_DR		0x00	/* Data read register */
-#define	RTC_MR		0x04	/* Match register */
-#define	RTC_LR		0x08	/* Data load register */
-#define	RTC_CR		0x0c	/* Control register */
-#define	RTC_IMSC	0x10	/* Interrupt mask and set register */
-#define	RTC_RIS		0x14	/* Raw interrupt status register */
-#define	RTC_MIS		0x18	/* Masked interrupt status register */
-#define	RTC_ICR		0x1c	/* Interrupt clear register */
-
-#define RTC_CR_START	(1 << 0)
-
-#define	RTC_WRITE_REG(addr, val) \
-			(*(volatile unsigned int *)(CONFIG_SYS_RTC_PL031_BASE + (addr)) = (val))
-#define	RTC_READ_REG(addr)	\
-			(*(volatile unsigned int *)(CONFIG_SYS_RTC_PL031_BASE + (addr)))
-
-static int pl031_initted = 0;
-
-/* Enable RTC Start in Control register*/
-void rtc_init(void)
-{
-	RTC_WRITE_REG(RTC_CR, RTC_CR_START);
-
-	pl031_initted = 1;
-}
-
-/*
- * Reset the RTC. We set the date back to 1970-01-01.
- */
-void rtc_reset(void)
-{
-	RTC_WRITE_REG(RTC_LR, 0x00);
-	if(!pl031_initted)
-		rtc_init();
-}
-
-/*
- * Set the RTC
-*/
-int rtc_set(struct rtc_time *tmp)
-{
-	unsigned long tim;
-
-	if(!pl031_initted)
-		rtc_init();
-
-	if (tmp == NULL) {
-		puts("Error setting the date/time\n");
-		return -1;
-	}
-
-	/* Calculate number of seconds this incoming time represents */
-	tim = mktime(tmp->tm_year, tmp->tm_mon, tmp->tm_mday,
-			tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
-
-	RTC_WRITE_REG(RTC_LR, tim);
-
-	return -1;
-}
-
-/*
- * Get the current time from the RTC
- */
-int rtc_get(struct rtc_time *tmp)
-{
-	ulong tim;
-
-	if(!pl031_initted)
-		rtc_init();
-
-	if (tmp == NULL) {
-		puts("Error getting the date/time\n");
-		return -1;
-	}
-
-	tim = RTC_READ_REG(RTC_DR);
-
-	to_tm (tim, tmp);
-
-	debug ( "Get DATE: %4d-%02d-%02d (wday=%d)  TIME: %2d:%02d:%02d\n",
-		tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
-		tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
-
-	return 0;
-}
-
-#endif
diff --git a/drivers/rtc/rs5c372.c b/drivers/rtc/rs5c372.c
deleted file mode 100644
index 65f45ea..0000000
--- a/drivers/rtc/rs5c372.c
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * rs5c372.c
- *
- * Device driver for Ricoh's Real Time Controller RS5C372A.
- *
- * Copyright (C) 2004 Gary Jennejohn garyj at denx.de
- *
- * Based in part in ds1307.c -
- * (C) Copyright 2001, 2002, 2003
- * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
- * Keith Outwater, keith_outwater at mvis.com`
- * Steven Scholz, steven.scholz at imc-berlin.de
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <common.h>
-#include <command.h>
-#include <rtc.h>
-#include <i2c.h>
-
-#if defined(CONFIG_CMD_DATE)
-/*
- * Reads are always done starting with register 15, which requires some
- * jumping-through-hoops to access the data correctly.
- *
- * Writes are always done starting with register 0.
- */
-
-#define DEBUG 0
-
-#if DEBUG
-static unsigned int rtc_debug = DEBUG;
-#else
-#define rtc_debug 0	/* gcc will remove all the debug code for us */
-#endif
-
-#ifndef CONFIG_SYS_I2C_RTC_ADDR
-#define CONFIG_SYS_I2C_RTC_ADDR 0x32
-#endif
-
-#define RS5C372_RAM_SIZE 0x10
-#define RATE_32000HZ	0x80	/* Rate Select 32.000KHz */
-#define RATE_32768HZ	0x00	/* Rate Select 32.768KHz */
-
-#define STATUS_XPT  0x10    /* data invalid because voltage was 0 */
-
-#define USE_24HOUR_MODE 0x20
-#define TWELVE_HOUR_MODE(n) ((((n) >> 5) & 1) == 0)
-#define HOURS_AP(n)	(((n) >> 5) & 1)
-#define HOURS_12(n)	bcd2bin((n) & 0x1F)
-#define HOURS_24(n)	bcd2bin((n) & 0x3F)
-
-
-static int setup_done = 0;
-
-static int
-rs5c372_readram(unsigned char *buf, int len)
-{
-	int ret;
-
-	ret = i2c_read(CONFIG_SYS_I2C_RTC_ADDR, 0, 0, buf, len);
-	if (ret != 0) {
-		printf("%s: failed to read\n", __FUNCTION__);
-		return ret;
-	}
-
-	if (buf[0] & STATUS_XPT)
-		printf("### Warning: RTC lost power\n");
-
-	return ret;
-}
-
-static void
-rs5c372_enable(void)
-{
-	unsigned char buf[RS5C372_RAM_SIZE + 1];
-	int ret;
-
-	/* note that this returns reg. 15 in buf[1] */
-	ret = rs5c372_readram(&buf[1], RS5C372_RAM_SIZE);
-	if (ret != 0) {
-		printf("%s: failed\n", __FUNCTION__);
-		return;
-	}
-
-	buf[0] = 0;
-	/* we want to start writing at register 0 so we have to copy the */
-	/* register contents up one slot */
-	for (ret = 2; ret < 9; ret++)
-		buf[ret - 1] = buf[ret];
-	/* registers 0 to 6 (time values) are not touched */
-	buf[8] = RATE_32768HZ; /* reg. 7 */
-	buf[9] = 0; /* reg. 8 */
-	buf[10] = 0; /* reg. 9 */
-	buf[11] = 0; /* reg. 10 */
-	buf[12] = 0; /* reg. 11 */
-	buf[13] = 0; /* reg. 12 */
-	buf[14] = 0; /* reg. 13 */
-	buf[15] = 0; /* reg. 14 */
-	buf[16] = USE_24HOUR_MODE; /* reg. 15 */
-	ret = i2c_write(CONFIG_SYS_I2C_RTC_ADDR, 0, 0, buf, RS5C372_RAM_SIZE+1);
-	if (ret != 0) {
-		printf("%s: failed\n", __FUNCTION__);
-		return;
-	}
-	setup_done = 1;
-
-	return;
-}
-
-static void
-rs5c372_convert_to_time(struct rtc_time *dt, unsigned char *buf)
-{
-	/* buf[0] is register 15 */
-	dt->tm_sec = bcd2bin(buf[1]);
-	dt->tm_min = bcd2bin(buf[2]);
-
-	if (TWELVE_HOUR_MODE(buf[0])) {
-		dt->tm_hour = HOURS_12(buf[3]);
-		if (HOURS_AP(buf[3])) /* PM */
-			dt->tm_hour += 12;
-	} else /* 24-hour-mode */
-		dt->tm_hour = HOURS_24(buf[3]);
-
-	dt->tm_mday = bcd2bin(buf[5]);
-	dt->tm_mon = bcd2bin(buf[6]);
-	dt->tm_year = bcd2bin(buf[7]);
-	if (dt->tm_year >= 70)
-		dt->tm_year += 1900;
-	else
-		dt->tm_year += 2000;
-	/* 0 is Sunday */
-	dt->tm_wday = bcd2bin(buf[4] & 0x07);
-	dt->tm_yday = 0;
-	dt->tm_isdst= 0;
-
-	if(rtc_debug > 2) {
-		printf("rs5c372_convert_to_time: year = %d\n", dt->tm_year);
-		printf("rs5c372_convert_to_time: mon  = %d\n", dt->tm_mon);
-		printf("rs5c372_convert_to_time: mday = %d\n", dt->tm_mday);
-		printf("rs5c372_convert_to_time: hour = %d\n", dt->tm_hour);
-		printf("rs5c372_convert_to_time: min  = %d\n", dt->tm_min);
-		printf("rs5c372_convert_to_time: sec  = %d\n", dt->tm_sec);
-	}
-}
-
-/*
- * Get the current time from the RTC
- */
-int
-rtc_get (struct rtc_time *tmp)
-{
-	unsigned char buf[RS5C372_RAM_SIZE];
-	int ret;
-
-	if (!setup_done)
-		rs5c372_enable();
-
-	if (!setup_done)
-		return -1;
-
-	memset(buf, 0, sizeof(buf));
-
-	/* note that this returns reg. 15 in buf[0] */
-	ret = rs5c372_readram(buf, RS5C372_RAM_SIZE);
-	if (ret != 0) {
-		printf("%s: failed\n", __FUNCTION__);
-		return -1;
-	}
-
-	rs5c372_convert_to_time(tmp, buf);
-
-	return 0;
-}
-
-/*
- * Set the RTC
- */
-int rtc_set (struct rtc_time *tmp)
-{
-	unsigned char buf[8], reg15;
-	int ret;
-
-	if (!setup_done)
-		rs5c372_enable();
-
-	if (!setup_done)
-		return -1;
-
-	if(rtc_debug > 2) {
-		printf("rtc_set: tm_year = %d\n", tmp->tm_year);
-		printf("rtc_set: tm_mon	 = %d\n", tmp->tm_mon);
-		printf("rtc_set: tm_mday = %d\n", tmp->tm_mday);
-		printf("rtc_set: tm_hour = %d\n", tmp->tm_hour);
-		printf("rtc_set: tm_min	 = %d\n", tmp->tm_min);
-		printf("rtc_set: tm_sec	 = %d\n", tmp->tm_sec);
-	}
-
-	memset(buf, 0, sizeof(buf));
-
-	/* only read register 15 */
-	ret = i2c_read(CONFIG_SYS_I2C_RTC_ADDR, 0, 0, buf, 1);
-
-	if (ret == 0) {
-		/* need to save register 15 */
-		reg15 = buf[0];
-		buf[0] = 0;	/* register address on RS5C372 */
-		buf[1] = bin2bcd(tmp->tm_sec);
-		buf[2] = bin2bcd(tmp->tm_min);
-		/* need to handle 12 hour mode */
-		if (TWELVE_HOUR_MODE(reg15)) {
-			if (tmp->tm_hour >= 12) { /* PM */
-				/* 12 PM is a special case */
-				if (tmp->tm_hour == 12)
-					buf[3] = bin2bcd(tmp->tm_hour);
-				else
-					buf[3] = bin2bcd(tmp->tm_hour - 12);
-				buf[3] |= 0x20;
-			}
-		} else {
-			buf[3] = bin2bcd(tmp->tm_hour);
-		}
-
-		buf[4] = bin2bcd(tmp->tm_wday);
-		buf[5] = bin2bcd(tmp->tm_mday);
-		buf[6] = bin2bcd(tmp->tm_mon);
-		if (tmp->tm_year < 1970 || tmp->tm_year > 2069)
-			printf("WARNING: year should be between 1970 and 2069!\n");
-		buf[7] = bin2bcd(tmp->tm_year % 100);
-
-		ret = i2c_write(CONFIG_SYS_I2C_RTC_ADDR, 0, 0, buf, 8);
-		if (ret != 0) {
-			printf("rs5c372_set_datetime(), i2c_master_send() returned %d\n",ret);
-			return -1;
-		}
-	} else {
-		return -1;
-	}
-
-	return 0;
-}
-
-/*
- * Reset the RTC. We set the date back to 1970-01-01.
- */
-void
-rtc_reset (void)
-{
-	struct rtc_time tmp;
-
-	if (!setup_done)
-		rs5c372_enable();
-
-	if (!setup_done)
-		return;
-
-	tmp.tm_year = 1970;
-	tmp.tm_mon = 1;
-	/* Jan. 1, 1970 was a Thursday */
-	tmp.tm_wday= 4;
-	tmp.tm_mday= 1;
-	tmp.tm_hour = 0;
-	tmp.tm_min = 0;
-	tmp.tm_sec = 0;
-
-	rtc_set(&tmp);
-
-	printf ("RTC:	%4d-%02d-%02d %2d:%02d:%02d UTC\n",
-		tmp.tm_year, tmp.tm_mon, tmp.tm_mday,
-		tmp.tm_hour, tmp.tm_min, tmp.tm_sec);
-
-	return;
-}
-
-#endif
-- 
1.9.1



More information about the U-Boot mailing list