Lines Matching +full:ev +full:- +full:evienb
1 // SPDX-License-Identifier: GPL-2.0-or-later
42 #define ISL1219_REG_EV_EVIENB (1<<7) /* event in pull-up disable */
163 return -ENODEV; in isl1208_i2c_validate_client()
206 return -EIO; in isl1208_i2c_get_dtr()
208 /* dtr encodes adjustments of {-60,-40,-20,0,20,40,60} ppm */ in isl1208_i2c_get_dtr()
209 dtr = ((dtr & 0x3) * 20) * (dtr & (1 << 2) ? -1 : 1); in isl1208_i2c_get_dtr()
246 dev_err(&client->dev, "%s: reading INT failed\n", __func__); in isl1208_rtc_toggle_alarm()
257 dev_err(&client->dev, "%s: writing INT failed\n", __func__); in isl1208_rtc_toggle_alarm()
272 dev_err(&client->dev, "%s: reading SR failed\n", __func__); in isl1208_rtc_proc()
289 seq_printf(seq, "digital_trim\t: %d ppm\n", dtr - 100); in isl1208_rtc_proc()
311 dev_err(&client->dev, "%s: reading SR failed\n", __func__); in isl1208_i2c_read_time()
312 return -EIO; in isl1208_i2c_read_time()
317 dev_err(&client->dev, "%s: reading RTC section failed\n", in isl1208_i2c_read_time()
322 tm->tm_sec = bcd2bin(regs[ISL1208_REG_SC]); in isl1208_i2c_read_time()
323 tm->tm_min = bcd2bin(regs[ISL1208_REG_MN]); in isl1208_i2c_read_time()
329 tm->tm_hour = bcd2bin(_hr & 0x3f); in isl1208_i2c_read_time()
332 tm->tm_hour = bcd2bin(_hr & 0x1f); in isl1208_i2c_read_time()
334 tm->tm_hour += 12; in isl1208_i2c_read_time()
338 tm->tm_mday = bcd2bin(regs[ISL1208_REG_DT]); in isl1208_i2c_read_time()
339 tm->tm_mon = bcd2bin(regs[ISL1208_REG_MO]) - 1; /* rtc starts at 1 */ in isl1208_i2c_read_time()
340 tm->tm_year = bcd2bin(regs[ISL1208_REG_YR]) + 100; in isl1208_i2c_read_time()
341 tm->tm_wday = bcd2bin(regs[ISL1208_REG_DW]); in isl1208_i2c_read_time()
349 struct rtc_time *const tm = &alarm->time; in isl1208_i2c_read_alarm()
354 dev_err(&client->dev, "%s: reading SR failed\n", __func__); in isl1208_i2c_read_alarm()
361 dev_err(&client->dev, "%s: reading alarm section failed\n", in isl1208_i2c_read_alarm()
367 tm->tm_sec = bcd2bin(regs[ISL1208_REG_SCA - ISL1208_REG_SCA] & 0x7f); in isl1208_i2c_read_alarm()
368 tm->tm_min = bcd2bin(regs[ISL1208_REG_MNA - ISL1208_REG_SCA] & 0x7f); in isl1208_i2c_read_alarm()
369 tm->tm_hour = bcd2bin(regs[ISL1208_REG_HRA - ISL1208_REG_SCA] & 0x3f); in isl1208_i2c_read_alarm()
370 tm->tm_mday = bcd2bin(regs[ISL1208_REG_DTA - ISL1208_REG_SCA] & 0x3f); in isl1208_i2c_read_alarm()
371 tm->tm_mon = in isl1208_i2c_read_alarm()
372 bcd2bin(regs[ISL1208_REG_MOA - ISL1208_REG_SCA] & 0x1f) - 1; in isl1208_i2c_read_alarm()
373 tm->tm_wday = bcd2bin(regs[ISL1208_REG_DWA - ISL1208_REG_SCA] & 0x03); in isl1208_i2c_read_alarm()
378 dev_err(&client->dev, "%s: reading RTC YR failed\n", __func__); in isl1208_i2c_read_alarm()
381 tm->tm_year = bcd2bin(yr) + 100; in isl1208_i2c_read_alarm()
385 dev_err(&client->dev, "%s: reading INT failed\n", __func__); in isl1208_i2c_read_alarm()
388 alarm->enabled = !!(icr & ISL1208_REG_INT_ALME); in isl1208_i2c_read_alarm()
396 struct rtc_time *alarm_tm = &alarm->time; in isl1208_i2c_set_alarm()
407 if (!alarm->enabled || rtc_tm_sub(alarm_tm, &rtc_tm) <= 0) in isl1208_i2c_set_alarm()
413 regs[ISL1208_REG_SCA - offs] = bin2bcd(alarm_tm->tm_sec) | enable; in isl1208_i2c_set_alarm()
414 regs[ISL1208_REG_MNA - offs] = bin2bcd(alarm_tm->tm_min) | enable; in isl1208_i2c_set_alarm()
415 regs[ISL1208_REG_HRA - offs] = bin2bcd(alarm_tm->tm_hour) | in isl1208_i2c_set_alarm()
418 regs[ISL1208_REG_DTA - offs] = bin2bcd(alarm_tm->tm_mday) | enable; in isl1208_i2c_set_alarm()
419 regs[ISL1208_REG_MOA - offs] = bin2bcd(alarm_tm->tm_mon + 1) | enable; in isl1208_i2c_set_alarm()
420 regs[ISL1208_REG_DWA - offs] = bin2bcd(alarm_tm->tm_wday & 7) | enable; in isl1208_i2c_set_alarm()
426 dev_err(&client->dev, "%s: writing ALARM section failed\n", in isl1208_i2c_set_alarm()
450 /* The clock has an 8 bit wide bcd-coded register (they never learn) in isl1208_i2c_set_time()
452 * in the 2000-2099 range, so any value less than 100 is invalid. in isl1208_i2c_set_time()
454 if (tm->tm_year < 100) in isl1208_i2c_set_time()
455 return -EINVAL; in isl1208_i2c_set_time()
457 regs[ISL1208_REG_SC] = bin2bcd(tm->tm_sec); in isl1208_i2c_set_time()
458 regs[ISL1208_REG_MN] = bin2bcd(tm->tm_min); in isl1208_i2c_set_time()
459 regs[ISL1208_REG_HR] = bin2bcd(tm->tm_hour) | ISL1208_REG_HR_MIL; in isl1208_i2c_set_time()
461 regs[ISL1208_REG_DT] = bin2bcd(tm->tm_mday); in isl1208_i2c_set_time()
462 regs[ISL1208_REG_MO] = bin2bcd(tm->tm_mon + 1); in isl1208_i2c_set_time()
463 regs[ISL1208_REG_YR] = bin2bcd(tm->tm_year - 100); in isl1208_i2c_set_time()
465 regs[ISL1208_REG_DW] = bin2bcd(tm->tm_wday & 7); in isl1208_i2c_set_time()
469 dev_err(&client->dev, "%s: reading SR failed\n", __func__); in isl1208_i2c_set_time()
477 dev_err(&client->dev, "%s: writing SR failed\n", __func__); in isl1208_i2c_set_time()
484 dev_err(&client->dev, "%s: writing RTC section failed\n", in isl1208_i2c_set_time()
492 dev_err(&client->dev, "%s: reading SR failed\n", __func__); in isl1208_i2c_set_time()
498 dev_err(&client->dev, "%s: writing SR failed\n", __func__); in isl1208_i2c_set_time()
528 struct i2c_client *client = to_i2c_client(dev->parent); in timestamp0_store()
550 struct i2c_client *client = to_i2c_client(dev->parent); in timestamp0_show()
573 tm.tm_sec = bcd2bin(regs[ISL1219_REG_SCT - ISL1219_REG_SCT] & 0x7f); in timestamp0_show()
574 tm.tm_min = bcd2bin(regs[ISL1219_REG_MNT - ISL1219_REG_SCT] & 0x7f); in timestamp0_show()
575 tm.tm_hour = bcd2bin(regs[ISL1219_REG_HRT - ISL1219_REG_SCT] & 0x3f); in timestamp0_show()
576 tm.tm_mday = bcd2bin(regs[ISL1219_REG_DTT - ISL1219_REG_SCT] & 0x3f); in timestamp0_show()
578 bcd2bin(regs[ISL1219_REG_MOT - ISL1219_REG_SCT] & 0x1f) - 1; in timestamp0_show()
579 tm.tm_year = bcd2bin(regs[ISL1219_REG_YRT - ISL1219_REG_SCT]) + 100; in timestamp0_show()
610 dev_err(&client->dev, "%s: reading SR failed\n", in isl1208_rtc_interrupt()
617 dev_dbg(&client->dev, "alarm!\n"); in isl1208_rtc_interrupt()
619 rtc_update_irq(isl1208->rtc, 1, RTC_IRQF | RTC_AF); in isl1208_rtc_interrupt()
625 dev_err(&client->dev, "%s: writing SR failed\n", in isl1208_rtc_interrupt()
636 if (isl1208->config->has_tamper && (sr & ISL1208_REG_SR_EVT)) { in isl1208_rtc_interrupt()
637 dev_warn(&client->dev, "event detected"); in isl1208_rtc_interrupt()
639 if (isl1208->config->has_timestamp) in isl1208_rtc_interrupt()
640 sysfs_notify(&isl1208->rtc->dev.kobj, NULL, in isl1208_rtc_interrupt()
661 int atr = isl1208_i2c_get_atr(to_i2c_client(dev->parent)); in isl1208_sysfs_show_atrim()
674 int dtr = isl1208_i2c_get_dtr(to_i2c_client(dev->parent)); in isl1208_sysfs_show_dtrim()
678 return sprintf(buf, "%d ppm\n", dtr - 100); in isl1208_sysfs_show_dtrim()
687 int usr = isl1208_i2c_get_usr(to_i2c_client(dev->parent)); in isl1208_sysfs_show_usr()
699 int usr = -1; in isl1208_sysfs_store_usr()
703 return -EINVAL; in isl1208_sysfs_store_usr()
706 return -EINVAL; in isl1208_sysfs_store_usr()
710 return -EINVAL; in isl1208_sysfs_store_usr()
712 if (isl1208_i2c_set_usr(to_i2c_client(dev->parent), usr)) in isl1208_sysfs_store_usr()
713 return -EIO; in isl1208_sysfs_store_usr()
745 struct i2c_client *client = to_i2c_client(isl1208->rtc->dev.parent); in isl1208_nvmem_read()
760 struct i2c_client *client = to_i2c_client(isl1208->rtc->dev.parent); in isl1208_nvmem_write()
783 int rc = devm_request_threaded_irq(&client->dev, irq, NULL, in isl1208_setup_irq()
789 device_init_wakeup(&client->dev, 1); in isl1208_setup_irq()
792 dev_err(&client->dev, in isl1208_setup_irq()
804 int evdet_irq = -1; in isl1208_probe()
806 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) in isl1208_probe()
807 return -ENODEV; in isl1208_probe()
810 return -ENODEV; in isl1208_probe()
813 isl1208 = devm_kzalloc(&client->dev, sizeof(*isl1208), GFP_KERNEL); in isl1208_probe()
815 return -ENOMEM; in isl1208_probe()
819 if (client->dev.of_node) { in isl1208_probe()
820 isl1208->config = of_device_get_match_data(&client->dev); in isl1208_probe()
821 if (!isl1208->config) in isl1208_probe()
822 return -ENODEV; in isl1208_probe()
824 if (id->driver_data >= ISL_LAST_ID) in isl1208_probe()
825 return -ENODEV; in isl1208_probe()
826 isl1208->config = &isl1208_configs[id->driver_data]; in isl1208_probe()
829 isl1208->rtc = devm_rtc_allocate_device(&client->dev); in isl1208_probe()
830 if (IS_ERR(isl1208->rtc)) in isl1208_probe()
831 return PTR_ERR(isl1208->rtc); in isl1208_probe()
833 isl1208->rtc->ops = &isl1208_rtc_ops; in isl1208_probe()
836 isl1208->nvmem_config = isl1208_nvmem_config; in isl1208_probe()
837 isl1208->nvmem_config.size = isl1208->config->nvmem_length; in isl1208_probe()
838 isl1208->nvmem_config.priv = isl1208; in isl1208_probe()
842 dev_err(&client->dev, "reading status failed\n"); in isl1208_probe()
847 dev_warn(&client->dev, "rtc power failure detected, " in isl1208_probe()
850 if (isl1208->config->has_tamper) { in isl1208_probe()
851 struct device_node *np = client->dev.of_node; in isl1208_probe()
852 u32 evienb; in isl1208_probe() local
856 dev_err(&client->dev, "failed to read EV reg\n"); in isl1208_probe()
860 if (!of_property_read_u32(np, "isil,ev-evienb", &evienb)) { in isl1208_probe()
861 if (evienb) in isl1208_probe()
868 dev_err(&client->dev, "could not enable tamper detection\n"); in isl1208_probe()
873 if (isl1208->config->has_timestamp) { in isl1208_probe()
874 rc = rtc_add_group(isl1208->rtc, &isl1219_rtc_sysfs_files); in isl1208_probe()
879 rc = rtc_add_group(isl1208->rtc, &isl1208_rtc_sysfs_files); in isl1208_probe()
883 if (client->irq > 0) in isl1208_probe()
884 rc = isl1208_setup_irq(client, client->irq); in isl1208_probe()
888 if (evdet_irq > 0 && evdet_irq != client->irq) in isl1208_probe()
893 rc = rtc_nvmem_register(isl1208->rtc, &isl1208->nvmem_config); in isl1208_probe()
897 return rtc_register_device(isl1208->rtc); in isl1208_probe()
902 .name = "rtc-isl1208",