Commit bde4330a authored by Abhishek Sahu's avatar Abhishek Sahu Committed by Boris Brezillon

mtd: nand: qcom: reorganize nand page read

Each NAND page consist of multiple codewords. Following is
sequence for NAND page read according to hardware guide.

1. Program Power-up configuration, page row, page column
address and flash configuration registers.
2. Write NAND_FLASH_CMD followed by NANC_EXEC_CMD for each
codeword.
3. Read NAND_FLASH_STATUS for each codeword.

The step 1 should be done once for each page and step 2,3 should
be done for each codeword.

Currently, all the 3 steps are being done for each codeword which
is wrong. Now this patch reorganizes read page functions to
configure page specific register once and per codeword specific
registers for each NAND ECC step.
Signed-off-by: default avatarAbhishek Sahu <absahu@codeaurora.org>
Reviewed-by: default avatarArchit Taneja <architt@codeaurora.org>
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
parent 4d4f2121
...@@ -602,15 +602,23 @@ static int write_data_dma(struct qcom_nand_controller *nandc, int reg_off, ...@@ -602,15 +602,23 @@ static int write_data_dma(struct qcom_nand_controller *nandc, int reg_off,
} }
/* /*
* helper to prepare dma descriptors to configure registers needed for reading a * Helper to prepare DMA descriptors for configuring registers
* codeword/step in a page * before reading a NAND page.
*/ */
static void config_cw_read(struct qcom_nand_controller *nandc) static void config_nand_page_read(struct qcom_nand_controller *nandc)
{ {
write_reg_dma(nandc, NAND_FLASH_CMD, 3); write_reg_dma(nandc, NAND_ADDR0, 2);
write_reg_dma(nandc, NAND_DEV0_CFG0, 3); write_reg_dma(nandc, NAND_DEV0_CFG0, 3);
write_reg_dma(nandc, NAND_EBI2_ECC_BUF_CFG, 1); write_reg_dma(nandc, NAND_EBI2_ECC_BUF_CFG, 1);
}
/*
* Helper to prepare DMA descriptors for configuring registers
* before reading each codeword in NAND page.
*/
static void config_nand_cw_read(struct qcom_nand_controller *nandc)
{
write_reg_dma(nandc, NAND_FLASH_CMD, 1);
write_reg_dma(nandc, NAND_EXEC_CMD, 1); write_reg_dma(nandc, NAND_EXEC_CMD, 1);
read_reg_dma(nandc, NAND_FLASH_STATUS, 2); read_reg_dma(nandc, NAND_FLASH_STATUS, 2);
...@@ -618,9 +626,15 @@ static void config_cw_read(struct qcom_nand_controller *nandc) ...@@ -618,9 +626,15 @@ static void config_cw_read(struct qcom_nand_controller *nandc)
} }
/* /*
* helpers to prepare dma descriptors used to configure registers needed for * Helper to prepare dma descriptors to configure registers needed for reading a
* writing a codeword/step in a page * single codeword in page
*/ */
static void config_nand_single_cw_page_read(struct qcom_nand_controller *nandc)
{
config_nand_page_read(nandc);
config_nand_cw_read(nandc);
}
static void config_cw_write_pre(struct qcom_nand_controller *nandc) static void config_cw_write_pre(struct qcom_nand_controller *nandc)
{ {
write_reg_dma(nandc, NAND_FLASH_CMD, 3); write_reg_dma(nandc, NAND_FLASH_CMD, 3);
...@@ -689,7 +703,7 @@ static int nandc_param(struct qcom_nand_host *host) ...@@ -689,7 +703,7 @@ static int nandc_param(struct qcom_nand_host *host)
nandc->buf_count = 512; nandc->buf_count = 512;
memset(nandc->data_buffer, 0xff, nandc->buf_count); memset(nandc->data_buffer, 0xff, nandc->buf_count);
config_cw_read(nandc); config_nand_single_cw_page_read(nandc);
read_data_dma(nandc, FLASH_BUF_ACC, nandc->data_buffer, read_data_dma(nandc, FLASH_BUF_ACC, nandc->data_buffer,
nandc->buf_count); nandc->buf_count);
...@@ -1102,6 +1116,8 @@ static int read_page_ecc(struct qcom_nand_host *host, u8 *data_buf, ...@@ -1102,6 +1116,8 @@ static int read_page_ecc(struct qcom_nand_host *host, u8 *data_buf,
struct nand_ecc_ctrl *ecc = &chip->ecc; struct nand_ecc_ctrl *ecc = &chip->ecc;
int i, ret; int i, ret;
config_nand_page_read(nandc);
/* queue cmd descs for each codeword */ /* queue cmd descs for each codeword */
for (i = 0; i < ecc->steps; i++) { for (i = 0; i < ecc->steps; i++) {
int data_size, oob_size; int data_size, oob_size;
...@@ -1115,7 +1131,7 @@ static int read_page_ecc(struct qcom_nand_host *host, u8 *data_buf, ...@@ -1115,7 +1131,7 @@ static int read_page_ecc(struct qcom_nand_host *host, u8 *data_buf,
oob_size = host->ecc_bytes_hw + host->spare_bytes; oob_size = host->ecc_bytes_hw + host->spare_bytes;
} }
config_cw_read(nandc); config_nand_cw_read(nandc);
if (data_buf) if (data_buf)
read_data_dma(nandc, FLASH_BUF_ACC, data_buf, read_data_dma(nandc, FLASH_BUF_ACC, data_buf,
...@@ -1175,7 +1191,7 @@ static int copy_last_cw(struct qcom_nand_host *host, int page) ...@@ -1175,7 +1191,7 @@ static int copy_last_cw(struct qcom_nand_host *host, int page)
set_address(host, host->cw_size * (ecc->steps - 1), page); set_address(host, host->cw_size * (ecc->steps - 1), page);
update_rw_regs(host, 1, true); update_rw_regs(host, 1, true);
config_cw_read(nandc); config_nand_single_cw_page_read(nandc);
read_data_dma(nandc, FLASH_BUF_ACC, nandc->data_buffer, size); read_data_dma(nandc, FLASH_BUF_ACC, nandc->data_buffer, size);
...@@ -1225,6 +1241,7 @@ static int qcom_nandc_read_page_raw(struct mtd_info *mtd, ...@@ -1225,6 +1241,7 @@ static int qcom_nandc_read_page_raw(struct mtd_info *mtd,
host->use_ecc = false; host->use_ecc = false;
update_rw_regs(host, ecc->steps, true); update_rw_regs(host, ecc->steps, true);
config_nand_page_read(nandc);
for (i = 0; i < ecc->steps; i++) { for (i = 0; i < ecc->steps; i++) {
int data_size1, data_size2, oob_size1, oob_size2; int data_size1, data_size2, oob_size1, oob_size2;
...@@ -1243,7 +1260,7 @@ static int qcom_nandc_read_page_raw(struct mtd_info *mtd, ...@@ -1243,7 +1260,7 @@ static int qcom_nandc_read_page_raw(struct mtd_info *mtd,
oob_size2 = host->ecc_bytes_hw + host->spare_bytes; oob_size2 = host->ecc_bytes_hw + host->spare_bytes;
} }
config_cw_read(nandc); config_nand_cw_read(nandc);
read_data_dma(nandc, reg_off, data_buf, data_size1); read_data_dma(nandc, reg_off, data_buf, data_size1);
reg_off += data_size1; reg_off += data_size1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment