• Home
  • Raw
  • Download

Lines Matching +full:trickle +full:- +full:diode +full:- +full:disable

2  * rtc-ds1307.c - RTC driver for some mostly-compatible I2C chips.
25 #include <linux/hwmon-sysfs.h>
26 #include <linux/clk-provider.h>
30 * We can't determine type by probing, but if we expect pre-Linux code
32 * setting the date and time), Linux can ignore the non-clock features.
56 #define DS1307_REG_SECS 0x00 /* 00-59 */
60 #define DS1307_REG_MIN 0x01 /* 00-59 */
62 #define DS1307_REG_HOUR 0x02 /* 00-23, or 1-12{am,pm} */
67 #define DS1307_REG_WDAY 0x03 /* 01-07 */
69 #define DS1307_REG_MDAY 0x04 /* 01-31 */
70 #define DS1307_REG_MONTH 0x05 /* 01-12 */
72 #define DS1307_REG_YEAR 0x06 /* 00-99 */
75 * Other registers (control, status, alarms, trickle charge, NVRAM, etc)
149 static u8 do_trickle_setup_ds1339(struct ds1307 *, u32 ohms, bool diode);
381 struct mutex *lock = &ds1307->rtc->ops_lock; in ds1307_irq()
385 ret = regmap_read(ds1307->regmap, DS1337_REG_STATUS, &stat); in ds1307_irq()
391 regmap_write(ds1307->regmap, DS1337_REG_STATUS, stat); in ds1307_irq()
393 ret = regmap_update_bits(ds1307->regmap, DS1337_REG_CONTROL, in ds1307_irq()
398 rtc_update_irq(ds1307->rtc, 1, RTC_AF | RTC_IRQF); in ds1307_irq()
407 /*----------------------------------------------------------------------*/
413 const struct chip_desc *chip = &chips[ds1307->type]; in ds1307_get_time()
417 ret = regmap_bulk_read(ds1307->regmap, chip->offset, regs, in ds1307_get_time()
427 if (ds1307->type == m41t0 && in ds1307_get_time()
430 return -EINVAL; in ds1307_get_time()
433 t->tm_sec = bcd2bin(regs[DS1307_REG_SECS] & 0x7f); in ds1307_get_time()
434 t->tm_min = bcd2bin(regs[DS1307_REG_MIN] & 0x7f); in ds1307_get_time()
436 t->tm_hour = bcd2bin(tmp); in ds1307_get_time()
437 t->tm_wday = bcd2bin(regs[DS1307_REG_WDAY] & 0x07) - 1; in ds1307_get_time()
438 t->tm_mday = bcd2bin(regs[DS1307_REG_MDAY] & 0x3f); in ds1307_get_time()
440 t->tm_mon = bcd2bin(tmp) - 1; in ds1307_get_time()
441 t->tm_year = bcd2bin(regs[DS1307_REG_YEAR]) + 100; in ds1307_get_time()
443 if (regs[chip->century_reg] & chip->century_bit && in ds1307_get_time()
445 t->tm_year += 100; in ds1307_get_time()
449 "read", t->tm_sec, t->tm_min, in ds1307_get_time()
450 t->tm_hour, t->tm_mday, in ds1307_get_time()
451 t->tm_mon, t->tm_year, t->tm_wday); in ds1307_get_time()
459 const struct chip_desc *chip = &chips[ds1307->type]; in ds1307_set_time()
466 "write", t->tm_sec, t->tm_min, in ds1307_set_time()
467 t->tm_hour, t->tm_mday, in ds1307_set_time()
468 t->tm_mon, t->tm_year, t->tm_wday); in ds1307_set_time()
470 if (t->tm_year < 100) in ds1307_set_time()
471 return -EINVAL; in ds1307_set_time()
474 if (t->tm_year > (chip->century_bit ? 299 : 199)) in ds1307_set_time()
475 return -EINVAL; in ds1307_set_time()
477 if (t->tm_year > 199) in ds1307_set_time()
478 return -EINVAL; in ds1307_set_time()
481 regs[DS1307_REG_SECS] = bin2bcd(t->tm_sec); in ds1307_set_time()
482 regs[DS1307_REG_MIN] = bin2bcd(t->tm_min); in ds1307_set_time()
483 regs[DS1307_REG_HOUR] = bin2bcd(t->tm_hour); in ds1307_set_time()
484 regs[DS1307_REG_WDAY] = bin2bcd(t->tm_wday + 1); in ds1307_set_time()
485 regs[DS1307_REG_MDAY] = bin2bcd(t->tm_mday); in ds1307_set_time()
486 regs[DS1307_REG_MONTH] = bin2bcd(t->tm_mon + 1); in ds1307_set_time()
489 tmp = t->tm_year - 100; in ds1307_set_time()
492 if (chip->century_enable_bit) in ds1307_set_time()
493 regs[chip->century_reg] |= chip->century_enable_bit; in ds1307_set_time()
494 if (t->tm_year > 199 && chip->century_bit) in ds1307_set_time()
495 regs[chip->century_reg] |= chip->century_bit; in ds1307_set_time()
497 if (ds1307->type == mcp794xx) { in ds1307_set_time()
509 result = regmap_bulk_write(ds1307->regmap, chip->offset, regs, in ds1307_set_time()
524 if (!test_bit(HAS_ALARM, &ds1307->flags)) in ds1337_read_alarm()
525 return -EINVAL; in ds1337_read_alarm()
528 ret = regmap_bulk_read(ds1307->regmap, DS1339_REG_ALARM1_SECS, in ds1337_read_alarm()
539 * report alarm time (ALARM1); assume 24 hour and day-of-month modes, in ds1337_read_alarm()
542 t->time.tm_sec = bcd2bin(regs[0] & 0x7f); in ds1337_read_alarm()
543 t->time.tm_min = bcd2bin(regs[1] & 0x7f); in ds1337_read_alarm()
544 t->time.tm_hour = bcd2bin(regs[2] & 0x3f); in ds1337_read_alarm()
545 t->time.tm_mday = bcd2bin(regs[3] & 0x3f); in ds1337_read_alarm()
548 t->enabled = !!(regs[7] & DS1337_BIT_A1IE); in ds1337_read_alarm()
549 t->pending = !!(regs[8] & DS1337_BIT_A1I); in ds1337_read_alarm()
553 "alarm read", t->time.tm_sec, t->time.tm_min, in ds1337_read_alarm()
554 t->time.tm_hour, t->time.tm_mday, in ds1337_read_alarm()
555 t->enabled, t->pending); in ds1337_read_alarm()
567 if (!test_bit(HAS_ALARM, &ds1307->flags)) in ds1337_set_alarm()
568 return -EINVAL; in ds1337_set_alarm()
572 "alarm set", t->time.tm_sec, t->time.tm_min, in ds1337_set_alarm()
573 t->time.tm_hour, t->time.tm_mday, in ds1337_set_alarm()
574 t->enabled, t->pending); in ds1337_set_alarm()
577 ret = regmap_bulk_read(ds1307->regmap, DS1339_REG_ALARM1_SECS, regs, in ds1337_set_alarm()
589 /* set ALARM1, using 24 hour and day-of-month modes */ in ds1337_set_alarm()
590 regs[0] = bin2bcd(t->time.tm_sec); in ds1337_set_alarm()
591 regs[1] = bin2bcd(t->time.tm_min); in ds1337_set_alarm()
592 regs[2] = bin2bcd(t->time.tm_hour); in ds1337_set_alarm()
593 regs[3] = bin2bcd(t->time.tm_mday); in ds1337_set_alarm()
595 /* set ALARM2 to non-garbage */ in ds1337_set_alarm()
600 /* disable alarms */ in ds1337_set_alarm()
604 ret = regmap_bulk_write(ds1307->regmap, DS1339_REG_ALARM1_SECS, regs, in ds1337_set_alarm()
612 if (t->enabled) { in ds1337_set_alarm()
615 regmap_write(ds1307->regmap, DS1337_REG_CONTROL, regs[7]); in ds1337_set_alarm()
625 if (!test_bit(HAS_ALARM, &ds1307->flags)) in ds1307_alarm_irq_enable()
626 return -ENOTTY; in ds1307_alarm_irq_enable()
628 return regmap_update_bits(ds1307->regmap, DS1337_REG_CONTROL, in ds1307_alarm_irq_enable()
641 /*----------------------------------------------------------------------*/
660 struct mutex *lock = &ds1307->rtc->ops_lock; in rx8130_irq()
667 ret = regmap_bulk_read(ds1307->regmap, RX8130_REG_EXTENSION, ctl, in rx8130_irq()
676 ret = regmap_bulk_write(ds1307->regmap, RX8130_REG_EXTENSION, ctl, in rx8130_irq()
681 rtc_update_irq(ds1307->rtc, 1, RTC_AF | RTC_IRQF); in rx8130_irq()
695 if (!test_bit(HAS_ALARM, &ds1307->flags)) in rx8130_read_alarm()
696 return -EINVAL; in rx8130_read_alarm()
699 ret = regmap_bulk_read(ds1307->regmap, RX8130_REG_ALARM_MIN, ald, in rx8130_read_alarm()
705 ret = regmap_bulk_read(ds1307->regmap, RX8130_REG_EXTENSION, ctl, in rx8130_read_alarm()
710 t->enabled = !!(ctl[2] & RX8130_REG_CONTROL0_AIE); in rx8130_read_alarm()
711 t->pending = !!(ctl[1] & RX8130_REG_FLAG_AF); in rx8130_read_alarm()
713 /* Report alarm 0 time assuming 24-hour and day-of-month modes. */ in rx8130_read_alarm()
714 t->time.tm_sec = -1; in rx8130_read_alarm()
715 t->time.tm_min = bcd2bin(ald[0] & 0x7f); in rx8130_read_alarm()
716 t->time.tm_hour = bcd2bin(ald[1] & 0x7f); in rx8130_read_alarm()
717 t->time.tm_wday = -1; in rx8130_read_alarm()
718 t->time.tm_mday = bcd2bin(ald[2] & 0x7f); in rx8130_read_alarm()
719 t->time.tm_mon = -1; in rx8130_read_alarm()
720 t->time.tm_year = -1; in rx8130_read_alarm()
721 t->time.tm_yday = -1; in rx8130_read_alarm()
722 t->time.tm_isdst = -1; in rx8130_read_alarm()
725 __func__, t->time.tm_sec, t->time.tm_min, t->time.tm_hour, in rx8130_read_alarm()
726 t->time.tm_wday, t->time.tm_mday, t->time.tm_mon, t->enabled); in rx8130_read_alarm()
737 if (!test_bit(HAS_ALARM, &ds1307->flags)) in rx8130_set_alarm()
738 return -EINVAL; in rx8130_set_alarm()
742 t->time.tm_sec, t->time.tm_min, t->time.tm_hour, in rx8130_set_alarm()
743 t->time.tm_wday, t->time.tm_mday, t->time.tm_mon, in rx8130_set_alarm()
744 t->enabled, t->pending); in rx8130_set_alarm()
747 ret = regmap_bulk_read(ds1307->regmap, RX8130_REG_EXTENSION, ctl, in rx8130_set_alarm()
756 ret = regmap_bulk_write(ds1307->regmap, RX8130_REG_EXTENSION, ctl, in rx8130_set_alarm()
762 ald[0] = bin2bcd(t->time.tm_min); in rx8130_set_alarm()
763 ald[1] = bin2bcd(t->time.tm_hour); in rx8130_set_alarm()
764 ald[2] = bin2bcd(t->time.tm_mday); in rx8130_set_alarm()
766 ret = regmap_bulk_write(ds1307->regmap, RX8130_REG_ALARM_MIN, ald, in rx8130_set_alarm()
771 if (!t->enabled) in rx8130_set_alarm()
776 return regmap_write(ds1307->regmap, RX8130_REG_CONTROL0, ctl[2]); in rx8130_set_alarm()
784 if (!test_bit(HAS_ALARM, &ds1307->flags)) in rx8130_alarm_irq_enable()
785 return -EINVAL; in rx8130_alarm_irq_enable()
787 ret = regmap_read(ds1307->regmap, RX8130_REG_CONTROL0, &reg); in rx8130_alarm_irq_enable()
796 return regmap_write(ds1307->regmap, RX8130_REG_CONTROL0, reg); in rx8130_alarm_irq_enable()
799 /*----------------------------------------------------------------------*/
824 struct mutex *lock = &ds1307->rtc->ops_lock; in mcp794xx_irq()
830 ret = regmap_read(ds1307->regmap, MCP794XX_REG_ALARM0_CTRL, &reg); in mcp794xx_irq()
836 ret = regmap_write(ds1307->regmap, MCP794XX_REG_ALARM0_CTRL, reg); in mcp794xx_irq()
840 /* Disable alarm 0. */ in mcp794xx_irq()
841 ret = regmap_update_bits(ds1307->regmap, MCP794XX_REG_CONTROL, in mcp794xx_irq()
846 rtc_update_irq(ds1307->rtc, 1, RTC_AF | RTC_IRQF); in mcp794xx_irq()
860 if (!test_bit(HAS_ALARM, &ds1307->flags)) in mcp794xx_read_alarm()
861 return -EINVAL; in mcp794xx_read_alarm()
864 ret = regmap_bulk_read(ds1307->regmap, MCP794XX_REG_CONTROL, regs, in mcp794xx_read_alarm()
869 t->enabled = !!(regs[0] & MCP794XX_BIT_ALM0_EN); in mcp794xx_read_alarm()
871 /* Report alarm 0 time assuming 24-hour and day-of-month modes. */ in mcp794xx_read_alarm()
872 t->time.tm_sec = bcd2bin(regs[3] & 0x7f); in mcp794xx_read_alarm()
873 t->time.tm_min = bcd2bin(regs[4] & 0x7f); in mcp794xx_read_alarm()
874 t->time.tm_hour = bcd2bin(regs[5] & 0x3f); in mcp794xx_read_alarm()
875 t->time.tm_wday = bcd2bin(regs[6] & 0x7) - 1; in mcp794xx_read_alarm()
876 t->time.tm_mday = bcd2bin(regs[7] & 0x3f); in mcp794xx_read_alarm()
877 t->time.tm_mon = bcd2bin(regs[8] & 0x1f) - 1; in mcp794xx_read_alarm()
878 t->time.tm_year = -1; in mcp794xx_read_alarm()
879 t->time.tm_yday = -1; in mcp794xx_read_alarm()
880 t->time.tm_isdst = -1; in mcp794xx_read_alarm()
884 t->time.tm_sec, t->time.tm_min, t->time.tm_hour, in mcp794xx_read_alarm()
885 t->time.tm_wday, t->time.tm_mday, t->time.tm_mon, t->enabled, in mcp794xx_read_alarm()
909 return (tm_now.tm_wday + days_alarm - days_now) % 7 + 1; in mcp794xx_alm_weekday()
918 if (!test_bit(HAS_ALARM, &ds1307->flags)) in mcp794xx_set_alarm()
919 return -EINVAL; in mcp794xx_set_alarm()
921 wday = mcp794xx_alm_weekday(dev, &t->time); in mcp794xx_set_alarm()
927 t->time.tm_sec, t->time.tm_min, t->time.tm_hour, in mcp794xx_set_alarm()
928 t->time.tm_wday, t->time.tm_mday, t->time.tm_mon, in mcp794xx_set_alarm()
929 t->enabled, t->pending); in mcp794xx_set_alarm()
932 ret = regmap_bulk_read(ds1307->regmap, MCP794XX_REG_CONTROL, regs, in mcp794xx_set_alarm()
937 /* Set alarm 0, using 24-hour and day-of-month modes. */ in mcp794xx_set_alarm()
938 regs[3] = bin2bcd(t->time.tm_sec); in mcp794xx_set_alarm()
939 regs[4] = bin2bcd(t->time.tm_min); in mcp794xx_set_alarm()
940 regs[5] = bin2bcd(t->time.tm_hour); in mcp794xx_set_alarm()
942 regs[7] = bin2bcd(t->time.tm_mday); in mcp794xx_set_alarm()
943 regs[8] = bin2bcd(t->time.tm_mon + 1); in mcp794xx_set_alarm()
949 /* Disable interrupt. We will not enable until completely programmed */ in mcp794xx_set_alarm()
952 ret = regmap_bulk_write(ds1307->regmap, MCP794XX_REG_CONTROL, regs, in mcp794xx_set_alarm()
957 if (!t->enabled) in mcp794xx_set_alarm()
960 return regmap_write(ds1307->regmap, MCP794XX_REG_CONTROL, regs[0]); in mcp794xx_set_alarm()
967 if (!test_bit(HAS_ALARM, &ds1307->flags)) in mcp794xx_alarm_irq_enable()
968 return -EINVAL; in mcp794xx_alarm_irq_enable()
970 return regmap_update_bits(ds1307->regmap, MCP794XX_REG_CONTROL, in mcp794xx_alarm_irq_enable()
975 /*----------------------------------------------------------------------*/
981 const struct chip_desc *chip = &chips[ds1307->type]; in ds1307_nvram_read()
983 return regmap_bulk_read(ds1307->regmap, chip->nvram_offset + offset, in ds1307_nvram_read()
991 const struct chip_desc *chip = &chips[ds1307->type]; in ds1307_nvram_write()
993 return regmap_bulk_write(ds1307->regmap, chip->nvram_offset + offset, in ds1307_nvram_write()
997 /*----------------------------------------------------------------------*/
1000 u32 ohms, bool diode) in do_trickle_setup_ds1339() argument
1002 u8 setup = (diode) ? DS1307_TRICKLE_CHARGER_DIODE : in do_trickle_setup_ds1339()
1016 dev_warn(ds1307->dev, in do_trickle_setup_ds1339()
1027 bool diode = true; in ds1307_trickle_init() local
1029 if (!chip->do_trickle_setup) in ds1307_trickle_init()
1032 if (device_property_read_u32(ds1307->dev, "trickle-resistor-ohms", in ds1307_trickle_init()
1036 if (device_property_read_bool(ds1307->dev, "trickle-diode-disable")) in ds1307_trickle_init()
1037 diode = false; in ds1307_trickle_init()
1039 return chip->do_trickle_setup(ds1307, ohms, diode); in ds1307_trickle_init()
1042 /*----------------------------------------------------------------------*/
1053 * A user-initiated temperature conversion is not started by this function,
1063 ret = regmap_bulk_read(ds1307->regmap, DS3231_REG_TEMPERATURE, in ds3231_hwmon_read_temp()
1068 * Temperature is represented as a 10-bit code with a resolution of in ds3231_hwmon_read_temp()
1103 if (ds1307->type != ds_3231) in ds1307_hwmon_register()
1106 dev = devm_hwmon_device_register_with_groups(ds1307->dev, ds1307->name, in ds1307_hwmon_register()
1110 dev_warn(ds1307->dev, "unable to register hwmon device %ld\n", in ds1307_hwmon_register()
1123 /*----------------------------------------------------------------------*/
1126 * Square-wave output support for DS3231
1150 struct mutex *lock = &ds1307->rtc->ops_lock; in ds1337_write_control()
1154 ret = regmap_update_bits(ds1307->regmap, DS1337_REG_CONTROL, in ds1337_write_control()
1168 ret = regmap_read(ds1307->regmap, DS1337_REG_CONTROL, &control); in ds3231_clk_sqw_recalc_rate()
1184 for (i = ARRAY_SIZE(ds3231_clk_sqw_rates) - 1; i >= 0; i--) { in ds3231_clk_sqw_round_rate()
1206 return -EINVAL; in ds3231_clk_sqw_set_rate()
1236 ret = regmap_read(ds1307->regmap, DS1337_REG_CONTROL, &control); in ds3231_clk_sqw_is_prepared()
1260 struct mutex *lock = &ds1307->rtc->ops_lock; in ds3231_clk_32khz_control()
1264 ret = regmap_update_bits(ds1307->regmap, DS1337_REG_STATUS, in ds3231_clk_32khz_control()
1291 ret = regmap_read(ds1307->regmap, DS1337_REG_STATUS, &status); in ds3231_clk_32khz_is_prepared()
1318 struct device_node *node = ds1307->dev->of_node; in ds3231_clks_register()
1322 onecell = devm_kzalloc(ds1307->dev, sizeof(*onecell), GFP_KERNEL); in ds3231_clks_register()
1324 return -ENOMEM; in ds3231_clks_register()
1326 onecell->clk_num = ARRAY_SIZE(ds3231_clks_init); in ds3231_clks_register()
1327 onecell->clks = devm_kcalloc(ds1307->dev, onecell->clk_num, in ds3231_clks_register()
1328 sizeof(onecell->clks[0]), GFP_KERNEL); in ds3231_clks_register()
1329 if (!onecell->clks) in ds3231_clks_register()
1330 return -ENOMEM; in ds3231_clks_register()
1336 * Interrupt signal due to alarm conditions and square-wave in ds3231_clks_register()
1339 if (i == DS3231_CLK_SQW && test_bit(HAS_ALARM, &ds1307->flags)) in ds3231_clks_register()
1343 of_property_read_string_index(node, "clock-output-names", i, in ds3231_clks_register()
1345 ds1307->clks[i].init = &init; in ds3231_clks_register()
1347 onecell->clks[i] = devm_clk_register(ds1307->dev, in ds3231_clks_register()
1348 &ds1307->clks[i]); in ds3231_clks_register()
1349 if (IS_ERR(onecell->clks[i])) in ds3231_clks_register()
1350 return PTR_ERR(onecell->clks[i]); in ds3231_clks_register()
1365 if (ds1307->type != ds_3231) in ds1307_clks_register()
1370 dev_warn(ds1307->dev, "unable to register clock device %d\n", in ds1307_clks_register()
1392 int err = -ENODEV; in ds1307_probe()
1398 struct ds1307_platform_data *pdata = dev_get_platdata(&client->dev); in ds1307_probe()
1401 ds1307 = devm_kzalloc(&client->dev, sizeof(struct ds1307), GFP_KERNEL); in ds1307_probe()
1403 return -ENOMEM; in ds1307_probe()
1405 dev_set_drvdata(&client->dev, ds1307); in ds1307_probe()
1406 ds1307->dev = &client->dev; in ds1307_probe()
1407 ds1307->name = client->name; in ds1307_probe()
1409 ds1307->regmap = devm_regmap_init_i2c(client, &regmap_config); in ds1307_probe()
1410 if (IS_ERR(ds1307->regmap)) { in ds1307_probe()
1411 dev_err(ds1307->dev, "regmap allocation failed\n"); in ds1307_probe()
1412 return PTR_ERR(ds1307->regmap); in ds1307_probe()
1417 if (client->dev.of_node) { in ds1307_probe()
1418 ds1307->type = (enum ds_type) in ds1307_probe()
1419 of_device_get_match_data(&client->dev); in ds1307_probe()
1420 chip = &chips[ds1307->type]; in ds1307_probe()
1422 chip = &chips[id->driver_data]; in ds1307_probe()
1423 ds1307->type = id->driver_data; in ds1307_probe()
1428 ds1307->dev); in ds1307_probe()
1430 return -ENODEV; in ds1307_probe()
1431 chip = &chips[acpi_id->driver_data]; in ds1307_probe()
1432 ds1307->type = acpi_id->driver_data; in ds1307_probe()
1435 want_irq = client->irq > 0 && chip->alarm; in ds1307_probe()
1439 else if (pdata->trickle_charger_setup) in ds1307_probe()
1440 trickle_charger_setup = pdata->trickle_charger_setup; in ds1307_probe()
1442 if (trickle_charger_setup && chip->trickle_charger_reg) { in ds1307_probe()
1444 dev_dbg(ds1307->dev, in ds1307_probe()
1445 "writing trickle charger info 0x%x to 0x%x\n", in ds1307_probe()
1446 trickle_charger_setup, chip->trickle_charger_reg); in ds1307_probe()
1447 regmap_write(ds1307->regmap, chip->trickle_charger_reg, in ds1307_probe()
1455 * the device's .dts file using the "wakeup-source" boolean property. in ds1307_probe()
1456 * If the "wakeup-source" property is set, don't request an IRQ. in ds1307_probe()
1460 if (chip->alarm && of_property_read_bool(client->dev.of_node, in ds1307_probe()
1461 "wakeup-source")) in ds1307_probe()
1465 switch (ds1307->type) { in ds1307_probe()
1471 err = regmap_bulk_read(ds1307->regmap, DS1337_REG_CONTROL, in ds1307_probe()
1474 dev_dbg(ds1307->dev, "read error %d\n", err); in ds1307_probe()
1483 * Using IRQ or defined as wakeup-source? in ds1307_probe()
1484 * Disable the square wave and both alarms. in ds1307_probe()
1489 regs[0] |= DS1337_BIT_INTCN | chip->bbsqi_bit; in ds1307_probe()
1493 regmap_write(ds1307->regmap, DS1337_REG_CONTROL, in ds1307_probe()
1498 regmap_write(ds1307->regmap, DS1337_REG_STATUS, in ds1307_probe()
1500 dev_warn(ds1307->dev, "SET TIME!\n"); in ds1307_probe()
1505 err = regmap_bulk_read(ds1307->regmap, in ds1307_probe()
1508 dev_dbg(ds1307->dev, "read error %d\n", err); in ds1307_probe()
1515 regmap_write(ds1307->regmap, in ds1307_probe()
1518 dev_warn(ds1307->dev, in ds1307_probe()
1519 "oscillator stop detected - SET TIME!\n"); in ds1307_probe()
1524 regmap_write(ds1307->regmap, in ds1307_probe()
1527 dev_warn(ds1307->dev, "power-on detected\n"); in ds1307_probe()
1532 regmap_write(ds1307->regmap, in ds1307_probe()
1535 dev_warn(ds1307->dev, "voltage drop detected\n"); in ds1307_probe()
1543 regmap_write(ds1307->regmap, in ds1307_probe()
1547 err = regmap_bulk_read(ds1307->regmap, in ds1307_probe()
1551 dev_dbg(ds1307->dev, "read error %d\n", err); in ds1307_probe()
1562 regmap_write(ds1307->regmap, in ds1307_probe()
1572 err = regmap_bulk_read(ds1307->regmap, chip->offset, regs, in ds1307_probe()
1575 dev_dbg(ds1307->dev, "read error %d\n", err); in ds1307_probe()
1581 * specify the extra bits as must-be-zero, but there are in ds1307_probe()
1582 * still a few values that are clearly out-of-range. in ds1307_probe()
1585 switch (ds1307->type) { in ds1307_probe()
1592 regmap_write(ds1307->regmap, DS1307_REG_SECS, 0); in ds1307_probe()
1593 dev_warn(ds1307->dev, "SET TIME!\n"); in ds1307_probe()
1601 regmap_write(ds1307->regmap, DS1307_REG_SECS, 0); in ds1307_probe()
1605 regmap_write(ds1307->regmap, DS1307_REG_CONTROL, in ds1307_probe()
1608 dev_warn(ds1307->dev, "SET TIME!\n"); in ds1307_probe()
1615 regmap_write(ds1307->regmap, DS1307_REG_SECS, 0); in ds1307_probe()
1617 err = regmap_read(ds1307->regmap, DS1340_REG_FLAG, &tmp); in ds1307_probe()
1619 dev_dbg(ds1307->dev, "read error %d\n", err); in ds1307_probe()
1625 regmap_write(ds1307->regmap, DS1340_REG_FLAG, 0); in ds1307_probe()
1626 dev_warn(ds1307->dev, "SET TIME!\n"); in ds1307_probe()
1632 regmap_write(ds1307->regmap, DS1307_REG_WDAY, in ds1307_probe()
1639 regmap_write(ds1307->regmap, DS1307_REG_SECS, in ds1307_probe()
1641 dev_warn(ds1307->dev, "SET TIME!\n"); in ds1307_probe()
1651 switch (ds1307->type) { in ds1307_probe()
1668 * Be sure we're in 24 hour mode. Multi-master systems in ds1307_probe()
1676 regmap_write(ds1307->regmap, chip->offset + DS1307_REG_HOUR, in ds1307_probe()
1681 device_set_wakeup_capable(ds1307->dev, true); in ds1307_probe()
1682 set_bit(HAS_ALARM, &ds1307->flags); in ds1307_probe()
1685 ds1307->rtc = devm_rtc_allocate_device(ds1307->dev); in ds1307_probe()
1686 if (IS_ERR(ds1307->rtc)) in ds1307_probe()
1687 return PTR_ERR(ds1307->rtc); in ds1307_probe()
1690 dev_info(ds1307->dev, in ds1307_probe()
1691 "'wakeup-source' is set, request for an IRQ is disabled!\n"); in ds1307_probe()
1693 ds1307->rtc->uie_unsupported = 1; in ds1307_probe()
1697 err = devm_request_threaded_irq(ds1307->dev, client->irq, NULL, in ds1307_probe()
1698 chip->irq_handler ?: ds1307_irq, in ds1307_probe()
1700 ds1307->name, ds1307); in ds1307_probe()
1702 client->irq = 0; in ds1307_probe()
1703 device_set_wakeup_capable(ds1307->dev, false); in ds1307_probe()
1704 clear_bit(HAS_ALARM, &ds1307->flags); in ds1307_probe()
1705 dev_err(ds1307->dev, "unable to request IRQ!\n"); in ds1307_probe()
1707 dev_dbg(ds1307->dev, "got IRQ %d\n", client->irq); in ds1307_probe()
1711 ds1307->rtc->ops = chip->rtc_ops ?: &ds13xx_rtc_ops; in ds1307_probe()
1712 err = rtc_register_device(ds1307->rtc); in ds1307_probe()
1716 if (chip->nvram_size) { in ds1307_probe()
1721 .size = chip->nvram_size, in ds1307_probe()
1727 ds1307->rtc->nvram_old_abi = true; in ds1307_probe()
1728 rtc_nvmem_register(ds1307->rtc, &nvmem_cfg); in ds1307_probe()
1742 .name = "rtc-ds1307",