Lines Matching +full:- +full:- +full:trim +full:- +full:-

1 // SPDX-License-Identifier: GPL-2.0-only
85 * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch
97 .addr = client->addr, in x1205_get_datetime()
102 .addr = client->addr, in x1205_get_datetime()
110 if (i2c_transfer(client->adapter, &msgs[0], 2) != 2) { in x1205_get_datetime()
111 dev_err(&client->dev, "%s: read error\n", __func__); in x1205_get_datetime()
112 return -EIO; in x1205_get_datetime()
115 dev_dbg(&client->dev, in x1205_get_datetime()
116 "%s: raw read data - sec=%02x, min=%02x, hr=%02x, " in x1205_get_datetime()
127 tm->tm_sec = bcd2bin(buf[CCR_SEC]); in x1205_get_datetime()
128 tm->tm_min = bcd2bin(buf[CCR_MIN]); in x1205_get_datetime()
129 tm->tm_hour = bcd2bin(buf[CCR_HOUR] & 0x3F); /* hr is 0-23 */ in x1205_get_datetime()
130 tm->tm_mday = bcd2bin(buf[CCR_MDAY]); in x1205_get_datetime()
131 tm->tm_mon = bcd2bin(buf[CCR_MONTH]) - 1; /* mon is 0-11 */ in x1205_get_datetime()
132 tm->tm_year = bcd2bin(buf[CCR_YEAR]) in x1205_get_datetime()
133 + (bcd2bin(buf[CCR_Y2K]) * 100) - 1900; in x1205_get_datetime()
134 tm->tm_wday = buf[CCR_WDAY]; in x1205_get_datetime()
136 dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " in x1205_get_datetime()
139 tm->tm_sec, tm->tm_min, tm->tm_hour, in x1205_get_datetime()
140 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); in x1205_get_datetime()
151 .addr = client->addr, in x1205_get_status()
156 .addr = client->addr, in x1205_get_status()
164 if (i2c_transfer(client->adapter, &msgs[0], 2) != 2) { in x1205_get_status()
165 dev_err(&client->dev, "%s: read error\n", __func__); in x1205_get_status()
166 return -EIO; in x1205_get_status()
187 dev_dbg(&client->dev, in x1205_set_datetime()
189 __func__, tm->tm_sec, tm->tm_min, tm->tm_hour, tm->tm_mday, in x1205_set_datetime()
190 tm->tm_mon, tm->tm_year, tm->tm_wday); in x1205_set_datetime()
192 buf[CCR_SEC] = bin2bcd(tm->tm_sec); in x1205_set_datetime()
193 buf[CCR_MIN] = bin2bcd(tm->tm_min); in x1205_set_datetime()
196 buf[CCR_HOUR] = bin2bcd(tm->tm_hour) | X1205_HR_MIL; in x1205_set_datetime()
198 buf[CCR_MDAY] = bin2bcd(tm->tm_mday); in x1205_set_datetime()
200 /* month, 1 - 12 */ in x1205_set_datetime()
201 buf[CCR_MONTH] = bin2bcd(tm->tm_mon + 1); in x1205_set_datetime()
204 buf[CCR_YEAR] = bin2bcd(tm->tm_year % 100); in x1205_set_datetime()
205 buf[CCR_WDAY] = tm->tm_wday & 0x07; in x1205_set_datetime()
206 buf[CCR_Y2K] = bin2bcd((tm->tm_year + 1900) / 100); in x1205_set_datetime()
208 /* If writing alarm registers, set compare bits on registers 0-4 */ in x1205_set_datetime()
216 dev_err(&client->dev, "%s: wel - %d\n", __func__, xfer); in x1205_set_datetime()
217 return -EIO; in x1205_set_datetime()
222 dev_err(&client->dev, "%s: rwel - %d\n", __func__, xfer); in x1205_set_datetime()
223 return -EIO; in x1205_set_datetime()
228 dev_err(&client->dev, in x1205_set_datetime()
232 return -EIO; in x1205_set_datetime()
246 dev_err(&client->dev, in x1205_set_datetime()
247 "%s: aloe rwel - %d\n", in x1205_set_datetime()
250 return -EIO; in x1205_set_datetime()
258 dev_err(&client->dev, in x1205_set_datetime()
259 "%s: al0e - %d\n", in x1205_set_datetime()
262 return -EIO; in x1205_set_datetime()
272 dev_err(&client->dev, "%s: diswe - %d\n", __func__, xfer); in x1205_set_datetime()
273 return -EIO; in x1205_set_datetime()
288 dev_err(&client->dev, "unable to restart the oscillator\n"); in x1205_fix_osc()
293 static int x1205_get_dtrim(struct i2c_client *client, int *trim) in x1205_get_dtrim() argument
300 .addr = client->addr, in x1205_get_dtrim()
305 .addr = client->addr, in x1205_get_dtrim()
313 if (i2c_transfer(client->adapter, &msgs[0], 2) != 2) { in x1205_get_dtrim()
314 dev_err(&client->dev, "%s: read error\n", __func__); in x1205_get_dtrim()
315 return -EIO; in x1205_get_dtrim()
318 dev_dbg(&client->dev, "%s: raw dtr=%x\n", __func__, dtr); in x1205_get_dtrim()
320 *trim = 0; in x1205_get_dtrim()
323 *trim += 20; in x1205_get_dtrim()
326 *trim += 10; in x1205_get_dtrim()
329 *trim = -*trim; in x1205_get_dtrim()
334 static int x1205_get_atrim(struct i2c_client *client, int *trim) in x1205_get_atrim() argument
341 .addr = client->addr, in x1205_get_atrim()
346 .addr = client->addr, in x1205_get_atrim()
354 if (i2c_transfer(client->adapter, &msgs[0], 2) != 2) { in x1205_get_atrim()
355 dev_err(&client->dev, "%s: read error\n", __func__); in x1205_get_atrim()
356 return -EIO; in x1205_get_atrim()
359 dev_dbg(&client->dev, "%s: raw atr=%x\n", __func__, atr); in x1205_get_atrim()
367 dev_dbg(&client->dev, "%s: raw atr=%x (%d)\n", __func__, atr, atr); in x1205_get_atrim()
369 *trim = (atr * 250) + 11000; in x1205_get_atrim()
371 dev_dbg(&client->dev, "%s: real=%d\n", __func__, *trim); in x1205_get_atrim()
418 .addr = client->addr, in x1205_validate_client()
423 .addr = client->addr, in x1205_validate_client()
430 xfer = i2c_transfer(client->adapter, msgs, 2); in x1205_validate_client()
432 dev_err(&client->dev, in x1205_validate_client()
436 return -EIO; in x1205_validate_client()
440 dev_err(&client->dev, in x1205_validate_client()
444 return -ENODEV; in x1205_validate_client()
456 .addr = client->addr, in x1205_validate_client()
461 .addr = client->addr, in x1205_validate_client()
468 xfer = i2c_transfer(client->adapter, msgs, 2); in x1205_validate_client()
470 dev_err(&client->dev, in x1205_validate_client()
474 return -EIO; in x1205_validate_client()
481 dev_dbg(&client->dev, in x1205_validate_client()
486 return -ENODEV; in x1205_validate_client()
501 .addr = client->addr, in x1205_rtc_read_alarm()
507 .addr = client->addr, in x1205_rtc_read_alarm()
515 if (i2c_transfer(client->adapter, &msgs[0], 2) != 2) { in x1205_rtc_read_alarm()
516 dev_err(&client->dev, "%s: read error\n", __func__); in x1205_rtc_read_alarm()
517 return -EIO; in x1205_rtc_read_alarm()
521 alrm->pending = (status & X1205_SR_AL0) ? 1 : 0; in x1205_rtc_read_alarm()
522 alrm->enabled = (intreg & X1205_INT_AL0E) ? 1 : 0; in x1205_rtc_read_alarm()
523 err = x1205_get_datetime(client, &alrm->time, X1205_ALM0_BASE); in x1205_rtc_read_alarm()
531 &alrm->time, X1205_ALM0_BASE, alrm->enabled); in x1205_rtc_set_alarm()
624 dev_dbg(&client->dev, "%s\n", __func__); in x1205_probe()
626 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) in x1205_probe()
627 return -ENODEV; in x1205_probe()
630 return -ENODEV; in x1205_probe()
632 rtc = devm_rtc_device_register(&client->dev, x1205_driver.driver.name, in x1205_probe()
644 dev_err(&client->dev, in x1205_probe()
651 dev_err(&client->dev, "couldn't read status\n"); in x1205_probe()
654 err = x1205_sysfs_register(&client->dev); in x1205_probe()
656 dev_err(&client->dev, "Unable to create sysfs entries\n"); in x1205_probe()
663 x1205_sysfs_unregister(&client->dev); in x1205_remove()
681 .name = "rtc-x1205",