Lines Matching +full:mspi +full:- +full:endian

4  * SPDX-License-Identifier: Apache-2.0
14 #include <zephyr/drivers/mspi.h>
114 const struct flash_mspi_atxp032_config *cfg = flash->config; in flash_mspi_atxp032_command_write()
115 struct flash_mspi_atxp032_data *data = flash->data; in flash_mspi_atxp032_command_write()
118 data->packet.dir = MSPI_TX; in flash_mspi_atxp032_command_write()
119 data->packet.cmd = cmd; in flash_mspi_atxp032_command_write()
120 data->packet.address = addr; in flash_mspi_atxp032_command_write()
121 data->packet.data_buf = wdata; in flash_mspi_atxp032_command_write()
122 data->packet.num_bytes = length; in flash_mspi_atxp032_command_write()
124 data->trans.async = false; in flash_mspi_atxp032_command_write()
125 data->trans.xfer_mode = MSPI_PIO; in flash_mspi_atxp032_command_write()
126 data->trans.tx_dummy = tx_dummy; in flash_mspi_atxp032_command_write()
127 data->trans.cmd_length = 1; in flash_mspi_atxp032_command_write()
128 data->trans.addr_length = addr_len; in flash_mspi_atxp032_command_write()
129 data->trans.hold_ce = false; in flash_mspi_atxp032_command_write()
130 data->trans.packets = &data->packet; in flash_mspi_atxp032_command_write()
131 data->trans.num_packet = 1; in flash_mspi_atxp032_command_write()
132 data->trans.timeout = 10; in flash_mspi_atxp032_command_write()
134 ret = mspi_transceive(cfg->bus, &cfg->dev_id, (const struct mspi_xfer *)&data->trans); in flash_mspi_atxp032_command_write()
136 LOG_ERR("MSPI write transaction failed with code: %d/%u", ret, __LINE__); in flash_mspi_atxp032_command_write()
137 return -EIO; in flash_mspi_atxp032_command_write()
146 const struct flash_mspi_atxp032_config *cfg = flash->config; in flash_mspi_atxp032_command_read()
147 struct flash_mspi_atxp032_data *data = flash->data; in flash_mspi_atxp032_command_read()
150 data->packet.dir = MSPI_RX; in flash_mspi_atxp032_command_read()
151 data->packet.cmd = cmd; in flash_mspi_atxp032_command_read()
152 data->packet.address = addr; in flash_mspi_atxp032_command_read()
153 data->packet.data_buf = rdata; in flash_mspi_atxp032_command_read()
154 data->packet.num_bytes = length; in flash_mspi_atxp032_command_read()
156 data->trans.async = false; in flash_mspi_atxp032_command_read()
157 data->trans.xfer_mode = MSPI_PIO; in flash_mspi_atxp032_command_read()
158 data->trans.rx_dummy = rx_dummy; in flash_mspi_atxp032_command_read()
159 data->trans.cmd_length = 1; in flash_mspi_atxp032_command_read()
160 data->trans.addr_length = addr_len; in flash_mspi_atxp032_command_read()
161 data->trans.hold_ce = false; in flash_mspi_atxp032_command_read()
162 data->trans.packets = &data->packet; in flash_mspi_atxp032_command_read()
163 data->trans.num_packet = 1; in flash_mspi_atxp032_command_read()
164 data->trans.timeout = 10; in flash_mspi_atxp032_command_read()
166 ret = mspi_transceive(cfg->bus, &cfg->dev_id, (const struct mspi_xfer *)&data->trans); in flash_mspi_atxp032_command_read()
168 LOG_ERR("MSPI read transaction failed with code: %d/%u", ret, __LINE__); in flash_mspi_atxp032_command_read()
169 return -EIO; in flash_mspi_atxp032_command_read()
176 const struct flash_mspi_atxp032_config *cfg = flash->config; in acquire()
177 struct flash_mspi_atxp032_data *data = flash->data; in acquire()
179 k_sem_take(&data->lock, K_FOREVER); in acquire()
181 if (cfg->sw_multi_periph) { in acquire()
182 while (mspi_dev_config(cfg->bus, &cfg->dev_id, in acquire()
183 MSPI_DEVICE_CONFIG_ALL, &data->dev_cfg)) { in acquire()
187 while (mspi_dev_config(cfg->bus, &cfg->dev_id, in acquire()
196 const struct flash_mspi_atxp032_config *cfg = flash->config; in release()
197 struct flash_mspi_atxp032_data *data = flash->data; in release()
199 while (mspi_get_channel_status(cfg->bus, cfg->port)) { in release()
203 k_sem_give(&data->lock); in release()
251 struct flash_mspi_atxp032_data *data = flash->data; in flash_mspi_atxp032_get_vendor_id()
256 return -EINVAL; in flash_mspi_atxp032_get_vendor_id()
264 data->jedec_id = (buffer[7] << 16) | (buffer[8] << 8) | buffer[9]; in flash_mspi_atxp032_get_vendor_id()
316 const struct flash_mspi_atxp032_config *cfg = flash->config; in flash_mspi_atxp032_page_program()
317 struct flash_mspi_atxp032_data *data = flash->data; in flash_mspi_atxp032_page_program()
320 data->packet.dir = MSPI_TX; in flash_mspi_atxp032_page_program()
321 data->packet.cmd = data->dev_cfg.write_cmd; in flash_mspi_atxp032_page_program()
322 data->packet.address = offset; in flash_mspi_atxp032_page_program()
323 data->packet.data_buf = wdata; in flash_mspi_atxp032_page_program()
324 data->packet.num_bytes = len; in flash_mspi_atxp032_page_program()
326 data->trans.async = false; in flash_mspi_atxp032_page_program()
327 data->trans.xfer_mode = MSPI_DMA; in flash_mspi_atxp032_page_program()
328 data->trans.tx_dummy = data->dev_cfg.tx_dummy; in flash_mspi_atxp032_page_program()
329 data->trans.cmd_length = data->dev_cfg.cmd_length; in flash_mspi_atxp032_page_program()
330 data->trans.addr_length = data->dev_cfg.addr_length; in flash_mspi_atxp032_page_program()
331 data->trans.hold_ce = false; in flash_mspi_atxp032_page_program()
332 data->trans.priority = 1; in flash_mspi_atxp032_page_program()
333 data->trans.packets = &data->packet; in flash_mspi_atxp032_page_program()
334 data->trans.num_packet = 1; in flash_mspi_atxp032_page_program()
335 data->trans.timeout = CONFIG_MSPI_COMPLETION_TIMEOUT_TOLERANCE; in flash_mspi_atxp032_page_program()
339 ret = mspi_transceive(cfg->bus, &cfg->dev_id, (const struct mspi_xfer *)&data->trans); in flash_mspi_atxp032_page_program()
341 LOG_ERR("MSPI write transaction failed with code: %d/%u", ret, __LINE__); in flash_mspi_atxp032_page_program()
342 return -EIO; in flash_mspi_atxp032_page_program()
349 const struct flash_mspi_atxp032_config *cfg = flash->config; in flash_mspi_atxp032_busy_wait()
350 struct flash_mspi_atxp032_data *data = flash->data; in flash_mspi_atxp032_busy_wait()
351 mspi_timing_cfg bkp = data->timing_cfg; in flash_mspi_atxp032_busy_wait()
357 if (data->dev_cfg.io_mode == MSPI_IO_MODE_SINGLE) { in flash_mspi_atxp032_busy_wait()
361 TIMING_CFG_SET_RX_DUMMY(&data->timing_cfg, 4); in flash_mspi_atxp032_busy_wait()
362 if (mspi_timing_config(cfg->bus, &cfg->dev_id, cfg->timing_cfg_mask, in flash_mspi_atxp032_busy_wait()
363 (void *)&data->timing_cfg)) { in flash_mspi_atxp032_busy_wait()
364 LOG_ERR("Failed to config mspi controller/%u", __LINE__); in flash_mspi_atxp032_busy_wait()
365 return -EIO; in flash_mspi_atxp032_busy_wait()
380 if (data->dev_cfg.io_mode != MSPI_IO_MODE_SINGLE) { in flash_mspi_atxp032_busy_wait()
381 data->timing_cfg = bkp; in flash_mspi_atxp032_busy_wait()
382 if (mspi_timing_config(cfg->bus, &cfg->dev_id, cfg->timing_cfg_mask, in flash_mspi_atxp032_busy_wait()
383 (void *)&data->timing_cfg)) { in flash_mspi_atxp032_busy_wait()
384 LOG_ERR("Failed to config mspi controller/%u", __LINE__); in flash_mspi_atxp032_busy_wait()
385 return -EIO; in flash_mspi_atxp032_busy_wait()
395 const struct flash_mspi_atxp032_config *cfg = flash->config; in flash_mspi_atxp032_read()
396 struct flash_mspi_atxp032_data *data = flash->data; in flash_mspi_atxp032_read()
402 data->packet.dir = MSPI_RX; in flash_mspi_atxp032_read()
403 data->packet.cmd = data->dev_cfg.read_cmd; in flash_mspi_atxp032_read()
404 data->packet.address = offset; in flash_mspi_atxp032_read()
405 data->packet.data_buf = rdata; in flash_mspi_atxp032_read()
406 data->packet.num_bytes = len; in flash_mspi_atxp032_read()
408 data->trans.async = false; in flash_mspi_atxp032_read()
409 data->trans.xfer_mode = MSPI_DMA; in flash_mspi_atxp032_read()
410 data->trans.rx_dummy = data->dev_cfg.rx_dummy; in flash_mspi_atxp032_read()
411 data->trans.cmd_length = data->dev_cfg.cmd_length; in flash_mspi_atxp032_read()
412 data->trans.addr_length = data->dev_cfg.addr_length; in flash_mspi_atxp032_read()
413 data->trans.hold_ce = false; in flash_mspi_atxp032_read()
414 data->trans.priority = 1; in flash_mspi_atxp032_read()
415 data->trans.packets = &data->packet; in flash_mspi_atxp032_read()
416 data->trans.num_packet = 1; in flash_mspi_atxp032_read()
417 data->trans.timeout = CONFIG_MSPI_COMPLETION_TIMEOUT_TOLERANCE; in flash_mspi_atxp032_read()
421 ret = mspi_transceive(cfg->bus, &cfg->dev_id, (const struct mspi_xfer *)&data->trans); in flash_mspi_atxp032_read()
423 LOG_ERR("MSPI read transaction failed with code: %d/%u", ret, __LINE__); in flash_mspi_atxp032_read()
424 return -EIO; in flash_mspi_atxp032_read()
446 i = MIN(SPI_NOR_PAGE_SIZE - (offset % SPI_NOR_PAGE_SIZE), len); in flash_mspi_atxp032_write()
465 len -= i; in flash_mspi_atxp032_write()
480 const struct flash_mspi_atxp032_config *cfg = flash->config; in flash_mspi_atxp032_erase()
491 return -EINVAL; in flash_mspi_atxp032_erase()
496 return -EINVAL; in flash_mspi_atxp032_erase()
499 if ((offset == 0) && (size == cfg->mem_size)) { in flash_mspi_atxp032_erase()
582 const struct flash_mspi_atxp032_config *cfg = flash->config; in flash_mspi_atxp032_get_parameters()
584 return &cfg->flash_param; in flash_mspi_atxp032_get_parameters()
592 const struct flash_mspi_atxp032_config *cfg = flash->config; in flash_mspi_atxp032_pages_layout()
594 *layout = &cfg->page_layout; in flash_mspi_atxp032_pages_layout()
601 const struct flash_mspi_atxp032_config *cfg = flash->config; in flash_mspi_atxp032_init()
602 struct flash_mspi_atxp032_data *data = flash->data; in flash_mspi_atxp032_init()
606 if (!device_is_ready(cfg->bus)) { in flash_mspi_atxp032_init()
608 return -ENODEV; in flash_mspi_atxp032_init()
611 switch (cfg->tar_dev_cfg.io_mode) { in flash_mspi_atxp032_init()
617 LOG_ERR("bus mode %d not supported/%u", cfg->tar_dev_cfg.io_mode, __LINE__); in flash_mspi_atxp032_init()
618 return -EIO; in flash_mspi_atxp032_init()
621 if (mspi_dev_config(cfg->bus, &cfg->dev_id, MSPI_DEVICE_CONFIG_ALL, &cfg->serial_cfg)) { in flash_mspi_atxp032_init()
622 LOG_ERR("Failed to config mspi controller/%u", __LINE__); in flash_mspi_atxp032_init()
623 return -EIO; in flash_mspi_atxp032_init()
625 data->dev_cfg = cfg->serial_cfg; in flash_mspi_atxp032_init()
629 return -EIO; in flash_mspi_atxp032_init()
634 return -EIO; in flash_mspi_atxp032_init()
642 if (atxp032_get_dummy_clk((TIMING_CFG_GET_RX_DUMMY(&cfg->tar_timing_cfg)), &CRB3)) { in flash_mspi_atxp032_init()
643 return -ENOTSUP; in flash_mspi_atxp032_init()
647 return -EIO; in flash_mspi_atxp032_init()
651 return -EIO; in flash_mspi_atxp032_init()
656 if (cfg->tar_dev_cfg.io_mode == MSPI_IO_MODE_QUAD) { in flash_mspi_atxp032_init()
658 } else if (cfg->tar_dev_cfg.io_mode == MSPI_IO_MODE_OCTAL) { in flash_mspi_atxp032_init()
665 return -EIO; in flash_mspi_atxp032_init()
668 return -EIO; in flash_mspi_atxp032_init()
671 if (mspi_dev_config(cfg->bus, &cfg->dev_id, MSPI_DEVICE_CONFIG_ALL, &cfg->tar_dev_cfg)) { in flash_mspi_atxp032_init()
672 LOG_ERR("Failed to config mspi controller/%u", __LINE__); in flash_mspi_atxp032_init()
673 return -EIO; in flash_mspi_atxp032_init()
675 data->dev_cfg = cfg->tar_dev_cfg; in flash_mspi_atxp032_init()
677 if (mspi_timing_config(cfg->bus, &cfg->dev_id, cfg->timing_cfg_mask, in flash_mspi_atxp032_init()
678 (void *)&cfg->tar_timing_cfg)) { in flash_mspi_atxp032_init()
679 LOG_ERR("Failed to config mspi timing/%u", __LINE__); in flash_mspi_atxp032_init()
680 return -EIO; in flash_mspi_atxp032_init()
682 data->timing_cfg = cfg->tar_timing_cfg; in flash_mspi_atxp032_init()
684 if (cfg->tar_xip_cfg.enable) { in flash_mspi_atxp032_init()
685 if (mspi_xip_config(cfg->bus, &cfg->dev_id, &cfg->tar_xip_cfg)) { in flash_mspi_atxp032_init()
687 return -EIO; in flash_mspi_atxp032_init()
689 data->xip_cfg = cfg->tar_xip_cfg; in flash_mspi_atxp032_init()
692 if (cfg->tar_scramble_cfg.enable) { in flash_mspi_atxp032_init()
693 if (mspi_scramble_config(cfg->bus, &cfg->dev_id, &cfg->tar_scramble_cfg)) { in flash_mspi_atxp032_init()
695 return -EIO; in flash_mspi_atxp032_init()
697 data->scramble_cfg = cfg->tar_scramble_cfg; in flash_mspi_atxp032_init()
709 const struct flash_mspi_atxp032_config *cfg = flash->config; in flash_mspi_atxp032_read_sfdp()
710 struct flash_mspi_atxp032_data *data = flash->data; in flash_mspi_atxp032_read_sfdp()
715 data->packet.dir = MSPI_RX; in flash_mspi_atxp032_read_sfdp()
716 data->packet.cmd = 0x5A; in flash_mspi_atxp032_read_sfdp()
717 data->packet.address = addr; in flash_mspi_atxp032_read_sfdp()
718 data->packet.data_buf = rdata; in flash_mspi_atxp032_read_sfdp()
719 data->packet.num_bytes = size; in flash_mspi_atxp032_read_sfdp()
721 data->trans.async = false; in flash_mspi_atxp032_read_sfdp()
722 data->trans.xfer_mode = MSPI_DMA; in flash_mspi_atxp032_read_sfdp()
723 data->trans.rx_dummy = 8; in flash_mspi_atxp032_read_sfdp()
724 data->trans.cmd_length = 1; in flash_mspi_atxp032_read_sfdp()
725 data->trans.addr_length = 3; in flash_mspi_atxp032_read_sfdp()
726 data->trans.hold_ce = false; in flash_mspi_atxp032_read_sfdp()
727 data->trans.priority = 1; in flash_mspi_atxp032_read_sfdp()
728 data->trans.packets = &data->packet; in flash_mspi_atxp032_read_sfdp()
729 data->trans.num_packet = 1; in flash_mspi_atxp032_read_sfdp()
730 data->trans.timeout = CONFIG_MSPI_COMPLETION_TIMEOUT_TOLERANCE; in flash_mspi_atxp032_read_sfdp()
734 ret = mspi_transceive(cfg->bus, &cfg->dev_id, (const struct mspi_xfer *)&data->trans); in flash_mspi_atxp032_read_sfdp()
737 LOG_ERR("MSPI read transaction failed with code: %d/%u", ret, __LINE__); in flash_mspi_atxp032_read_sfdp()
738 return -EIO; in flash_mspi_atxp032_read_sfdp()
746 struct flash_mspi_atxp032_data *data = flash->data; in flash_mspi_atxp032_read_jedec_id()
748 id = &data->jedec_id; in flash_mspi_atxp032_read_jedec_id()
770 return -ENOTSUP; in flash_mspi_atxp032_pm_action()
798 .endian = MSPI_XFER_LITTLE_ENDIAN, \