Lines Matching +full:sfdp +full:- +full:bfp
4 * SPDX-License-Identifier: Apache-2.0
39 read-while-write hazards. This configuration is not recommended."
91 /* 1S-1S-1S flash read command, should be compatible with all SPI nor flashes */
99 /* Install read SFDP command */
107 /* Standard 1S-1S-1S flash write command, can be switched to 1S-1S-4S when QE is set */
155 .port = data->port, in flash_flexspi_nor_read_id_helper()
165 ret = memc_flexspi_transfer(&data->controller, &transfer); in flash_flexspi_nor_read_id_helper()
177 struct flash_flexspi_nor_data *data = dev->data; in flash_flexspi_nor_read_id()
187 .port = data->port, in flash_flexspi_nor_read_status()
197 return memc_flexspi_transfer(&data->controller, &transfer); in flash_flexspi_nor_read_status()
204 .port = data->port, in flash_flexspi_nor_write_enable()
214 return memc_flexspi_transfer(&data->controller, &transfer); in flash_flexspi_nor_write_enable()
222 .port = data->port, in flash_flexspi_nor_erase_sector()
232 return memc_flexspi_transfer(&data->controller, &transfer); in flash_flexspi_nor_erase_sector()
240 .port = data->port, in flash_flexspi_nor_erase_block()
250 return memc_flexspi_transfer(&data->controller, &transfer); in flash_flexspi_nor_erase_block()
257 .port = data->port, in flash_flexspi_nor_erase_chip()
267 return memc_flexspi_transfer(&data->controller, &transfer); in flash_flexspi_nor_erase_chip()
275 .port = data->port, in flash_flexspi_nor_page_program()
285 return memc_flexspi_transfer(&data->controller, &transfer); in flash_flexspi_nor_page_program()
301 if (data->legacy_poll) { in flash_flexspi_nor_wait_bus_busy()
318 struct flash_flexspi_nor_data *data = dev->data; in flash_flexspi_nor_read()
319 uint8_t *src = memc_flexspi_get_ahb_address(&data->controller, in flash_flexspi_nor_read()
320 data->port, in flash_flexspi_nor_read()
331 struct flash_flexspi_nor_data *data = dev->data; in flash_flexspi_nor_write()
337 uint8_t *dst = memc_flexspi_get_ahb_address(&data->controller, in flash_flexspi_nor_write()
338 data->port, in flash_flexspi_nor_write()
341 if (memc_flexspi_is_running_xip(&data->controller)) { in flash_flexspi_nor_write()
348 memc_flexspi_wait_bus_idle(&data->controller); in flash_flexspi_nor_write()
356 i = MIN(SPI_NOR_PAGE_SIZE - (offset % SPI_NOR_PAGE_SIZE), len); in flash_flexspi_nor_write()
363 if (memc_flexspi_is_running_xip(&data->controller)) { in flash_flexspi_nor_write()
364 memc_flexspi_wait_bus_idle(&data->controller); in flash_flexspi_nor_write()
374 memc_flexspi_reset(&data->controller); in flash_flexspi_nor_write()
377 len -= i; in flash_flexspi_nor_write()
380 if (memc_flexspi_is_running_xip(&data->controller)) { in flash_flexspi_nor_write()
395 struct flash_flexspi_nor_data *data = dev->data; in flash_flexspi_nor_erase()
402 uint8_t *dst = memc_flexspi_get_ahb_address(&data->controller, in flash_flexspi_nor_erase()
403 data->port, in flash_flexspi_nor_erase()
408 return -EINVAL; in flash_flexspi_nor_erase()
413 return -EINVAL; in flash_flexspi_nor_erase()
416 if (memc_flexspi_is_running_xip(&data->controller)) { in flash_flexspi_nor_erase()
423 memc_flexspi_wait_bus_idle(&data->controller); in flash_flexspi_nor_erase()
426 if ((offset == 0) && (size == data->config.flashSize * KB(1))) { in flash_flexspi_nor_erase()
430 memc_flexspi_reset(&data->controller); in flash_flexspi_nor_erase()
436 memc_flexspi_reset(&data->controller); in flash_flexspi_nor_erase()
444 memc_flexspi_reset(&data->controller); in flash_flexspi_nor_erase()
449 if (memc_flexspi_is_running_xip(&data->controller)) { in flash_flexspi_nor_erase()
464 struct flash_flexspi_nor_data *data = dev->data; in flash_flexspi_nor_get_parameters()
466 return &data->flash_parameters; in flash_flexspi_nor_get_parameters()
471 struct flash_flexspi_nor_data *data = dev->data; in flash_flexspi_nor_get_size()
473 *size = (uint64_t)data->size; in flash_flexspi_nor_get_size()
482 struct flash_flexspi_nor_data *data = dev->data; in flash_flexspi_nor_pages_layout()
484 *layout = &data->layout; in flash_flexspi_nor_pages_layout()
496 * @return 0 if quad mode was entered, or -ENOTSUP if quad mode is not supported
508 .port = data->port, in flash_flexspi_nor_quad_enable()
595 return -ENOTSUP; in flash_flexspi_nor_quad_enable()
597 ret = memc_flexspi_set_device_config(&data->controller, in flash_flexspi_nor_quad_enable()
601 data->port); in flash_flexspi_nor_quad_enable()
609 ret = memc_flexspi_transfer(&data->controller, &transfer); in flash_flexspi_nor_quad_enable()
626 ret = memc_flexspi_transfer(&data->controller, &transfer); in flash_flexspi_nor_quad_enable()
641 * @return 0 if 4 byte mode was entered, or -ENOTSUP if 4 byte mode was not supported
651 .port = data->port, in flash_flexspi_nor_4byte_enable()
666 return -ENOTSUP; in flash_flexspi_nor_4byte_enable()
675 ret = memc_flexspi_set_device_config(&data->controller, in flash_flexspi_nor_4byte_enable()
679 data->port); in flash_flexspi_nor_4byte_enable()
687 ret = memc_flexspi_transfer(&data->controller, &transfer); in flash_flexspi_nor_4byte_enable()
695 return memc_flexspi_transfer(&data->controller, &transfer); in flash_flexspi_nor_4byte_enable()
702 ret = memc_flexspi_set_device_config(&data->controller, in flash_flexspi_nor_4byte_enable()
706 data->port); in flash_flexspi_nor_4byte_enable()
713 return memc_flexspi_transfer(&data->controller, &transfer); in flash_flexspi_nor_4byte_enable()
719 ret = memc_flexspi_set_device_config(&data->controller, in flash_flexspi_nor_4byte_enable()
723 data->port); in flash_flexspi_nor_4byte_enable()
730 return memc_flexspi_transfer(&data->controller, &transfer); in flash_flexspi_nor_4byte_enable()
733 return -ENOTSUP; in flash_flexspi_nor_4byte_enable()
738 * based on values in SFDP header
740 * @param header: SFDP header for flash
741 * @param bfp: basic flash parameters for flash
747 struct jesd216_bfp *bfp, in flash_flexspi_nor_config_flash() argument
759 ret = jesd216_bfp_decode_dw14(&header->phdr[0], bfp, &dw14); in flash_flexspi_nor_config_flash()
766 data->legacy_poll = false; in flash_flexspi_nor_config_flash()
772 data->legacy_poll = true; in flash_flexspi_nor_config_flash()
778 addr_width = jesd216_bfp_addrbytes(bfp) == in flash_flexspi_nor_config_flash()
782 ret = jesd216_bfp_decode_dw16(&header->phdr[0], bfp, &dw16); in flash_flexspi_nor_config_flash()
802 * Note- enhanced XIP not currently supported, nor is 4-4-4 mode. in flash_flexspi_nor_config_flash()
804 if (jesd216_bfp_read_support(&header->phdr[0], bfp, in flash_flexspi_nor_config_flash()
816 return -ENOTSUP; in flash_flexspi_nor_config_flash()
821 /* Note- we always set mode bits to 0x0 */ in flash_flexspi_nor_config_flash()
828 /* Read 1S-4S-4S enable method */ in flash_flexspi_nor_config_flash()
829 ret = jesd216_bfp_decode_dw15(&header->phdr[0], bfp, &dw15); in flash_flexspi_nor_config_flash()
834 /* Now, install 1S-1S-4S page program command */ in flash_flexspi_nor_config_flash()
846 } else if (jesd216_bfp_read_support(&header->phdr[0], bfp, in flash_flexspi_nor_config_flash()
859 return -ENOTSUP; in flash_flexspi_nor_config_flash()
864 /* Note- we always set mode bits to 0x0 */ in flash_flexspi_nor_config_flash()
871 /* Now, install 1S-1S-2S page program command */ in flash_flexspi_nor_config_flash()
884 /* Helper so we can avoid flash access while performing SFDP probe */
890 .port = dev_data->port, in flash_flexspi_nor_sfdp_read_helper()
898 /* Get SFDP data */ in flash_flexspi_nor_sfdp_read_helper()
899 return memc_flexspi_transfer(&dev_data->controller, &transfer); in flash_flexspi_nor_sfdp_read_helper()
908 struct flash_flexspi_nor_data *dev_data = dev->data; in flash_flexspi_nor_sfdp_read()
924 .port = data->port, in flash_flexspi_nor_is25_clear_read_param()
941 ret = memc_flexspi_set_device_config(&data->controller, in flash_flexspi_nor_is25_clear_read_param()
945 data->port); in flash_flexspi_nor_is25_clear_read_param()
949 return memc_flexspi_transfer(&data->controller, &transfer); in flash_flexspi_nor_is25_clear_read_param()
981 /* Still return an error- we want the JEDEC configuration to run */ in flash_flexspi_nor_check_jedec()
982 return -ENOTSUP; in flash_flexspi_nor_check_jedec()
1001 /* Still return an error- we want the JEDEC configuration to run */ in flash_flexspi_nor_check_jedec()
1002 return -ENOTSUP; in flash_flexspi_nor_check_jedec()
1004 /* W25Q512JV-IQ/IN flash, use 4 byte read/write */ in flash_flexspi_nor_check_jedec()
1012 /* Only 1S-1S-4S page program supported */ in flash_flexspi_nor_check_jedec()
1027 data->legacy_poll = true; in flash_flexspi_nor_check_jedec()
1035 /* W25Q512NW-IQ/IN flash, use 4 byte read/write */ in flash_flexspi_nor_check_jedec()
1043 /* Only 1S-1S-4S page program supported */ in flash_flexspi_nor_check_jedec()
1058 data->legacy_poll = true; in flash_flexspi_nor_check_jedec()
1074 /* Only 1S-4S-4S page program supported */ in flash_flexspi_nor_check_jedec()
1089 data->legacy_poll = true; in flash_flexspi_nor_check_jedec()
1111 /* Update PROGRAM commands for 4 byte 1S-4S-4S mode */ in flash_flexspi_nor_check_jedec()
1126 data->legacy_poll = true; in flash_flexspi_nor_check_jedec()
1130 /* Device has no QE bit, 1-4-4 and 1-1-4 is always enabled */ in flash_flexspi_nor_check_jedec()
1133 return -ENOTSUP; in flash_flexspi_nor_check_jedec()
1137 /* Probe parameters from flash SFDP header, and use them to configure the FlexSPI */
1142 /* Space to store SFDP header and first parameter header */ in flash_flexspi_nor_probe()
1144 struct jesd216_bfp *bfp = (struct jesd216_bfp *)param_buf; in flash_flexspi_nor_probe() local
1156 if (memc_flexspi_is_running_xip(&data->controller)) { in flash_flexspi_nor_probe()
1163 memc_flexspi_wait_bus_idle(&data->controller); in flash_flexspi_nor_probe()
1166 /* SFDP spec requires that we downclock the FlexSPI to 50MHz or less */ in flash_flexspi_nor_probe()
1167 ret = memc_flexspi_update_clock(&data->controller, &config, in flash_flexspi_nor_probe()
1168 data->port, MHZ(50)); in flash_flexspi_nor_probe()
1177 ret = memc_flexspi_set_device_config(&data->controller, &config, in flash_flexspi_nor_probe()
1180 data->port); in flash_flexspi_nor_probe()
1190 /* Flash was supported, SFDP probe not needed */ in flash_flexspi_nor_probe()
1199 LOG_DBG("SFDP header magic: 0x%x", header->magic); in flash_flexspi_nor_probe()
1203 data->legacy_poll = true; in flash_flexspi_nor_probe()
1207 if (header->phdr[0].len_dw > ARRAY_SIZE(param_buf)) { in flash_flexspi_nor_probe()
1209 ret = -ENOBUFS; in flash_flexspi_nor_probe()
1215 jesd216_param_addr(&header->phdr[0]), in flash_flexspi_nor_probe()
1217 sizeof(uint32_t) * header->phdr[0].len_dw); in flash_flexspi_nor_probe()
1223 ret = flash_flexspi_nor_config_flash(data, header, bfp, in flash_flexspi_nor_probe()
1234 ret = memc_flexspi_set_device_config(&data->controller, &data->config, in flash_flexspi_nor_probe()
1237 data->port); in flash_flexspi_nor_probe()
1243 memc_flexspi_reset(&data->controller); in flash_flexspi_nor_probe()
1245 if (memc_flexspi_is_running_xip(&data->controller)) { in flash_flexspi_nor_probe()
1255 const struct flash_flexspi_nor_config *config = dev->config; in flash_flexspi_nor_init()
1256 struct flash_flexspi_nor_data *data = dev->data; in flash_flexspi_nor_init()
1259 /* First step- use ROM pointer to controller device to create in flash_flexspi_nor_init()
1263 memcpy(&data->controller, config->controller, sizeof(struct device)); in flash_flexspi_nor_init()
1265 if (!device_is_ready(&data->controller)) { in flash_flexspi_nor_init()
1267 return -ENODEV; in flash_flexspi_nor_init()
1271 if (memc_flexspi_is_running_xip(&data->controller)) { in flash_flexspi_nor_init()
1272 /* We can't continue from here- the LUT stored in in flash_flexspi_nor_init()
1280 LOG_ERR("SFDP probe failed"); in flash_flexspi_nor_init()
1281 return -EIO; in flash_flexspi_nor_init()
1285 if (memc_flexspi_update_clock(&data->controller, &data->config, in flash_flexspi_nor_init()
1286 data->port, data->config.flexspiRootClk)) { in flash_flexspi_nor_init()
1288 return -ENOTSUP; in flash_flexspi_nor_init()
1292 memc_flexspi_reset(&data->controller); in flash_flexspi_nor_init()
1296 return -EIO; in flash_flexspi_nor_init()