Lines Matching refs:ds1307
106 struct ds1307 { struct
320 struct ds1307 *ds1307 = i2c_get_clientdata(client); in ds1307_irq() local
321 struct mutex *lock = &ds1307->rtc->ops_lock; in ds1307_irq()
340 rtc_update_irq(ds1307->rtc, 1, RTC_AF | RTC_IRQF); in ds1307_irq()
353 struct ds1307 *ds1307 = dev_get_drvdata(dev); in ds1307_get_time() local
357 tmp = ds1307->read_block_data(ds1307->client, in ds1307_get_time()
358 ds1307->offset, 7, ds1307->regs); in ds1307_get_time()
364 dev_dbg(dev, "%s: %7ph\n", "read", ds1307->regs); in ds1307_get_time()
366 t->tm_sec = bcd2bin(ds1307->regs[DS1307_REG_SECS] & 0x7f); in ds1307_get_time()
367 t->tm_min = bcd2bin(ds1307->regs[DS1307_REG_MIN] & 0x7f); in ds1307_get_time()
368 tmp = ds1307->regs[DS1307_REG_HOUR] & 0x3f; in ds1307_get_time()
370 t->tm_wday = bcd2bin(ds1307->regs[DS1307_REG_WDAY] & 0x07) - 1; in ds1307_get_time()
371 t->tm_mday = bcd2bin(ds1307->regs[DS1307_REG_MDAY] & 0x3f); in ds1307_get_time()
372 tmp = ds1307->regs[DS1307_REG_MONTH] & 0x1f; in ds1307_get_time()
376 t->tm_year = bcd2bin(ds1307->regs[DS1307_REG_YEAR]) + 100; in ds1307_get_time()
390 struct ds1307 *ds1307 = dev_get_drvdata(dev); in ds1307_set_time() local
393 u8 *buf = ds1307->regs; in ds1307_set_time()
412 switch (ds1307->type) { in ds1307_set_time()
437 result = ds1307->write_block_data(ds1307->client, in ds1307_set_time()
438 ds1307->offset, 7, buf); in ds1307_set_time()
449 struct ds1307 *ds1307 = i2c_get_clientdata(client); in ds1337_read_alarm() local
452 if (!test_bit(HAS_ALARM, &ds1307->flags)) in ds1337_read_alarm()
456 ret = ds1307->read_block_data(client, in ds1337_read_alarm()
457 DS1339_REG_ALARM1_SECS, 9, ds1307->regs); in ds1337_read_alarm()
465 ds1307->regs[0], ds1307->regs[1], in ds1337_read_alarm()
466 ds1307->regs[2], ds1307->regs[3], in ds1337_read_alarm()
467 ds1307->regs[4], ds1307->regs[5], in ds1337_read_alarm()
468 ds1307->regs[6], ds1307->regs[7], in ds1337_read_alarm()
469 ds1307->regs[8]); in ds1337_read_alarm()
475 t->time.tm_sec = bcd2bin(ds1307->regs[0] & 0x7f); in ds1337_read_alarm()
476 t->time.tm_min = bcd2bin(ds1307->regs[1] & 0x7f); in ds1337_read_alarm()
477 t->time.tm_hour = bcd2bin(ds1307->regs[2] & 0x3f); in ds1337_read_alarm()
478 t->time.tm_mday = bcd2bin(ds1307->regs[3] & 0x3f); in ds1337_read_alarm()
486 t->enabled = !!(ds1307->regs[7] & DS1337_BIT_A1IE); in ds1337_read_alarm()
487 t->pending = !!(ds1307->regs[8] & DS1337_BIT_A1I); in ds1337_read_alarm()
501 struct ds1307 *ds1307 = i2c_get_clientdata(client); in ds1337_set_alarm() local
502 unsigned char *buf = ds1307->regs; in ds1337_set_alarm()
506 if (!test_bit(HAS_ALARM, &ds1307->flags)) in ds1337_set_alarm()
516 ret = ds1307->read_block_data(client, in ds1337_set_alarm()
522 control = ds1307->regs[7]; in ds1337_set_alarm()
523 status = ds1307->regs[8]; in ds1337_set_alarm()
527 ds1307->regs[0], ds1307->regs[1], in ds1337_set_alarm()
528 ds1307->regs[2], ds1307->regs[3], in ds1337_set_alarm()
529 ds1307->regs[4], ds1307->regs[5], in ds1337_set_alarm()
530 ds1307->regs[6], control, status); in ds1337_set_alarm()
551 ret = ds1307->write_block_data(client, in ds1337_set_alarm()
564 struct ds1307 *ds1307 = i2c_get_clientdata(client); in ds1307_alarm_irq_enable() local
567 if (!test_bit(HAS_ALARM, &ds1307->flags)) in ds1307_alarm_irq_enable()
619 struct ds1307 *ds1307 = i2c_get_clientdata(client); in mcp794xx_irq() local
620 struct mutex *lock = &ds1307->rtc->ops_lock; in mcp794xx_irq()
645 rtc_update_irq(ds1307->rtc, 1, RTC_AF | RTC_IRQF); in mcp794xx_irq()
656 struct ds1307 *ds1307 = i2c_get_clientdata(client); in mcp794xx_read_alarm() local
657 u8 *regs = ds1307->regs; in mcp794xx_read_alarm()
660 if (!test_bit(HAS_ALARM, &ds1307->flags)) in mcp794xx_read_alarm()
664 ret = ds1307->read_block_data(client, MCP794XX_REG_CONTROL, 10, regs); in mcp794xx_read_alarm()
671 t->time.tm_sec = bcd2bin(ds1307->regs[3] & 0x7f); in mcp794xx_read_alarm()
672 t->time.tm_min = bcd2bin(ds1307->regs[4] & 0x7f); in mcp794xx_read_alarm()
673 t->time.tm_hour = bcd2bin(ds1307->regs[5] & 0x3f); in mcp794xx_read_alarm()
674 t->time.tm_wday = bcd2bin(ds1307->regs[6] & 0x7) - 1; in mcp794xx_read_alarm()
675 t->time.tm_mday = bcd2bin(ds1307->regs[7] & 0x3f); in mcp794xx_read_alarm()
676 t->time.tm_mon = bcd2bin(ds1307->regs[8] & 0x1f) - 1; in mcp794xx_read_alarm()
685 !!(ds1307->regs[6] & MCP794XX_BIT_ALMX_POL), in mcp794xx_read_alarm()
686 !!(ds1307->regs[6] & MCP794XX_BIT_ALMX_IF), in mcp794xx_read_alarm()
687 (ds1307->regs[6] & MCP794XX_MSK_ALMX_MATCH) >> 4); in mcp794xx_read_alarm()
695 struct ds1307 *ds1307 = i2c_get_clientdata(client); in mcp794xx_set_alarm() local
696 unsigned char *regs = ds1307->regs; in mcp794xx_set_alarm()
699 if (!test_bit(HAS_ALARM, &ds1307->flags)) in mcp794xx_set_alarm()
709 ret = ds1307->read_block_data(client, MCP794XX_REG_CONTROL, 10, regs); in mcp794xx_set_alarm()
728 ret = ds1307->write_block_data(client, MCP794XX_REG_CONTROL, 10, regs); in mcp794xx_set_alarm()
741 struct ds1307 *ds1307 = i2c_get_clientdata(client); in mcp794xx_alarm_irq_enable() local
744 if (!test_bit(HAS_ALARM, &ds1307->flags)) in mcp794xx_alarm_irq_enable()
775 struct ds1307 *ds1307; in ds1307_nvram_read() local
779 ds1307 = i2c_get_clientdata(client); in ds1307_nvram_read()
781 result = ds1307->read_block_data(client, ds1307->nvram_offset + off, in ds1307_nvram_read()
794 struct ds1307 *ds1307; in ds1307_nvram_write() local
798 ds1307 = i2c_get_clientdata(client); in ds1307_nvram_write()
800 result = ds1307->write_block_data(client, ds1307->nvram_offset + off, in ds1307_nvram_write()
857 struct ds1307 *ds1307; in ds1307_probe() local
878 ds1307 = devm_kzalloc(&client->dev, sizeof(struct ds1307), GFP_KERNEL); in ds1307_probe()
879 if (!ds1307) in ds1307_probe()
882 i2c_set_clientdata(client, ds1307); in ds1307_probe()
884 ds1307->client = client; in ds1307_probe()
885 ds1307->type = id->driver_data; in ds1307_probe()
901 buf = ds1307->regs; in ds1307_probe()
903 ds1307->read_block_data = ds1307_native_smbus_read_block_data; in ds1307_probe()
904 ds1307->write_block_data = ds1307_native_smbus_write_block_data; in ds1307_probe()
906 ds1307->read_block_data = ds1307_read_block_data; in ds1307_probe()
907 ds1307->write_block_data = ds1307_write_block_data; in ds1307_probe()
910 switch (ds1307->type) { in ds1307_probe()
915 tmp = ds1307->read_block_data(ds1307->client, in ds1307_probe()
924 if (ds1307->regs[0] & DS1337_BIT_nEOSC) in ds1307_probe()
925 ds1307->regs[0] &= ~DS1337_BIT_nEOSC; in ds1307_probe()
932 if (ds1307->client->irq > 0 && chip->alarm) { in ds1307_probe()
933 ds1307->regs[0] |= DS1337_BIT_INTCN in ds1307_probe()
934 | bbsqi_bitpos[ds1307->type]; in ds1307_probe()
935 ds1307->regs[0] &= ~(DS1337_BIT_A2IE | DS1337_BIT_A1IE); in ds1307_probe()
941 ds1307->regs[0]); in ds1307_probe()
944 if (ds1307->regs[1] & DS1337_BIT_OSF) { in ds1307_probe()
946 ds1307->regs[1] & ~DS1337_BIT_OSF); in ds1307_probe()
952 tmp = i2c_smbus_read_i2c_block_data(ds1307->client, in ds1307_probe()
961 if (!(ds1307->regs[1] & RX8025_BIT_XST)) { in ds1307_probe()
962 ds1307->regs[1] |= RX8025_BIT_XST; in ds1307_probe()
965 ds1307->regs[1]); in ds1307_probe()
970 if (ds1307->regs[1] & RX8025_BIT_PON) { in ds1307_probe()
971 ds1307->regs[1] &= ~RX8025_BIT_PON; in ds1307_probe()
974 ds1307->regs[1]); in ds1307_probe()
978 if (ds1307->regs[1] & RX8025_BIT_VDET) { in ds1307_probe()
979 ds1307->regs[1] &= ~RX8025_BIT_VDET; in ds1307_probe()
982 ds1307->regs[1]); in ds1307_probe()
987 if (!(ds1307->regs[0] & RX8025_BIT_2412)) { in ds1307_probe()
993 ds1307->regs[0] | in ds1307_probe()
996 tmp = i2c_smbus_read_i2c_block_data(ds1307->client, in ds1307_probe()
1005 hour = bcd2bin(ds1307->regs[DS1307_REG_HOUR]); in ds1307_probe()
1008 if (ds1307->regs[DS1307_REG_HOUR] & DS1307_BIT_PM) in ds1307_probe()
1017 ds1307->offset = 1; /* Seconds starts at 1 */ in ds1307_probe()
1021 if (ds1307->client->irq > 0 && chip->alarm) { in ds1307_probe()
1032 tmp = ds1307->read_block_data(ds1307->client, ds1307->offset, 8, buf); in ds1307_probe()
1044 tmp = ds1307->regs[DS1307_REG_SECS]; in ds1307_probe()
1045 switch (ds1307->type) { in ds1307_probe()
1061 if (ds1307->regs[DS1307_REG_CONTROL] & DS1338_BIT_OSF) { in ds1307_probe()
1063 ds1307->regs[DS1307_REG_CONTROL] in ds1307_probe()
1089 if (!(ds1307->regs[DS1307_REG_WDAY] & MCP794XX_BIT_VBATEN)) { in ds1307_probe()
1091 ds1307->regs[DS1307_REG_WDAY] in ds1307_probe()
1108 tmp = ds1307->regs[DS1307_REG_HOUR]; in ds1307_probe()
1109 switch (ds1307->type) { in ds1307_probe()
1130 if (ds1307->regs[DS1307_REG_HOUR] & DS1307_BIT_PM) in ds1307_probe()
1133 ds1307->offset + DS1307_REG_HOUR, in ds1307_probe()
1139 set_bit(HAS_ALARM, &ds1307->flags); in ds1307_probe()
1141 ds1307->rtc = devm_rtc_device_register(&client->dev, client->name, in ds1307_probe()
1143 if (IS_ERR(ds1307->rtc)) { in ds1307_probe()
1144 return PTR_ERR(ds1307->rtc); in ds1307_probe()
1151 ds1307->rtc->name, client); in ds1307_probe()
1155 clear_bit(HAS_ALARM, &ds1307->flags); in ds1307_probe()
1163 ds1307->nvram = devm_kzalloc(&client->dev, in ds1307_probe()
1166 if (!ds1307->nvram) { in ds1307_probe()
1170 ds1307->nvram->attr.name = "nvram"; in ds1307_probe()
1171 ds1307->nvram->attr.mode = S_IRUGO | S_IWUSR; in ds1307_probe()
1173 sysfs_bin_attr_init(ds1307->nvram); in ds1307_probe()
1175 ds1307->nvram->read = ds1307_nvram_read; in ds1307_probe()
1176 ds1307->nvram->write = ds1307_nvram_write; in ds1307_probe()
1177 ds1307->nvram->size = chip->nvram_size; in ds1307_probe()
1178 ds1307->nvram_offset = chip->nvram_offset; in ds1307_probe()
1181 ds1307->nvram); in ds1307_probe()
1185 ds1307->nvram->attr.name); in ds1307_probe()
1187 set_bit(HAS_NVRAM, &ds1307->flags); in ds1307_probe()
1189 ds1307->nvram->size); in ds1307_probe()
1202 struct ds1307 *ds1307 = i2c_get_clientdata(client); in ds1307_remove() local
1204 if (test_and_clear_bit(HAS_NVRAM, &ds1307->flags)) in ds1307_remove()
1205 sysfs_remove_bin_file(&client->dev.kobj, ds1307->nvram); in ds1307_remove()