Exemplo n.º 1
0
static int tps80031_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
	u8 buff[6];
	int err;

	err = tps80031_read_regs(dev, RTC_ALARM, sizeof(buff), buff);
	if (err)
		return err;
	convert_bcd_to_decimal(buff, sizeof(buff));

	alrm->time.tm_sec = buff[0];
	alrm->time.tm_min = buff[1];
	alrm->time.tm_hour = buff[2];
	alrm->time.tm_mday = buff[3];
	alrm->time.tm_mon = buff[4] - 1;
	alrm->time.tm_year = buff[5] + RTC_YEAR_OFFSET;

	return 0;
}
Exemplo n.º 2
0
static int tps80031_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
	u8 buff[7];
	int err;
	err = tps80031_read_regs(dev, RTC_SECONDS_REG, sizeof(buff), buff);
	if (err < 0) {
		dev_err(dev->parent, "failed reading time\n");
		return err;
	}
	convert_bcd_to_decimal(buff, sizeof(buff));
	tm->tm_sec = buff[0];
	tm->tm_min = buff[1];
	tm->tm_hour = buff[2];
	tm->tm_mday = buff[3];
	tm->tm_mon = buff[4] - 1;
	tm->tm_year = buff[5] + RTC_YEAR_OFFSET;
	tm->tm_wday = buff[6];
	return 0;
}
Exemplo n.º 3
0
static int tps6591x_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
    u8 buff[7];
    int err;
    err = tps6591x_read_regs(dev, RTC_SECONDS_REG, sizeof(buff), buff);
    if (err < 0) {
        dev_err(dev, "\n %s :: failed to read time\n", __FILE__);
        return err;
    }
    convert_bcd_to_decimal(buff, sizeof(buff));
    tm->tm_sec = buff[0];
    tm->tm_min = buff[1];
    tm->tm_hour = buff[2];
    tm->tm_mday = buff[3];
    tm->tm_mon = buff[4] - 1;
    tm->tm_year = buff[5] + RTC_YEAR_OFFSET;
    tm->tm_wday = buff[6];
    print_time(dev, tm);
    return tps6591x_rtc_valid_tm(tm);
}
Exemplo n.º 4
0
static int ricoh583_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
	u8 buff[7];
	int err;
	err = ricoh583_read_regs(dev, rtc_seconds_reg, sizeof(buff), buff);
	if (err < 0) {
		dev_err(dev, "\n %s :: failed to read time\n", __FILE__);
		return err;
	}
	convert_bcd_to_decimal(buff, sizeof(buff));
	tm->tm_sec  = buff[0];
	tm->tm_min  = buff[1];
	tm->tm_hour = buff[2];
	tm->tm_wday = buff[3];
	tm->tm_mday = buff[4];
	tm->tm_mon  = buff[5] - 1;
	tm->tm_year = buff[6] + rtc_year_offset;
	print_time(dev, tm);
	return ricoh583_rtc_valid_tm(dev, tm);
}
Exemplo n.º 5
0
static int tps6591x_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
    u8 buff[6];
    int err;

    err = tps6591x_read_regs(dev, RTC_ALARM, sizeof(buff), buff);
    if (err)
        return err;
    convert_bcd_to_decimal(buff, sizeof(buff));

    alrm->time.tm_sec = buff[0];
    alrm->time.tm_min = buff[1];
    alrm->time.tm_hour = buff[2];
    alrm->time.tm_mday = buff[3];
    alrm->time.tm_mon = buff[4] - 1;
    alrm->time.tm_year = buff[5] + RTC_YEAR_OFFSET;

    dev_info(dev->parent, "\n getting alarm time::\n");
    print_time(dev, &alrm->time);

    return 0;
}
Exemplo n.º 6
0
static int ricoh583_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
	struct ricoh583_rtc *rtc = dev_get_drvdata(dev);
	u8 buff[5];
	int err;

	err = ricoh583_read_regs(dev, rtc_alarm_y, sizeof(buff), buff);
	if (err)
		return err;
	convert_bcd_to_decimal(buff, sizeof(buff));

	alrm->time.tm_min  = buff[0];
	alrm->time.tm_hour = buff[1];
	alrm->time.tm_mday = buff[2];
	alrm->time.tm_mon  = buff[3] - 1;
	alrm->time.tm_year = buff[4] + rtc_year_offset;
	alrm->enabled = rtc->irq_en;

	dev_info(dev->parent, "\n getting alarm time::\n");
	print_time(dev, &alrm->time);

	return 0;
}
static int tps6591x_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
	u8 buff[7];
	int err;
	err = tps6591x_read_regs(dev, RTC_SECONDS_REG, sizeof(buff), buff);
	if (err < 0) {
		dev_err(dev, "\n %s :: failed to read time\n", __FILE__);
		return err;
	}
	convert_bcd_to_decimal(buff, sizeof(buff));
	tm->tm_sec = buff[0];
	tm->tm_min = buff[1];
	tm->tm_hour = buff[2];
	tm->tm_mday = buff[3];
	tm->tm_mon = buff[4];
	tm->tm_year = buff[5];
	tm->tm_wday = buff[6];
	if(tm->tm_mon >= 1)
		tm->tm_mon -=1;
	else
		printk("[Error]tps6591x_rtc_read_time tm->tm_mon=%x! This value should be above 0. \n", tm->tm_mon );
	print_time(dev, tm);
	return tps6591x_rtc_valid_tm(tm);
}