Lines Matching refs:rs5c
133 static int rs5c_get_regs(struct rs5c372 *rs5c) in rs5c_get_regs() argument
135 struct i2c_client *client = rs5c->client; in rs5c_get_regs()
140 .len = sizeof(rs5c->buf), in rs5c_get_regs()
141 .buf = rs5c->buf in rs5c_get_regs()
156 if (rs5c->smbus) { in rs5c_get_regs()
158 int size = sizeof(rs5c->buf) - 1; in rs5c_get_regs()
161 rs5c->buf + 1) != size) { in rs5c_get_regs()
174 rs5c->regs + 0, rs5c->regs[3], in rs5c_get_regs()
175 rs5c->regs + 4, rs5c->regs[7], in rs5c_get_regs()
176 rs5c->regs + 8, rs5c->regs + 11, in rs5c_get_regs()
177 rs5c->regs[14], rs5c->regs[15]); in rs5c_get_regs()
182 static unsigned rs5c_reg2hr(struct rs5c372 *rs5c, unsigned reg) in rs5c_reg2hr() argument
186 if (rs5c->time24) in rs5c_reg2hr()
197 static unsigned rs5c_hr2reg(struct rs5c372 *rs5c, unsigned hour) in rs5c_hr2reg() argument
199 if (rs5c->time24) in rs5c_hr2reg()
214 struct rs5c372 *rs5c = i2c_get_clientdata(client); in rs5c372_rtc_read_time() local
215 int status = rs5c_get_regs(rs5c); in rs5c372_rtc_read_time()
216 unsigned char ctrl2 = rs5c->regs[RS5C_REG_CTRL2]; in rs5c372_rtc_read_time()
221 switch (rs5c->type) { in rs5c372_rtc_read_time()
224 if ((rs5c->type == rtc_r2025sd && !(ctrl2 & R2x2x_CTRL2_XSTP)) || in rs5c372_rtc_read_time()
225 (rs5c->type == rtc_r2221tl && (ctrl2 & R2x2x_CTRL2_XSTP))) { in rs5c372_rtc_read_time()
237 tm->tm_sec = bcd2bin(rs5c->regs[RS5C372_REG_SECS] & 0x7f); in rs5c372_rtc_read_time()
238 tm->tm_min = bcd2bin(rs5c->regs[RS5C372_REG_MINS] & 0x7f); in rs5c372_rtc_read_time()
239 tm->tm_hour = rs5c_reg2hr(rs5c, rs5c->regs[RS5C372_REG_HOURS]); in rs5c372_rtc_read_time()
241 tm->tm_wday = bcd2bin(rs5c->regs[RS5C372_REG_WDAY] & 0x07); in rs5c372_rtc_read_time()
242 tm->tm_mday = bcd2bin(rs5c->regs[RS5C372_REG_DAY] & 0x3f); in rs5c372_rtc_read_time()
245 tm->tm_mon = bcd2bin(rs5c->regs[RS5C372_REG_MONTH] & 0x1f) - 1; in rs5c372_rtc_read_time()
248 tm->tm_year = bcd2bin(rs5c->regs[RS5C372_REG_YEAR]) + 100; in rs5c372_rtc_read_time()
262 struct rs5c372 *rs5c = i2c_get_clientdata(client); in rs5c372_rtc_set_time() local
276 buf[2] = rs5c_hr2reg(rs5c, tm->tm_hour); in rs5c372_rtc_set_time()
292 switch (rs5c->type) { in rs5c372_rtc_set_time()
296 if (rs5c->type == rtc_r2025sd) in rs5c372_rtc_set_time()
360 struct rs5c372 *rs5c = i2c_get_clientdata(client); in rs5c_rtc_alarm_irq_enable() local
364 buf = rs5c->regs[RS5C_REG_CTRL1]; in rs5c_rtc_alarm_irq_enable()
366 if (!rs5c->has_irq) in rs5c_rtc_alarm_irq_enable()
369 status = rs5c_get_regs(rs5c); in rs5c_rtc_alarm_irq_enable()
383 rs5c->regs[RS5C_REG_CTRL1] = buf; in rs5c_rtc_alarm_irq_enable()
401 struct rs5c372 *rs5c = i2c_get_clientdata(client); in rs5c_read_alarm() local
404 status = rs5c_get_regs(rs5c); in rs5c_read_alarm()
410 t->time.tm_min = bcd2bin(rs5c->regs[RS5C_REG_ALARM_A_MIN] & 0x7f); in rs5c_read_alarm()
411 t->time.tm_hour = rs5c_reg2hr(rs5c, rs5c->regs[RS5C_REG_ALARM_A_HOURS]); in rs5c_read_alarm()
414 t->enabled = !!(rs5c->regs[RS5C_REG_CTRL1] & RS5C_CTRL1_AALE); in rs5c_read_alarm()
415 t->pending = !!(rs5c->regs[RS5C_REG_CTRL2] & RS5C_CTRL2_AAFG); in rs5c_read_alarm()
423 struct rs5c372 *rs5c = i2c_get_clientdata(client); in rs5c_set_alarm() local
436 status = rs5c_get_regs(rs5c); in rs5c_set_alarm()
439 if (rs5c->regs[RS5C_REG_CTRL1] & RS5C_CTRL1_AALE) { in rs5c_set_alarm()
441 buf[0] = rs5c->regs[RS5C_REG_CTRL1] & ~RS5C_CTRL1_AALE; in rs5c_set_alarm()
446 rs5c->regs[RS5C_REG_CTRL1] = buf[0]; in rs5c_set_alarm()
451 buf[1] = rs5c_hr2reg(rs5c, t->time.tm_hour); in rs5c_set_alarm()
465 buf[0] = rs5c->regs[RS5C_REG_CTRL1] | RS5C_CTRL1_AALE; in rs5c_set_alarm()
468 rs5c->regs[RS5C_REG_CTRL1] = buf[0]; in rs5c_set_alarm()
497 struct rs5c372 *rs5c = i2c_get_clientdata(to_i2c_client(dev)); in rs5c372_ioctl() local
505 ctrl2 = i2c_smbus_read_byte_data(rs5c->client, addr); in rs5c372_ioctl()
511 switch (rs5c->type) { in rs5c372_ioctl()
514 if ((rs5c->type == rtc_r2025sd && !(ctrl2 & R2x2x_CTRL2_XSTP)) || in rs5c372_ioctl()
515 (rs5c->type == rtc_r2221tl && (ctrl2 & R2x2x_CTRL2_XSTP))) { in rs5c372_ioctl()
530 if (rs5c->type == rtc_r2025sd || rs5c->type == rtc_r2221tl) { in rs5c372_ioctl()
532 if (i2c_smbus_write_byte_data(rs5c->client, addr, ctrl2) < 0) { in rs5c372_ioctl()
533 dev_dbg(&rs5c->client->dev, "%s: write error in line %i\n", in rs5c372_ioctl()
550 struct rs5c372 *rs5c = i2c_get_clientdata(to_i2c_client(dev)); in rs5c372_read_offset() local
551 u8 val = rs5c->regs[RS5C372_REG_TRIM]; in rs5c372_read_offset()
555 switch (rs5c->type) { in rs5c372_read_offset()
586 struct rs5c372 *rs5c = i2c_get_clientdata(to_i2c_client(dev)); in rs5c372_set_offset() local
593 switch (rs5c->type) { in rs5c372_set_offset()
596 tmp = rs5c->regs[RS5C372_REG_TRIM]; in rs5c372_set_offset()
646 if (rs5c->type == rtc_rs5c372a || rs5c->type == rtc_rs5c372b) in rs5c372_set_offset()
652 dev_dbg(&rs5c->client->dev, "write 0x%x for offset %ld\n", val, offset); in rs5c372_set_offset()
654 if (i2c_smbus_write_byte_data(rs5c->client, addr, val) < 0) { in rs5c372_set_offset()
655 dev_err(&rs5c->client->dev, "failed to write 0x%x to reg %d\n", val, addr); in rs5c372_set_offset()
659 rs5c->regs[RS5C372_REG_TRIM] = val; in rs5c372_set_offset()