Lines Matching refs:rv3029

122 static int rv3029_eeprom_busywait(struct rv3029_data *rv3029)  in rv3029_eeprom_busywait()  argument
128 ret = regmap_read(rv3029->regmap, RV3029_STATUS, &sr); in rv3029_eeprom_busywait()
136 dev_err(rv3029->dev, "EEPROM busy wait timeout.\n"); in rv3029_eeprom_busywait()
143 static int rv3029_eeprom_exit(struct rv3029_data *rv3029) in rv3029_eeprom_exit() argument
146 return regmap_update_bits(rv3029->regmap, RV3029_ONOFF_CTRL, in rv3029_eeprom_exit()
151 static int rv3029_eeprom_enter(struct rv3029_data *rv3029) in rv3029_eeprom_enter() argument
157 ret = regmap_read(rv3029->regmap, RV3029_STATUS, &sr); in rv3029_eeprom_enter()
166 ret = regmap_update_bits(rv3029->regmap, RV3029_STATUS, in rv3029_eeprom_enter()
171 ret = regmap_read(rv3029->regmap, RV3029_STATUS, &sr); in rv3029_eeprom_enter()
175 dev_err(rv3029->dev, in rv3029_eeprom_enter()
182 ret = regmap_update_bits(rv3029->regmap, RV3029_ONOFF_CTRL, in rv3029_eeprom_enter()
188 ret = rv3029_eeprom_busywait(rv3029); in rv3029_eeprom_enter()
190 rv3029_eeprom_exit(rv3029); in rv3029_eeprom_enter()
195 static int rv3029_eeprom_read(struct rv3029_data *rv3029, u8 reg, in rv3029_eeprom_read() argument
200 err = rv3029_eeprom_enter(rv3029); in rv3029_eeprom_read()
204 ret = regmap_bulk_read(rv3029->regmap, reg, buf, len); in rv3029_eeprom_read()
206 err = rv3029_eeprom_exit(rv3029); in rv3029_eeprom_read()
213 static int rv3029_eeprom_write(struct rv3029_data *rv3029, u8 reg, in rv3029_eeprom_write() argument
220 err = rv3029_eeprom_enter(rv3029); in rv3029_eeprom_write()
225 ret = regmap_read(rv3029->regmap, reg, &tmp); in rv3029_eeprom_write()
230 ret = regmap_write(rv3029->regmap, reg, tmp); in rv3029_eeprom_write()
234 ret = rv3029_eeprom_busywait(rv3029); in rv3029_eeprom_write()
239 err = rv3029_eeprom_exit(rv3029); in rv3029_eeprom_write()
246 static int rv3029_eeprom_update_bits(struct rv3029_data *rv3029, in rv3029_eeprom_update_bits() argument
252 ret = rv3029_eeprom_read(rv3029, reg, &buf, 1); in rv3029_eeprom_update_bits()
257 ret = rv3029_eeprom_write(rv3029, reg, &buf, 1); in rv3029_eeprom_update_bits()
267 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_handle_irq() local
272 rtc_lock(rv3029->rtc); in rv3029_handle_irq()
274 ret = regmap_read(rv3029->regmap, RV3029_IRQ_CTRL, &controls); in rv3029_handle_irq()
277 rtc_unlock(rv3029->rtc); in rv3029_handle_irq()
281 ret = regmap_read(rv3029->regmap, RV3029_IRQ_FLAGS, &flags); in rv3029_handle_irq()
284 rtc_unlock(rv3029->rtc); in rv3029_handle_irq()
295 rtc_update_irq(rv3029->rtc, 1, events); in rv3029_handle_irq()
296 regmap_write(rv3029->regmap, RV3029_IRQ_FLAGS, flags); in rv3029_handle_irq()
297 regmap_write(rv3029->regmap, RV3029_IRQ_CTRL, controls); in rv3029_handle_irq()
299 rtc_unlock(rv3029->rtc); in rv3029_handle_irq()
306 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_read_time() local
311 ret = regmap_read(rv3029->regmap, RV3029_STATUS, &sr); in rv3029_read_time()
318 ret = regmap_bulk_read(rv3029->regmap, RV3029_W_SEC, regs, in rv3029_read_time()
349 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_read_alarm() local
355 ret = regmap_bulk_read(rv3029->regmap, RV3029_A_SC, regs, in rv3029_read_alarm()
360 ret = regmap_read(rv3029->regmap, RV3029_IRQ_CTRL, &controls); in rv3029_read_alarm()
364 ret = regmap_read(rv3029->regmap, RV3029_IRQ_FLAGS, &flags); in rv3029_read_alarm()
384 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_alarm_irq_enable() local
386 return regmap_update_bits(rv3029->regmap, RV3029_IRQ_CTRL, in rv3029_alarm_irq_enable()
393 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_set_alarm() local
413 ret = regmap_bulk_write(rv3029->regmap, RV3029_A_SC, regs, in rv3029_set_alarm()
423 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_set_time() local
435 ret = regmap_bulk_write(rv3029->regmap, RV3029_W_SEC, regs, in rv3029_set_time()
441 return regmap_update_bits(rv3029->regmap, RV3029_STATUS, in rv3029_set_time()
447 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_ioctl() local
453 ret = regmap_read(rv3029->regmap, RV3029_STATUS, &sr); in rv3029_ioctl()
466 return regmap_update_bits(rv3029->regmap, RV3029_STATUS, in rv3029_ioctl()
545 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_trickle_config() local
572 err = rv3029_eeprom_update_bits(rv3029, RV3029_CONTROL_E2P_EECTRL, in rv3029_trickle_config()
581 static int rv3029_read_temp(struct rv3029_data *rv3029, int *temp_mC) in rv3029_read_temp() argument
586 ret = regmap_read(rv3029->regmap, RV3029_TEMP_PAGE, &temp); in rv3029_read_temp()
599 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_hwmon_show_temp() local
602 ret = rv3029_read_temp(rv3029, &temp_mC); in rv3029_hwmon_show_temp()
614 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_hwmon_set_update_interval() local
628 ret = rv3029_eeprom_update_bits(rv3029, RV3029_CONTROL_E2P_EECTRL, in rv3029_hwmon_set_update_interval()
641 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_hwmon_show_update_interval() local
645 ret = rv3029_eeprom_read(rv3029, RV3029_CONTROL_E2P_EECTRL, in rv3029_hwmon_show_update_interval()
677 struct rv3029_data *rv3029 = dev_get_drvdata(dev); in rv3029_hwmon_register() local
680 hwmon_dev = devm_hwmon_device_register_with_groups(dev, name, rv3029, in rv3029_hwmon_register()
708 struct rv3029_data *rv3029; in rv3029_probe() local
720 rv3029 = devm_kzalloc(dev, sizeof(*rv3029), GFP_KERNEL); in rv3029_probe()
721 if (!rv3029) in rv3029_probe()
724 rv3029->regmap = regmap; in rv3029_probe()
725 rv3029->irq = irq; in rv3029_probe()
726 rv3029->dev = dev; in rv3029_probe()
727 dev_set_drvdata(dev, rv3029); in rv3029_probe()
732 rv3029->rtc = devm_rtc_allocate_device(dev); in rv3029_probe()
733 if (IS_ERR(rv3029->rtc)) in rv3029_probe()
734 return PTR_ERR(rv3029->rtc); in rv3029_probe()
736 if (rv3029->irq > 0) { in rv3029_probe()
737 rc = devm_request_threaded_irq(dev, rv3029->irq, in rv3029_probe()
743 rv3029->irq = 0; in rv3029_probe()
746 if (!rv3029->irq) in rv3029_probe()
747 clear_bit(RTC_FEATURE_ALARM, rv3029->rtc->features); in rv3029_probe()
749 rv3029->rtc->ops = &rv3029_rtc_ops; in rv3029_probe()
750 rv3029->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; in rv3029_probe()
751 rv3029->rtc->range_max = RTC_TIMESTAMP_END_2079; in rv3029_probe()
753 rc = devm_rtc_register_device(rv3029->rtc); in rv3029_probe()
757 nvmem_cfg.priv = rv3029->regmap; in rv3029_probe()
758 devm_rtc_nvmem_register(rv3029->rtc, &nvmem_cfg); in rv3029_probe()