ds1305
struct ds1305 *ds1305 = dev_get_drvdata(dev);
buf[1] = ds1305->ctrl[0];
if (ds1305->ctrl[0] & DS1305_AEI0)
err = spi_write_then_read(ds1305->spi, buf, sizeof(buf), NULL, 0);
ds1305->ctrl[0] = buf[1];
struct ds1305 *ds1305 = dev_get_drvdata(dev);
status = spi_write_then_read(ds1305->spi, &addr, sizeof(addr),
struct ds1305 *ds1305 = dev_get_drvdata(dev);
*bp++ = hour2bcd(ds1305->hr12, time->tm_hour);
return spi_write_then_read(ds1305->spi, buf, sizeof(buf),
struct ds1305 *ds1305 = dev_get_drvdata(dev);
struct spi_device *spi = ds1305->spi;
ds1305->ctrl, sizeof(ds1305->ctrl));
alm->enabled = !!(ds1305->ctrl[0] & DS1305_AEI0);
alm->pending = !!(ds1305->ctrl[1] & DS1305_AEI0);
struct ds1305 *ds1305 = dev_get_drvdata(dev);
struct spi_device *spi = ds1305->spi;
if ((later - now) > ds1305->rtc->alarm_offset_max)
if (ds1305->ctrl[0] & DS1305_AEI0) {
ds1305->ctrl[0] &= ~DS1305_AEI0;
buf[1] = ds1305->ctrl[0];
status = spi_write_then_read(ds1305->spi, buf, 2, NULL, 0);
buf[1 + DS1305_HOUR] = hour2bcd(ds1305->hr12, alm->time.tm_hour);
ds1305->ctrl[0] |= DS1305_AEI0;
buf[1] = ds1305->ctrl[0];
status = spi_write_then_read(ds1305->spi, buf, 2, NULL, 0);
struct ds1305 *ds1305 = dev_get_drvdata(dev);
if ((ds1305->ctrl[2] & 0xf0) == DS1305_TRICKLE_MAGIC) {
switch (ds1305->ctrl[2] & 0x0c) {
switch (ds1305->ctrl[2] & 0x03) {
struct ds1305 *ds1305 = container_of(work, struct ds1305, work);
struct spi_device *spi = ds1305->spi;
rtc_lock(ds1305->rtc);
ds1305->ctrl[0] &= ~(DS1305_AEI1 | DS1305_AEI0);
ds1305->ctrl[1] = 0;
buf[1] = ds1305->ctrl[0];
rtc_unlock(ds1305->rtc);
if (!test_bit(FLAG_EXITING, &ds1305->flags))
rtc_update_irq(ds1305->rtc, 1, RTC_AF | RTC_IRQF);
struct ds1305 *ds1305 = p;
schedule_work(&ds1305->work);
struct ds1305 *ds1305 = priv;
struct spi_device *spi = ds1305->spi;
struct ds1305 *ds1305 = priv;
struct spi_device *spi = ds1305->spi;
struct ds1305 *ds1305;
ds1305 = devm_kzalloc(&spi->dev, sizeof(*ds1305), GFP_KERNEL);
if (!ds1305)
ds1305->spi = spi;
spi_set_drvdata(spi, ds1305);
ds1305->ctrl, sizeof(ds1305->ctrl));
dev_dbg(&spi->dev, "ctrl %s: %3ph\n", "read", ds1305->ctrl);
if ((ds1305->ctrl[0] & 0x38) != 0 || (ds1305->ctrl[1] & 0xfc) != 0) {
if (ds1305->ctrl[2] == 0)
if (ds1305->ctrl[0] & DS1305_WP) {
ds1305->ctrl[0] &= ~DS1305_WP;
buf[1] = ds1305->ctrl[0];
if (ds1305->ctrl[0] & DS1305_nEOSC) {
ds1305->ctrl[0] &= ~DS1305_nEOSC;
if (ds1305->ctrl[1]) {
ds1305->ctrl[1] = 0;
if (((ds1305->ctrl[2] & 0xf0) != DS1305_TRICKLE_MAGIC)) {
ds1305->ctrl[2] = DS1305_TRICKLE_MAGIC
if (!(ds1305->ctrl[0] & DS1306_1HZ)) {
ds1305->ctrl[0] |= DS1306_1HZ;
if (ds1305->ctrl[0] & DS1306_1HZ) {
ds1305->ctrl[0] &= ~DS1306_1HZ;
buf[1] = ds1305->ctrl[0];
buf[2] = ds1305->ctrl[1];
buf[3] = ds1305->ctrl[2];
dev_dbg(&spi->dev, "ctrl %s: %3ph\n", "write", ds1305->ctrl);
ds1305->hr12 = (DS1305_HR_12 & value) != 0;
if (ds1305->hr12)
ds1305->rtc = devm_rtc_allocate_device(&spi->dev);
if (IS_ERR(ds1305->rtc))
return PTR_ERR(ds1305->rtc);
ds1305->rtc->ops = &ds1305_ops;
ds1305->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
ds1305->rtc->range_max = RTC_TIMESTAMP_END_2099;
ds1305->rtc->alarm_offset_max = 24 * 60 * 60;
ds1305_nvmem_cfg.priv = ds1305;
status = devm_rtc_register_device(ds1305->rtc);
devm_rtc_nvmem_register(ds1305->rtc, &ds1305_nvmem_cfg);
INIT_WORK(&ds1305->work, ds1305_work);
0, dev_name(&ds1305->rtc->dev), ds1305);
struct ds1305 *ds1305 = spi_get_drvdata(spi);
set_bit(FLAG_EXITING, &ds1305->flags);
devm_free_irq(&spi->dev, spi->irq, ds1305);
cancel_work_sync(&ds1305->work);