Lines Matching refs:ds1305
88 struct ds1305 { struct
145 struct ds1305 *ds1305 = dev_get_drvdata(dev); in ds1305_alarm_irq_enable() local
150 buf[1] = ds1305->ctrl[0]; in ds1305_alarm_irq_enable()
153 if (ds1305->ctrl[0] & DS1305_AEI0) in ds1305_alarm_irq_enable()
161 err = spi_write_then_read(ds1305->spi, buf, sizeof(buf), NULL, 0); in ds1305_alarm_irq_enable()
163 ds1305->ctrl[0] = buf[1]; in ds1305_alarm_irq_enable()
176 struct ds1305 *ds1305 = dev_get_drvdata(dev); in ds1305_get_time() local
184 status = spi_write_then_read(ds1305->spi, &addr, sizeof(addr), in ds1305_get_time()
214 struct ds1305 *ds1305 = dev_get_drvdata(dev); in ds1305_set_time() local
229 *bp++ = hour2bcd(ds1305->hr12, time->tm_hour); in ds1305_set_time()
240 return spi_write_then_read(ds1305->spi, buf, sizeof(buf), in ds1305_set_time()
277 struct ds1305 *ds1305 = dev_get_drvdata(dev); in ds1305_get_alarm() local
278 struct spi_device *spi = ds1305->spi; in ds1305_get_alarm()
290 ds1305->ctrl, sizeof(ds1305->ctrl)); in ds1305_get_alarm()
294 alm->enabled = !!(ds1305->ctrl[0] & DS1305_AEI0); in ds1305_get_alarm()
295 alm->pending = !!(ds1305->ctrl[1] & DS1305_AEI0); in ds1305_get_alarm()
336 struct ds1305 *ds1305 = dev_get_drvdata(dev); in ds1305_set_alarm() local
337 struct spi_device *spi = ds1305->spi; in ds1305_set_alarm()
363 if (ds1305->ctrl[0] & DS1305_AEI0) { in ds1305_set_alarm()
364 ds1305->ctrl[0] &= ~DS1305_AEI0; in ds1305_set_alarm()
367 buf[1] = ds1305->ctrl[0]; in ds1305_set_alarm()
368 status = spi_write_then_read(ds1305->spi, buf, 2, NULL, 0); in ds1305_set_alarm()
377 buf[1 + DS1305_HOUR] = hour2bcd(ds1305->hr12, alm->time.tm_hour); in ds1305_set_alarm()
390 ds1305->ctrl[0] |= DS1305_AEI0; in ds1305_set_alarm()
393 buf[1] = ds1305->ctrl[0]; in ds1305_set_alarm()
394 status = spi_write_then_read(ds1305->spi, buf, 2, NULL, 0); in ds1305_set_alarm()
404 struct ds1305 *ds1305 = dev_get_drvdata(dev); in ds1305_proc() local
409 if ((ds1305->ctrl[2] & 0xf0) == DS1305_TRICKLE_MAGIC) { in ds1305_proc()
410 switch (ds1305->ctrl[2] & 0x0c) { in ds1305_proc()
420 switch (ds1305->ctrl[2] & 0x03) { in ds1305_proc()
457 struct ds1305 *ds1305 = container_of(work, struct ds1305, work); in ds1305_work() local
458 struct mutex *lock = &ds1305->rtc->ops_lock; in ds1305_work()
459 struct spi_device *spi = ds1305->spi; in ds1305_work()
470 ds1305->ctrl[0] &= ~(DS1305_AEI1 | DS1305_AEI0); in ds1305_work()
471 ds1305->ctrl[1] = 0; in ds1305_work()
474 buf[1] = ds1305->ctrl[0]; in ds1305_work()
484 if (!test_bit(FLAG_EXITING, &ds1305->flags)) in ds1305_work()
487 rtc_update_irq(ds1305->rtc, 1, RTC_AF | RTC_IRQF); in ds1305_work()
497 struct ds1305 *ds1305 = p; in ds1305_irq() local
500 schedule_work(&ds1305->work); in ds1305_irq()
588 struct ds1305 *ds1305; in ds1305_probe() local
604 ds1305 = devm_kzalloc(&spi->dev, sizeof(*ds1305), GFP_KERNEL); in ds1305_probe()
605 if (!ds1305) in ds1305_probe()
607 ds1305->spi = spi; in ds1305_probe()
608 spi_set_drvdata(spi, ds1305); in ds1305_probe()
613 ds1305->ctrl, sizeof(ds1305->ctrl)); in ds1305_probe()
620 dev_dbg(&spi->dev, "ctrl %s: %3ph\n", "read", ds1305->ctrl); in ds1305_probe()
627 if ((ds1305->ctrl[0] & 0x38) != 0 || (ds1305->ctrl[1] & 0xfc) != 0) { in ds1305_probe()
631 if (ds1305->ctrl[2] == 0) in ds1305_probe()
637 if (ds1305->ctrl[0] & DS1305_WP) { in ds1305_probe()
640 ds1305->ctrl[0] &= ~DS1305_WP; in ds1305_probe()
643 buf[1] = ds1305->ctrl[0]; in ds1305_probe()
654 if (ds1305->ctrl[0] & DS1305_nEOSC) { in ds1305_probe()
655 ds1305->ctrl[0] &= ~DS1305_nEOSC; in ds1305_probe()
661 if (ds1305->ctrl[1]) { in ds1305_probe()
662 ds1305->ctrl[1] = 0; in ds1305_probe()
669 if (((ds1305->ctrl[2] & 0xf0) != DS1305_TRICKLE_MAGIC)) { in ds1305_probe()
670 ds1305->ctrl[2] = DS1305_TRICKLE_MAGIC in ds1305_probe()
678 if (!(ds1305->ctrl[0] & DS1306_1HZ)) { in ds1305_probe()
679 ds1305->ctrl[0] |= DS1306_1HZ; in ds1305_probe()
683 if (ds1305->ctrl[0] & DS1306_1HZ) { in ds1305_probe()
684 ds1305->ctrl[0] &= ~DS1306_1HZ; in ds1305_probe()
695 buf[1] = ds1305->ctrl[0]; in ds1305_probe()
696 buf[2] = ds1305->ctrl[1]; in ds1305_probe()
697 buf[3] = ds1305->ctrl[2]; in ds1305_probe()
705 dev_dbg(&spi->dev, "ctrl %s: %3ph\n", "write", ds1305->ctrl); in ds1305_probe()
717 ds1305->hr12 = (DS1305_HR_12 & value) != 0; in ds1305_probe()
718 if (ds1305->hr12) in ds1305_probe()
722 ds1305->rtc = devm_rtc_device_register(&spi->dev, "ds1305", in ds1305_probe()
724 if (IS_ERR(ds1305->rtc)) { in ds1305_probe()
725 status = PTR_ERR(ds1305->rtc); in ds1305_probe()
737 INIT_WORK(&ds1305->work, ds1305_work); in ds1305_probe()
739 0, dev_name(&ds1305->rtc->dev), ds1305); in ds1305_probe()
759 struct ds1305 *ds1305 = spi_get_drvdata(spi); in ds1305_remove() local
765 set_bit(FLAG_EXITING, &ds1305->flags); in ds1305_remove()
766 devm_free_irq(&spi->dev, spi->irq, ds1305); in ds1305_remove()
767 cancel_work_sync(&ds1305->work); in ds1305_remove()