Lines Matching +full:read +full:- +full:cmd
4 * SPDX-License-Identifier: Apache-2.0
26 #define EEPROM_MB85RSXX_RDSR 0x05U /* Read Status Register */
28 #define EEPROM_MB85RSXX_READ 0x03U /* Read Memory Code */
30 #define EEPROM_MB85RSXX_RDID 0x9FU /* Read Device ID */
31 #define EEPROM_MB85RSXX_FSTRD 0x0BU /* Fast Read Memory Code */
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()
66 uint8_t cmd[4] = {EEPROM_MB85RSXX_READ, 0, 0, 0}; in eeprom_mb85rsxx_read() local
67 uint8_t *paddr = &cmd[1]; in eeprom_mb85rsxx_read()
70 if (offset + len > config->size) { in eeprom_mb85rsxx_read()
71 LOG_ERR("attempt to read past device boundary"); in eeprom_mb85rsxx_read()
72 return -EINVAL; in eeprom_mb85rsxx_read()
85 .buf = cmd, in eeprom_mb85rsxx_read()
86 .len = sizeof(cmd), in eeprom_mb85rsxx_read()
95 .len = sizeof(cmd), 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()
114 LOG_ERR("failed to read FRAM (err %d)", err); in eeprom_mb85rsxx_read()
122 const struct eeprom_mb85rsxx_config *config = dev->config; in eeprom_mb85rsxx_wren()
123 uint8_t cmd = EEPROM_MB85RSXX_WREN; in eeprom_mb85rsxx_wren() local
125 .buf = &cmd, in eeprom_mb85rsxx_wren()
126 .len = sizeof(cmd), 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()
139 uint8_t cmd = EEPROM_MB85RSXX_WRDI; in eeprom_mb85rsxx_wrdi() local
141 .buf = &cmd, in eeprom_mb85rsxx_wrdi()
142 .len = sizeof(cmd), 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()
157 uint8_t cmd[4] = {EEPROM_MB85RSXX_WRITE, 0, 0, 0}; in eeprom_mb85rsxx_write() local
158 uint8_t *paddr = &cmd[1]; 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()
168 return -EINVAL; in eeprom_mb85rsxx_write()
178 .buf = cmd, in eeprom_mb85rsxx_write()
179 .len = sizeof(cmd), in eeprom_mb85rsxx_write()
191 k_mutex_lock(&data->lock, K_FOREVER); 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()
203 k_mutex_unlock(&data->lock); 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()
229 uint8_t cmd = EEPROM_MB85RSXX_RDID; in eeprom_mb85rsxx_rdid() local
233 .buf = &cmd, in eeprom_mb85rsxx_rdid()
234 .len = sizeof(cmd), in eeprom_mb85rsxx_rdid()
243 .len = sizeof(cmd), 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()
259 LOG_ERR("failed to read RDID (err %d)", err); in eeprom_mb85rsxx_rdid()
269 return -EIO; in eeprom_mb85rsxx_rdid()
272 LOG_INF("device ID read successfully: %02X %02X %02X %02X", id[0], id[1], id[2], id[3]); 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()
299 .read = &eeprom_mb85rsxx_read,