Lines Matching +full:trickle +full:- +full:diode +full:- +full:disable

1 // SPDX-License-Identifier: GPL-2.0-only
3 * rtc-ds1390.c -- driver for the Dallas/Maxim DS1390/93/94 SPI RTC
10 * (alarms, trickle charger, different control registers) are unavailable.
74 return -EINVAL; in ds1390_get_reg()
77 chip->txrx_buf[0] = address & 0x7f; in ds1390_get_reg()
79 status = spi_write_then_read(spi, chip->txrx_buf, 1, chip->txrx_buf, 1); in ds1390_get_reg()
83 *data = chip->txrx_buf[0]; in ds1390_get_reg()
93 if (of_property_read_u32(spi->dev.of_node, "trickle-resistor-ohms", in ds1390_trickle_of_init()
99 if (of_property_read_bool(spi->dev.of_node, "trickle-diode-disable")) in ds1390_trickle_of_init()
116 dev_warn(&spi->dev, in ds1390_trickle_of_init()
121 ds1390_set_reg(&spi->dev, DS1390_REG_TRICKLE, value); in ds1390_trickle_of_init()
134 chip->txrx_buf[0] = DS1390_REG_SECONDS; in ds1390_read_time()
137 status = spi_write_then_read(spi, chip->txrx_buf, 1, chip->txrx_buf, 8); in ds1390_read_time()
143 dt->tm_sec = bcd2bin(chip->txrx_buf[0]); in ds1390_read_time()
144 dt->tm_min = bcd2bin(chip->txrx_buf[1]); in ds1390_read_time()
145 dt->tm_hour = bcd2bin(chip->txrx_buf[2]); in ds1390_read_time()
146 dt->tm_wday = bcd2bin(chip->txrx_buf[3]); in ds1390_read_time()
147 dt->tm_mday = bcd2bin(chip->txrx_buf[4]); in ds1390_read_time()
149 dt->tm_mon = bcd2bin(chip->txrx_buf[5] & 0x7f) - 1; in ds1390_read_time()
151 dt->tm_year = bcd2bin(chip->txrx_buf[6]) + ((chip->txrx_buf[5] & 0x80) ? 100 : 0); in ds1390_read_time()
162 chip->txrx_buf[0] = DS1390_REG_SECONDS | 0x80; in ds1390_set_time()
163 chip->txrx_buf[1] = bin2bcd(dt->tm_sec); in ds1390_set_time()
164 chip->txrx_buf[2] = bin2bcd(dt->tm_min); in ds1390_set_time()
165 chip->txrx_buf[3] = bin2bcd(dt->tm_hour); in ds1390_set_time()
166 chip->txrx_buf[4] = bin2bcd(dt->tm_wday); in ds1390_set_time()
167 chip->txrx_buf[5] = bin2bcd(dt->tm_mday); in ds1390_set_time()
168 chip->txrx_buf[6] = bin2bcd(dt->tm_mon + 1) | in ds1390_set_time()
169 ((dt->tm_year > 99) ? 0x80 : 0x00); in ds1390_set_time()
170 chip->txrx_buf[7] = bin2bcd(dt->tm_year % 100); in ds1390_set_time()
173 return spi_write_then_read(spi, chip->txrx_buf, 8, NULL, 0); in ds1390_set_time()
187 spi->mode = SPI_MODE_3; in ds1390_probe()
188 spi->bits_per_word = 8; in ds1390_probe()
191 chip = devm_kzalloc(&spi->dev, sizeof(*chip), GFP_KERNEL); in ds1390_probe()
193 return -ENOMEM; in ds1390_probe()
197 res = ds1390_get_reg(&spi->dev, DS1390_REG_SECONDS, &tmp); in ds1390_probe()
199 dev_err(&spi->dev, "unable to read device\n"); in ds1390_probe()
203 if (spi->dev.of_node) in ds1390_probe()
206 chip->rtc = devm_rtc_device_register(&spi->dev, "ds1390", in ds1390_probe()
208 if (IS_ERR(chip->rtc)) { in ds1390_probe()
209 dev_err(&spi->dev, "unable to register device\n"); in ds1390_probe()
210 res = PTR_ERR(chip->rtc); in ds1390_probe()
230 .name = "rtc-ds1390",
242 MODULE_ALIAS("spi:rtc-ds1390");