rtc: allow rtc_set to return an error and use it in cmd_date
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
This commit is contained in:
parent
ee9536a28c
commit
d1e2319414
@ -299,8 +299,7 @@ rtc_get( struct rtc_time *tmp )
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
rtc_set( struct rtc_time *tmp )
|
||||
int rtc_set( struct rtc_time *tmp )
|
||||
{
|
||||
m48_tod_set(tmp->tm_year, /* 1980-2079 */
|
||||
tmp->tm_mon, /* 01-12 */
|
||||
@ -315,6 +314,7 @@ rtc_set( struct rtc_time *tmp )
|
||||
tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -181,9 +181,9 @@ int rtc_get (struct rtc_time *tmp)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
void rtc_set (struct rtc_time *tmp)
|
||||
int rtc_set (struct rtc_time *tmp)
|
||||
{
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
void rtc_reset (void)
|
||||
{
|
||||
|
@ -254,7 +254,7 @@ int rtc_get( struct rtc_time *tmp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_set( struct rtc_time *tmp )
|
||||
int rtc_set( struct rtc_time *tmp )
|
||||
{
|
||||
if (phantom_flag < 0)
|
||||
phantom_flag = get_phantom_flag();
|
||||
@ -307,6 +307,8 @@ void rtc_set( struct rtc_time *tmp )
|
||||
/* unlock clock registers after read */
|
||||
rtc_write( RTC_CONTROLA, ( reg_a & ~RTC_CA_WRITE ));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -299,8 +299,7 @@ rtc_get( struct rtc_time *tmp )
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
rtc_set( struct rtc_time *tmp )
|
||||
int rtc_set( struct rtc_time *tmp )
|
||||
{
|
||||
m48_tod_set(tmp->tm_year, /* 1980-2079 */
|
||||
tmp->tm_mon, /* 01-12 */
|
||||
@ -315,6 +314,7 @@ rtc_set( struct rtc_time *tmp )
|
||||
tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -56,18 +56,30 @@ int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
rtc_reset ();
|
||||
} else {
|
||||
/* initialize tm with current time */
|
||||
rtc_get (&tm);
|
||||
/* insert new date & time */
|
||||
if (mk_date (argv[1], &tm) != 0) {
|
||||
puts ("## Bad date format\n");
|
||||
break;
|
||||
rcode = rtc_get (&tm);
|
||||
|
||||
if(!rcode) {
|
||||
/* insert new date & time */
|
||||
if (mk_date (argv[1], &tm) != 0) {
|
||||
puts ("## Bad date format\n");
|
||||
break;
|
||||
}
|
||||
/* and write to RTC */
|
||||
rcode = rtc_set (&tm);
|
||||
if(rcode)
|
||||
puts("## Set date failled\n");
|
||||
} else {
|
||||
puts("## Get date failled\n");
|
||||
}
|
||||
/* and write to RTC */
|
||||
rtc_set (&tm);
|
||||
}
|
||||
/* FALL TROUGH */
|
||||
case 1: /* get date & time */
|
||||
rtc_get (&tm);
|
||||
rcode = rtc_get (&tm);
|
||||
|
||||
if (rcode) {
|
||||
puts("## Get date failled\n");
|
||||
break;
|
||||
}
|
||||
|
||||
printf ("Date: %4d-%02d-%02d (%sday) Time: %2d:%02d:%02d\n",
|
||||
tm.tm_year, tm.tm_mon, tm.tm_mday,
|
||||
|
@ -188,7 +188,7 @@ int rtc_get (struct rtc_time* tm)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_set (struct rtc_time* tm)
|
||||
int rtc_set (struct rtc_time* tm)
|
||||
{
|
||||
if(tm->tm_year < 2000)
|
||||
tm->tm_year -= 1900;
|
||||
@ -204,6 +204,8 @@ void rtc_set (struct rtc_time* tm)
|
||||
BCDMIN = HEX2BCD(tm->tm_min);
|
||||
BCDSEC = HEX2BCD(tm->tm_sec);
|
||||
RTCCON &= 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_reset (void)
|
||||
|
@ -53,7 +53,7 @@ int rtc_init(void)
|
||||
/* Set the time. Get the time_in_secs which is the number of seconds since Jan 1970 and set the RTC registers
|
||||
* based on this value.
|
||||
*/
|
||||
void rtc_set(struct rtc_time *tmp)
|
||||
int rtc_set(struct rtc_time *tmp)
|
||||
{
|
||||
unsigned long remain, days, hrs, mins, secs;
|
||||
|
||||
@ -61,7 +61,7 @@ void rtc_set(struct rtc_time *tmp)
|
||||
|
||||
if (tmp == NULL) {
|
||||
puts("Error setting the date/time\n");
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
wait_for_complete();
|
||||
@ -82,6 +82,8 @@ void rtc_set(struct rtc_time *tmp)
|
||||
|
||||
/* Encode these time values into our RTC_STAT register */
|
||||
bfin_write_RTC_STAT(SET_ALARM(days, hrs, mins, secs));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Read the time from the RTC_STAT. time_in_seconds is seconds since Jan 1970 */
|
||||
|
@ -154,7 +154,7 @@ else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_set (struct rtc_time *tmp)
|
||||
int rtc_set (struct rtc_time *tmp)
|
||||
{
|
||||
uchar save_ctrl_b;
|
||||
uchar sec, min, hour, mday, wday, mon, year;
|
||||
@ -202,6 +202,8 @@ void rtc_set (struct rtc_time *tmp)
|
||||
/* enables the RTC to update the regs */
|
||||
save_ctrl_b &= ~RTC_CB_SET;
|
||||
rtc_write(RTC_CONTROL_B, save_ctrl_b);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_reset (void)
|
||||
|
@ -287,8 +287,7 @@ rtc_get(struct rtc_time *tmp)
|
||||
return rel;
|
||||
}
|
||||
|
||||
void
|
||||
rtc_set(struct rtc_time *tmp)
|
||||
int rtc_set(struct rtc_time *tmp)
|
||||
{
|
||||
struct ds1302_st bbclk;
|
||||
unsigned char b=0;
|
||||
@ -326,6 +325,8 @@ rtc_set(struct rtc_time *tmp)
|
||||
|
||||
write_ser_drv(0x8e,&b,1); /* disable write protect */
|
||||
write_ser_drv(0xbe,(unsigned char *)&bbclk, 8); /* write burst */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -141,7 +141,7 @@ int rtc_get (struct rtc_time *tmp)
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* set clock time in DS1306 RTC and in MPC8xx RTC */
|
||||
void rtc_set (struct rtc_time *tmp)
|
||||
int rtc_set (struct rtc_time *tmp)
|
||||
{
|
||||
volatile immap_t *immap = (immap_t *) CFG_IMMR;
|
||||
|
||||
@ -209,6 +209,8 @@ void rtc_set (struct rtc_time *tmp)
|
||||
debug ("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);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -371,7 +373,7 @@ int rtc_get (struct rtc_time *tmp)
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* set clock time from *tmp in DS1306 RTC */
|
||||
void rtc_set (struct rtc_time *tmp)
|
||||
int rtc_set (struct rtc_time *tmp)
|
||||
{
|
||||
/* Assuming Vcc = 2.0V (lowest speed) */
|
||||
if (!slave) {
|
||||
|
@ -128,7 +128,7 @@ int rtc_get (struct rtc_time *tmp)
|
||||
/*
|
||||
* Set the RTC
|
||||
*/
|
||||
void rtc_set (struct rtc_time *tmp)
|
||||
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,
|
||||
@ -144,6 +144,8 @@ void rtc_set (struct rtc_time *tmp)
|
||||
rtc_write (RTC_HR_REG_ADDR, bin2bcd (tmp->tm_hour));
|
||||
rtc_write (RTC_MIN_REG_ADDR, bin2bcd (tmp->tm_min));
|
||||
rtc_write (RTC_SEC_REG_ADDR, bin2bcd (tmp->tm_sec));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -132,7 +132,7 @@ int rtc_get (struct rtc_time *tmp)
|
||||
/*
|
||||
* Set the RTC
|
||||
*/
|
||||
void rtc_set (struct rtc_time *tmp)
|
||||
int rtc_set (struct rtc_time *tmp)
|
||||
{
|
||||
uchar century;
|
||||
|
||||
@ -150,6 +150,8 @@ void rtc_set (struct rtc_time *tmp)
|
||||
rtc_write (RTC_HR_REG_ADDR, bin2bcd (tmp->tm_hour));
|
||||
rtc_write (RTC_MIN_REG_ADDR, bin2bcd (tmp->tm_min));
|
||||
rtc_write (RTC_SEC_REG_ADDR, bin2bcd (tmp->tm_sec));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -160,7 +160,7 @@ int rtc_get (struct rtc_time *tm){
|
||||
/*
|
||||
* Set the RTC
|
||||
*/
|
||||
void rtc_set (struct rtc_time *tmp){
|
||||
int rtc_set (struct rtc_time *tmp){
|
||||
|
||||
unsigned long time;
|
||||
unsigned i;
|
||||
@ -186,6 +186,8 @@ void rtc_set (struct rtc_time *tmp){
|
||||
|
||||
/* Start clock */
|
||||
rtc_write(RTC_CTL_ADDR, RTC_CTL_BIT_EN_OSC, FALSE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -120,7 +120,7 @@ int rtc_get( struct rtc_time *tmp )
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_set( struct rtc_time *tmp )
|
||||
int rtc_set( struct rtc_time *tmp )
|
||||
{
|
||||
uchar reg_a;
|
||||
#ifdef RTC_DEBUG
|
||||
@ -146,6 +146,8 @@ void rtc_set( struct rtc_time *tmp )
|
||||
|
||||
/* unlock clock registers after read */
|
||||
rtc_write( RTC_CONTROLA, ( reg_a & ~RTC_CA_WRITE ));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_reset (void)
|
||||
|
@ -119,7 +119,7 @@ int rtc_get( struct rtc_time *tmp )
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_set( struct rtc_time *tmp )
|
||||
int rtc_set( struct rtc_time *tmp )
|
||||
{
|
||||
uchar reg_a;
|
||||
|
||||
@ -145,6 +145,8 @@ void rtc_set( struct rtc_time *tmp )
|
||||
|
||||
/* unlock clock registers after read */
|
||||
rtc_write( RTC_CONTROLA, ( reg_a & ~RTC_CA_WRITE ));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_reset (void)
|
||||
|
@ -117,7 +117,7 @@ int rtc_get( struct rtc_time *tmp )
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_set( struct rtc_time *tmp )
|
||||
int rtc_set( struct rtc_time *tmp )
|
||||
{
|
||||
uchar reg_a;
|
||||
#ifdef RTC_DEBUG
|
||||
@ -143,6 +143,8 @@ void rtc_set( struct rtc_time *tmp )
|
||||
|
||||
/* unlock clock registers after read */
|
||||
rtc_write( RTC_CONTROLA, ( reg_a & ~RTC_CA_WRITE ));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_reset (void)
|
||||
|
@ -134,7 +134,7 @@ int rtc_get (struct rtc_time *tmp)
|
||||
/*
|
||||
* Set the RTC
|
||||
*/
|
||||
void rtc_set (struct rtc_time *tmp)
|
||||
int rtc_set (struct rtc_time *tmp)
|
||||
{
|
||||
uchar century;
|
||||
|
||||
@ -152,6 +152,8 @@ void rtc_set (struct rtc_time *tmp)
|
||||
rtc_write (RTC_HR_REG_ADDR, bin2bcd (tmp->tm_hour));
|
||||
rtc_write (RTC_MIN_REG_ADDR, bin2bcd (tmp->tm_min));
|
||||
rtc_write (RTC_SEC_REG_ADDR, bin2bcd (tmp->tm_sec));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -118,7 +118,7 @@ int rtc_get (struct rtc_time *tmp)
|
||||
/*
|
||||
* Set the RTC
|
||||
*/
|
||||
void rtc_set (struct rtc_time *tmp)
|
||||
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,
|
||||
@ -139,6 +139,8 @@ void rtc_set (struct rtc_time *tmp)
|
||||
/* disable write */
|
||||
rtc_write(RTC_STAT_REG_ADDR,
|
||||
rtc_read(RTC_STAT_REG_ADDR) & ~RTC_STAT_BIT_WRTC);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_reset (void)
|
||||
|
@ -143,7 +143,7 @@ int rtc_get (struct rtc_time *tmp)
|
||||
return rel;
|
||||
}
|
||||
|
||||
void rtc_set (struct rtc_time *tmp)
|
||||
int rtc_set (struct rtc_time *tmp)
|
||||
{
|
||||
uchar data[RTC_REG_CNT];
|
||||
|
||||
@ -176,6 +176,8 @@ void rtc_set (struct rtc_time *tmp)
|
||||
}
|
||||
#endif
|
||||
i2c_write(CFG_I2C_RTC_ADDR, RTC_SEC_ADDR, 1, data, RTC_REG_CNT);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_reset (void)
|
||||
|
@ -193,12 +193,12 @@ int rtc_get(struct rtc_time *tmp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_set(struct rtc_time *tmp)
|
||||
int rtc_set(struct rtc_time *tmp)
|
||||
{
|
||||
uchar *const data = rtc_validate();
|
||||
|
||||
if (!data)
|
||||
return;
|
||||
return -1;
|
||||
|
||||
debug("Set DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n",
|
||||
tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
|
||||
@ -214,8 +214,10 @@ void rtc_set(struct rtc_time *tmp)
|
||||
data[RTC_DAY] = bin2bcd(tmp->tm_wday + 1) & 0x07;
|
||||
if (i2c_write(CFG_I2C_RTC_ADDR, 0, 1, data, RTC_REG_CNT)) {
|
||||
printf("I2C write failed in rtc_set()\n");
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_reset(void)
|
||||
|
@ -96,7 +96,7 @@ int rtc_get(struct rtc_time *tm)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_set(struct rtc_time *tm)
|
||||
int rtc_set(struct rtc_time *tm)
|
||||
{
|
||||
u8 buf[M41T62_DATETIME_REG_SIZE];
|
||||
|
||||
@ -123,8 +123,12 @@ void rtc_set(struct rtc_time *tm)
|
||||
/* assume 20YY not 19YY */
|
||||
buf[M41T62_REG_YEAR] = BIN2BCD(tm->tm_year % 100);
|
||||
|
||||
if (i2c_write(CFG_I2C_RTC_ADDR, 0, 1, buf, M41T62_DATETIME_REG_SIZE))
|
||||
if (i2c_write(CFG_I2C_RTC_ADDR, 0, 1, buf, M41T62_DATETIME_REG_SIZE)) {
|
||||
printf("I2C write failed in %s()\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_reset(void)
|
||||
|
@ -87,7 +87,7 @@ int rtc_get (struct rtc_time *tmp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_set (struct rtc_time *tmp)
|
||||
int rtc_set (struct rtc_time *tmp)
|
||||
{
|
||||
uchar ccr; /* Clock control register */
|
||||
uchar century;
|
||||
@ -116,6 +116,8 @@ void rtc_set (struct rtc_time *tmp)
|
||||
ccr = rtc_read(0);
|
||||
ccr = ccr & 0x7F;
|
||||
rtc_write(0, ccr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_reset (void)
|
||||
|
@ -107,7 +107,7 @@ int rtc_get (struct rtc_time *tmp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_set (struct rtc_time *tmp)
|
||||
int rtc_set (struct rtc_time *tmp)
|
||||
{
|
||||
|
||||
debug ( "Set DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n",
|
||||
@ -124,6 +124,8 @@ void rtc_set (struct rtc_time *tmp)
|
||||
rtc_write (0x84, bin2bcd(tmp->tm_hour));
|
||||
rtc_write (0x82, bin2bcd(tmp->tm_min ));
|
||||
rtc_write (0x80, bin2bcd(tmp->tm_sec ));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_reset (void)
|
||||
|
@ -77,7 +77,7 @@ int rtc_get(struct rtc_time *rtc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_set(struct rtc_time *rtc)
|
||||
int rtc_set(struct rtc_time *rtc)
|
||||
{
|
||||
u32 time, day, reg;
|
||||
|
||||
@ -86,7 +86,7 @@ void rtc_set(struct rtc_time *rtc)
|
||||
slave = spi_setup_slave(1, 0, 1000000,
|
||||
SPI_MODE_2 | SPI_CS_HIGH);
|
||||
if (!slave)
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
time = mktime(rtc->tm_year, rtc->tm_mon, rtc->tm_mday,
|
||||
@ -95,7 +95,7 @@ void rtc_set(struct rtc_time *rtc)
|
||||
time %= 86400;
|
||||
|
||||
if (spi_claim_bus(slave))
|
||||
return;
|
||||
return -1;
|
||||
|
||||
reg = 0x2c000000 | day | 0x80000000;
|
||||
spi_xfer(slave, 32, (uchar *)®, (uchar *)&day,
|
||||
@ -106,6 +106,8 @@ void rtc_set(struct rtc_time *rtc)
|
||||
SPI_XFER_BEGIN | SPI_XFER_END);
|
||||
|
||||
spi_release_bus(slave);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void rtc_reset(void)
|
||||
|
@ -105,7 +105,7 @@ int rtc_get (struct rtc_time *tmp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_set (struct rtc_time *tmp)
|
||||
int rtc_set (struct rtc_time *tmp)
|
||||
{
|
||||
#ifdef RTC_DEBUG
|
||||
printf ( "Set DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n",
|
||||
@ -127,6 +127,7 @@ void rtc_set (struct rtc_time *tmp)
|
||||
rtc_write (RTC_SECONDS, bin2bcd(tmp->tm_sec ));
|
||||
rtc_write(RTC_CONFIG_B,0x02); /* enables the RTC to update the regs */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_reset (void)
|
||||
|
@ -68,7 +68,7 @@ int rtc_get(struct rtc_time *tmp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_set(struct rtc_time *tmp)
|
||||
int rtc_set(struct rtc_time *tmp)
|
||||
{
|
||||
volatile rtc_t *rtc = (rtc_t *) (CFG_MCFRTC_BASE);
|
||||
|
||||
@ -106,6 +106,8 @@ void rtc_set(struct rtc_time *tmp)
|
||||
rtc->days = days;
|
||||
rtc->hourmin = (tmp->tm_hour << 8) | tmp->tm_min;
|
||||
rtc->seconds = tmp->tm_sec;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_reset(void)
|
||||
|
@ -185,7 +185,7 @@ int rtc_get (struct rtc_time *tmp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_set (struct rtc_time *tmp)
|
||||
int rtc_set (struct rtc_time *tmp)
|
||||
{
|
||||
uchar save_ctrl_a;
|
||||
|
||||
@ -210,6 +210,8 @@ void rtc_set (struct rtc_time *tmp)
|
||||
|
||||
save_ctrl_a &= ~RTC_CA_WRITE;
|
||||
rtc_write(RTC_CONTROLA, save_ctrl_a); /* enables the RTC to update the regs */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_reset (void)
|
||||
@ -225,7 +227,7 @@ void rtc_reset (void)
|
||||
rtc_write(RTC_CONTROLB, control_b);
|
||||
}
|
||||
|
||||
void rtc_set_watchdog(short multi, short res)
|
||||
int rtc_set_watchdog(short multi, short res)
|
||||
{
|
||||
uchar wd_value;
|
||||
|
||||
|
@ -88,7 +88,7 @@ int rtc_get (struct rtc_time *tmp)
|
||||
/*****************************************************************************
|
||||
* set time
|
||||
*****************************************************************************/
|
||||
void rtc_set (struct rtc_time *tmp)
|
||||
int rtc_set (struct rtc_time *tmp)
|
||||
{
|
||||
RTC5200 *rtc = (RTC5200 *) (CFG_MBAR+0x800);
|
||||
ulong time, date, year;
|
||||
@ -129,6 +129,8 @@ void rtc_set (struct rtc_time *tmp)
|
||||
udelay (1000);
|
||||
rtc->tsr = time;
|
||||
udelay (1000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
|
@ -51,7 +51,7 @@ int rtc_get (struct rtc_time *tmp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_set (struct rtc_time *tmp)
|
||||
int rtc_set (struct rtc_time *tmp)
|
||||
{
|
||||
volatile immap_t *immr = (immap_t *)CFG_IMMR;
|
||||
ulong tim;
|
||||
@ -65,6 +65,8 @@ void rtc_set (struct rtc_time *tmp)
|
||||
|
||||
immr->im_sitk.sitk_rtck = KAPWR_KEY;
|
||||
immr->im_sit.sit_rtc = tim;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_reset (void)
|
||||
|
@ -86,7 +86,7 @@ int rtc_get (struct rtc_time *tmp)
|
||||
return rel;
|
||||
}
|
||||
|
||||
void rtc_set (struct rtc_time *tmp)
|
||||
int rtc_set (struct rtc_time *tmp)
|
||||
{
|
||||
uchar century;
|
||||
|
||||
@ -104,6 +104,8 @@ void rtc_set (struct rtc_time *tmp)
|
||||
rtc_write (0x04, bin2bcd(tmp->tm_hour));
|
||||
rtc_write (0x03, bin2bcd(tmp->tm_min ));
|
||||
rtc_write (0x02, bin2bcd(tmp->tm_sec ));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_reset (void)
|
||||
|
6
drivers/rtc/pl031.c
Executable file → Normal file
6
drivers/rtc/pl031.c
Executable file → Normal file
@ -75,7 +75,7 @@ void rtc_reset(void)
|
||||
/*
|
||||
* Set the RTC
|
||||
*/
|
||||
void rtc_set(struct rtc_time *tmp)
|
||||
int rtc_set(struct rtc_time *tmp)
|
||||
{
|
||||
unsigned long tim;
|
||||
|
||||
@ -84,7 +84,7 @@ void rtc_set(struct rtc_time *tmp)
|
||||
|
||||
if (tmp == NULL) {
|
||||
puts("Error setting the date/time\n");
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Calculate number of seconds this incoming time represents */
|
||||
@ -92,6 +92,8 @@ void rtc_set(struct rtc_time *tmp)
|
||||
tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
|
||||
|
||||
RTC_WRITE_REG(RTC_LR, tim);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -205,7 +205,7 @@ rtc_set (struct rtc_time *tmp)
|
||||
rs5c372_enable();
|
||||
|
||||
if (!setup_done)
|
||||
return;
|
||||
return -1;
|
||||
|
||||
if(rtc_debug > 2) {
|
||||
printf("rtc_set: tm_year = %d\n", tmp->tm_year);
|
||||
@ -249,11 +249,15 @@ rtc_set (struct rtc_time *tmp)
|
||||
buf[7] = bin2bcd(tmp->tm_year % 100);
|
||||
|
||||
ret = i2c_write(CFG_I2C_RTC_ADDR, 0, 0, buf, 8);
|
||||
if (ret != 0)
|
||||
if (ret != 0) {
|
||||
printf("rs5c372_set_datetime(), i2c_master_send() returned %d\n",ret);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -158,7 +158,7 @@ int rtc_get (struct rtc_time *tmp)
|
||||
/*
|
||||
* Set the RTC
|
||||
*/
|
||||
void rtc_set (struct rtc_time *tmp)
|
||||
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,
|
||||
@ -176,6 +176,8 @@ void rtc_set (struct rtc_time *tmp)
|
||||
rtc_write (RTC_SEC_REG_ADDR, bin2bcd (tmp->tm_sec));
|
||||
|
||||
rtc_write (RTC_CTL1_REG_ADDR, RTC_CTL1_BIT_2412);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -135,7 +135,7 @@ int rtc_get (struct rtc_time *tmp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_set (struct rtc_time *tmp)
|
||||
int rtc_set (struct rtc_time *tmp)
|
||||
{
|
||||
S3C24X0_RTC * const rtc = S3C24X0_GetBase_RTC();
|
||||
uchar sec, min, hour, mday, wday, mon, year;
|
||||
@ -167,6 +167,8 @@ void rtc_set (struct rtc_time *tmp)
|
||||
|
||||
/* disable access to RTC registers */
|
||||
SetRTC_Access(RTC_DISABLE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_reset (void)
|
||||
|
@ -134,7 +134,7 @@ int rtc_get(struct rtc_time *tm)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_set(struct rtc_time *tm)
|
||||
int rtc_set(struct rtc_time *tm)
|
||||
{
|
||||
int i;
|
||||
u8 buf[8];
|
||||
@ -168,6 +168,8 @@ void rtc_set(struct rtc_time *tm)
|
||||
rtc_write(X1205_CCR_BASE + i, buf[i]);
|
||||
|
||||
rtc_write(X1205_REG_SR, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_reset(void)
|
||||
|
@ -53,7 +53,7 @@ struct rtc_time {
|
||||
};
|
||||
|
||||
int rtc_get (struct rtc_time *);
|
||||
void rtc_set (struct rtc_time *);
|
||||
int rtc_set (struct rtc_time *);
|
||||
void rtc_reset (void);
|
||||
|
||||
void GregorianDay (struct rtc_time *);
|
||||
|
Loading…
Reference in New Issue
Block a user