Lines Matching refs:rv3029
123 static int rv3029_eeprom_busywait(struct rv3029_data *rv3029) in rv3029_eeprom_busywait() argument
129 ret = regmap_read(rv3029->regmap, RV3029_STATUS, &sr); in rv3029_eeprom_busywait()
137 dev_err(rv3029->dev, "EEPROM busy wait timeout.\n"); in rv3029_eeprom_busywait()
144 static int rv3029_eeprom_exit(struct rv3029_data *rv3029) in rv3029_eeprom_exit() argument
147 return regmap_update_bits(rv3029->regmap, RV3029_ONOFF_CTRL, in rv3029_eeprom_exit()
152 static int rv3029_eeprom_enter(struct rv3029_data *rv3029) in rv3029_eeprom_enter() argument
158 ret = regmap_read(rv3029->regmap, RV3029_STATUS, &sr); in rv3029_eeprom_enter()
167 ret = regmap_update_bits(rv3029->regmap, RV3029_STATUS, in rv3029_eeprom_enter()
172 ret = regmap_read(rv3029->regmap, RV3029_STATUS, &sr); in rv3029_eeprom_enter()
176 dev_err(rv3029->dev, in rv3029_eeprom_enter()
183 ret = regmap_update_bits(rv3029->regmap, RV3029_ONOFF_CTRL, in rv3029_eeprom_enter()
189 ret = rv3029_eeprom_busywait(rv3029); in rv3029_eeprom_enter()
191 rv3029_eeprom_exit(rv3029); in rv3029_eeprom_enter()
196 static int rv3029_eeprom_read(struct rv3029_data *rv3029, u8 reg, in rv3029_eeprom_read() argument
201 err = rv3029_eeprom_enter(rv3029); in rv3029_eeprom_read()
205 ret = regmap_bulk_read(rv3029->regmap, reg, buf, len); in rv3029_eeprom_read()
207 err = rv3029_eeprom_exit(rv3029); in rv3029_eeprom_read()
214 static int rv3029_eeprom_write(struct rv3029_data *rv3029, u8 reg, in rv3029_eeprom_write() argument
221 err = rv3029_eeprom_enter(rv3029); in rv3029_eeprom_write()
226 ret = regmap_read(rv3029->regmap, reg, &tmp); in rv3029_eeprom_write()
231 ret = regmap_write(rv3029->regmap, reg, tmp); in rv3029_eeprom_write()
235 ret = rv3029_eeprom_busywait(rv3029); in rv3029_eeprom_write()
240 err = rv3029_eeprom_exit(rv3029); in rv3029_eeprom_write()
247 static int rv3029_eeprom_update_bits(struct rv3029_data *rv3029, in rv3029_eeprom_update_bits() argument
253 ret = rv3029_eeprom_read(rv3029, reg, &buf, 1); in rv3029_eeprom_update_bits()
258 ret = rv3029_eeprom_write(rv3029, reg, &buf, 1); in rv3029_eeprom_update_bits()
268 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_handle_irq() local
273 rtc_lock(rv3029->rtc); in rv3029_handle_irq()
275 ret = regmap_read(rv3029->regmap, RV3029_IRQ_CTRL, &controls); in rv3029_handle_irq()
278 rtc_unlock(rv3029->rtc); in rv3029_handle_irq()
282 ret = regmap_read(rv3029->regmap, RV3029_IRQ_FLAGS, &flags); in rv3029_handle_irq()
285 rtc_unlock(rv3029->rtc); in rv3029_handle_irq()
296 rtc_update_irq(rv3029->rtc, 1, events); in rv3029_handle_irq()
297 regmap_write(rv3029->regmap, RV3029_IRQ_FLAGS, flags); in rv3029_handle_irq()
298 regmap_write(rv3029->regmap, RV3029_IRQ_CTRL, controls); in rv3029_handle_irq()
300 rtc_unlock(rv3029->rtc); in rv3029_handle_irq()
307 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_read_time() local
312 ret = regmap_read(rv3029->regmap, RV3029_STATUS, &sr); in rv3029_read_time()
319 ret = regmap_bulk_read(rv3029->regmap, RV3029_W_SEC, regs, in rv3029_read_time()
350 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_read_alarm() local
356 ret = regmap_bulk_read(rv3029->regmap, RV3029_A_SC, regs, in rv3029_read_alarm()
361 ret = regmap_read(rv3029->regmap, RV3029_IRQ_CTRL, &controls); in rv3029_read_alarm()
365 ret = regmap_read(rv3029->regmap, RV3029_IRQ_FLAGS, &flags); in rv3029_read_alarm()
385 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_alarm_irq_enable() local
387 return regmap_update_bits(rv3029->regmap, RV3029_IRQ_CTRL, in rv3029_alarm_irq_enable()
394 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_set_alarm() local
414 ret = regmap_bulk_write(rv3029->regmap, RV3029_A_SC, regs, in rv3029_set_alarm()
424 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_set_time() local
436 ret = regmap_bulk_write(rv3029->regmap, RV3029_W_SEC, regs, in rv3029_set_time()
442 return regmap_update_bits(rv3029->regmap, RV3029_STATUS, in rv3029_set_time()
448 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_ioctl() local
454 ret = regmap_read(rv3029->regmap, RV3029_STATUS, &sr); in rv3029_ioctl()
467 return regmap_update_bits(rv3029->regmap, RV3029_STATUS, in rv3029_ioctl()
546 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_trickle_config() local
573 err = rv3029_eeprom_update_bits(rv3029, RV3029_CONTROL_E2P_EECTRL, in rv3029_trickle_config()
582 static int rv3029_read_temp(struct rv3029_data *rv3029, int *temp_mC) in rv3029_read_temp() argument
587 ret = regmap_read(rv3029->regmap, RV3029_TEMP_PAGE, &temp); in rv3029_read_temp()
600 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_hwmon_show_temp() local
603 ret = rv3029_read_temp(rv3029, &temp_mC); in rv3029_hwmon_show_temp()
615 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_hwmon_set_update_interval() local
629 ret = rv3029_eeprom_update_bits(rv3029, RV3029_CONTROL_E2P_EECTRL, in rv3029_hwmon_set_update_interval()
642 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_hwmon_show_update_interval() local
646 ret = rv3029_eeprom_read(rv3029, RV3029_CONTROL_E2P_EECTRL, in rv3029_hwmon_show_update_interval()
678 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_hwmon_register() local
681 hwmon_dev = devm_hwmon_device_register_with_groups(dev, name, rv3029, in rv3029_hwmon_register()
709 struct rv3029_data *rv3029; in rv3029_probe() local
721 rv3029 = devm_kzalloc(dev, sizeof(*rv3029), GFP_KERNEL); in rv3029_probe()
722 if (!rv3029) in rv3029_probe()
725 rv3029->regmap = regmap; in rv3029_probe()
726 rv3029->irq = irq; in rv3029_probe()
727 rv3029->dev = dev; in rv3029_probe()
728 dev_set_drvdata(dev, rv3029); in rv3029_probe()
733 rv3029->rtc = devm_rtc_allocate_device(dev); in rv3029_probe()
734 if (IS_ERR(rv3029->rtc)) in rv3029_probe()
735 return PTR_ERR(rv3029->rtc); in rv3029_probe()
737 if (rv3029->irq > 0) { in rv3029_probe()
743 rc = devm_request_threaded_irq(dev, rv3029->irq, in rv3029_probe()
749 rv3029->irq = 0; in rv3029_probe()
752 if (!rv3029->irq) in rv3029_probe()
753 clear_bit(RTC_FEATURE_ALARM, rv3029->rtc->features); in rv3029_probe()
755 rv3029->rtc->ops = &rv3029_rtc_ops; in rv3029_probe()
756 rv3029->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; in rv3029_probe()
757 rv3029->rtc->range_max = RTC_TIMESTAMP_END_2079; in rv3029_probe()
759 rc = devm_rtc_register_device(rv3029->rtc); in rv3029_probe()
763 nvmem_cfg.priv = rv3029->regmap; in rv3029_probe()
764 devm_rtc_nvmem_register(rv3029->rtc, &nvmem_cfg); in rv3029_probe()