Lines Matching +full:trickle +full:- +full:resistor +full:- +full:ohms

1 // SPDX-License-Identifier: GPL-2.0
3 * Real Time Clock driver for AB-RTCMC-32.768kHz-EOZ9 chip.
16 #include <linux/hwmon-sysfs.h>
81 #define ABEOZ953_TEMP_MIN -60
103 struct regmap *regmap = data->regmap; in abeoz9_check_validity()
115 dev_warn(dev, "power-on reset detected, date is invalid\n"); in abeoz9_check_validity()
116 return -EINVAL; in abeoz9_check_validity()
122 return -EINVAL; in abeoz9_check_validity()
128 return -EINVAL; in abeoz9_check_validity()
153 ret = regmap_bulk_read(data->regmap, ABEOZ9_REG_SEC, in abeoz9_rtc_get_time()
161 tm->tm_sec = bcd2bin(regs[ABEOZ9_REG_SEC - ABEOZ9_REG_SEC] & 0x7F); in abeoz9_rtc_get_time()
162 tm->tm_min = bcd2bin(regs[ABEOZ9_REG_MIN - ABEOZ9_REG_SEC] & 0x7F); in abeoz9_rtc_get_time()
164 if (regs[ABEOZ9_REG_HOURS - ABEOZ9_REG_SEC] & ABEOZ9_HOURS_PM) { in abeoz9_rtc_get_time()
165 tm->tm_hour = in abeoz9_rtc_get_time()
166 bcd2bin(regs[ABEOZ9_REG_HOURS - ABEOZ9_REG_SEC] & 0x1f); in abeoz9_rtc_get_time()
167 if (regs[ABEOZ9_REG_HOURS - ABEOZ9_REG_SEC] & ABEOZ9_HOURS_PM) in abeoz9_rtc_get_time()
168 tm->tm_hour += 12; in abeoz9_rtc_get_time()
170 tm->tm_hour = bcd2bin(regs[ABEOZ9_REG_HOURS - ABEOZ9_REG_SEC]); in abeoz9_rtc_get_time()
173 tm->tm_mday = bcd2bin(regs[ABEOZ9_REG_DAYS - ABEOZ9_REG_SEC]); in abeoz9_rtc_get_time()
174 tm->tm_wday = bcd2bin(regs[ABEOZ9_REG_WEEKDAYS - ABEOZ9_REG_SEC]); in abeoz9_rtc_get_time()
175 tm->tm_mon = bcd2bin(regs[ABEOZ9_REG_MONTHS - ABEOZ9_REG_SEC]) - 1; in abeoz9_rtc_get_time()
176 tm->tm_year = bcd2bin(regs[ABEOZ9_REG_YEARS - ABEOZ9_REG_SEC]) + 100; in abeoz9_rtc_get_time()
184 struct regmap *regmap = data->regmap; in abeoz9_rtc_set_time()
188 regs[ABEOZ9_REG_SEC - ABEOZ9_REG_SEC] = bin2bcd(tm->tm_sec); in abeoz9_rtc_set_time()
189 regs[ABEOZ9_REG_MIN - ABEOZ9_REG_SEC] = bin2bcd(tm->tm_min); in abeoz9_rtc_set_time()
190 regs[ABEOZ9_REG_HOURS - ABEOZ9_REG_SEC] = bin2bcd(tm->tm_hour); in abeoz9_rtc_set_time()
191 regs[ABEOZ9_REG_DAYS - ABEOZ9_REG_SEC] = bin2bcd(tm->tm_mday); in abeoz9_rtc_set_time()
192 regs[ABEOZ9_REG_WEEKDAYS - ABEOZ9_REG_SEC] = bin2bcd(tm->tm_wday); in abeoz9_rtc_set_time()
193 regs[ABEOZ9_REG_MONTHS - ABEOZ9_REG_SEC] = bin2bcd(tm->tm_mon + 1); in abeoz9_rtc_set_time()
194 regs[ABEOZ9_REG_YEARS - ABEOZ9_REG_SEC] = bin2bcd(tm->tm_year - 100); in abeoz9_rtc_set_time()
196 ret = regmap_bulk_write(data->regmap, ABEOZ9_REG_SEC, in abeoz9_rtc_set_time()
211 struct regmap *regmap = data->regmap; in abeoz9_rtc_read_alarm()
224 alarm->enabled = val[0] & ABEOZ9_REG_CTRL_INT_AIE; in abeoz9_rtc_read_alarm()
225 alarm->pending = val[1] & ABEOZ9_REG_CTRL_INT_FLAG_AF; in abeoz9_rtc_read_alarm()
231 alarm->time.tm_sec = bcd2bin(FIELD_GET(ABEOZ9_BIT_ALARM_SEC, regs[0])); in abeoz9_rtc_read_alarm()
232 alarm->time.tm_min = bcd2bin(FIELD_GET(ABEOZ9_BIT_ALARM_MIN, regs[1])); in abeoz9_rtc_read_alarm()
233 alarm->time.tm_hour = bcd2bin(FIELD_GET(ABEOZ9_BIT_ALARM_HOURS, regs[2])); in abeoz9_rtc_read_alarm()
235 alarm->time.tm_hour += 12; in abeoz9_rtc_read_alarm()
237 alarm->time.tm_mday = bcd2bin(FIELD_GET(ABEOZ9_BIT_ALARM_DAYS, regs[3])); in abeoz9_rtc_read_alarm()
246 return regmap_update_bits(data->regmap, ABEOZ9_REG_CTRL_INT, in abeoz9_rtc_alarm_irq_enable()
257 ret = regmap_update_bits(data->regmap, ABEOZ9_REG_CTRL_INT_FLAG, in abeoz9_rtc_set_alarm()
263 bin2bcd(alarm->time.tm_sec)); in abeoz9_rtc_set_alarm()
265 bin2bcd(alarm->time.tm_min)); in abeoz9_rtc_set_alarm()
267 bin2bcd(alarm->time.tm_hour)); in abeoz9_rtc_set_alarm()
269 bin2bcd(alarm->time.tm_mday)); in abeoz9_rtc_set_alarm()
271 ret = regmap_bulk_write(data->regmap, ABEOZ9_REG_ALARM_SEC, regs, in abeoz9_rtc_set_alarm()
276 return abeoz9_rtc_alarm_irq_enable(dev, alarm->enabled); in abeoz9_rtc_set_alarm()
285 ret = regmap_read(data->regmap, ABEOZ9_REG_CTRL_INT_FLAG, &val); in abeoz9_rtc_irq()
292 regmap_update_bits(data->regmap, ABEOZ9_REG_CTRL_INT_FLAG, in abeoz9_rtc_irq()
295 rtc_update_irq(data->rtc, 1, RTC_IRQF | RTC_AF); in abeoz9_rtc_irq()
302 u32 ohms = 0; in abeoz9_trickle_parse_dt() local
304 if (of_property_read_u32(node, "trickle-resistor-ohms", &ohms)) in abeoz9_trickle_parse_dt()
307 switch (ohms) { in abeoz9_trickle_parse_dt()
324 struct regmap *regmap = data->regmap; in abeoz9_rtc_setup()
356 /* Enable built-in termometer */ in abeoz9_rtc_setup()
391 struct regmap *regmap = data->regmap; in abeoz9z3_temp_read()
403 return -EINVAL; in abeoz9z3_temp_read()
420 return -EOPNOTSUPP; in abeoz9z3_temp_read()
477 data->hwmon_dev = in abeoz9_hwmon_register()
483 if (IS_ERR(data->hwmon_dev)) { in abeoz9_hwmon_register()
485 PTR_ERR(data->hwmon_dev)); in abeoz9_hwmon_register()
501 struct device *dev = &client->dev; in abeoz9_probe()
505 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C | in abeoz9_probe()
508 return -ENODEV; in abeoz9_probe()
519 return -ENOMEM; in abeoz9_probe()
521 data->regmap = regmap; in abeoz9_probe()
524 ret = abeoz9_rtc_setup(dev, client->dev.of_node); in abeoz9_probe()
528 data->rtc = devm_rtc_allocate_device(dev); in abeoz9_probe()
529 ret = PTR_ERR_OR_ZERO(data->rtc); in abeoz9_probe()
533 data->rtc->ops = &rtc_ops; in abeoz9_probe()
534 data->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; in abeoz9_probe()
535 data->rtc->range_max = RTC_TIMESTAMP_END_2099; in abeoz9_probe()
536 clear_bit(RTC_FEATURE_ALARM, data->rtc->features); in abeoz9_probe()
538 if (client->irq > 0) { in abeoz9_probe()
541 if (dev_fwnode(&client->dev)) in abeoz9_probe()
544 ret = devm_request_threaded_irq(dev, client->irq, NULL, in abeoz9_probe()
553 clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, data->rtc->features); in abeoz9_probe()
556 if (client->irq > 0 || device_property_read_bool(dev, "wakeup-source")) { in abeoz9_probe()
558 set_bit(RTC_FEATURE_ALARM, data->rtc->features); in abeoz9_probe()
561 ret = devm_rtc_register_device(data->rtc); in abeoz9_probe()
584 .name = "rtc-ab-eoz9",
594 MODULE_DESCRIPTION("Abracon AB-RTCMC-32.768kHz-EOZ9 RTC driver");