Lines Matching +full:tc +full:- +full:diode

1 // SPDX-License-Identifier: GPL-2.0
6 * Copyright 2014-2015 Macq S.A.
135 dev_err(&client->dev, "Unable to write configuration key\n"); in abx80x_write_config_key()
136 return -EIO; in abx80x_write_config_key()
148 dev_err(&client->dev, in abx80x_is_rc_mode()
166 return -EIO; in abx80x_enable_trickle_charger()
172 dev_err(&client->dev, "Unable to write trickle register\n"); in abx80x_enable_trickle_charger()
173 return -EIO; in abx80x_enable_trickle_charger()
197 return -EINVAL; in abx80x_rtc_read_time()
204 dev_err(&client->dev, "Unable to read date\n"); in abx80x_rtc_read_time()
205 return -EIO; in abx80x_rtc_read_time()
208 tm->tm_sec = bcd2bin(buf[ABX8XX_REG_SC] & 0x7F); in abx80x_rtc_read_time()
209 tm->tm_min = bcd2bin(buf[ABX8XX_REG_MN] & 0x7F); in abx80x_rtc_read_time()
210 tm->tm_hour = bcd2bin(buf[ABX8XX_REG_HR] & 0x3F); in abx80x_rtc_read_time()
211 tm->tm_wday = buf[ABX8XX_REG_WD] & 0x7; in abx80x_rtc_read_time()
212 tm->tm_mday = bcd2bin(buf[ABX8XX_REG_DA] & 0x3F); in abx80x_rtc_read_time()
213 tm->tm_mon = bcd2bin(buf[ABX8XX_REG_MO] & 0x1F) - 1; in abx80x_rtc_read_time()
214 tm->tm_year = bcd2bin(buf[ABX8XX_REG_YR]) + 100; in abx80x_rtc_read_time()
225 if (tm->tm_year < 100) in abx80x_rtc_set_time()
226 return -EINVAL; in abx80x_rtc_set_time()
229 buf[ABX8XX_REG_SC] = bin2bcd(tm->tm_sec); in abx80x_rtc_set_time()
230 buf[ABX8XX_REG_MN] = bin2bcd(tm->tm_min); in abx80x_rtc_set_time()
231 buf[ABX8XX_REG_HR] = bin2bcd(tm->tm_hour); in abx80x_rtc_set_time()
232 buf[ABX8XX_REG_DA] = bin2bcd(tm->tm_mday); in abx80x_rtc_set_time()
233 buf[ABX8XX_REG_MO] = bin2bcd(tm->tm_mon + 1); in abx80x_rtc_set_time()
234 buf[ABX8XX_REG_YR] = bin2bcd(tm->tm_year - 100); in abx80x_rtc_set_time()
235 buf[ABX8XX_REG_WD] = tm->tm_wday; in abx80x_rtc_set_time()
240 dev_err(&client->dev, "Unable to write to date registers\n"); in abx80x_rtc_set_time()
241 return -EIO; in abx80x_rtc_set_time()
252 dev_err(&client->dev, "Unable to write oscillator status register\n"); in abx80x_rtc_set_time()
263 struct rtc_device *rtc = priv->rtc; in abx80x_handle_irq()
278 dev_alert(&client->dev, "watchdog timeout interrupt.\n"); in abx80x_handle_irq()
292 if (client->irq <= 0) in abx80x_read_alarm()
293 return -EINVAL; in abx80x_read_alarm()
304 t->time.tm_sec = bcd2bin(buf[0] & 0x7F); in abx80x_read_alarm()
305 t->time.tm_min = bcd2bin(buf[1] & 0x7F); in abx80x_read_alarm()
306 t->time.tm_hour = bcd2bin(buf[2] & 0x3F); in abx80x_read_alarm()
307 t->time.tm_mday = bcd2bin(buf[3] & 0x3F); in abx80x_read_alarm()
308 t->time.tm_mon = bcd2bin(buf[4] & 0x1F) - 1; in abx80x_read_alarm()
309 t->time.tm_wday = buf[5] & 0x7; in abx80x_read_alarm()
311 t->enabled = !!(irq_mask & ABX8XX_IRQ_AIE); in abx80x_read_alarm()
312 t->pending = (buf[6] & ABX8XX_STATUS_AF) && t->enabled; in abx80x_read_alarm()
323 if (client->irq <= 0) in abx80x_set_alarm()
324 return -EINVAL; in abx80x_set_alarm()
327 alarm[1] = bin2bcd(t->time.tm_sec); in abx80x_set_alarm()
328 alarm[2] = bin2bcd(t->time.tm_min); in abx80x_set_alarm()
329 alarm[3] = bin2bcd(t->time.tm_hour); in abx80x_set_alarm()
330 alarm[4] = bin2bcd(t->time.tm_mday); in abx80x_set_alarm()
331 alarm[5] = bin2bcd(t->time.tm_mon + 1); in abx80x_set_alarm()
336 dev_err(&client->dev, "Unable to write alarm registers\n"); in abx80x_set_alarm()
337 return -EIO; in abx80x_set_alarm()
340 if (t->enabled) { in abx80x_set_alarm()
360 return -EINVAL; in abx80x_rtc_set_autocalibration()
380 return -EIO; in abx80x_rtc_set_autocalibration()
416 return -EINVAL; in autocalibration_store()
419 retval = abx80x_rtc_set_autocalibration(dev->parent, autocalibration); in autocalibration_store()
429 autocalibration = abx80x_rtc_get_autocalibration(dev->parent); in autocalibration_show()
445 struct i2c_client *client = to_i2c_client(dev->parent); in oscillator_store()
454 return -EINVAL; in oscillator_store()
468 return -EIO; in oscillator_store()
483 struct i2c_client *client = to_i2c_client(dev->parent); in oscillator_show()
555 return -ENOIOCTLCMD; in abx80x_ioctl()
570 struct device_node *np = client->dev.of_node; in abx80x_dt_trickle_cfg()
571 const char *diode; in abx80x_dt_trickle_cfg() local
576 ret = of_property_read_string(np, "abracon,tc-diode", &diode); in abx80x_dt_trickle_cfg()
580 if (!strcmp(diode, "standard")) { in abx80x_dt_trickle_cfg()
582 } else if (!strcmp(diode, "schottky")) { in abx80x_dt_trickle_cfg()
585 dev_dbg(&client->dev, "Invalid tc-diode value: %s\n", diode); in abx80x_dt_trickle_cfg()
586 return -EINVAL; in abx80x_dt_trickle_cfg()
589 ret = of_property_read_u32(np, "abracon,tc-resistor", &tmp); in abx80x_dt_trickle_cfg()
598 dev_dbg(&client->dev, "Invalid tc-resistor value: %u\n", tmp); in abx80x_dt_trickle_cfg()
599 return -EINVAL; in abx80x_dt_trickle_cfg()
623 return i2c_smbus_write_byte_data(priv->client, ABX8XX_REG_WDT, val); in __abx80x_wdog_set_timeout()
635 wdog->timeout = new_timeout; in abx80x_wdog_set_timeout()
642 return __abx80x_wdog_set_timeout(wdog, wdog->timeout); in abx80x_wdog_ping()
647 return __abx80x_wdog_set_timeout(wdog, wdog->timeout); in abx80x_wdog_start()
670 priv->wdog.parent = &priv->client->dev; in abx80x_setup_watchdog()
671 priv->wdog.ops = &abx80x_wdog_ops; in abx80x_setup_watchdog()
672 priv->wdog.info = &abx80x_wdog_info; in abx80x_setup_watchdog()
673 priv->wdog.min_timeout = 1; in abx80x_setup_watchdog()
674 priv->wdog.max_timeout = ABX8XX_WDT_MAX_TIME; in abx80x_setup_watchdog()
675 priv->wdog.timeout = ABX8XX_WDT_MAX_TIME; in abx80x_setup_watchdog()
677 watchdog_set_drvdata(&priv->wdog, priv); in abx80x_setup_watchdog()
679 return devm_watchdog_register_device(&priv->client->dev, &priv->wdog); in abx80x_setup_watchdog()
700 len = min(lower + bytes, (size_t)ABX8XX_SRAM_WIN_SIZE) - lower; in abx80x_nvmem_xfer()
703 ret = i2c_smbus_write_byte_data(priv->client, ABX8XX_REG_EXTRAM, in abx80x_nvmem_xfer()
709 ret = i2c_smbus_write_i2c_block_data(priv->client, reg, in abx80x_nvmem_xfer()
714 ret = i2c_smbus_read_i2c_block_data(priv->client, reg, in abx80x_nvmem_xfer()
717 return ret ? ret : -EIO; in abx80x_nvmem_xfer()
723 bytes -= len; in abx80x_nvmem_xfer()
751 return devm_rtc_nvmem_register(priv->rtc, &config); in abx80x_setup_nvmem()
771 struct device_node *np = client->dev.of_node; in abx80x_probe()
773 int i, data, err, trickle_cfg = -EINVAL; in abx80x_probe()
776 unsigned int part = id->driver_data; in abx80x_probe()
783 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) in abx80x_probe()
784 return -ENODEV; in abx80x_probe()
789 dev_err(&client->dev, "Unable to read partnumber\n"); in abx80x_probe()
790 return -EIO; in abx80x_probe()
799 dev_info(&client->dev, "model %04x, revision %u.%u, lot %x, wafer %x, uid %x\n", in abx80x_probe()
804 dev_err(&client->dev, "Unable to read control register\n"); in abx80x_probe()
805 return -EIO; in abx80x_probe()
813 dev_err(&client->dev, "Unable to write control register\n"); in abx80x_probe()
814 return -EIO; in abx80x_probe()
822 * register is set. RV-1805-C3 datasheet indicates that in abx80x_probe()
823 * the bit should be cleared in section 11h - Control2. in abx80x_probe()
827 dev_err(&client->dev, in abx80x_probe()
829 return -EIO; in abx80x_probe()
835 dev_err(&client->dev, in abx80x_probe()
837 return -EIO; in abx80x_probe()
847 dev_err(&client->dev, in abx80x_probe()
849 return -EIO; in abx80x_probe()
857 return -EIO; in abx80x_probe()
862 dev_err(&client->dev, in abx80x_probe()
864 return -EIO; in abx80x_probe()
874 dev_err(&client->dev, "Unknown part: %04x\n", in abx80x_probe()
876 return -EINVAL; in abx80x_probe()
882 dev_err(&client->dev, "partnumber mismatch %04x != %04x\n", in abx80x_probe()
884 return -EINVAL; in abx80x_probe()
891 dev_info(&client->dev, "Enabling trickle charger: %02x\n", in abx80x_probe()
901 priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL); in abx80x_probe()
903 return -ENOMEM; in abx80x_probe()
905 priv->rtc = devm_rtc_allocate_device(&client->dev); in abx80x_probe()
906 if (IS_ERR(priv->rtc)) in abx80x_probe()
907 return PTR_ERR(priv->rtc); in abx80x_probe()
909 priv->rtc->ops = &abx80x_rtc_ops; in abx80x_probe()
910 priv->client = client; in abx80x_probe()
924 if (client->irq > 0) { in abx80x_probe()
925 dev_info(&client->dev, "IRQ %d supplied\n", client->irq); in abx80x_probe()
926 err = devm_request_threaded_irq(&client->dev, client->irq, NULL, in abx80x_probe()
932 dev_err(&client->dev, "unable to request IRQ, alarms disabled\n"); in abx80x_probe()
933 client->irq = 0; in abx80x_probe()
937 err = rtc_add_group(priv->rtc, &rtc_calib_attr_group); in abx80x_probe()
939 dev_err(&client->dev, "Failed to create sysfs group: %d\n", in abx80x_probe()
944 return devm_rtc_register_device(priv->rtc); in abx80x_probe()
996 .name = "rtc-abx80x",