Lines Matching +full:write +full:- +full:protect
4 * SPDX-License-Identifier: Apache-2.0
24 #define EEPROM_MB85RSXX_WREN 0x06U /* Set Write Enable Latch */
25 #define EEPROM_MB85RSXX_WRDI 0x04U /* Reset Write Enable Latch */
27 #define EEPROM_MB85RSXX_WRSR 0x01U /* Write Status Register */
29 #define EEPROM_MB85RSXX_WRITE 0x02U /* Write Memory Code */
35 #define EEPROM_MB85RSXX_STATUS_WPEN BIT(7) /* Status Register Write Protect (RW) */
38 #define EEPROM_MB85RSXX_STATUS_WEL BIT(1) /* Write Enable Latch (RO) */
64 const struct eeprom_mb85rsxx_config *config = dev->config; in eeprom_mb85rsxx_read()
65 struct eeprom_mb85rsxx_data *data = dev->data; in eeprom_mb85rsxx_read()
70 if (offset + len > config->size) { in eeprom_mb85rsxx_read()
72 return -EINVAL; in eeprom_mb85rsxx_read()
107 k_mutex_lock(&data->lock, K_FOREVER); in eeprom_mb85rsxx_read()
109 err = spi_transceive_dt(&config->spi, &tx, &rx); in eeprom_mb85rsxx_read()
111 k_mutex_unlock(&data->lock); in eeprom_mb85rsxx_read()
122 const struct eeprom_mb85rsxx_config *config = dev->config; in eeprom_mb85rsxx_wren()
133 return spi_write_dt(&config->spi, &tx); in eeprom_mb85rsxx_wren()
138 const struct eeprom_mb85rsxx_config *config = dev->config; in eeprom_mb85rsxx_wrdi()
149 return spi_write_dt(&config->spi, &tx); in eeprom_mb85rsxx_wrdi()
155 const struct eeprom_mb85rsxx_config *config = dev->config; in eeprom_mb85rsxx_write()
156 struct eeprom_mb85rsxx_data *data = dev->data; in eeprom_mb85rsxx_write()
161 if (config->readonly) { in eeprom_mb85rsxx_write()
162 LOG_ERR("attempt to write to read-only device"); in eeprom_mb85rsxx_write()
163 return -EACCES; in eeprom_mb85rsxx_write()
166 if (offset + len > config->size) { in eeprom_mb85rsxx_write()
167 LOG_ERR("attempt to write past device boundary"); in eeprom_mb85rsxx_write()
168 return -EINVAL; in eeprom_mb85rsxx_write()
191 k_mutex_lock(&data->lock, K_FOREVER); in eeprom_mb85rsxx_write()
195 LOG_ERR("failed to disable write protection (err %d)", err); in eeprom_mb85rsxx_write()
196 k_mutex_unlock(&data->lock); in eeprom_mb85rsxx_write()
200 err = spi_write_dt(&config->spi, &tx); in eeprom_mb85rsxx_write()
202 LOG_ERR("failed to write to FRAM (err %d)", err); in eeprom_mb85rsxx_write()
203 k_mutex_unlock(&data->lock); in eeprom_mb85rsxx_write()
209 LOG_ERR("failed to disable write (err %d)", err); in eeprom_mb85rsxx_write()
212 k_mutex_unlock(&data->lock); in eeprom_mb85rsxx_write()
219 const struct eeprom_mb85rsxx_config *config = dev->config; in eeprom_mb85rsxx_size()
221 return config->size; in eeprom_mb85rsxx_size()
226 const struct eeprom_mb85rsxx_config *config = dev->config; in eeprom_mb85rsxx_rdid()
227 struct eeprom_mb85rsxx_data *data = dev->data; in eeprom_mb85rsxx_rdid()
254 k_mutex_lock(&data->lock, K_FOREVER); in eeprom_mb85rsxx_rdid()
255 err = spi_transceive_dt(&config->spi, &tx, &rx); in eeprom_mb85rsxx_rdid()
256 k_mutex_unlock(&data->lock); in eeprom_mb85rsxx_rdid()
269 return -EIO; in eeprom_mb85rsxx_rdid()
278 const struct eeprom_mb85rsxx_config *config = dev->config; in eeprom_mb85rsxx_init()
279 struct eeprom_mb85rsxx_data *data = dev->data; in eeprom_mb85rsxx_init()
282 k_mutex_init(&data->lock); in eeprom_mb85rsxx_init()
284 if (!spi_is_ready_dt(&config->spi)) { in eeprom_mb85rsxx_init()
286 return -EINVAL; in eeprom_mb85rsxx_init()
300 .write = &eeprom_mb85rsxx_write,