Lines Matching +full:reg +full:- +full:offset

7  * SPDX-License-Identifier:	GPL-2.0+
12 * but also supports setting the time, using an offset from the current
14 * time-keeping. It does not change the system time.
34 * struct sandbox_i2c_rtc_plat_data - platform data for the RTC
37 * @offset: RTC offset from current system time
39 * @reg: Register values
43 long offset; member
45 u8 reg[REG_COUNT]; member
53 int offset) in sandbox_i2c_rtc_set_offset() argument
58 old_offset = plat->offset; in sandbox_i2c_rtc_set_offset()
59 plat->use_system_time = use_system_time; in sandbox_i2c_rtc_set_offset()
60 if (offset != -1) in sandbox_i2c_rtc_set_offset()
61 plat->offset = offset; in sandbox_i2c_rtc_set_offset()
71 old_base_time = plat->base_time; in sandbox_i2c_rtc_get_set_base_time()
72 if (base_time != -1) in sandbox_i2c_rtc_get_set_base_time()
73 plat->base_time = base_time; in sandbox_i2c_rtc_get_set_base_time()
84 plat->base_time = rtc_mktime(&now); in reset_time()
85 plat->offset = 0; in reset_time()
86 plat->use_system_time = true; in reset_time()
95 if (plat->use_system_time) { in sandbox_i2c_rtc_get()
99 now = plat->base_time; in sandbox_i2c_rtc_get()
102 return rtc_to_tm(now + plat->offset, time); in sandbox_i2c_rtc_get()
111 if (plat->use_system_time) { in sandbox_i2c_rtc_set()
115 now = plat->base_time; in sandbox_i2c_rtc_set()
117 plat->offset = rtc_mktime(time) - now; in sandbox_i2c_rtc_set()
133 plat->reg[REG_SEC] = time.tm_sec; in sandbox_i2c_rtc_prepare_read()
134 plat->reg[REG_MIN] = time.tm_min; in sandbox_i2c_rtc_prepare_read()
135 plat->reg[REG_HOUR] = time.tm_hour; in sandbox_i2c_rtc_prepare_read()
136 plat->reg[REG_MDAY] = time.tm_mday; in sandbox_i2c_rtc_prepare_read()
137 plat->reg[REG_MON] = time.tm_mon; in sandbox_i2c_rtc_prepare_read()
138 plat->reg[REG_YEAR] = time.tm_year - 1900; in sandbox_i2c_rtc_prepare_read()
139 plat->reg[REG_WDAY] = time.tm_wday; in sandbox_i2c_rtc_prepare_read()
150 time.tm_sec = plat->reg[REG_SEC]; in sandbox_i2c_rtc_complete_write()
151 time.tm_min = plat->reg[REG_MIN]; in sandbox_i2c_rtc_complete_write()
152 time.tm_hour = plat->reg[REG_HOUR]; in sandbox_i2c_rtc_complete_write()
153 time.tm_mday = plat->reg[REG_MDAY]; in sandbox_i2c_rtc_complete_write()
154 time.tm_mon = plat->reg[REG_MON]; in sandbox_i2c_rtc_complete_write()
155 time.tm_year = plat->reg[REG_YEAR] + 1900; in sandbox_i2c_rtc_complete_write()
156 time.tm_wday = plat->reg[REG_WDAY]; in sandbox_i2c_rtc_complete_write()
169 uint offset = 0; in sandbox_i2c_rtc_xfer() local
176 for (; nmsgs > 0; nmsgs--, msg++) { in sandbox_i2c_rtc_xfer()
180 len = msg->len; in sandbox_i2c_rtc_xfer()
181 debug(" %s: msg->len=%d", in sandbox_i2c_rtc_xfer()
182 msg->flags & I2C_M_RD ? "read" : "write", in sandbox_i2c_rtc_xfer()
183 msg->len); in sandbox_i2c_rtc_xfer()
184 if (msg->flags & I2C_M_RD) { in sandbox_i2c_rtc_xfer()
185 debug(", offset %x, len %x: ", offset, len); in sandbox_i2c_rtc_xfer()
188 memcpy(msg->buf, plat->reg + offset, len); in sandbox_i2c_rtc_xfer()
189 memset(msg->buf + len, '\xff', msg->len - len); in sandbox_i2c_rtc_xfer()
190 debug_buffer(0, msg->buf, 1, msg->len, 0); in sandbox_i2c_rtc_xfer()
192 ptr = msg->buf; in sandbox_i2c_rtc_xfer()
193 offset = *ptr++ & (REG_COUNT - 1); in sandbox_i2c_rtc_xfer()
194 len--; in sandbox_i2c_rtc_xfer()
195 debug(", set offset %x: ", offset); in sandbox_i2c_rtc_xfer()
196 debug_buffer(0, msg->buf, 1, msg->len, 0); in sandbox_i2c_rtc_xfer()
199 memcpy(plat->reg + offset, ptr, len); in sandbox_i2c_rtc_xfer()
200 if (offset == REG_RESET) in sandbox_i2c_rtc_xfer()
223 { .compatible = "sandbox,i2c-rtc" },