Lines Matching +full:offset +full:- +full:mode
4 * SPDX-License-Identifier: Apache-2.0
22 /* EEPROM Mode Register */
28 /* EEPROM Execute Register - Transfer size bit position */
31 /* EEPROM Execute Register - Commands */
37 /* EEPROM Execute Register - Address mask */
54 uint32_t mode; member
84 regs->execute = temp; in eeprom_xec_execute_reg_set()
96 *destination_ptr = regs->buffer[count]; in eeprom_xec_data_buffer_read()
112 regs->buffer[count] = *source_ptr; in eeprom_xec_data_buffer_write()
133 sts = XEC_EEPROM_STS_TRANSFER_COMPL & regs->status; in eeprom_xec_wait_transfer_compl()
140 regs->status = XEC_EEPROM_STS_TRANSFER_COMPL; in eeprom_xec_wait_transfer_compl()
155 regs->buffer[0] = 0; in eeprom_xec_wait_write_compl()
158 regs->execute = XEC_EEPROM_EXC_CMD_READ_STS; in eeprom_xec_wait_write_compl()
162 sts = regs->buffer[0] & (XEC_EEPROM_STS_BYTE_WIP | in eeprom_xec_wait_write_compl()
171 uint8_t *buf, size_t len, off_t offset) in eeprom_xec_data_read_32_bytes() argument
174 eeprom_xec_execute_reg_set(regs, len, XEC_EEPROM_EXC_CMD_READ, offset); in eeprom_xec_data_read_32_bytes()
184 uint8_t *buf, size_t len, off_t offset) in eeprom_xec_data_write_32_bytes() argument
189 sz = offset % XEC_EEPROM_PAGE_SIZE; in eeprom_xec_data_write_32_bytes()
195 rem_bytes = (XEC_EEPROM_PAGE_SIZE - sz); in eeprom_xec_data_write_32_bytes()
201 XEC_EEPROM_EXC_CMD_WRITE, offset); in eeprom_xec_data_write_32_bytes()
207 offset += rem_bytes; in eeprom_xec_data_write_32_bytes()
209 len = (len - rem_bytes); in eeprom_xec_data_write_32_bytes()
216 eeprom_xec_execute_reg_set(regs, len, XEC_EEPROM_EXC_CMD_WRITE, offset); in eeprom_xec_data_write_32_bytes()
223 static int eeprom_xec_read(const struct device *dev, off_t offset, in eeprom_xec_read() argument
227 const struct eeprom_xec_config *config = dev->config; in eeprom_xec_read()
228 struct eeprom_xec_data * const data = dev->data; in eeprom_xec_read()
229 struct eeprom_xec_regs * const regs = config->regs; in eeprom_xec_read()
238 if ((offset + len) > config->size) { in eeprom_xec_read()
240 return -EINVAL; in eeprom_xec_read()
243 k_mutex_lock(&data->lock_mtx, K_FOREVER); in eeprom_xec_read()
248 if ((len-chunk_idx) < XEC_EEPROM_TRANSFER_SIZE_READ) { in eeprom_xec_read()
249 chunk_size = (len-chunk_idx); in eeprom_xec_read()
252 chunk_size, (offset+chunk_idx)); in eeprom_xec_read()
255 k_mutex_unlock(&data->lock_mtx); in eeprom_xec_read()
260 static int eeprom_xec_write(const struct device *dev, off_t offset, in eeprom_xec_write() argument
263 const struct eeprom_xec_config *config = dev->config; in eeprom_xec_write()
264 struct eeprom_xec_data * const data = dev->data; in eeprom_xec_write()
265 struct eeprom_xec_regs * const regs = config->regs; in eeprom_xec_write()
274 if ((offset + len) > config->size) { in eeprom_xec_write()
276 return -EINVAL; in eeprom_xec_write()
279 k_mutex_lock(&data->lock_mtx, K_FOREVER); in eeprom_xec_write()
284 if ((len-chunk_idx) < XEC_EEPROM_TRANSFER_SIZE_WRITE) { in eeprom_xec_write()
285 chunk_size = (len-chunk_idx); in eeprom_xec_write()
288 chunk_size, (offset+chunk_idx)); in eeprom_xec_write()
292 k_mutex_unlock(&data->lock_mtx); in eeprom_xec_write()
299 const struct eeprom_xec_config *config = dev->config; in eeprom_xec_size()
301 return config->size; in eeprom_xec_size()
307 const struct eeprom_xec_config *const devcfg = dev->config; in eeprom_xec_pm_action()
308 struct eeprom_xec_regs * const regs = devcfg->regs; in eeprom_xec_pm_action()
313 ret = pinctrl_apply_state(devcfg->pcfg, PINCTRL_STATE_DEFAULT); in eeprom_xec_pm_action()
318 regs->mode |= XEC_EEPROM_MODE_ACTIVATE; in eeprom_xec_pm_action()
322 regs->mode &= (~XEC_EEPROM_MODE_ACTIVATE); in eeprom_xec_pm_action()
323 ret = pinctrl_apply_state(devcfg->pcfg, PINCTRL_STATE_SLEEP); in eeprom_xec_pm_action()
324 /* pinctrl-1 does not exist. */ in eeprom_xec_pm_action()
325 if (ret == -ENOENT) { in eeprom_xec_pm_action()
330 ret = -ENOTSUP; in eeprom_xec_pm_action()
339 const struct eeprom_xec_config *config = dev->config; in eeprom_xec_init()
340 struct eeprom_xec_data * const data = dev->data; in eeprom_xec_init()
341 struct eeprom_xec_regs * const regs = config->regs; in eeprom_xec_init()
343 k_mutex_init(&data->lock_mtx); in eeprom_xec_init()
345 int ret = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT); in eeprom_xec_init()
352 regs->mode |= XEC_EEPROM_MODE_ACTIVATE; in eeprom_xec_init()