Lines Matching +full:write +full:- +full:protect
1 // SPDX-License-Identifier: GPL-2.0-only
21 #define MAX6900_REG_SC 0 /* seconds 00-59 */
22 #define MAX6900_REG_MN 1 /* minutes 00-59 */
23 #define MAX6900_REG_HR 2 /* hours 00-23 */
24 #define MAX6900_REG_DT 3 /* day of month 00-31 */
25 #define MAX6900_REG_MO 4 /* month 01-12 */
26 #define MAX6900_REG_DW 5 /* day of week 1-7 */
27 #define MAX6900_REG_YR 6 /* year 00-99 */
35 #define MAX6900_REG_CT_WP (1 << 7) /* Write Protect */
38 * register read/write commands
57 .addr = client->addr, in max6900_i2c_read_regs()
58 .flags = 0, /* write */ in max6900_i2c_read_regs()
63 .addr = client->addr, in max6900_i2c_read_regs()
69 .addr = client->addr, in max6900_i2c_read_regs()
70 .flags = 0, /* write */ in max6900_i2c_read_regs()
75 .addr = client->addr, in max6900_i2c_read_regs()
83 rc = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); in max6900_i2c_read_regs()
85 dev_err(&client->dev, "%s: register read failed\n", __func__); in max6900_i2c_read_regs()
86 return -EIO; in max6900_i2c_read_regs()
96 .addr = client->addr, in max6900_i2c_write_regs()
97 .flags = 0, /* write */ in max6900_i2c_write_regs()
104 .addr = client->addr, in max6900_i2c_write_regs()
105 .flags = 0, /* write */ in max6900_i2c_write_regs()
113 * the need to delay after each write to the chip. Also, in max6900_i2c_write_regs()
114 * we write the century byte first, since we set the write-protect in max6900_i2c_write_regs()
115 * bit as part of the burst write. in max6900_i2c_write_regs()
119 rc = i2c_transfer(client->adapter, century_msgs, in max6900_i2c_write_regs()
128 rc = i2c_transfer(client->adapter, burst_msgs, ARRAY_SIZE(burst_msgs)); in max6900_i2c_write_regs()
136 dev_err(&client->dev, "%s: register write failed\n", __func__); in max6900_i2c_write_regs()
137 return -EIO; in max6900_i2c_write_regs()
150 tm->tm_sec = bcd2bin(regs[MAX6900_REG_SC]); in max6900_rtc_read_time()
151 tm->tm_min = bcd2bin(regs[MAX6900_REG_MN]); in max6900_rtc_read_time()
152 tm->tm_hour = bcd2bin(regs[MAX6900_REG_HR] & 0x3f); in max6900_rtc_read_time()
153 tm->tm_mday = bcd2bin(regs[MAX6900_REG_DT]); in max6900_rtc_read_time()
154 tm->tm_mon = bcd2bin(regs[MAX6900_REG_MO]) - 1; in max6900_rtc_read_time()
155 tm->tm_year = bcd2bin(regs[MAX6900_REG_YR]) + in max6900_rtc_read_time()
156 bcd2bin(regs[MAX6900_REG_CENTURY]) * 100 - 1900; in max6900_rtc_read_time()
157 tm->tm_wday = bcd2bin(regs[MAX6900_REG_DW]); in max6900_rtc_read_time()
177 regs[MAX6900_REG_SC] = bin2bcd(tm->tm_sec); in max6900_rtc_set_time()
178 regs[MAX6900_REG_MN] = bin2bcd(tm->tm_min); in max6900_rtc_set_time()
179 regs[MAX6900_REG_HR] = bin2bcd(tm->tm_hour); in max6900_rtc_set_time()
180 regs[MAX6900_REG_DT] = bin2bcd(tm->tm_mday); in max6900_rtc_set_time()
181 regs[MAX6900_REG_MO] = bin2bcd(tm->tm_mon + 1); in max6900_rtc_set_time()
182 regs[MAX6900_REG_DW] = bin2bcd(tm->tm_wday); in max6900_rtc_set_time()
183 regs[MAX6900_REG_YR] = bin2bcd(tm->tm_year % 100); in max6900_rtc_set_time()
184 regs[MAX6900_REG_CENTURY] = bin2bcd((tm->tm_year + 1900) / 100); in max6900_rtc_set_time()
185 /* set write protect */ in max6900_rtc_set_time()
204 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) in max6900_probe()
205 return -ENODEV; in max6900_probe()
207 rtc = devm_rtc_device_register(&client->dev, max6900_driver.driver.name, in max6900_probe()
225 .name = "rtc-max6900",