rtc: allow rtc_set to return an error and use it in cmd_date

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
master
Jean-Christophe PLAGNIOL-VILLARD 17 years ago committed by Wolfgang Denk
parent ee9536a28c
commit d1e2319414
  1. 4
      board/bmw/m48t59y.c
  2. 4
      board/cray/L1/L1.c
  3. 4
      board/etin/debris/phantom.c
  4. 4
      board/mousse/m48t59y.c
  5. 28
      common/cmd_date.c
  6. 4
      cpu/s3c44b0/cpu.c
  7. 6
      drivers/rtc/bfin_rtc.c
  8. 4
      drivers/rtc/ds12887.c
  9. 5
      drivers/rtc/ds1302.c
  10. 6
      drivers/rtc/ds1306.c
  11. 4
      drivers/rtc/ds1307.c
  12. 4
      drivers/rtc/ds1337.c
  13. 4
      drivers/rtc/ds1374.c
  14. 4
      drivers/rtc/ds1556.c
  15. 4
      drivers/rtc/ds164x.c
  16. 4
      drivers/rtc/ds174x.c
  17. 4
      drivers/rtc/ds3231.c
  18. 4
      drivers/rtc/isl1208.c
  19. 4
      drivers/rtc/m41t11.c
  20. 8
      drivers/rtc/m41t60.c
  21. 8
      drivers/rtc/m41t62.c
  22. 4
      drivers/rtc/m48t35ax.c
  23. 4
      drivers/rtc/max6900.c
  24. 8
      drivers/rtc/mc13783-rtc.c
  25. 3
      drivers/rtc/mc146818.c
  26. 4
      drivers/rtc/mcfrtc.c
  27. 6
      drivers/rtc/mk48t59.c
  28. 4
      drivers/rtc/mpc5xxx.c
  29. 4
      drivers/rtc/mpc8xx.c
  30. 4
      drivers/rtc/pcf8563.c
  31. 6
      drivers/rtc/pl031.c
  32. 10
      drivers/rtc/rs5c372.c
  33. 4
      drivers/rtc/rx8025.c
  34. 4
      drivers/rtc/s3c24x0_rtc.c
  35. 4
      drivers/rtc/x1205.c
  36. 2
      include/rtc.h

@ -299,8 +299,7 @@ rtc_get( struct rtc_time *tmp )
return 0; return 0;
} }
void int rtc_set( struct rtc_time *tmp )
rtc_set( struct rtc_time *tmp )
{ {
m48_tod_set(tmp->tm_year, /* 1980-2079 */ m48_tod_set(tmp->tm_year, /* 1980-2079 */
tmp->tm_mon, /* 01-12 */ tmp->tm_mon, /* 01-12 */
@ -315,6 +314,7 @@ rtc_set( struct rtc_time *tmp )
tmp->tm_hour, tmp->tm_min, tmp->tm_sec); tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
#endif #endif
return 0;
} }
void void

@ -181,9 +181,9 @@ int rtc_get (struct rtc_time *tmp)
{ {
return 0; return 0;
} }
void rtc_set (struct rtc_time *tmp) int rtc_set (struct rtc_time *tmp)
{ {
return; return 0;
} }
void rtc_reset (void) void rtc_reset (void)
{ {

@ -254,7 +254,7 @@ int rtc_get( struct rtc_time *tmp)
return 0; return 0;
} }
void rtc_set( struct rtc_time *tmp ) int rtc_set( struct rtc_time *tmp )
{ {
if (phantom_flag < 0) if (phantom_flag < 0)
phantom_flag = get_phantom_flag(); phantom_flag = get_phantom_flag();
@ -307,6 +307,8 @@ void rtc_set( struct rtc_time *tmp )
/* unlock clock registers after read */ /* unlock clock registers after read */
rtc_write( RTC_CONTROLA, ( reg_a & ~RTC_CA_WRITE )); rtc_write( RTC_CONTROLA, ( reg_a & ~RTC_CA_WRITE ));
} }
return 0;
} }
#endif #endif

@ -299,8 +299,7 @@ rtc_get( struct rtc_time *tmp )
return 0; return 0;
} }
void int rtc_set( struct rtc_time *tmp )
rtc_set( struct rtc_time *tmp )
{ {
m48_tod_set(tmp->tm_year, /* 1980-2079 */ m48_tod_set(tmp->tm_year, /* 1980-2079 */
tmp->tm_mon, /* 01-12 */ tmp->tm_mon, /* 01-12 */
@ -315,6 +314,7 @@ rtc_set( struct rtc_time *tmp )
tmp->tm_hour, tmp->tm_min, tmp->tm_sec); tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
#endif #endif
return 0;
} }
void void

@ -56,18 +56,30 @@ int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
rtc_reset (); rtc_reset ();
} else { } else {
/* initialize tm with current time */ /* initialize tm with current time */
rtc_get (&tm); rcode = rtc_get (&tm);
/* insert new date & time */
if (mk_date (argv[1], &tm) != 0) { if(!rcode) {
puts ("## Bad date format\n"); /* insert new date & time */
break; 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 */ /* FALL TROUGH */
case 1: /* get date & time */ 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", printf ("Date: %4d-%02d-%02d (%sday) Time: %2d:%02d:%02d\n",
tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_year, tm.tm_mon, tm.tm_mday,

@ -188,7 +188,7 @@ int rtc_get (struct rtc_time* tm)
return 0; return 0;
} }
void rtc_set (struct rtc_time* tm) int rtc_set (struct rtc_time* tm)
{ {
if(tm->tm_year < 2000) if(tm->tm_year < 2000)
tm->tm_year -= 1900; tm->tm_year -= 1900;
@ -204,6 +204,8 @@ void rtc_set (struct rtc_time* tm)
BCDMIN = HEX2BCD(tm->tm_min); BCDMIN = HEX2BCD(tm->tm_min);
BCDSEC = HEX2BCD(tm->tm_sec); BCDSEC = HEX2BCD(tm->tm_sec);
RTCCON &= 1; RTCCON &= 1;
return 0;
} }
void rtc_reset (void) 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 /* 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. * 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; unsigned long remain, days, hrs, mins, secs;
@ -61,7 +61,7 @@ void rtc_set(struct rtc_time *tmp)
if (tmp == NULL) { if (tmp == NULL) {
puts("Error setting the date/time\n"); puts("Error setting the date/time\n");
return; return -1;
} }
wait_for_complete(); wait_for_complete();
@ -82,6 +82,8 @@ void rtc_set(struct rtc_time *tmp)
/* Encode these time values into our RTC_STAT register */ /* Encode these time values into our RTC_STAT register */
bfin_write_RTC_STAT(SET_ALARM(days, hrs, mins, secs)); 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 */ /* Read the time from the RTC_STAT. time_in_seconds is seconds since Jan 1970 */

@ -154,7 +154,7 @@ else
return 0; return 0;
} }
void rtc_set (struct rtc_time *tmp) int rtc_set (struct rtc_time *tmp)
{ {
uchar save_ctrl_b; uchar save_ctrl_b;
uchar sec, min, hour, mday, wday, mon, year; 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 */ /* enables the RTC to update the regs */
save_ctrl_b &= ~RTC_CB_SET; save_ctrl_b &= ~RTC_CB_SET;
rtc_write(RTC_CONTROL_B, save_ctrl_b); rtc_write(RTC_CONTROL_B, save_ctrl_b);
return 0;
} }
void rtc_reset (void) void rtc_reset (void)

@ -287,8 +287,7 @@ rtc_get(struct rtc_time *tmp)
return rel; return rel;
} }
void int rtc_set(struct rtc_time *tmp)
rtc_set(struct rtc_time *tmp)
{ {
struct ds1302_st bbclk; struct ds1302_st bbclk;
unsigned char b=0; 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(0x8e,&b,1); /* disable write protect */
write_ser_drv(0xbe,(unsigned char *)&bbclk, 8); /* write burst */ write_ser_drv(0xbe,(unsigned char *)&bbclk, 8); /* write burst */
return 0;
} }
#endif #endif

@ -141,7 +141,7 @@ int rtc_get (struct rtc_time *tmp)
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* set clock time in DS1306 RTC and in MPC8xx RTC */ /* 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; 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", 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_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
tmp->tm_hour, tmp->tm_min, tmp->tm_sec); 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 */ /* 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) */ /* Assuming Vcc = 2.0V (lowest speed) */
if (!slave) { if (!slave) {

@ -128,7 +128,7 @@ int rtc_get (struct rtc_time *tmp)
/* /*
* Set the RTC * 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", 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_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_HR_REG_ADDR, bin2bcd (tmp->tm_hour));
rtc_write (RTC_MIN_REG_ADDR, bin2bcd (tmp->tm_min)); rtc_write (RTC_MIN_REG_ADDR, bin2bcd (tmp->tm_min));
rtc_write (RTC_SEC_REG_ADDR, bin2bcd (tmp->tm_sec)); 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 * Set the RTC
*/ */
void rtc_set (struct rtc_time *tmp) int rtc_set (struct rtc_time *tmp)
{ {
uchar century; 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_HR_REG_ADDR, bin2bcd (tmp->tm_hour));
rtc_write (RTC_MIN_REG_ADDR, bin2bcd (tmp->tm_min)); rtc_write (RTC_MIN_REG_ADDR, bin2bcd (tmp->tm_min));
rtc_write (RTC_SEC_REG_ADDR, bin2bcd (tmp->tm_sec)); 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 * Set the RTC
*/ */
void rtc_set (struct rtc_time *tmp){ int rtc_set (struct rtc_time *tmp){
unsigned long time; unsigned long time;
unsigned i; unsigned i;
@ -186,6 +186,8 @@ void rtc_set (struct rtc_time *tmp){
/* Start clock */ /* Start clock */
rtc_write(RTC_CTL_ADDR, RTC_CTL_BIT_EN_OSC, FALSE); 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; return 0;
} }
void rtc_set( struct rtc_time *tmp ) int rtc_set( struct rtc_time *tmp )
{ {
uchar reg_a; uchar reg_a;
#ifdef RTC_DEBUG #ifdef RTC_DEBUG
@ -146,6 +146,8 @@ void rtc_set( struct rtc_time *tmp )
/* unlock clock registers after read */ /* unlock clock registers after read */
rtc_write( RTC_CONTROLA, ( reg_a & ~RTC_CA_WRITE )); rtc_write( RTC_CONTROLA, ( reg_a & ~RTC_CA_WRITE ));
return 0;
} }
void rtc_reset (void) void rtc_reset (void)

@ -119,7 +119,7 @@ int rtc_get( struct rtc_time *tmp )
return 0; return 0;
} }
void rtc_set( struct rtc_time *tmp ) int rtc_set( struct rtc_time *tmp )
{ {
uchar reg_a; uchar reg_a;
@ -145,6 +145,8 @@ void rtc_set( struct rtc_time *tmp )
/* unlock clock registers after read */ /* unlock clock registers after read */
rtc_write( RTC_CONTROLA, ( reg_a & ~RTC_CA_WRITE )); rtc_write( RTC_CONTROLA, ( reg_a & ~RTC_CA_WRITE ));
return 0;
} }
void rtc_reset (void) void rtc_reset (void)

@ -117,7 +117,7 @@ int rtc_get( struct rtc_time *tmp )
return 0; return 0;
} }
void rtc_set( struct rtc_time *tmp ) int rtc_set( struct rtc_time *tmp )
{ {
uchar reg_a; uchar reg_a;
#ifdef RTC_DEBUG #ifdef RTC_DEBUG
@ -143,6 +143,8 @@ void rtc_set( struct rtc_time *tmp )
/* unlock clock registers after read */ /* unlock clock registers after read */
rtc_write( RTC_CONTROLA, ( reg_a & ~RTC_CA_WRITE )); rtc_write( RTC_CONTROLA, ( reg_a & ~RTC_CA_WRITE ));
return 0;
} }
void rtc_reset (void) void rtc_reset (void)

@ -134,7 +134,7 @@ int rtc_get (struct rtc_time *tmp)
/* /*
* Set the RTC * Set the RTC
*/ */
void rtc_set (struct rtc_time *tmp) int rtc_set (struct rtc_time *tmp)
{ {
uchar century; 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_HR_REG_ADDR, bin2bcd (tmp->tm_hour));
rtc_write (RTC_MIN_REG_ADDR, bin2bcd (tmp->tm_min)); rtc_write (RTC_MIN_REG_ADDR, bin2bcd (tmp->tm_min));
rtc_write (RTC_SEC_REG_ADDR, bin2bcd (tmp->tm_sec)); 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 * 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", 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_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
@ -139,6 +139,8 @@ void rtc_set (struct rtc_time *tmp)
/* disable write */ /* disable write */
rtc_write(RTC_STAT_REG_ADDR, rtc_write(RTC_STAT_REG_ADDR,
rtc_read(RTC_STAT_REG_ADDR) & ~RTC_STAT_BIT_WRTC); rtc_read(RTC_STAT_REG_ADDR) & ~RTC_STAT_BIT_WRTC);
return 0;
} }
void rtc_reset (void) void rtc_reset (void)

@ -143,7 +143,7 @@ int rtc_get (struct rtc_time *tmp)
return rel; return rel;
} }
void rtc_set (struct rtc_time *tmp) int rtc_set (struct rtc_time *tmp)
{ {
uchar data[RTC_REG_CNT]; uchar data[RTC_REG_CNT];
@ -176,6 +176,8 @@ void rtc_set (struct rtc_time *tmp)
} }
#endif #endif
i2c_write(CFG_I2C_RTC_ADDR, RTC_SEC_ADDR, 1, data, RTC_REG_CNT); i2c_write(CFG_I2C_RTC_ADDR, RTC_SEC_ADDR, 1, data, RTC_REG_CNT);
return 0;
} }
void rtc_reset (void) void rtc_reset (void)

@ -193,12 +193,12 @@ int rtc_get(struct rtc_time *tmp)
return 0; return 0;
} }
void rtc_set(struct rtc_time *tmp) int rtc_set(struct rtc_time *tmp)
{ {
uchar *const data = rtc_validate(); uchar *const data = rtc_validate();
if (!data) if (!data)
return; return -1;
debug("Set DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", 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_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; data[RTC_DAY] = bin2bcd(tmp->tm_wday + 1) & 0x07;
if (i2c_write(CFG_I2C_RTC_ADDR, 0, 1, data, RTC_REG_CNT)) { if (i2c_write(CFG_I2C_RTC_ADDR, 0, 1, data, RTC_REG_CNT)) {
printf("I2C write failed in rtc_set()\n"); printf("I2C write failed in rtc_set()\n");
return; return -1;
} }
return 0;
} }
void rtc_reset(void) void rtc_reset(void)

@ -96,7 +96,7 @@ int rtc_get(struct rtc_time *tm)
return 0; return 0;
} }
void rtc_set(struct rtc_time *tm) int rtc_set(struct rtc_time *tm)
{ {
u8 buf[M41T62_DATETIME_REG_SIZE]; u8 buf[M41T62_DATETIME_REG_SIZE];
@ -123,8 +123,12 @@ void rtc_set(struct rtc_time *tm)
/* assume 20YY not 19YY */ /* assume 20YY not 19YY */
buf[M41T62_REG_YEAR] = BIN2BCD(tm->tm_year % 100); 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__); printf("I2C write failed in %s()\n", __func__);
return -1;
}
return 0;
} }
void rtc_reset(void) void rtc_reset(void)

@ -87,7 +87,7 @@ int rtc_get (struct rtc_time *tmp)
return 0; return 0;
} }
void rtc_set (struct rtc_time *tmp) int rtc_set (struct rtc_time *tmp)
{ {
uchar ccr; /* Clock control register */ uchar ccr; /* Clock control register */
uchar century; uchar century;
@ -116,6 +116,8 @@ void rtc_set (struct rtc_time *tmp)
ccr = rtc_read(0); ccr = rtc_read(0);
ccr = ccr & 0x7F; ccr = ccr & 0x7F;
rtc_write(0, ccr); rtc_write(0, ccr);
return 0;
} }
void rtc_reset (void) void rtc_reset (void)

@ -107,7 +107,7 @@ int rtc_get (struct rtc_time *tmp)
return 0; 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", 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 (0x84, bin2bcd(tmp->tm_hour));
rtc_write (0x82, bin2bcd(tmp->tm_min )); rtc_write (0x82, bin2bcd(tmp->tm_min ));
rtc_write (0x80, bin2bcd(tmp->tm_sec )); rtc_write (0x80, bin2bcd(tmp->tm_sec ));
return 0;
} }
void rtc_reset (void) void rtc_reset (void)

@ -77,7 +77,7 @@ int rtc_get(struct rtc_time *rtc)
return 0; return 0;
} }
void rtc_set(struct rtc_time *rtc) int rtc_set(struct rtc_time *rtc)
{ {
u32 time, day, reg; u32 time, day, reg;
@ -86,7 +86,7 @@ void rtc_set(struct rtc_time *rtc)
slave = spi_setup_slave(1, 0, 1000000, slave = spi_setup_slave(1, 0, 1000000,
SPI_MODE_2 | SPI_CS_HIGH); SPI_MODE_2 | SPI_CS_HIGH);
if (!slave) if (!slave)
return; return -1;
} }
time = mktime(rtc->tm_year, rtc->tm_mon, rtc->tm_mday, time = mktime(rtc->tm_year, rtc->tm_mon, rtc->tm_mday,
@ -95,7 +95,7 @@ void rtc_set(struct rtc_time *rtc)
time %= 86400; time %= 86400;
if (spi_claim_bus(slave)) if (spi_claim_bus(slave))
return; return -1;
reg = 0x2c000000 | day | 0x80000000; reg = 0x2c000000 | day | 0x80000000;
spi_xfer(slave, 32, (uchar *)&reg, (uchar *)&day, spi_xfer(slave, 32, (uchar *)&reg, (uchar *)&day,
@ -106,6 +106,8 @@ void rtc_set(struct rtc_time *rtc)
SPI_XFER_BEGIN | SPI_XFER_END); SPI_XFER_BEGIN | SPI_XFER_END);
spi_release_bus(slave); spi_release_bus(slave);
return -1;
} }
void rtc_reset(void) void rtc_reset(void)

@ -105,7 +105,7 @@ int rtc_get (struct rtc_time *tmp)
return 0; return 0;
} }
void rtc_set (struct rtc_time *tmp) int rtc_set (struct rtc_time *tmp)
{ {
#ifdef RTC_DEBUG #ifdef RTC_DEBUG
printf ( "Set DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", 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_SECONDS, bin2bcd(tmp->tm_sec ));
rtc_write(RTC_CONFIG_B,0x02); /* enables the RTC to update the regs */ rtc_write(RTC_CONFIG_B,0x02); /* enables the RTC to update the regs */
return 0;
} }
void rtc_reset (void) void rtc_reset (void)

@ -68,7 +68,7 @@ int rtc_get(struct rtc_time *tmp)
return 0; 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); volatile rtc_t *rtc = (rtc_t *) (CFG_MCFRTC_BASE);
@ -106,6 +106,8 @@ void rtc_set(struct rtc_time *tmp)
rtc->days = days; rtc->days = days;
rtc->hourmin = (tmp->tm_hour << 8) | tmp->tm_min; rtc->hourmin = (tmp->tm_hour << 8) | tmp->tm_min;
rtc->seconds = tmp->tm_sec; rtc->seconds = tmp->tm_sec;
return 0;
} }
void rtc_reset(void) void rtc_reset(void)

@ -185,7 +185,7 @@ int rtc_get (struct rtc_time *tmp)
return 0; return 0;
} }
void rtc_set (struct rtc_time *tmp) int rtc_set (struct rtc_time *tmp)
{ {
uchar save_ctrl_a; uchar save_ctrl_a;
@ -210,6 +210,8 @@ void rtc_set (struct rtc_time *tmp)
save_ctrl_a &= ~RTC_CA_WRITE; save_ctrl_a &= ~RTC_CA_WRITE;
rtc_write(RTC_CONTROLA, save_ctrl_a); /* enables the RTC to update the regs */ rtc_write(RTC_CONTROLA, save_ctrl_a); /* enables the RTC to update the regs */
return 0;
} }
void rtc_reset (void) void rtc_reset (void)
@ -225,7 +227,7 @@ void rtc_reset (void)
rtc_write(RTC_CONTROLB, control_b); 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; uchar wd_value;

@ -88,7 +88,7 @@ int rtc_get (struct rtc_time *tmp)
/***************************************************************************** /*****************************************************************************
* set time * set time
*****************************************************************************/ *****************************************************************************/
void rtc_set (struct rtc_time *tmp) int rtc_set (struct rtc_time *tmp)
{ {
RTC5200 *rtc = (RTC5200 *) (CFG_MBAR+0x800); RTC5200 *rtc = (RTC5200 *) (CFG_MBAR+0x800);
ulong time, date, year; ulong time, date, year;
@ -129,6 +129,8 @@ void rtc_set (struct rtc_time *tmp)
udelay (1000); udelay (1000);
rtc->tsr = time; rtc->tsr = time;
udelay (1000); udelay (1000);
return 0;
} }
/***************************************************************************** /*****************************************************************************

@ -51,7 +51,7 @@ int rtc_get (struct rtc_time *tmp)
return 0; return 0;
} }
void rtc_set (struct rtc_time *tmp) int rtc_set (struct rtc_time *tmp)
{ {
volatile immap_t *immr = (immap_t *)CFG_IMMR; volatile immap_t *immr = (immap_t *)CFG_IMMR;
ulong tim; ulong tim;
@ -65,6 +65,8 @@ void rtc_set (struct rtc_time *tmp)
immr->im_sitk.sitk_rtck = KAPWR_KEY; immr->im_sitk.sitk_rtck = KAPWR_KEY;
immr->im_sit.sit_rtc = tim; immr->im_sit.sit_rtc = tim;
return 0;
} }
void rtc_reset (void) void rtc_reset (void)

@ -86,7 +86,7 @@ int rtc_get (struct rtc_time *tmp)
return rel; return rel;
} }
void rtc_set (struct rtc_time *tmp) int rtc_set (struct rtc_time *tmp)
{ {
uchar century; uchar century;
@ -104,6 +104,8 @@ void rtc_set (struct rtc_time *tmp)
rtc_write (0x04, bin2bcd(tmp->tm_hour)); rtc_write (0x04, bin2bcd(tmp->tm_hour));
rtc_write (0x03, bin2bcd(tmp->tm_min )); rtc_write (0x03, bin2bcd(tmp->tm_min ));
rtc_write (0x02, bin2bcd(tmp->tm_sec )); rtc_write (0x02, bin2bcd(tmp->tm_sec ));
return 0;
} }
void rtc_reset (void) void rtc_reset (void)

@ -75,7 +75,7 @@ void rtc_reset(void)
/* /*
* Set the RTC * Set the RTC
*/ */
void rtc_set(struct rtc_time *tmp) int rtc_set(struct rtc_time *tmp)
{ {
unsigned long tim; unsigned long tim;
@ -84,7 +84,7 @@ void rtc_set(struct rtc_time *tmp)
if (tmp == NULL) { if (tmp == NULL) {
puts("Error setting the date/time\n"); puts("Error setting the date/time\n");
return; return -1;
} }
/* Calculate number of seconds this incoming time represents */ /* 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); tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
RTC_WRITE_REG(RTC_LR, tim); RTC_WRITE_REG(RTC_LR, tim);
return -1;
} }
/* /*

@ -205,7 +205,7 @@ rtc_set (struct rtc_time *tmp)
rs5c372_enable(); rs5c372_enable();
if (!setup_done) if (!setup_done)
return; return -1;
if(rtc_debug > 2) { if(rtc_debug > 2) {
printf("rtc_set: tm_year = %d\n", tmp->tm_year); 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); buf[7] = bin2bcd(tmp->tm_year % 100);
ret = i2c_write(CFG_I2C_RTC_ADDR, 0, 0, buf, 8); 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); 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 * 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", 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_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_SEC_REG_ADDR, bin2bcd (tmp->tm_sec));
rtc_write (RTC_CTL1_REG_ADDR, RTC_CTL1_BIT_2412); 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; return 0;
} }
void rtc_set (struct rtc_time *tmp) int rtc_set (struct rtc_time *tmp)
{ {
S3C24X0_RTC * const rtc = S3C24X0_GetBase_RTC(); S3C24X0_RTC * const rtc = S3C24X0_GetBase_RTC();
uchar sec, min, hour, mday, wday, mon, year; uchar sec, min, hour, mday, wday, mon, year;
@ -167,6 +167,8 @@ void rtc_set (struct rtc_time *tmp)
/* disable access to RTC registers */ /* disable access to RTC registers */
SetRTC_Access(RTC_DISABLE); SetRTC_Access(RTC_DISABLE);
return 0;
} }
void rtc_reset (void) void rtc_reset (void)

@ -134,7 +134,7 @@ int rtc_get(struct rtc_time *tm)
return 0; return 0;
} }
void rtc_set(struct rtc_time *tm) int rtc_set(struct rtc_time *tm)
{ {
int i; int i;
u8 buf[8]; 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_CCR_BASE + i, buf[i]);
rtc_write(X1205_REG_SR, 0); rtc_write(X1205_REG_SR, 0);
return 0;
} }
void rtc_reset(void) void rtc_reset(void)

@ -53,7 +53,7 @@ struct rtc_time {
}; };
int rtc_get (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 rtc_reset (void);
void GregorianDay (struct rtc_time *); void GregorianDay (struct rtc_time *);

Loading…
Cancel
Save