mirror of
https://git.codelinaro.org/clo/qsdk/oss/boot/u-boot-2016.git
synced 2025-12-10 07:44:53 +01:00
Merge "drivers: mtd: qpic_nand: Read one complete page for serial trainig"
This commit is contained in:
commit
05a60f1d5a
1 changed files with 20 additions and 19 deletions
|
|
@ -4133,7 +4133,7 @@ static int qpic_execute_serial_training(struct mtd_info *mtd)
|
||||||
|
|
||||||
unsigned int start, blk_cnt = 0;
|
unsigned int start, blk_cnt = 0;
|
||||||
unsigned int offset, pageno, curr_freq;
|
unsigned int offset, pageno, curr_freq;
|
||||||
int size = sizeof(training_block_128);
|
int i;
|
||||||
unsigned int io_macro_freq_tbl[] = {24000000, 100000000, 200000000, 320000000};
|
unsigned int io_macro_freq_tbl[] = {24000000, 100000000, 200000000, 320000000};
|
||||||
|
|
||||||
unsigned char *data_buff, trained_phase[TOTAL_NUM_PHASE] = {'\0'};
|
unsigned char *data_buff, trained_phase[TOTAL_NUM_PHASE] = {'\0'};
|
||||||
|
|
@ -4187,15 +4187,16 @@ static int qpic_execute_serial_training(struct mtd_info *mtd)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
data_buff = (unsigned char *)malloc(size);
|
data_buff = (unsigned char *)malloc(mtd->writesize);
|
||||||
if (!data_buff) {
|
if (!data_buff) {
|
||||||
printf("Errorn in allocating memory.\n");
|
printf("Errorn in allocating memory.\n");
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
/* prepare clean buffer */
|
/* prepare clean buffer */
|
||||||
memset(data_buff, 0xff, size);
|
memset(data_buff, 0xff, mtd->writesize);
|
||||||
memcpy(data_buff, training_block_128, size);
|
for (i = 0; i < mtd->writesize; i += sizeof(training_block_64))
|
||||||
|
memcpy(data_buff + i, training_block_64, sizeof(training_block_64));
|
||||||
|
|
||||||
/*write training data to flash */
|
/*write training data to flash */
|
||||||
ret = NANDC_RESULT_SUCCESS;
|
ret = NANDC_RESULT_SUCCESS;
|
||||||
|
|
@ -4207,7 +4208,7 @@ static int qpic_execute_serial_training(struct mtd_info *mtd)
|
||||||
memset(dev->pad_oob, 0xFF, dev->oob_per_page);
|
memset(dev->pad_oob, 0xFF, dev->oob_per_page);
|
||||||
|
|
||||||
ops.mode = MTD_OPS_AUTO_OOB;
|
ops.mode = MTD_OPS_AUTO_OOB;
|
||||||
ops.len = size;
|
ops.len = mtd->writesize;
|
||||||
ops.retlen = 0;
|
ops.retlen = 0;
|
||||||
ops.ooblen = dev->oob_per_page;
|
ops.ooblen = dev->oob_per_page;
|
||||||
ops.oobretlen = 0;
|
ops.oobretlen = 0;
|
||||||
|
|
@ -4224,7 +4225,7 @@ static int qpic_execute_serial_training(struct mtd_info *mtd)
|
||||||
/* After write verify the the data with read @ lower frequency
|
/* After write verify the the data with read @ lower frequency
|
||||||
* after that only start serial tarining @ higher frequency
|
* after that only start serial tarining @ higher frequency
|
||||||
*/
|
*/
|
||||||
memset(data_buff, 0xff, size);
|
memset(data_buff, 0xff, mtd->writesize);
|
||||||
ops.datbuf = (uint8_t *)data_buff;
|
ops.datbuf = (uint8_t *)data_buff;
|
||||||
|
|
||||||
ret = qpic_nand_read_page(mtd, pageno, NAND_CFG, &ops);
|
ret = qpic_nand_read_page(mtd, pageno, NAND_CFG, &ops);
|
||||||
|
|
@ -4234,9 +4235,11 @@ static int qpic_execute_serial_training(struct mtd_info *mtd)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* compare original data and read data */
|
/* compare original data and read data */
|
||||||
if (memcmp(data_buff, training_block_128, size)) {
|
for (i = 0; i < mtd->writesize; i += sizeof(training_block_64)) {
|
||||||
printf("Training data read failed @ lower frequency\n");
|
if (memcmp(data_buff + i, training_block_64, sizeof(training_block_64))) {
|
||||||
goto free;
|
printf("Training data read failed @ lower frequency\n");
|
||||||
|
goto free;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* disable feed back clock bit to start serial training */
|
/* disable feed back clock bit to start serial training */
|
||||||
|
|
@ -4258,7 +4261,7 @@ rettry:
|
||||||
/* set the phase */
|
/* set the phase */
|
||||||
qpic_set_phase(phase);
|
qpic_set_phase(phase);
|
||||||
|
|
||||||
memset(data_buff, 0, size);
|
memset(data_buff, 0, mtd->writesize);
|
||||||
ops.datbuf = (uint8_t *)data_buff;
|
ops.datbuf = (uint8_t *)data_buff;
|
||||||
|
|
||||||
ret = qpic_nand_read_page(mtd, pageno, NAND_CFG, &ops);
|
ret = qpic_nand_read_page(mtd, pageno, NAND_CFG, &ops);
|
||||||
|
|
@ -4267,17 +4270,15 @@ rettry:
|
||||||
goto free;
|
goto free;
|
||||||
}
|
}
|
||||||
/* compare original data and read data */
|
/* compare original data and read data */
|
||||||
if (memcmp(data_buff, training_block_128, size)) {
|
for (i = 0; i < mtd->writesize; i += sizeof(training_block_64)) {
|
||||||
/* wrong data read on one of miso line
|
if (memcmp(data_buff + i, training_block_64, sizeof(training_block_64))) {
|
||||||
* change the phase value and try again
|
phase_failed++;
|
||||||
*/
|
break;
|
||||||
phase_failed++;
|
}
|
||||||
} else {
|
}
|
||||||
/* we got good phase update the good phase list
|
if (i == mtd->writesize)
|
||||||
*/
|
|
||||||
trained_phase[phase_cnt++] = phase;
|
trained_phase[phase_cnt++] = phase;
|
||||||
/*printf("%s : Found good phase %d\n",__func__,phase);*/
|
/*printf("%s : Found good phase %d\n",__func__,phase);*/
|
||||||
}
|
|
||||||
|
|
||||||
} while (phase++ < TOTAL_NUM_PHASE);
|
} while (phase++ < TOTAL_NUM_PHASE);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue