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
268 struct mutex *lock = &rv3029->rtc->ops_lock; in rv3029_handle_irq()
275 ret = regmap_read(rv3029->regmap, RV3029_IRQ_CTRL, &controls); in rv3029_handle_irq()
282 ret = regmap_read(rv3029->regmap, RV3029_IRQ_FLAGS, &flags); 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()
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()
706 struct rv3029_data *rv3029; in rv3029_probe() local
718 rv3029 = devm_kzalloc(dev, sizeof(*rv3029), GFP_KERNEL); in rv3029_probe()
719 if (!rv3029) in rv3029_probe()
722 rv3029->regmap = regmap; in rv3029_probe()
723 rv3029->irq = irq; in rv3029_probe()
724 rv3029->dev = dev; in rv3029_probe()
725 dev_set_drvdata(dev, rv3029); in rv3029_probe()
730 rv3029->rtc = devm_rtc_allocate_device(dev); in rv3029_probe()
731 if (IS_ERR(rv3029->rtc)) in rv3029_probe()
732 return PTR_ERR(rv3029->rtc); in rv3029_probe()
734 if (rv3029->irq > 0) { in rv3029_probe()
735 rc = devm_request_threaded_irq(dev, rv3029->irq, in rv3029_probe()
741 rv3029->irq = 0; 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 = rtc_register_device(rv3029->rtc); in rv3029_probe()
757 nvmem_cfg.priv = rv3029->regmap; in rv3029_probe()
758 rtc_nvmem_register(rv3029->rtc, &nvmem_cfg); in rv3029_probe()