unsigned long rtc_time_s3c2410(unsigned base) { struct tm tm; hwi_add_device(HWI_ITEM_BUS_UNKNOWN, HWI_ITEM_DEVCLASS_RTC, "s3c2410", 0); hwi_add_location(base, S3C2410_RTC_SIZE, 0, hwi_find_as(base, 1)); // get the current time from the RTC, and convert it to seconds since epoch chip_access(base, 0, 0, S3C2410_RTC_SIZE); // enable RTC chip_write8(S3C2410_RTCCON, chip_read8(S3C2410_RTCCON) | 1); // convert BCD to binary tm.tm_sec = bcd2bin(chip_read8(S3C2410_BCDSEC) & 0xff); // seconds tm.tm_min = bcd2bin(chip_read8(S3C2410_BCDMIN) & 0xff); // minutes tm.tm_hour = bcd2bin(chip_read8(S3C2410_BCDHOUR) & 0xff); // hours tm.tm_mday = bcd2bin(chip_read8(S3C2410_BCDDAY) & 0xff); // day tm.tm_mon = bcd2bin(chip_read8(S3C2410_BCDMON) & 0xff) -1; // month tm.tm_year = (bcd2bin(chip_read8(S3C2410_BCDYEAR) & 0xff))+100; // year chip_done(); return(calc_time_t(&tm)); }
unsigned long rtc_time_omap(unsigned base) { struct tm tm; hwi_add_device(HWI_ITEM_BUS_UNKNOWN, HWI_ITEM_DEVCLASS_RTC, "omap", 0); hwi_add_location(base, OMAP_RTC_SIZE, 0, hwi_find_as(base, 1)); // get the current time from the RTC, and convert it to seconds since epoch chip_access(base, 0, 0, OMAP_RTC_SIZE); // start the RTC, if it's not already running chip_write32(OMAP_RTC_CTRL, 0x01); // convert BCD to binary tm.tm_sec = bcd2bin(chip_read32(OMAP_RTC_SECONDS) & 0xff); // seconds tm.tm_min = bcd2bin(chip_read32(OMAP_RTC_MINUTES) & 0xff); // minutes tm.tm_hour = bcd2bin(chip_read32(OMAP_RTC_HOURS) & 0xff); // hours tm.tm_mday = bcd2bin(chip_read32(OMAP_RTC_DAYS) & 0xff); // day tm.tm_mon = bcd2bin(chip_read32(OMAP_RTC_MONTHS) & 0xff); // month tm.tm_year = (bcd2bin(chip_read32(OMAP_RTC_YEARS) & 0xff))+100; // year chip_done(); return(calc_time_t(&tm)); }
unsigned long rtc_time_primecell(unsigned base) { hwi_add_device(HWI_ITEM_BUS_UNKNOWN, HWI_ITEM_DEVCLASS_RTC, "primecell", 0); hwi_add_location(base, PRIMECELL_RTC_SIZE, 0, hwi_find_as(base, 1)); /* * Read counter register. * The manual says the RTSR interrupts bits are cleared on reset. */ return in32(base + PRIMECELL_RTC_DR); }
void hwi_add_rtc(const char *name, paddr_t base, unsigned reg_shift, unsigned len, int mmap, int cent_reg) { hwi_add_device(HWI_ITEM_BUS_UNKNOWN, HWI_ITEM_DEVCLASS_RTC, name, 0); hwi_add_location(base, len << reg_shift, reg_shift, hwi_find_as(base, mmap)); if(cent_reg != -1) { hwi_tag *cent = hwi_alloc_tag(HWI_TAG_INFO(regname)); cent->regname.regname = 0; cent->regname.offset = cent_reg; } }