Lines Matching refs:ds1305
84 struct ds1305 { struct
141 struct ds1305 *ds1305 = dev_get_drvdata(dev); in ds1305_alarm_irq_enable() local
146 buf[1] = ds1305->ctrl[0]; in ds1305_alarm_irq_enable()
149 if (ds1305->ctrl[0] & DS1305_AEI0) in ds1305_alarm_irq_enable()
157 err = spi_write_then_read(ds1305->spi, buf, sizeof(buf), NULL, 0); in ds1305_alarm_irq_enable()
159 ds1305->ctrl[0] = buf[1]; in ds1305_alarm_irq_enable()
172 struct ds1305 *ds1305 = dev_get_drvdata(dev); in ds1305_get_time() local
180 status = spi_write_then_read(ds1305->spi, &addr, sizeof(addr), in ds1305_get_time()
207 struct ds1305 *ds1305 = dev_get_drvdata(dev); in ds1305_set_time() local
222 *bp++ = hour2bcd(ds1305->hr12, time->tm_hour); in ds1305_set_time()
231 return spi_write_then_read(ds1305->spi, buf, sizeof(buf), in ds1305_set_time()
268 struct ds1305 *ds1305 = dev_get_drvdata(dev); in ds1305_get_alarm() local
269 struct spi_device *spi = ds1305->spi; in ds1305_get_alarm()
281 ds1305->ctrl, sizeof(ds1305->ctrl)); in ds1305_get_alarm()
285 alm->enabled = !!(ds1305->ctrl[0] & DS1305_AEI0); in ds1305_get_alarm()
286 alm->pending = !!(ds1305->ctrl[1] & DS1305_AEI0); in ds1305_get_alarm()
320 struct ds1305 *ds1305 = dev_get_drvdata(dev); in ds1305_set_alarm() local
321 struct spi_device *spi = ds1305->spi; in ds1305_set_alarm()
343 if (ds1305->ctrl[0] & DS1305_AEI0) { in ds1305_set_alarm()
344 ds1305->ctrl[0] &= ~DS1305_AEI0; in ds1305_set_alarm()
347 buf[1] = ds1305->ctrl[0]; in ds1305_set_alarm()
348 status = spi_write_then_read(ds1305->spi, buf, 2, NULL, 0); in ds1305_set_alarm()
357 buf[1 + DS1305_HOUR] = hour2bcd(ds1305->hr12, alm->time.tm_hour); in ds1305_set_alarm()
370 ds1305->ctrl[0] |= DS1305_AEI0; in ds1305_set_alarm()
373 buf[1] = ds1305->ctrl[0]; in ds1305_set_alarm()
374 status = spi_write_then_read(ds1305->spi, buf, 2, NULL, 0); in ds1305_set_alarm()
384 struct ds1305 *ds1305 = dev_get_drvdata(dev); in ds1305_proc() local
389 if ((ds1305->ctrl[2] & 0xf0) == DS1305_TRICKLE_MAGIC) { in ds1305_proc()
390 switch (ds1305->ctrl[2] & 0x0c) { in ds1305_proc()
400 switch (ds1305->ctrl[2] & 0x03) { in ds1305_proc()
437 struct ds1305 *ds1305 = container_of(work, struct ds1305, work); in ds1305_work() local
438 struct mutex *lock = &ds1305->rtc->ops_lock; in ds1305_work()
439 struct spi_device *spi = ds1305->spi; in ds1305_work()
450 ds1305->ctrl[0] &= ~(DS1305_AEI1 | DS1305_AEI0); in ds1305_work()
451 ds1305->ctrl[1] = 0; in ds1305_work()
454 buf[1] = ds1305->ctrl[0]; in ds1305_work()
464 if (!test_bit(FLAG_EXITING, &ds1305->flags)) in ds1305_work()
467 rtc_update_irq(ds1305->rtc, 1, RTC_AF | RTC_IRQF); in ds1305_work()
477 struct ds1305 *ds1305 = p; in ds1305_irq() local
480 schedule_work(&ds1305->work); in ds1305_irq()
511 struct ds1305 *ds1305 = priv; in ds1305_nvram_read() local
512 struct spi_device *spi = ds1305->spi; in ds1305_nvram_read()
526 struct ds1305 *ds1305 = priv; in ds1305_nvram_write() local
527 struct spi_device *spi = ds1305->spi; in ds1305_nvram_write()
546 struct ds1305 *ds1305; in ds1305_probe() local
570 ds1305 = devm_kzalloc(&spi->dev, sizeof(*ds1305), GFP_KERNEL); in ds1305_probe()
571 if (!ds1305) in ds1305_probe()
573 ds1305->spi = spi; in ds1305_probe()
574 spi_set_drvdata(spi, ds1305); in ds1305_probe()
579 ds1305->ctrl, sizeof(ds1305->ctrl)); in ds1305_probe()
586 dev_dbg(&spi->dev, "ctrl %s: %3ph\n", "read", ds1305->ctrl); in ds1305_probe()
593 if ((ds1305->ctrl[0] & 0x38) != 0 || (ds1305->ctrl[1] & 0xfc) != 0) { in ds1305_probe()
597 if (ds1305->ctrl[2] == 0) in ds1305_probe()
603 if (ds1305->ctrl[0] & DS1305_WP) { in ds1305_probe()
606 ds1305->ctrl[0] &= ~DS1305_WP; in ds1305_probe()
609 buf[1] = ds1305->ctrl[0]; in ds1305_probe()
620 if (ds1305->ctrl[0] & DS1305_nEOSC) { in ds1305_probe()
621 ds1305->ctrl[0] &= ~DS1305_nEOSC; in ds1305_probe()
627 if (ds1305->ctrl[1]) { in ds1305_probe()
628 ds1305->ctrl[1] = 0; in ds1305_probe()
635 if (((ds1305->ctrl[2] & 0xf0) != DS1305_TRICKLE_MAGIC)) { in ds1305_probe()
636 ds1305->ctrl[2] = DS1305_TRICKLE_MAGIC in ds1305_probe()
644 if (!(ds1305->ctrl[0] & DS1306_1HZ)) { in ds1305_probe()
645 ds1305->ctrl[0] |= DS1306_1HZ; in ds1305_probe()
649 if (ds1305->ctrl[0] & DS1306_1HZ) { in ds1305_probe()
650 ds1305->ctrl[0] &= ~DS1306_1HZ; in ds1305_probe()
661 buf[1] = ds1305->ctrl[0]; in ds1305_probe()
662 buf[2] = ds1305->ctrl[1]; in ds1305_probe()
663 buf[3] = ds1305->ctrl[2]; in ds1305_probe()
671 dev_dbg(&spi->dev, "ctrl %s: %3ph\n", "write", ds1305->ctrl); in ds1305_probe()
683 ds1305->hr12 = (DS1305_HR_12 & value) != 0; in ds1305_probe()
684 if (ds1305->hr12) in ds1305_probe()
688 ds1305->rtc = devm_rtc_allocate_device(&spi->dev); in ds1305_probe()
689 if (IS_ERR(ds1305->rtc)) in ds1305_probe()
690 return PTR_ERR(ds1305->rtc); in ds1305_probe()
692 ds1305->rtc->ops = &ds1305_ops; in ds1305_probe()
693 ds1305->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; in ds1305_probe()
694 ds1305->rtc->range_max = RTC_TIMESTAMP_END_2099; in ds1305_probe()
696 ds1305_nvmem_cfg.priv = ds1305; in ds1305_probe()
697 ds1305->rtc->nvram_old_abi = true; in ds1305_probe()
698 status = rtc_register_device(ds1305->rtc); in ds1305_probe()
702 rtc_nvmem_register(ds1305->rtc, &ds1305_nvmem_cfg); in ds1305_probe()
711 INIT_WORK(&ds1305->work, ds1305_work); in ds1305_probe()
713 0, dev_name(&ds1305->rtc->dev), ds1305); in ds1305_probe()
727 struct ds1305 *ds1305 = spi_get_drvdata(spi); in ds1305_remove() local
731 set_bit(FLAG_EXITING, &ds1305->flags); in ds1305_remove()
732 devm_free_irq(&spi->dev, spi->irq, ds1305); in ds1305_remove()
733 cancel_work_sync(&ds1305->work); in ds1305_remove()