Changeset a8a0d43 in mainline
- Timestamp:
- 2012-04-14T18:08:21Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 80d3f846
- Parents:
- cf72943
- Location:
- uspace/drv/time/cmos-rtc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/time/cmos-rtc/cmos-regs.h
rcf72943 ra8a0d43 30 30 #define _CMOS_RTC_H_ 31 31 32 #define RTC_SEC 0x0033 #define RTC_MIN 0x0234 #define RTC_HOUR 0x0435 #define RTC_DAY 0x0736 #define RTC_MON 0x0837 #define RTC_YEAR 0x0932 #define RTC_SEC 0x00 33 #define RTC_MIN 0x02 34 #define RTC_HOUR 0x04 35 #define RTC_DAY 0x07 36 #define RTC_MON 0x08 37 #define RTC_YEAR 0x09 38 38 39 #define RTC_STATUS_B 0x0B 40 #define RTC_MASK_24H 0x02 /* 24h mode */ 41 #define RTC_MASK_BCD 0x04 /* BCD mode */ 39 #define RTC_STATUS_B 0x0B 40 #define RTC_MASK_24H 0x02 /* 24h mode */ 41 #define RTC_MASK_BCD 0x04 /* BCD mode */ 42 #define RTC_MASK_INH 0x80 /* Inhibit updates */ 42 43 43 #define RTC_STATUS_D 0x0D44 #define RTC_BATTERY_OK 0x80 /* Battery status */44 #define RTC_STATUS_D 0x0D 45 #define RTC_BATTERY_OK 0x80 /* Battery status */ 45 46 46 #define RTC_STATUS_A 0x0A 47 #define RTC_MASK_UPDATE 0x80 /* Update in progress */ 47 #define RTC_STATUS_A 0x0A 48 #define RTC_MASK_UPDATE 0x80 /* Update in progress */ 49 #define RTC_MASK_CLK_STOP 0x70 /* Stop the clock */ 48 50 49 51 #endif -
uspace/drv/time/cmos-rtc/cmos-rtc.c
rcf72943 ra8a0d43 91 91 static int rtc_dev_remove(ddf_dev_t *dev); 92 92 static int rtc_tm_sanity_check(struct tm *t); 93 static void rtc_register_write(rtc_t *rtc, int reg, int data); 93 94 94 95 … … 247 248 } 248 249 249 /* XXX */250 #if 0251 250 /** Write a register to the CMOS memory 252 251 * … … 261 260 pio_write_8(rtc->port + 1, data); 262 261 } 263 264 #endif265 266 /* XXX */267 262 268 263 /** Check if an update is in progress … … 373 368 rtc_time_set(ddf_fun_t *fun, struct tm *t) 374 369 { 375 int rc;370 int rc; 376 371 bool bcd_mode; 372 int reg_b; 373 int reg_a; 377 374 rtc_t *rtc = RTC_FROM_FNODE(fun); 378 375 … … 381 378 return rc; 382 379 383 t->tm_mon++; /* Must startfrom 1, not from 0 */380 t->tm_mon++; /* counts from 1, not from 0 */ 384 381 385 382 fibril_mutex_lock(&rtc->mutex); 386 383 384 reg_b = rtc_register_read(rtc, RTC_STATUS_B); 385 387 386 /* Check if the rtc is working in bcd mode */ 388 bcd_mode = !(r tc_register_read(rtc, RTC_STATUS_B)& RTC_MASK_BCD);387 bcd_mode = !(reg_b & RTC_MASK_BCD); 389 388 if (bcd_mode) { 390 389 /* Convert the tm struct fields in BCD mode */ … … 397 396 } 398 397 399 /* XXX Inhibit updates */ 398 /* Inhibit updates */ 399 rtc_register_write(rtc, RTC_STATUS_B, reg_b | RTC_MASK_INH); 400 401 /* Write current time to RTC */ 402 rtc_register_write(rtc, RTC_SEC, t->tm_sec); 403 rtc_register_write(rtc, RTC_MIN, t->tm_min); 404 rtc_register_write(rtc, RTC_HOUR, t->tm_hour); 405 rtc_register_write(rtc, RTC_DAY, t->tm_mday); 406 rtc_register_write(rtc, RTC_MON, t->tm_mon); 407 rtc_register_write(rtc, RTC_YEAR, t->tm_year); 408 409 /* Stop the clock */ 410 reg_a = rtc_register_read(rtc, RTC_STATUS_A); 411 rtc_register_write(rtc, RTC_STATUS_A, RTC_MASK_CLK_STOP | reg_a); 412 413 /* Enable updates */ 414 rtc_register_write(rtc, RTC_STATUS_B, reg_b); 415 rtc_register_write(rtc, RTC_STATUS_A, reg_a); 400 416 401 417 fibril_mutex_unlock(&rtc->mutex);
Note:
See TracChangeset
for help on using the changeset viewer.