Lines Matching +full:operation +full:- +full:mode

4  * SPDX-License-Identifier: Apache-2.0
14 * @retval 0 on success or -ETIMEDOUT error value on failure.
22 return -ETIMEDOUT; in cdns_nand_wait_idle()
39 block_number = ((page_set) / (params->npages_per_block)); in row_address_set()
41 *local_row_address |= ROW_VAL_SET((params->page_size_bit) - 1, 0, in row_address_set()
42 ((page_set) % (params->npages_per_block))); in row_address_set()
44 ROW_VAL_SET((params->block_size_bit) - 1, (params->page_size_bit), block_number); in row_address_set()
45 *local_row_address |= ROW_VAL_SET((params->lun_size_bit) - 1, (params->block_size_bit), in row_address_set()
46 (block_number / params->nblocks_per_lun)); in row_address_set()
53 * @retval 0 on success or -ENXIO error value on failure.
62 base_address = params->nand_base; in cdns_nand_device_info()
69 LOG_INF("HPNFC Magic Number 0x%x", nf_ver->hpnfc_magic_number); in cdns_nand_device_info()
70 LOG_INF("Fixed number 0x%x", nf_ver->ctrl_fix); in cdns_nand_device_info()
71 LOG_INF("Controller Revision Number 0x%x", nf_ver->ctrl_rev); in cdns_nand_device_info()
78 return -ENXIO; in cdns_nand_device_info()
81 params->nluns = CNF_GET_NLUNS(reg_value); in cdns_nand_device_info()
82 LOG_INF("Number of LUMs %hhx", params->nluns); in cdns_nand_device_info()
86 params->npages_per_block = GET_PAGES_PER_BLOCK(reg_value); in cdns_nand_device_info()
90 params->page_size = GET_PAGE_SIZE(reg_value); in cdns_nand_device_info()
91 params->spare_size = GET_SPARE_SIZE(reg_value); in cdns_nand_device_info()
94 params->nblocks_per_lun = sys_read32(CNF_CTRLPARAM(base_address, DEV_BLOCKS_PLUN)); in cdns_nand_device_info()
97 params->block_size = (params->npages_per_block * params->page_size); in cdns_nand_device_info()
98 params->device_size = ((long long)params->block_size * in cdns_nand_device_info()
99 (long long)(params->nblocks_per_lun * params->nluns)); in cdns_nand_device_info()
100 LOG_INF("block size %x total device size %llx", params->block_size, params->device_size); in cdns_nand_device_info()
103 params->page_size_bit = find_msb_set((params->npages_per_block) - 1); in cdns_nand_device_info()
104 params->block_size_bit = find_msb_set((params->nblocks_per_lun) - 1); in cdns_nand_device_info()
105 params->lun_size_bit = find_msb_set((params->nluns) - 1); in cdns_nand_device_info()
130 * @retval 0 on success or -ETIMEDOUT error value on failure.
138 return -ETIMEDOUT; in cdns_wait_for_thread()
150 * @param thread The thread identifier for the PIO operation.
151 * @param vol_id The volume identifier for the feature set operation.
152 * @param use_intr Flag indicating whether to use interrupts during the operation.
153 * @retval 0 on success or -ETIMEDOUT error value on failure.
178 * Check whether a transfer complete for PIO operation in the Cadence controller has finished.
181 * @param thread The thread identifier for the PIO operation.
193 return -ETIMEDOUT; in cdns_pio_transfer_complete()
198 LOG_ERR("Cadence status operation failed %s", __func__); in cdns_pio_transfer_complete()
199 return -EIO; in cdns_pio_transfer_complete()
203 return -EIO; in cdns_pio_transfer_complete()
209 * Set the operational mode for the Cadence NAND controller.
212 * @param opr_mode The operational mode SDR / NVDDR to set.
226 timing_mode = find_lsb_set(status) - 1; in cdns_nand_set_opr_mode()
236 /* Async mode timing settings */ in cdns_nand_set_opr_mode()
241 /* Set operation work mode in common settings */ in cdns_nand_set_opr_mode()
246 /* NVDDR MODE */ in cdns_nand_set_opr_mode()
249 timing_mode = find_lsb_set(status) - 1; in cdns_nand_set_opr_mode()
257 /* Set operation work mode in common settings */ in cdns_nand_set_opr_mode()
274 return -ENOTSUP; in cdns_nand_set_opr_mode()
320 * @retval 0 on success or -ETIMEDOUT error value on failure.
354 uintptr_t base_address = params->nand_base; in cdns_nand_init()
355 uint8_t datarate_mode = params->datarate_mode; in cdns_nand_init()
361 return -ETIMEDOUT; in cdns_nand_init()
366 return -ENODEV; in cdns_nand_init()
387 /* Status polling mode, device control and status register */ in cdns_nand_init()
396 /* Set operation work mode */ in cdns_nand_init()
424 params->total_bit_row = find_msb_set(((params->npages_per_block) - 1)) + in cdns_nand_init()
425 find_msb_set((params->nblocks_per_lun) - 1); in cdns_nand_init()
429 return -EINVAL; in cdns_nand_init()
448 * @param dma_sel select DMA engine (0 - slave DMA, 1 - master DMA)
460 cdma_desc->flash_pointer = flash_ptr; in cdns_nand_cdma_prepare()
461 cdma_desc->bank_number = nf_mem; in cdns_nand_cdma_prepare()
462 cdma_desc->command_flags |= CDMA_CF_DMA_MASTER_SET(dma_sel) | F_CFLAGS_VOL_ID_SET(vol_id); in cdns_nand_cdma_prepare()
463 cdma_desc->memory_pointer = (uintptr_t)mem_ptr; in cdns_nand_cdma_prepare()
464 cdma_desc->status = 0; in cdns_nand_cdma_prepare()
465 cdma_desc->sync_flag_pointer = 0; in cdns_nand_cdma_prepare()
466 cdma_desc->sync_arguments = 0; in cdns_nand_cdma_prepare()
467 cdma_desc->ctrl_data_ptr = 0x40; in cdns_nand_cdma_prepare()
468 cdma_desc->command_type = ctype; in cdns_nand_cdma_prepare()
470 cdma_desc->next_pointer = (uintptr_t)(desc + 1); in cdns_nand_cdma_prepare()
471 cdma_desc->command_flags |= CFLAGS_MPTRPC_SET | CFLAGS_MPTRPC_SET; in cdns_nand_cdma_prepare()
472 cdma_desc->command_flags |= CFLAGS_CONT_SET; in cdns_nand_cdma_prepare()
474 cdma_desc->next_pointer = 0; in cdns_nand_cdma_prepare()
476 cdma_desc->command_flags |= CDMA_CF_INT_SET; in cdns_nand_cdma_prepare()
495 sys_write32(NF_TDEF_TRD_NUM, (params->nand_base + CMD_STATUS_PTR_ADDR)); in cdns_transfer_complete()
496 status = sys_read32((params->nand_base + CMD_STAT_CMD_STATUS)); in cdns_transfer_complete()
499 LOG_ERR("Cadence status operation failed %s", __func__); in cdns_transfer_complete()
500 return -EIO; in cdns_transfer_complete()
504 return -EIO; in cdns_transfer_complete()
509 if (!WAIT_FOR(((desc_ptr->status & (BIT(F_CSTAT_COMP))) != 0), IDLE_TIME_OUT, in cdns_transfer_complete()
512 return -ETIMEDOUT; in cdns_transfer_complete()
514 if ((desc_ptr->status & (BIT(F_CSTAT_FAIL))) != 0) { in cdns_transfer_complete()
515 LOG_ERR("Cadence status operation failed %s", __func__); in cdns_transfer_complete()
516 return -EIO; in cdns_transfer_complete()
528 * @retval 0 on success or -ETIMEDOUT error value on failure.
548 /* CDMA Mode selection */ in cdns_nand_send()
572 return -ENOSR; in cdns_cdma_desc_transfer_finish()
575 base_address = params->nand_base; in cdns_cdma_desc_transfer_finish()
582 page_count = page_count - max_page_desc; in cdns_cdma_desc_transfer_finish()
586 page_count = page_count - page_count_pass; in cdns_cdma_desc_transfer_finish()
590 (ctype + index), (page_count_pass - index), in cdns_cdma_desc_transfer_finish()
601 buffer = buffer + (max_page_desc * params->page_size); in cdns_cdma_desc_transfer_finish()
617 * Perform a CDMA write operation for the Cadence NAND controller.
620 * @param start_page_number The starting page number for the write operation.
637 * Perform a CDMA read operation for the Cadence NAND controller.
640 * @param start_page_number The starting page number for the read operation.
657 * Perform a CDMA erase operation for the Cadence NAND controller.
660 * @param start_block_number The starting block number for the erase operation.
680 * Perform an erase operation on the Cadence NAND controller using PIO.
683 * @param thread The thread identifier for the PIO operation.
684 * @param bank The bank identifier for the erase operation.
685 * @param start_block The starting block number for the erase operation.
686 * @param ctype The command type for the erase operation.
699 base_address = params->nand_base; in cdns_nand_pio_erase()
707 row_address_set(params, &row_address, (start_block * params->npages_per_block)); in cdns_nand_pio_erase()
729 * Prepare for a PIO operation in the Cadence NAND controller.
732 * @param thread The thread ID associated with the operation.
733 * @param bank The bank ID for the operation.
734 * @param row_address The row address for the operation.
735 * @param buf The buffer containing the data for the operation.
736 * @param ctype The command type for the operation.
737 * @param dma_sel The DMA selection flag for the operation.
738 * @param vol_id The volume ID for the operation.
739 * @retval 0 on success or -ETIMEDOUT error value on failure.
772 * Perform a PIO write operation for the Cadence NAND controller.
775 * @param row_address The row address for the write operation.
785 base_address = params->nand_base; in cdns_nand_pio_write()
803 * Perform a PIO read operation for the Cadence NAND controller.
806 * @param row_address The row address for the read operation.
816 base_address = params->nand_base; in cdns_nand_pio_read()
835 * Perform a combined PIO read and write operation for the Cadence NAND controller.
838 * @param start_page_number The starting page number for the read/write operation.
841 * @param mode The mode of operation (read, write).
845 char *buffer, uint32_t page_count, uint8_t mode) in cdns_nand_pio_read_write() argument
853 if (mode == CDNS_READ) { in cdns_nand_pio_read_write()
855 buffer + (index * (params->page_size))); in cdns_nand_pio_read_write()
858 buffer + (index * (params->page_size))); in cdns_nand_pio_read_write()
871 * @retval 0 on success or -ETIMEDOUT error value on failure.
880 base_address = params->nand_base; in cdns_generic_send_cmd()
905 * @param mode The mode of operation (read, write).
907 * @retval 0 on success or -ETIMEDOUT error value on failure.
909 static int cdns_generic_cmd_data(struct cadence_nand_params *params, uint8_t mode, in cdns_generic_cmd_data() argument
919 mini_ctrl_cmd |= GEN_DIR_SET((uint64_t)mode); in cdns_generic_cmd_data()
926 * Wait for the completion of an SDMA operation in the Cadence NAND controller.
929 * @retval 0 on success or -ETIMEDOUT error value on failure.
937 return -ETIMEDOUT; in cdns_wait_sdma()
947 * @param buffer The source or destination buffer for the copy operation.
963 * @param buffer The source or destination buffer for the copy operation.
976 * Perform a generic page read operation in the Cadence NAND controller.
987 uintptr_t base_address = params->nand_base; in cdns_generic_page_read()
992 if ((params->nluns > 1) || (params->total_bit_row > 16)) { in cdns_generic_page_read()
995 mini_ctrl_cmd |= PAGE_MAX_BYTES(PAGE_MAX_SIZE - 1); in cdns_generic_page_read()
1003 ret = cdns_generic_cmd_data(params, CDNS_READ, params->page_size); in cdns_generic_page_read()
1012 sdma_buffer_copy_out(params->sdma_base, data_buffer, params->page_size); in cdns_generic_page_read()
1017 * Perform a generic page write operation in the Cadence NAND controller.
1030 uintptr_t base_address = params->nand_base; in cdns_generic_page_write()
1034 if ((params->nluns > 1) || (params->total_bit_row > BIT16_CHECK)) { in cdns_generic_page_write()
1037 mini_ctrl_cmd |= PAGE_MAX_BYTES(PAGE_MAX_SIZE - 1); in cdns_generic_page_write()
1045 ret = cdns_generic_cmd_data(params, CDNS_WRITE, params->page_size); in cdns_generic_page_write()
1049 sdma_buffer_copy_in(params->sdma_base, data_buffer, params->page_size); in cdns_generic_page_write()
1065 * Perform a generic read or write operation for a range of pages in the Cadence NAND controller.
1068 * @param start_page_number The starting page number for the read or write operation.
1071 * @param mode The mode of operation (read, write).
1075 char *buffer, uint32_t page_count, uint8_t mode) in cdns_nand_gen_read_write() argument
1085 if (mode == CDNS_READ) { in cdns_nand_gen_read_write()
1087 buffer + (index * (params->page_size))); in cdns_nand_gen_read_write()
1094 buffer + (index * (params->page_size))); in cdns_nand_gen_read_write()
1105 * Perform a generic erase operation for a range of blocks in the Cadence NAND controller.
1108 * @param start_block The starting block number for the erase operation.
1110 * @retval 0 on success or -ETIMEDOUT error value on failure.
1122 row_address_set(params, &gen_row_address, (start_block * params->npages_per_block)); in cdns_nand_gen_erase()
1124 base_address = params->nand_base; in cdns_nand_gen_erase()
1185 return -EINVAL; in cdns_nand_read()
1192 if ((offset >= params->device_size) || (size > (params->device_size - offset))) { in cdns_nand_read()
1194 return -EINVAL; in cdns_nand_read()
1197 start_page_number = offset / (params->page_size); in cdns_nand_read()
1198 end_page_number = ((offset + size) - 1) / ((params->page_size)); in cdns_nand_read()
1200 if ((offset % params->page_size) == 0) { in cdns_nand_read()
1203 if (((offset + size) % params->page_size) == 0) { in cdns_nand_read()
1206 page_count = end_page_number - start_page_number; in cdns_nand_read()
1217 first_end_page = (char *)k_malloc(sizeof(char) * (params->page_size)); in cdns_nand_read()
1219 memset(first_end_page, 0xFF, sizeof(char) * (params->page_size)); in cdns_nand_read()
1222 return -ENOSR; in cdns_nand_read()
1229 memcpy((char *)buffer, first_end_page + (offset % (params->page_size)), size); in cdns_nand_read()
1234 first_end_page = (char *)k_malloc(sizeof(char) * (params->page_size * 2)); in cdns_nand_read()
1236 memset(first_end_page, 0xFF, sizeof(char) * (params->page_size * 2)); in cdns_nand_read()
1239 return -ENOSR; in cdns_nand_read()
1246 memcpy((char *)buffer, first_end_page + (offset % (params->page_size)), size); in cdns_nand_read()
1250 first_end_page = (char *)k_malloc(sizeof(char) * (params->page_size)); in cdns_nand_read()
1252 memset(first_end_page, 0xFF, sizeof(char) * (params->page_size)); in cdns_nand_read()
1255 return -ENOSR; in cdns_nand_read()
1262 r_bytes = (offset + size) % (params->page_size); in cdns_nand_read()
1263 ret = cdns_read_data(params, start_page_number, (char *)buffer, (--page_count)); in cdns_nand_read()
1269 memcpy((char *)buffer + ((page_count - 1) * params->page_size), first_end_page, in cdns_nand_read()
1274 first_end_page = (char *)k_malloc(sizeof(char) * (params->page_size)); in cdns_nand_read()
1276 memset(first_end_page, 0xFF, sizeof(char) * (params->page_size)); in cdns_nand_read()
1279 return -ENOSR; in cdns_nand_read()
1286 r_bytes = (offset) % (params->page_size); in cdns_nand_read()
1287 bytes_dif = (((start_page_number + 1) * params->page_size) - r_bytes); in cdns_nand_read()
1288 r_bytes = (offset + size) % (params->page_size); in cdns_nand_read()
1290 (--page_count)); in cdns_nand_read()
1298 first_end_page = (char *)k_malloc(sizeof(char) * (params->page_size)); in cdns_nand_read()
1299 last_end_page = (char *)k_malloc(sizeof(char) * (params->page_size)); in cdns_nand_read()
1301 memset(first_end_page, 0xFF, sizeof(char) * (params->page_size)); in cdns_nand_read()
1302 memset(last_end_page, 0xFF, sizeof(char) * (params->page_size)); in cdns_nand_read()
1305 return -ENOSR; in cdns_nand_read()
1313 r_bytes = (offset) % (params->page_size); in cdns_nand_read()
1314 bytes_dif = (((start_page_number + 1) * params->page_size) - r_bytes); in cdns_nand_read()
1315 lp_bytes_dif = (offset + size) % (params->page_size); in cdns_nand_read()
1322 r_bytes = (offset + size) % (params->page_size); in cdns_nand_read()
1324 (page_count - 2)); in cdns_nand_read()
1332 ((page_count - 2) * (params->npages_per_block))), in cdns_nand_read()
1358 return -EINVAL; in cdns_nand_write()
1365 if ((offset >= params->device_size) || (len > (params->device_size - offset))) { in cdns_nand_write()
1367 return -EINVAL; in cdns_nand_write()
1370 if ((offset % params->page_size) != 0) { in cdns_nand_write()
1371 LOG_ERR("offset not page aligned!!! Page size = 0x%x", params->page_size); in cdns_nand_write()
1372 return -EINVAL; in cdns_nand_write()
1375 if ((len % params->page_size) != 0) { in cdns_nand_write()
1376 LOG_ERR("length not page aligned!!! Page size = 0x%x", params->page_size); in cdns_nand_write()
1377 return -EINVAL; in cdns_nand_write()
1380 start_page_number = offset / (params->page_size); in cdns_nand_write()
1381 end_page_number = ((offset + len) - 1) / ((params->page_size)); in cdns_nand_write()
1382 page_count = end_page_number - start_page_number; in cdns_nand_write()
1401 * Perform an erase operation on the Cadence NAND controller.
1417 return -EINVAL; in cdns_nand_erase()
1424 if ((offset >= params->device_size) || (size > (params->device_size - offset))) { in cdns_nand_erase()
1426 return -EINVAL; in cdns_nand_erase()
1428 if ((offset % (params->block_size)) != 0) { in cdns_nand_erase()
1430 params->block_size); in cdns_nand_erase()
1431 return -EINVAL; in cdns_nand_erase()
1433 if ((size % (params->block_size)) != 0) { in cdns_nand_erase()
1435 params->block_size); in cdns_nand_erase()
1436 return -EINVAL; in cdns_nand_erase()
1439 start_block_number = (offset / ((params->page_size))) / (params->npages_per_block); in cdns_nand_erase()
1441 (((offset + size) - 1) / ((params->page_size))) / (params->npages_per_block); in cdns_nand_erase()
1442 block_count = end_block_number - start_block_number; in cdns_nand_erase()
1464 status = sys_read32(params->nand_base + THREAD_INTERRUPT_STATUS); in cdns_nand_irq_handler_ll()
1467 if (GET_INIT_SET_CHECK(status, (thread_num - 1)) != 0) { in cdns_nand_irq_handler_ll()
1469 sys_write32(BIT((thread_num - 1)), params->nand_base + THREAD_INTERRUPT_STATUS); in cdns_nand_irq_handler_ll()